From 42b8dfd0ab71cf3f4de91d96795a5d5ded026e65 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 23 Aug 2024 11:16:31 -0400 Subject: [PATCH 1/6] Minor changes to view-portal-object utility script. --- CHANGELOG.rst | 6 ++++++ dcicutils/scripts/view_portal_object.py | 7 ++++++- pyproject.toml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6926218df..029e1c6d8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,12 @@ dcicutils Change Log ---------- +8.14.4 +====== + +* Minor changes to view-portal-object utility script. + + 8.14.3 ====== diff --git a/dcicutils/scripts/view_portal_object.py b/dcicutils/scripts/view_portal_object.py index 8696c94b6..7d440df2e 100644 --- a/dcicutils/scripts/view_portal_object.py +++ b/dcicutils/scripts/view_portal_object.py @@ -360,7 +360,12 @@ def write_insert_files(response: dict) -> None: path = f"/{uuid}" else: path = uuid - response = portal.get(path, raw=raw or inserts, database=database) + if (response := portal.get(path, raw=raw or inserts, database=database)) is not None: + if response.status_code == 403: + _exit(f"Permission error getting Portal object from {portal.server}: {uuid}") + elif response.status_code == 404: + _exit(f"Not found Portal object from {portal.server}: {uuid}") + except Exception as e: if "404" in str(e) and "not found" in str(e).lower(): _print(f"Portal object not found at {portal.server}: {uuid}") diff --git a/pyproject.toml b/pyproject.toml index 3d1dd5044..b2e3cbec1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.14.3" +version = "8.14.3.1b1" # TODO: To become 8.14.4 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 60b183876da23a0e21cc811ea657b4a4cf7020a3 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Sat, 24 Aug 2024 07:17:20 -0400 Subject: [PATCH 2/6] Minor changes to validators hooks in structured_data. --- CHANGELOG.rst | 3 ++- dcicutils/structured_data.py | 8 +------- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 029e1c6d8..b42cecedf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,7 +9,8 @@ Change Log 8.14.4 ====== -* Minor changes to view-portal-object utility script. +* Minor changes to view_portal_object utility script. +* Minor changes to validators hooks in structured_data. 8.14.3 diff --git a/dcicutils/structured_data.py b/dcicutils/structured_data.py index 945723040..4a95153ed 100644 --- a/dcicutils/structured_data.py +++ b/dcicutils/structured_data.py @@ -388,13 +388,7 @@ def _load_reader(self, reader: RowReader, type_name: str) -> None: structured_row = structured_row_template.create_row() for column_name, value in row.items(): if self._validator_hook: - value, validator_error = ( - self._validator_hook(self, type_name, column_name, reader.row_number, value)) - if validator_error: - self._note_error({ - "src": create_dict(type=schema_name, row=reader.row_number), - "error": validator_error - }, "validation") + value = self._validator_hook(self, type_name, column_name, reader.row_number, value) structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number) if self._autoadd_properties: self._add_properties(structured_row, self._autoadd_properties, schema) diff --git a/pyproject.toml b/pyproject.toml index b2e3cbec1..2abcc6442 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.14.3.1b1" # TODO: To become 8.14.4 +version = "8.14.3.1b2" # TODO: To become 8.14.4 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 297df962bf226f1d838ff2a20a3420a6163b2939 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Sat, 24 Aug 2024 08:14:53 -0400 Subject: [PATCH 3/6] added portal_utils.Portal.get_version method --- CHANGELOG.rst | 1 + dcicutils/portal_utils.py | 6 ++++++ pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b42cecedf..aa87fe536 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,7 @@ Change Log * Minor changes to view_portal_object utility script. * Minor changes to validators hooks in structured_data. +* Added portal_utils.Portal.get_version method. 8.14.3 diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index ce92c9270..3467cf19f 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -294,6 +294,12 @@ def head(self, url: str, follow: bool = True, raise_exception: bool = False, **k def get_health(self) -> OptionalResponse: return self.get("/health") + def get_version(self) -> Optional[str]: + try: + return self.get_health().json()["project_version"] + except Exception: + return None + def ping(self) -> bool: try: return self.get_health().status_code == 200 diff --git a/pyproject.toml b/pyproject.toml index 2abcc6442..fcfbeccbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.14.3.1b2" # TODO: To become 8.14.4 +version = "8.14.3.1b3" # TODO: To become 8.14.4 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From cb49834887e7d7eddf58dd0188e8b50aa7fc121f Mon Sep 17 00:00:00 2001 From: David Michaels Date: Sat, 24 Aug 2024 10:17:01 -0400 Subject: [PATCH 4/6] added portal_utils.Portal.get_version method --- dcicutils/structured_data.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dcicutils/structured_data.py b/dcicutils/structured_data.py index 4a95153ed..fa2ae7d52 100644 --- a/dcicutils/structured_data.py +++ b/dcicutils/structured_data.py @@ -318,7 +318,7 @@ def get_counts() -> Tuple[int, int]: order = {Schema.type_name(key): index for index, key in enumerate(self._order)} if self._order else {} for sheet_name in sorted(excel.sheet_names, key=lambda key: order.get(Schema.type_name(key), sys.maxsize)): self._load_reader(excel.sheet_reader(sheet_name), type_name=Schema.type_name(sheet_name)) - if self._validator_sheet_hook: + if self._validator_sheet_hook and self.data.get(sheet_name): self._validator_sheet_hook(self, sheet_name, self.data[sheet_name]) # TODO: Do we really need progress reporting for the below? # Check for unresolved reference errors which really are not because of ordering. diff --git a/pyproject.toml b/pyproject.toml index fcfbeccbe..3c928af98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.14.3.1b3" # TODO: To become 8.14.4 +version = "8.14.3.1b4" # TODO: To become 8.14.4 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 6334238362c13e8c081e27d53d7a11077d360b42 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Mon, 9 Sep 2024 15:58:50 -0400 Subject: [PATCH 5/6] minor fix to misc_utils.format_duration --- CHANGELOG.rst | 1 + dcicutils/misc_utils.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aa87fe536..489694236 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,7 @@ Change Log * Minor changes to view_portal_object utility script. * Minor changes to validators hooks in structured_data. * Added portal_utils.Portal.get_version method. +* Minor fix in misc_utils.format_duration. 8.14.3 diff --git a/dcicutils/misc_utils.py b/dcicutils/misc_utils.py index 5de86755e..2df638862 100644 --- a/dcicutils/misc_utils.py +++ b/dcicutils/misc_utils.py @@ -2802,7 +2802,7 @@ def format_duration(seconds: Union[int, float]) -> str: durations = [("year", 31536000), ("day", 86400), ("hour", 3600), ("minute", 60), ("second", 1)] parts = [] for name, duration in durations: - if seconds >= duration: + if (seconds == 0) or (seconds >= duration): count = seconds // duration seconds %= duration if count != 1: diff --git a/pyproject.toml b/pyproject.toml index 3c928af98..7960efa50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.14.3.1b4" # TODO: To become 8.14.4 +version = "8.14.3.1b5" # TODO: To become 8.14.4 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 86bb150a1dec5b2ae99212d1bfa891a46a2b5eda Mon Sep 17 00:00:00 2001 From: David Michaels Date: Mon, 7 Oct 2024 11:49:58 -0400 Subject: [PATCH 6/6] update version to 8.16.0 - ready to merge pr-317 with minor changes for smaht-submitr --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 76b5577be..ac6809802 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.15.0.1b1" # TODO: To become 8.16.0 +version = "8.16.0" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"