Skip to content

Commit eea1276

Browse files
authored
Merge pull request #1317 from Sage-Bionetworks/develop
Schematic `v23.11.1`
2 parents 6eb54b5 + 07d90e7 commit eea1276

File tree

23 files changed

+2602
-2564
lines changed

23 files changed

+2602
-2564
lines changed

.github/workflows/api_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
test:
1616
runs-on: ubuntu-latest
1717
env:
18-
POETRY_VERSION: 1.2.0
18+
POETRY_VERSION: 1.3.0
1919
strategy:
2020
fail-fast: false
2121
matrix:
@@ -85,4 +85,4 @@ jobs:
8585
if: ${{ false == inputs.perform_benchmarking }}
8686
run: >
8787
source .venv/bin/activate;
88-
pytest -m "schematic_api and not submission and not rule_benchmark"
88+
pytest -m "schematic_api and not submission and not rule_benchmark"

.github/workflows/pdoc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
build:
2828
runs-on: ubuntu-latest
2929
env:
30-
POETRY_VERSION: 1.2.0
30+
POETRY_VERSION: 1.3.0
3131
strategy:
3232
matrix:
3333
python-version: ["3.9", "3.10"]
@@ -93,4 +93,4 @@ jobs:
9393
url: ${{ steps.deployment.outputs.page_url }}
9494
steps:
9595
- id: deployment
96-
uses: actions/deploy-pages@v1
96+
uses: actions/deploy-pages@v1

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
pypi_release:
1010
runs-on: ubuntu-latest
1111
env:
12-
POETRY_VERSION: 1.2.0
12+
POETRY_VERSION: 1.3.0
1313
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
1414
steps:
1515
#----------------------------------------------

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
test:
2828
runs-on: ubuntu-latest
2929
env:
30-
POETRY_VERSION: 1.2.0
30+
POETRY_VERSION: 1.3.0
3131
strategy:
3232
fail-fast: false
3333
matrix:
@@ -127,7 +127,7 @@ jobs:
127127
if: ${{ contains(github.event.head_commit.message, 'runcombos') }}
128128
run: >
129129
source .venv/bin/activate;
130-
pytest --cov-report=term --cov-report=html:htmlcov --cov=schematic/
130+
pytest --durations=0 --cov-report=term --cov-report=html:htmlcov --cov=schematic/
131131
-m "not (google_credentials_needed or schematic_api or table_operations)"
132132
133133
- name: Run tests
@@ -137,7 +137,7 @@ jobs:
137137
if: ${{ false == contains(github.event.head_commit.message, 'runcombos') }}
138138
run: >
139139
source .venv/bin/activate;
140-
pytest --cov-report=term --cov-report=html:htmlcov --cov=schematic/
140+
pytest --durations=0 --cov-report=term --cov-report=html:htmlcov --cov=schematic/
141141
-m "not (google_credentials_needed or rule_combos or schematic_api or table_operations)"
142142
143143
- name: Upload pytest test results

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in
5959
```
6060
git clone https://github.com/Sage-Bionetworks/schematic.git
6161
```
62-
2. Install `poetry` (version 1.2 or later) using either the [official installer](https://python-poetry.org/docs/#installing-with-the-official-installer) or [pipx](https://python-poetry.org/docs/#installing-with-pipx). If you have an older installation of Poetry, we recommend uninstalling it first.
62+
2. Install `poetry` (version 1.3.0 or later) using either the [official installer](https://python-poetry.org/docs/#installing-with-the-official-installer) or [pipx](https://python-poetry.org/docs/#installing-with-pipx). If you have an older installation of Poetry, we recommend uninstalling it first.
6363

6464
3. Start the virtual environment by doing:
6565
```

poetry.lock

Lines changed: 2192 additions & 2281 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "schematicpy"
3-
version = "22.3.2"
3+
version = "23.11.1"
44
description = "Package for biomedical data model and metadata ingress management"
55
authors = [
66
"Milen Nikolov <milen.nikolov@sagebase.org>",
@@ -54,7 +54,7 @@ pygsheets = "^2.0.4"
5454
PyYAML = "^6.0.0"
5555
rdflib = "^6.0.0"
5656
setuptools = "^66.0.0"
57-
synapseclient = "^2.7.0"
57+
synapseclient = "^3.1.1"
5858
tenacity = "^8.0.1"
5959
toml = "^0.10.2"
6060
Flask = "^2.0.0"
@@ -70,7 +70,7 @@ Flask-Cors = "^3.0.10"
7070
pdoc = "^12.2.0"
7171
dateparser = "^1.1.4"
7272
pandarallel = "^1.6.4"
73-
schematic-db = {version = "^0.0.29", extras = ["synapse"]}
73+
schematic-db = {version = "0.0.dev33", extras = ["synapse"]}
7474
pyopenssl = "^23.0.0"
7575
typing-extensions = "<4.6.0"
7676

schematic/manifest/generator.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ def __init__(
5454
self.creds = services_creds["creds"]
5555

5656
# schema root
57-
self.root = root
57+
if root:
58+
self.root = root
59+
# Raise an error if no DataType has been provided
60+
else:
61+
raise ValueError("No DataType has been provided.")
5862

5963
# alphabetize valid values
6064
self.alphabetize = alphabetize_valid_values
@@ -79,12 +83,19 @@ def __init__(
7983

8084
# additional metadata to add to manifest
8185
self.additional_metadata = additional_metadata
86+
87+
# Check if the class is in the schema
88+
root_in_schema = self.sg.se.is_class_in_schema(self.root)
89+
90+
# If the class could not be found, give a notification
91+
if not root_in_schema:
92+
exception_message = f"The DataType entered ({self.root}) could not be found in the data model schema. " + \
93+
"Please confirm that the datatype is in the data model and that the spelling matches the class label in the .jsonld file."
94+
raise LookupError(exception_message)
8295

8396
# Determine whether current data type is file-based
84-
is_file_based = False
85-
if self.root:
86-
is_file_based = "Filename" in self.sg.get_node_dependencies(self.root)
87-
self.is_file_based = is_file_based
97+
self.is_file_based = "Filename" in self.sg.get_node_dependencies(self.root)
98+
8899

89100
def _attribute_to_letter(self, attribute, manifest_fields):
90101
"""Map attribute to column letter in a google sheet"""

schematic/models/metadata.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def get_component_requirements(
186186

187187
# TODO: abstract validation in its own module
188188
def validateModelManifest(
189-
self, manifestPath: str, rootNode: str, restrict_rules: bool = False, jsonSchema: str = None, project_scope: List = None,
189+
self, manifestPath: str, rootNode: str, restrict_rules: bool = False, jsonSchema: str = None, project_scope: List = None, access_token: str = None,
190190
) -> List[str]:
191191
"""Check if provided annotations manifest dataframe satisfies all model requirements.
192192
@@ -251,7 +251,16 @@ def validateModelManifest(
251251

252252
return errors, warnings
253253

254-
errors, warnings, manifest = validate_all(self, errors, warnings, manifest, manifestPath, self.sg, jsonSchema, restrict_rules, project_scope)
254+
errors, warnings, manifest = validate_all(self,
255+
errors=errors,
256+
warnings=warnings,
257+
manifest=manifest,
258+
manifestPath=manifestPath,
259+
sg=self.sg,
260+
jsonSchema=jsonSchema,
261+
restrict_rules=restrict_rules,
262+
project_scope=project_scope,
263+
access_token=access_token)
255264
return errors, warnings
256265

257266
def populateModelManifest(self, title, manifestPath: str, rootNode: str, return_excel = False) -> str:
@@ -328,7 +337,7 @@ def submit_metadata_manifest(
328337

329338
# automatic JSON schema generation and validation with that JSON schema
330339
val_errors, val_warnings = self.validateModelManifest(
331-
manifestPath=manifest_path, rootNode=validate_component, restrict_rules=restrict_rules, project_scope=project_scope,
340+
manifestPath=manifest_path, rootNode=validate_component, restrict_rules=restrict_rules, project_scope=project_scope, access_token=access_token
332341
)
333342

334343
# if there are no errors in validation process

schematic/models/validate_attribute.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
rule_in_rule_list,
2828
)
2929

30+
from synapseclient.core.exceptions import SynapseNoCredentialsError
3031

3132
logger = logging.getLogger(__name__)
3233

@@ -564,13 +565,18 @@ class ValidateAttribute(object):
564565
- Add string length validator
565566
"""
566567

567-
def get_target_manifests(target_component, project_scope: List):
568+
def get_target_manifests(target_component, project_scope: List, access_token: str = None):
568569
t_manifest_search = perf_counter()
569570
target_manifest_IDs=[]
570571
target_dataset_IDs=[]
571572

572573
#login
573-
synStore = SynapseStorage(project_scope=project_scope)
574+
try:
575+
synStore = SynapseStorage(access_token=access_token, project_scope=project_scope)
576+
except SynapseNoCredentialsError as e:
577+
raise ValueError(
578+
"No Synapse credentials were provided. Credentials must be provided to utilize cross-manfiest validation functionality."
579+
) from e
574580

575581
#Get list of all projects user has access to
576582
projects = synStore.getStorageProjects(project_scope=project_scope)
@@ -893,7 +899,7 @@ def url_validation(self, val_rule: str, manifest_col: str, sg: SchemaGenerator,)
893899
return errors, warnings
894900

895901
def cross_validation(
896-
self, val_rule: str, manifest_col: pd.core.series.Series, project_scope: List, sg: SchemaGenerator,
902+
self, val_rule: str, manifest_col: pd.core.series.Series, project_scope: List, sg: SchemaGenerator, access_token: str,
897903
) -> List[List[str]]:
898904
"""
899905
Purpose:
@@ -921,7 +927,7 @@ def cross_validation(
921927

922928

923929
#Get IDs of manifests with target component
924-
synStore, target_manifest_IDs, target_dataset_IDs = ValidateAttribute.get_target_manifests(target_component,project_scope)
930+
synStore, target_manifest_IDs, target_dataset_IDs = ValidateAttribute.get_target_manifests(target_component, project_scope, access_token)
925931

926932
t_cross_manifest = perf_counter()
927933
#Read each manifest

0 commit comments

Comments
 (0)