Skip to content

Commit

Permalink
Deploying to gh-pages from @ f1b8895 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ielis committed Dec 12, 2024
1 parent 96cfd08 commit ac86a28
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
12 changes: 6 additions & 6 deletions latest/_modules/hpotk/store/_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ <h1>Source code for hpotk.store._api</h1><div class="highlight"><pre>
<a class="viewcode-back" href="../../../apidocs/hpotk.store.html#hpotk.OntologyReleaseService.fetch_tags">[docs]</a>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">fetch_tags</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">ontology_type</span><span class="p">:</span> <span class="n">OntologyType</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">ontology_type</span><span class="p">:</span> <span class="n">OntologyType</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Fetch sequence of tags for an ontology.</span>
Expand All @@ -194,10 +194,10 @@ <h1>Source code for hpotk.store._api</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">store_dir</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">ontology_release_service</span><span class="p">:</span> <span class="n">OntologyReleaseService</span><span class="p">,</span>
<span class="n">remote_ontology_service</span><span class="p">:</span> <span class="n">RemoteOntologyService</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">store_dir</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">ontology_release_service</span><span class="p">:</span> <span class="n">OntologyReleaseService</span><span class="p">,</span>
<span class="n">remote_ontology_service</span><span class="p">:</span> <span class="n">RemoteOntologyService</span><span class="p">,</span>
<span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_store_dir</span> <span class="o">=</span> <span class="n">store_dir</span>
Expand Down
8 changes: 4 additions & 4 deletions latest/_modules/hpotk/store/_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ <h1>Source code for hpotk.store._config</h1><div class="highlight"><pre>
<div class="viewcode-block" id="configure_ontology_store">
<a class="viewcode-back" href="../../../apidocs/hpotk.store.html#hpotk.configure_ontology_store">[docs]</a>
<span class="k">def</span> <span class="nf">configure_ontology_store</span><span class="p">(</span>
<span class="n">store_dir</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">ontology_release_service</span><span class="p">:</span> <span class="n">OntologyReleaseService</span> <span class="o">=</span> <span class="n">GitHubOntologyReleaseService</span><span class="p">(),</span>
<span class="n">remote_ontology_service</span><span class="p">:</span> <span class="n">RemoteOntologyService</span> <span class="o">=</span> <span class="n">GitHubRemoteOntologyService</span><span class="p">(),</span>
<span class="n">store_dir</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">ontology_release_service</span><span class="p">:</span> <span class="n">OntologyReleaseService</span> <span class="o">=</span> <span class="n">GitHubOntologyReleaseService</span><span class="p">(),</span>
<span class="n">remote_ontology_service</span><span class="p">:</span> <span class="n">RemoteOntologyService</span> <span class="o">=</span> <span class="n">GitHubRemoteOntologyService</span><span class="p">(),</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">OntologyStore</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Configure and create the default ontology store.</span>
Expand All @@ -107,7 +107,7 @@ <h1>Source code for hpotk.store._config</h1><div class="highlight"><pre>
<span class="n">store_dir</span> <span class="o">=</span> <span class="n">get_default_ontology_store_dir</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">store_dir</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;`store_dir` must point to an existing directory&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;`store_dir` must point to an existing directory&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">OntologyStore</span><span class="p">(</span>
<span class="n">store_dir</span><span class="o">=</span><span class="n">store_dir</span><span class="p">,</span>
<span class="n">ontology_release_service</span><span class="o">=</span><span class="n">ontology_release_service</span><span class="p">,</span>
Expand Down
38 changes: 27 additions & 11 deletions latest/_modules/hpotk/store/_github.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ <h1>Source code for hpotk.store._github</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">io</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">ssl</span>
<span class="kn">import</span> <span class="nn">typing</span>
<span class="kn">from</span> <span class="nn">urllib.request</span> <span class="kn">import</span> <span class="n">urlopen</span>
Expand All @@ -87,22 +88,31 @@ <h1>Source code for hpotk.store._github</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">._api</span> <span class="kn">import</span> <span class="n">OntologyType</span><span class="p">,</span> <span class="n">OntologyReleaseService</span><span class="p">,</span> <span class="n">RemoteOntologyService</span>


<span class="n">production_tag_pt</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;^v(?P&lt;year&gt;\d</span><span class="si">{4}</span><span class="s1">)-(?P&lt;month&gt;\d</span><span class="si">{2}</span><span class="s1">)-(?P&lt;day&gt;\d</span><span class="si">{2}</span><span class="s1">)$&#39;</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">A tag pattern to ensure we only include the &quot;production&quot; tags (e.g. not `v2024-12-12X`).</span>
<span class="sd">&quot;&quot;&quot;</span>


<span class="n">ONTOLOGY_CREDENTIALS</span> <span class="o">=</span> <span class="p">{</span>
<span class="n">OntologyType</span><span class="o">.</span><span class="n">HPO</span><span class="p">:</span> <span class="p">{</span>
<span class="s1">&#39;owner&#39;</span><span class="p">:</span> <span class="s1">&#39;obophenotype&#39;</span><span class="p">,</span>
<span class="s1">&#39;repo&#39;</span><span class="p">:</span> <span class="s1">&#39;human-phenotype-ontology&#39;</span><span class="p">,</span>
<span class="s1">&#39;tag_pt&#39;</span><span class="p">:</span> <span class="n">production_tag_pt</span><span class="p">,</span>
<span class="p">},</span>
<span class="n">OntologyType</span><span class="o">.</span><span class="n">MAxO</span><span class="p">:</span> <span class="p">{</span>
<span class="s1">&#39;owner&#39;</span><span class="p">:</span> <span class="s1">&#39;monarch-initiative&#39;</span><span class="p">,</span>
<span class="s1">&#39;repo&#39;</span><span class="p">:</span> <span class="s1">&#39;MAxO&#39;</span><span class="p">,</span>
<span class="s1">&#39;tag_pt&#39;</span><span class="p">:</span> <span class="n">production_tag_pt</span><span class="p">,</span>
<span class="p">},</span>
<span class="n">OntologyType</span><span class="o">.</span><span class="n">MONDO</span><span class="p">:</span> <span class="p">{</span>
<span class="s1">&#39;owner&#39;</span><span class="p">:</span> <span class="s1">&#39;monarch-initiative&#39;</span><span class="p">,</span>
<span class="s1">&#39;repo&#39;</span><span class="p">:</span> <span class="s1">&#39;mondo&#39;</span><span class="p">,</span>
<span class="s1">&#39;tag_pt&#39;</span><span class="p">:</span> <span class="n">production_tag_pt</span><span class="p">,</span>
<span class="p">},</span>
<span class="p">}</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">The default ontology credentials that only include HPO at the time.</span>
<span class="sd">The default ontology credentials that only include HPO, MAxO, and MONDO at this time.</span>
<span class="sd">&quot;&quot;&quot;</span>


Expand All @@ -114,9 +124,9 @@ <h1>Source code for hpotk.store._github</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">timeout</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span>
<span class="n">ontology_credentials</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Mapping</span><span class="p">[</span><span class="n">OntologyType</span><span class="p">,</span> <span class="n">typing</span><span class="o">.</span><span class="n">Mapping</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="n">ONTOLOGY_CREDENTIALS</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">timeout</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span>
<span class="n">ontology_credentials</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Mapping</span><span class="p">[</span><span class="n">OntologyType</span><span class="p">,</span> <span class="n">typing</span><span class="o">.</span><span class="n">Mapping</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="n">ONTOLOGY_CREDENTIALS</span><span class="p">,</span>
<span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_timeout</span> <span class="o">=</span> <span class="n">timeout</span>
Expand All @@ -137,21 +147,23 @@ <h1>Source code for hpotk.store._github</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_tag_names</span><span class="p">(</span>
<span class="n">owner</span><span class="o">=</span><span class="n">credentials</span><span class="p">[</span><span class="s1">&#39;owner&#39;</span><span class="p">],</span>
<span class="n">repo</span><span class="o">=</span><span class="n">credentials</span><span class="p">[</span><span class="s1">&#39;repo&#39;</span><span class="p">],</span>
<span class="n">tag_pt</span><span class="o">=</span><span class="n">credentials</span><span class="p">[</span><span class="s1">&#39;tag_pt&#39;</span><span class="p">],</span>
<span class="p">)</span></div>


<span class="k">def</span> <span class="nf">_get_tag_names</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">owner</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">repo</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">owner</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">repo</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">tag_pt</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span>
<span class="n">tag_url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tag_api_url</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">owner</span><span class="o">=</span><span class="n">owner</span><span class="p">,</span> <span class="n">repo</span><span class="o">=</span><span class="n">repo</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Pulling tag from </span><span class="si">%s</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">tag_url</span><span class="p">)</span>

<span class="k">with</span> <span class="n">urlopen</span><span class="p">(</span>
<span class="n">tag_url</span><span class="p">,</span>
<span class="n">timeout</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_timeout</span><span class="p">,</span>
<span class="n">context</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_ctx</span><span class="p">,</span>
<span class="n">tag_url</span><span class="p">,</span>
<span class="n">timeout</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_timeout</span><span class="p">,</span>
<span class="n">context</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_ctx</span><span class="p">,</span>
<span class="p">)</span> <span class="k">as</span> <span class="n">fh</span><span class="p">:</span>
<span class="n">tags</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">fh</span><span class="p">)</span>

Expand All @@ -160,7 +172,11 @@ <h1>Source code for hpotk.store._github</h1><div class="highlight"><pre>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Fetched </span><span class="si">%d</span><span class="s1"> tags&#39;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">tags</span><span class="p">))</span>

<span class="k">return</span> <span class="p">(</span><span class="n">tag</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">tag</span> <span class="ow">in</span> <span class="n">tags</span><span class="p">)</span></div>
<span class="n">pattern</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">tag_pt</span><span class="p">)</span>
<span class="k">return</span> <span class="nb">filter</span><span class="p">(</span>
<span class="k">lambda</span> <span class="n">tag</span><span class="p">:</span> <span class="n">pattern</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">tag</span><span class="p">),</span>
<span class="p">(</span><span class="n">tag</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">tag</span> <span class="ow">in</span> <span class="n">tags</span><span class="p">),</span>
<span class="p">)</span></div>



Expand Down
Loading

0 comments on commit ac86a28

Please sign in to comment.