Skip to content

Commit

Permalink
fix(doi): correct metadata return to use original phsids, improve doc… (
Browse files Browse the repository at this point in the history
#215)

* fix(doi): correct metadata return to use original phsids, improve docs / debugging

* Apply automatic documentation changes

* fix(dbgap-metadata): ensure testing that function return is using IDs provided as input

* Apply automatic documentation changes

* fix(dbgap): fix tests and code to properly handle metadata response always include input IDs as-is

* Apply automatic documentation changes

* fix(tests): remove debug line

* Apply automatic documentation changes

* chore(docs): relock and add additional info to docstring

* Apply automatic documentation changes

* feat(doi): support prod and test DOI resolver URLs. NEW DEFAULT IS TEST

* Apply automatic documentation changes

* chore(lock): new version, lock

* Apply automatic documentation changes

* Update gen3/auth.py

Co-authored-by: burtonk <117617405+k-burt-uch@users.noreply.github.com>

* Apply automatic documentation changes

---------

Co-authored-by: burtonk <117617405+k-burt-uch@users.noreply.github.com>
  • Loading branch information
Avantol13 and k-burt-uch committed Apr 19, 2024
1 parent b5b0c9a commit e5fa931
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 210 deletions.
Binary file modified docs/_build/doctrees/auth.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/tools/indexing.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/tools/metadata.doctree
Binary file not shown.
7 changes: 6 additions & 1 deletion docs/_build/html/_modules/gen3/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ <h1>Source code for gen3.auth</h1><div class="highlight"><pre>
<span class="sd"> that has the &#39;client_credentials&#39; grant, allowing it to obtain access tokens.</span>
<span class="sd"> client_scopes (str, opt): Space-separated list of scopes requested for access tokens obtained from client</span>
<span class="sd"> credentials. Default: &quot;user data openid&quot;</span>
<span class="sd"> access_token (str, opt): provide an access token to override the use of any</span>
<span class="sd"> API key/refresh token. This is intended for cases where you may want to</span>
<span class="sd"> pass a token that was issued to a particular OIDC client (rather than acting on</span>
<span class="sd"> your own direct behalf, you can provide a key that was client-issued to your user)</span>

<span class="sd"> Examples:</span>
<span class="sd"> This generates the Gen3Auth class pointed at the sandbox commons while</span>
Expand Down Expand Up @@ -218,13 +222,14 @@ <h1>Source code for gen3.auth</h1><div class="highlight"><pre>
<span class="n">idp</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">client_credentials</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">client_scopes</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">access_token</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="p">):</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Initializing auth..&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">endpoint</span> <span class="o">=</span> <span class="n">remove_trailing_whitespace_and_slashes_in_url</span><span class="p">(</span><span class="n">endpoint</span><span class="p">)</span>
<span class="c1"># note - `_refresh_token` is not actually a JWT refresh token - it&#39;s a</span>
<span class="c1"># gen3 api key with a token as the &quot;api_key&quot; property</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_refresh_token</span> <span class="o">=</span> <span class="n">refresh_token</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_access_token</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_access_token</span> <span class="o">=</span> <span class="n">access_token</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_access_token_info</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_wts_idp</span> <span class="o">=</span> <span class="n">idp</span> <span class="ow">or</span> <span class="s2">&quot;local&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_wts_namespace</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;NAMESPACE&quot;</span><span class="p">,</span> <span class="s2">&quot;default&quot;</span><span class="p">)</span>
Expand Down
6 changes: 5 additions & 1 deletion docs/_build/html/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<h1>Gen3 Auth Helper<a class="headerlink" href="#gen3-auth-helper" title="Link to this heading"></a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="gen3.auth.Gen3Auth">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gen3.auth.</span></span><span class="sig-name descname"><span class="pre">Gen3Auth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">endpoint</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">refresh_file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">refresh_token</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">idp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">client_credentials</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">client_scopes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/gen3/auth.html#Gen3Auth"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#gen3.auth.Gen3Auth" title="Link to this definition"></a></dt>
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gen3.auth.</span></span><span class="sig-name descname"><span class="pre">Gen3Auth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">endpoint</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">refresh_file</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">refresh_token</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">idp</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">client_credentials</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">client_scopes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">access_token</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/gen3/auth.html#Gen3Auth"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#gen3.auth.Gen3Auth" title="Link to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">AuthBase</span></code></p>
<p>Gen3 auth helper class for use with requests auth.</p>
<p>Implements requests.auth.AuthBase in order to support JWT authentication.
Expand All @@ -57,6 +57,10 @@ <h1>Gen3 Auth Helper<a class="headerlink" href="#gen3-auth-helper" title="Link t
that has the ‘client_credentials’ grant, allowing it to obtain access tokens.</p></li>
<li><p><strong>client_scopes</strong> (<em>str</em><em>, </em><em>opt</em>) – Space-separated list of scopes requested for access tokens obtained from client
credentials. Default: “user data openid”</p></li>
<li><p><strong>access_token</strong> (<em>str</em><em>, </em><em>opt</em>) – provide an access token to override the use of any
API key/refresh token. This is intended for cases where you may want to
pass a token that was issued to a particular OIDC client (rather than acting on
your own direct behalf, you can provide a key that was client-issued to your user)</p></li>
</ul>
</dd>
</dl>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/_build/html/tools/indexing.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ <h1>Indexing Tools<a class="headerlink" href="#indexing-tools" title="Link to th

<dl class="py function">
<dt class="sig sig-object py" id="gen3.tools.indexing.verify_manifest.async_verify_object_manifest">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gen3.tools.indexing.verify_manifest.</span></span><span class="sig-name descname"><span class="pre">async_verify_object_manifest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">commons_url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_concurrent_requests=24</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_row_parsers={'acl':</span> <span class="pre">&lt;function</span> <span class="pre">_get_acl_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'authz':</span> <span class="pre">&lt;function</span> <span class="pre">_get_authz_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'file_name':</span> <span class="pre">&lt;function</span> <span class="pre">_get_file_name_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'file_size':</span> <span class="pre">&lt;function</span> <span class="pre">_get_file_size_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'guid':</span> <span class="pre">&lt;function</span> <span class="pre">_get_guid_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'md5':</span> <span class="pre">&lt;function</span> <span class="pre">_get_md5_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'urls':</span> <span class="pre">&lt;function</span> <span class="pre">_get_urls_from_row&gt;}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file_delimiter=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename='verify-manifest-errors-1712350570.9982884.log'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/gen3/tools/indexing/verify_manifest.html#async_verify_object_manifest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#gen3.tools.indexing.verify_manifest.async_verify_object_manifest" title="Link to this definition"></a></dt>
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gen3.tools.indexing.verify_manifest.</span></span><span class="sig-name descname"><span class="pre">async_verify_object_manifest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">commons_url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_concurrent_requests=24</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_row_parsers={'acl':</span> <span class="pre">&lt;function</span> <span class="pre">_get_acl_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'authz':</span> <span class="pre">&lt;function</span> <span class="pre">_get_authz_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'file_name':</span> <span class="pre">&lt;function</span> <span class="pre">_get_file_name_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'file_size':</span> <span class="pre">&lt;function</span> <span class="pre">_get_file_size_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'guid':</span> <span class="pre">&lt;function</span> <span class="pre">_get_guid_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'md5':</span> <span class="pre">&lt;function</span> <span class="pre">_get_md5_from_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'urls':</span> <span class="pre">&lt;function</span> <span class="pre">_get_urls_from_row&gt;}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file_delimiter=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename='verify-manifest-errors-1711461363.0524344.log'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/gen3/tools/indexing/verify_manifest.html#async_verify_object_manifest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#gen3.tools.indexing.verify_manifest.async_verify_object_manifest" title="Link to this definition"></a></dt>
<dd><p>Verify all file object records into a manifest csv</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/tools/metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h1>Metadata Tools<a class="headerlink" href="#metadata-tools" title="Link to th

<dl class="py function">
<dt class="sig sig-object py" id="gen3.tools.metadata.ingest_manifest.async_ingest_metadata_manifest">
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gen3.tools.metadata.ingest_manifest.</span></span><span class="sig-name descname"><span class="pre">async_ingest_metadata_manifest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">commons_url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metadata_source</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auth=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_concurrent_requests=24</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_row_parsers={'guid_for_row':</span> <span class="pre">&lt;function</span> <span class="pre">_get_guid_for_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'indexed_file_object_guid':</span> <span class="pre">&lt;function</span> <span class="pre">_query_for_associated_indexd_record_guid&gt;}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file_delimiter=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename='ingest-metadata-manifest-errors-1712350571.3286045.log'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">get_guid_from_file=True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metadata_type=None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/gen3/tools/metadata/ingest_manifest.html#async_ingest_metadata_manifest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#gen3.tools.metadata.ingest_manifest.async_ingest_metadata_manifest" title="Link to this definition"></a></dt>
<em class="property"><span class="k"><span class="pre">async</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gen3.tools.metadata.ingest_manifest.</span></span><span class="sig-name descname"><span class="pre">async_ingest_metadata_manifest</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">commons_url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metadata_source</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auth=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_concurrent_requests=24</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_row_parsers={'guid_for_row':</span> <span class="pre">&lt;function</span> <span class="pre">_get_guid_for_row&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">'indexed_file_object_guid':</span> <span class="pre">&lt;function</span> <span class="pre">_query_for_associated_indexd_record_guid&gt;}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manifest_file_delimiter=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output_filename='ingest-metadata-manifest-errors-1711461363.3879402.log'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">get_guid_from_file=True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">metadata_type=None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/gen3/tools/metadata/ingest_manifest.html#async_ingest_metadata_manifest"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#gen3.tools.metadata.ingest_manifest.async_ingest_metadata_manifest" title="Link to this definition"></a></dt>
<dd><p>Ingest all metadata records into a manifest csv</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
Expand Down
6 changes: 3 additions & 3 deletions docs/howto/discoveryMetadataTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_manual_single_doi(publish_dois=False):
# If your Discovery metadata records don't use the DOI as the GUID,
# you may need to supply the URL yourself like below
url = COMMONS_DISCOVERY_PAGE.rstrip("/") + f"/{gen3_metadata_guid}"
doi = DigitalObjectIdentifier(url=url, **doi_metadata)
doi = DigitalObjectIdentifier(url=url, use_prod=False, **doi_metadata)

if publish_dois:
logging.info(f"Publishing DOI `{identifier}`...")
Expand All @@ -176,7 +176,7 @@ def test_manual_single_doi(publish_dois=False):
# works for only new DOIs
# You can use this for updates: `datacite.update_doi(doi)`
response = datacite.create_doi(doi)
doi = DigitalObjectIdentifier.from_datacite_create_doi_response(response)
doi = DigitalObjectIdentifier.from_datacite_create_doi_response(response, use_prod=False)

# Persist necessary DOI Metadata in Gen3 Discovery to support the landing page
metadata = datacite.persist_doi_metadata_in_gen3(
Expand Down Expand Up @@ -504,7 +504,7 @@ def main():
"phs000179.v6",
]
dbgapfhir = dbgapFHIR()
simplified_data = dbgapfhir.get_metadata_for_ids(phsids=studies)
simplified_data = dbgapfhir.get_metadata_for_ids(ids=studies)
dbgapFHIR.write_data_to_file(simplified_data, "fhir_metadata_file.tsv")

# Combine new FHIR Metadata with existing Discovery Metadata
Expand Down
Loading

0 comments on commit e5fa931

Please sign in to comment.