Skip to content
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

Adjustments for new Plugins #1351

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Update MERFISH directory schema
- Update Phenocycler docs
- Update MERFISH directory schema
- Adding support for EPIC's new plugin

## v0.0.23
- Add token to validation_utils.get_assaytype_data, replace URL string concatenation with urllib
Expand Down
27 changes: 24 additions & 3 deletions src/ingest_validation_tools/plugin_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections.abc import Iterator
from importlib import util
from pathlib import Path
from typing import List, Optional, Tuple, Type, Union
from typing import Dict, List, Optional, Tuple, Type, Union

from ingest_validation_tools.schema_loader import SchemaVersion

Expand Down Expand Up @@ -53,6 +53,9 @@ def __init__(
assay_type: str,
contains: List = [],
verbose: bool = False,
metadata_tsv: SchemaVersion = None,
globus_token: str = None,
app_context: Dict[str, str] = {},
**kwargs,
):
"""
Expand All @@ -72,6 +75,9 @@ def __init__(
self.assay_type = assay_type
self.contains = contains
self.verbose = verbose
self.metadata_tsv = metadata_tsv
self.token = globus_token
self.app_context = app_context

def _log(self, message):
if self.verbose:
Expand Down Expand Up @@ -99,6 +105,8 @@ def run_plugin_validators_iter(
plugin_dir: PathOrStr,
is_shared_upload: bool,
verbose: bool = True,
globus_token: str = None,
app_context: Dict[str, str] = {},
**kwargs,
) -> Iterator[KeyValuePair]:
"""
Expand Down Expand Up @@ -134,7 +142,15 @@ def run_plugin_validators_iter(
raise ValidatorError(f"{data_path} should be the base directory of a dataset")
data_paths.append(data_path)
for k, v in validation_error_iter(
data_paths, sv.dataset_type, plugin_dir, sv.contains, verbose=verbose, **kwargs
data_paths,
sv.dataset_type,
plugin_dir,
sv.contains,
verbose=verbose,
metadata_tsv=sv,
globus_token=globus_token,
app_context=app_context,
**kwargs,
):
yield k, v
else:
Expand Down Expand Up @@ -179,6 +195,9 @@ def validation_error_iter(
plugin_dir: PathOrStr,
contains: List,
verbose: bool = False,
metadata_tsv: SchemaVersion = None,
globus_token: str = None,
app_context: Dict[str, str] = {},
**kwargs,
) -> Iterator[KeyValuePair]:
"""
Expand All @@ -195,6 +214,8 @@ def validation_error_iter(
error messages
"""
for cls in validation_class_iter(plugin_dir):
validator = cls(paths, assay_type, contains, verbose)
validator = cls(
paths, assay_type, contains, verbose, metadata_tsv, globus_token, app_context
)
for err in validator.collect_errors(**kwargs):
yield cls, err
5 changes: 4 additions & 1 deletion src/ingest_validation_tools/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def get_app_context(self, submitted_app_context: Dict):
Ensure that all default values are present, but privilege any
submitted values (after making a basic validity check).
"""
for url_type in ["entities_url", "ingest_url", "constraints_url"]:
for url_type in ["entities_url", "ingest_url", "constraints_url", "uuid_url"]:
if submitted_app_context.get(url_type):
split_url = urlsplit(submitted_app_context[url_type])
assert (
Expand All @@ -193,6 +193,7 @@ def get_app_context(self, submitted_app_context: Dict):
"request_header": {"X-Hubmap-Application": "ingest-pipeline"},
# TODO: does not work in HuBMAP currently
"constraints_url": None,
"uuid_url": "https://uuid.api.hubmapconsortium.org/uuid/",
} | submitted_app_context

def validation_routine(
Expand Down Expand Up @@ -444,6 +445,8 @@ def _get_plugin_errors(self, **kwargs) -> dict:
plugin_path,
self.is_shared_upload,
verbose=self.verbose,
globus_token=self.globus_token,
app_context=self.app_context,
**kwargs,
):
if v is None:
Expand Down
Loading