Repository navigation
Add derived dataset provenance to the ro-crate #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
9384684
introduce CroissantWrapper; add -d; logging; write zip
jswelling de508ac
separate CroissantWrapper
jswelling abb5621
use a scratch directory; save only zip
jswelling e68ccdf
working on provenance. WIP.
jswelling 9c05578
walk_ancestors is working. WIP.
jswelling 18197c5
working walk_ancestors
jswelling 08620e9
better docstring for walk_ancestors
jswelling bc6b25f
croissant provenance fully functional
jswelling 9569375
croissant now knows about files but not records
jswelling eb6052f
support version, cite_as, license, date_published for croissant
jswelling 6d18f77
previous_version_uuid should be previous_revision_uuid
jswelling 35b2643
add some edam codes; fix edam logic
jswelling e4612a3
first pass rocrate prov for derived dataset. WIP.
jswelling cda7854
fix derived dataset workflow agent
jswelling 932e00d
workflow crate passes validation
jswelling ab54f5a
cleanup
jswelling 59397b5
more cleanup
jswelling 5cd94bb
refactor out extractors
jswelling 950f722
move pipeline_steps to extractors
jswelling 1b0a5c1
introduce WrappedEntity
jswelling 4e09468
use WrappedEntity throughout
jswelling d7388ca
working on workflow steps. WIP.
jswelling a797e39
checkpoint (WIP)
jswelling 77766ac
fix cwl info for steps
jswelling 655794e
hardcode CWL version
jswelling 119a6ec
add full workflow description
jswelling 16f23b5
working but incomplete primary ds provenance
jswelling efa30a0
black/lint
jswelling 0b3e27b
spelling error
jswelling dd3f5f9
black
jswelling e30381b
croissant[dev] requires black 23.11.0
jswelling fd9c3e1
lint
jswelling 743d9eb
black
jswelling de7bb48
add pyproject.toml
jswelling 8e84c2d
trying to fix python 3.13 pandas build error
jswelling 9cdb341
clean up get() defaults
jswelling 6b9a69e
use parent doi_url if necessary
jswelling bf41e3e
fix croissant handling of snare-seq
jswelling fdd99b9
better info for failed entity fetches
jswelling 35683a6
allow python steps to support IVT
jswelling 4b482ef
more flexible EDAM code handling
jswelling 261e3ef
support datasets with missing workflow info
jswelling 0d6b0e1
armor against earlier contributor format
jswelling f452a49
make robust against missing file attributes
jswelling b97f721
support EDAM 2333
jswelling c07b4a6
armor against missing sample description
jswelling 15dc521
fix walk_ancestors
jswelling 4d83df3
small lru cache for fetches
jswelling d72e390
linting
jswelling 7a82ec4
Add EDAM 3003
jswelling 0d09c5c
croissant citeAs to BiBTeX
jswelling 1555ec6
linting
jswelling 280b97c
adding keywords. WIP.
jswelling e5a80f9
working keywords for rocrate and croissant
jswelling b85d439
lint
jswelling 691431f
missing import in inactive code?
jswelling d8e9682
flake8
jswelling 056b71c
added entity_iri(); black
jswelling db99ab7
flake8
jswelling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [tool.isort] | ||
| profile = "black" | ||
| multi_line_output = 3 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| """Handle requests to HuBMAP APIs.""" | ||
| import logging | ||
| import os | ||
| from functools import lru_cache | ||
| from pprint import pformat | ||
| from typing import Any | ||
|
|
||
| import requests | ||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
| ENTITY_API = "https://entity.api.hubmapconsortium.org" | ||
| ASSETS_API = "https://assets.hubmapconsortium.org" | ||
| UUID_API = "https://uuid.api.hubmapconsortium.org" | ||
|
|
||
| AUTH_TOK = os.environ["AUTH_TOK"] | ||
|
|
||
| HUBMAP = "https://hubmapconsortium.org/" | ||
|
|
||
| HUBMAP_ORG_ENTITY = HUBMAP # for lack of a better choice | ||
|
|
||
| ENTITY_BASE = "https://portal.hubmapconsortium.org/browse/" | ||
|
|
||
| HUBMAP_ORG_ENTITY = HUBMAP # for lack of a better choice | ||
|
|
||
|
|
||
| def entity_iri(entity: Any) -> str: | ||
| """Return a resolvable IRI for a HuBMAP entity (dataset / sample / donor). | ||
|
|
||
| Raw datasets and multi-assay splits carry `doi_url`; processed datasets, samples | ||
| and donors do not, and fall back to the portal browse URL, which resolves by | ||
| HuBMAP ID for every entity type. | ||
| """ | ||
| return entity.get("doi_url") or ENTITY_BASE + (entity.get("hubmap_id") or "") | ||
|
|
||
|
|
||
| @lru_cache(maxsize=8) | ||
| def fetch_entity_info(target_id: str) -> dict[str, Any]: | ||
| """Fetch a dataset's entity information.""" | ||
| LOGGER.debug("FETCH %s", target_id) | ||
| try: | ||
| resp = requests.get( | ||
| ENTITY_API + f"/entities/{target_id}", | ||
| headers={"Authorization": f"Bearer {AUTH_TOK}"}, | ||
| ) | ||
| resp.raise_for_status() | ||
| except Exception as excp: | ||
| raise RuntimeError(f"Fetch of entity {target_id} failed: {excp}") from excp | ||
| ds_info = resp.json() | ||
| LOGGER.debug("TOP LEVEL for %s:\n%s", target_id, pformat(ds_info, depth=1)) | ||
| LOGGER.debug( | ||
| "INGEST METADATA:\n%s", pformat(ds_info.get("ingest_metadata", {}), depth=2) | ||
| ) | ||
| LOGGER.debug("METADATA:\n%s", pformat(ds_info.get("metadata", {}), depth=2)) | ||
| LOGGER.debug( | ||
| "DIRECT ANCESTORS: %s\n%s", | ||
| [elt["hubmap_id"] for elt in ds_info.get("direct_ancestors", [])], | ||
| pformat(ds_info.get("direct_ancestors"), depth=2), | ||
| ) | ||
| LOGGER.debug( | ||
| "DIRECT ANCESTOR:\n%s", pformat(ds_info.get("direct_ancestor"), depth=2) | ||
| ) | ||
| if "direct_ancestors" in ds_info: | ||
| first_ancestor = ds_info["direct_ancestors"][0] | ||
| elif "direct_ancestor" in ds_info: | ||
| first_ancestor = ds_info["direct_ancestor"] | ||
| else: | ||
| first_ancestor = {} | ||
| LOGGER.debug( | ||
| "ANCESTOR INGEST MD\n%s", pformat(first_ancestor.get("ingest_metadata", {})) | ||
| ) | ||
| LOGGER.debug("ANCESTOR MD\n%s", pformat(first_ancestor.get("metadata", {}))) | ||
| return ds_info | ||
|
|
||
|
|
||
| @lru_cache(maxsize=8) | ||
| def fetch_uuid_files_info(target_id: str) -> dict[str, Any]: | ||
| """Fetch files informaion from the UUID API.""" | ||
| resp = requests.get( | ||
| UUID_API + f"/{target_id}/files", | ||
| headers={"Authorization": f"Bearer {AUTH_TOK}"}, | ||
| ) | ||
| resp.raise_for_status() | ||
| # LOGGER.debug("UUID FILES first 10:\n%s", pformat(resp.json()[:10])) | ||
| return resp.json() | ||
|
|
||
|
|
||
| def asset_url(uuid: str, rel_path: str) -> str: | ||
| """Build the URL by which a file should be available from the ASSETS API.""" | ||
| return f"{ASSETS_API}/{uuid}/{rel_path}" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.