Skip to content

Commit

Permalink
fix in structured_data for json file
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed May 29, 2024
1 parent a5e84df commit b59a5c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions dcicutils/structured_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,22 @@ def get_counts() -> Tuple[int, int]:

def _load_json_file(self, file: str) -> None:
with open(file) as f:
item = json.load(f)
data = json.load(f)
import pdb ; pdb.set_trace() # noqa
pass
if ((schema_name_inferred_from_file_name := Schema.type_name(file)) and
(self._portal.get_schema(schema_name_inferred_from_file_name) is not None)): # noqa
# If the JSON file name looks like a schema name then assume it
# contains an object or an array of object of that schema type.
if self._merge:
item = self._merge_with_existing_portal_object(item, schema_name_inferred_from_file_name)
self._add(Schema.type_name(file), item)
elif isinstance(item, dict):
data = self._merge_with_existing_portal_object(data, schema_name_inferred_from_file_name)
self._add(Schema.type_name(file), data)
elif isinstance(data, dict):
# Otherwise if the JSON file name does not look like a schema name then
# assume it a dictionary where each property is the name of a schema, and
# which (each property) contains a list of object of that schema type.
for schema_name in item:
item = item[schema_name]
for schema_name in data:
item = data[schema_name]
if self._merge:
item = self._merge_with_existing_portal_object(item, schema_name)
self._add(schema_name, item)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.8.6.1b12"
version = "8.8.6.1b13"
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit b59a5c1

Please sign in to comment.