Skip to content

Commit

Permalink
minor update-portal-object script update for deleting fields on patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Jul 25, 2024
1 parent dc05821 commit 1ce283a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dcicutils/scripts/update_portal_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def usage(message: Optional[str] = None) -> None:
update_action_name="PATCH",
patch_delete_fields=args.delete,
confirm=args.confirm, verbose=args.verbose, quiet=args.quiet, debug=args.debug)
args.delete = None
if args.upsert:
_post_or_patch_or_upsert(portal=portal,
file_or_directory=args.upsert,
Expand All @@ -173,6 +174,7 @@ def usage(message: Optional[str] = None) -> None:
update_action_name="UPSERT",
patch_delete_fields=args.delete,
confirm=args.confirm, verbose=args.verbose, quiet=args.quiet, debug=args.debug)
args.delete = None

if args.delete:
if not portal.get_metadata(args.delete, raise_exception=False):
Expand Down Expand Up @@ -256,14 +258,17 @@ def post_or_patch_or_upsert(portal: Portal, file: str, schema_name: Optional[str
_print(f"ERROR: Schema cannot be inferred from file name and --schema not specified: {file}")
continue
post_or_patch_or_upsert(portal, file_and_schema[0], schema_name=schema_name,
patch_delete_fields=patch_delete_fields,
confirm=confirm, quiet=quiet, verbose=verbose, debug=debug)
elif os.path.isfile(file := file_or_directory):
if ((schema_name := _get_schema_name_from_schema_named_json_file_name(portal, file)) or
(schema_name := explicit_schema_name)): # noqa
post_or_patch_or_upsert(portal, file, schema_name=schema_name,
patch_delete_fields=patch_delete_fields,
confirm=confirm, quiet=quiet, verbose=verbose, debug=debug)
else:
post_or_patch_or_upsert(portal, file, schema_name=schema_name,
patch_delete_fields=patch_delete_fields,
confirm=confirm, quiet=quiet, verbose=verbose, debug=debug)
# _print(f"ERROR: Schema cannot be inferred from file name and --schema not specified: {file}")
# return
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.13.3.1b9" # TODO: To become 8.13.4
version = "8.13.3.1b10" # TODO: To become 8.13.4
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 1ce283a

Please sign in to comment.