Skip to content

Commit

Permalink
Minor changes to utility/troubleshooting/convenience scripts view-por…
Browse files Browse the repository at this point in the history
…tal-object and update-portal-object.
  • Loading branch information
dmichaels-harvard committed Aug 16, 2024
1 parent a19a372 commit 83c1f4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dcicutils/scripts/update_portal_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ def post_or_patch_or_upsert(portal: Portal, file: str, schema_name: Optional[str
_print(f"DEBUG: File ({file}) contains a dictionary of schema names.")
for schema_name in data:
if isinstance(schema_data := data[schema_name], list):
schema_data = _impose_special_ordering(schema_data, schema_name)
if debug:
_print(f"DEBUG: Processing {update_action_name}s for type: {schema_name}")
for index, item in enumerate(schema_data):
Expand All @@ -250,6 +251,8 @@ def post_or_patch_or_upsert(portal: Portal, file: str, schema_name: Optional[str
elif isinstance(data, list):
if debug:
_print(f"DEBUG: File ({file}) contains a list of objects of type: {schema_name}")
import pdb ; pdb.set_trace() # noqa
data = _impose_special_ordering(data, schema_name)
for index, item in enumerate(data):
update_function(portal, item, schema_name, file=file, index=index,
patch_delete_fields=patch_delete_fields,
Expand Down Expand Up @@ -286,6 +289,12 @@ def post_or_patch_or_upsert(portal: Portal, file: str, schema_name: Optional[str
_print(f"ERROR: Cannot find file or directory: {file_or_directory}")


def _impose_special_ordering(data: List[dict], schema_name: str) -> List[dict]:
if schema_name == "FileFormat":
return sorted(data, key=lambda item: "extra_file_formats" in item)
return data


def post_data(portal: Portal, data: dict, schema_name: str,
file: Optional[str] = None, index: int = 0,
patch_delete_fields: Optional[str] = None,
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.14.0.1b3" # TODO: To become 8.14.1
version = "8.14.0.1b4" # TODO: To become 8.14.1
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 83c1f4b

Please sign in to comment.