Skip to content

Commit 9d353c0

Browse files
authored
Merge pull request #1300 from Sage-Bionetworks/revert-1286-develop-node-error-FDS-955
Revert "Raise a helpful error when a datatype cannot be found in a schema"
2 parents a0424cb + 492fbf1 commit 9d353c0

File tree

2 files changed

+9
-39
lines changed

2 files changed

+9
-39
lines changed

schematic/manifest/generator.py

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

5656
# schema 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.")
57+
self.root = root
6258

6359
# alphabetize valid values
6460
self.alphabetize = alphabetize_valid_values
@@ -83,19 +79,12 @@ def __init__(
8379

8480
# additional metadata to add to manifest
8581
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)
9582

9683
# Determine whether current data type is file-based
97-
self.is_file_based = "Filename" in self.sg.get_node_dependencies(self.root)
98-
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
9988

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

tests/test_manifest.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,13 @@ def test_init(self, helpers):
8787
generator = ManifestGenerator(
8888
title="mock_title",
8989
path_to_json_ld=helpers.get_data_path("example.model.jsonld"),
90-
root = "Patient"
9190
)
9291

9392
assert type(generator.title) is str
9493
# assert generator.sheet_service == mock_creds["sheet_service"]
95-
assert generator.root is "Patient"
94+
assert generator.root is None
9695
assert type(generator.sg) is SchemaGenerator
9796

98-
@pytest.mark.parametrize("data_type, exc, exc_message",
99-
[("MissingComponent", LookupError, "could not be found in the data model schema"),
100-
(None, ValueError, "No DataType has been provided.")],
101-
ids = ["DataType not found in Schema", "No DataType provided"])
102-
def test_missing_root_error(self, helpers, data_type, exc, exc_message):
103-
"""
104-
Test for errors when either no DataType is provided or when a DataType is provided but not found in the schema
105-
"""
106-
107-
# A LookupError should be raised and include message when the component cannot be found
108-
with pytest.raises(exc) as e:
109-
generator = ManifestGenerator(
110-
path_to_json_ld=helpers.get_data_path("example.model.jsonld"),
111-
root=data_type,
112-
use_annotations=False,
113-
)
114-
115-
# Check message contents
116-
assert exc_message in str(e)
117-
11897
@pytest.mark.google_credentials_needed
11998
def test_get_manifest_first_time(self, manifest):
12099

@@ -166,7 +145,7 @@ def test_get_manifest_first_time(self, manifest):
166145
# An annotation merged with an attribute from the data model
167146
if use_annotations:
168147
assert output["File Format"].tolist() == ["txt", "csv", "fastq"]
169-
148+
170149
@pytest.mark.parametrize("output_format", [None, "dataframe", "excel", "google_sheet"])
171150
@pytest.mark.parametrize("sheet_url", [None, True, False])
172151
@pytest.mark.parametrize("dataset_id", [None, "syn27600056"])
@@ -433,3 +412,5 @@ def test_populate_existing_excel_spreadsheet(self, simple_manifest_generator, si
433412
# remove file
434413
os.remove(dummy_output_path)
435414

415+
416+

0 commit comments

Comments
 (0)