From ca9a460401b6ebc7cce95cea16703215a4e16123 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Wed, 5 Mar 2025 08:10:45 -0500 Subject: [PATCH 01/10] Added method portal_utils.get_schema_super_type_names (for use by smaht-submitr). --- CHANGELOG.rst | 6 ++++++ dcicutils/portal_utils.py | 13 +++++++++++++ pyproject.toml | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b4a3d6c06..a229435f9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,12 @@ dcicutils Change Log ---------- +8.18.2 +====== +* dmichaels / 2025-03-05 / branch: dmichaels-20250305-add-portal-get-schema-super-types / PR-328 + - Added method portal_utils.get_schema_super_type_names (for use by smaht-submitr). + + 8.18.1 ====== * dmichaels / 2025-02-28 / branch: dmichaels-20250228-correct-submitr-config-path / PR-327 diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index b2378c75a..4c645f88f 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -471,6 +471,19 @@ def list_breadth_first(super_type_map: dict, super_type_name: str) -> dict: super_type_map_flattened[super_type_name] = list_breadth_first(super_type_map, super_type_name) return super_type_map_flattened + @lru_cache(maxsize=100) + def get_schema_super_type_names(self, schema_name: str, include_schema_name: bool = False) -> List[str]: + if isinstance(schema_name, str) and (schema_name := self.schema_name(schema_name)): + if isinstance(super_type_map := self.get_schemas_super_type_map(), dict): + super_types = set() + for super_type_name in super_type_map: + if schema_name in super_type_map[super_type_name]: + super_types.add(super_type_name) + if (include_schema_name is True) and super_types and self.get_schema(schema_name): + super_types.add(schema_name) + return list(super_types) + return [] + @lru_cache(maxsize=100) def get_schema_subtype_names(self, type_name: str) -> List[str]: if not (schemas_super_type_map := self.get_schemas_super_type_map()): diff --git a/pyproject.toml b/pyproject.toml index 6ebeb31cb..1e47703b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.1" +version = "8.18.1.1b1" # TODO: 8.18.2 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From aefca3cdf203cf74de81c6c425bdf7819a8991a2 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Wed, 5 Mar 2025 08:38:01 -0500 Subject: [PATCH 02/10] - Added method portal_utils.get_schema_super_type_names (for use by smaht-submitr). --- dcicutils/portal_utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index 4c645f88f..d123dbce2 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -473,16 +473,15 @@ def list_breadth_first(super_type_map: dict, super_type_name: str) -> dict: @lru_cache(maxsize=100) def get_schema_super_type_names(self, schema_name: str, include_schema_name: bool = False) -> List[str]: + super_types = set() if isinstance(schema_name, str) and (schema_name := self.schema_name(schema_name)): if isinstance(super_type_map := self.get_schemas_super_type_map(), dict): - super_types = set() for super_type_name in super_type_map: if schema_name in super_type_map[super_type_name]: super_types.add(super_type_name) - if (include_schema_name is True) and super_types and self.get_schema(schema_name): - super_types.add(schema_name) - return list(super_types) - return [] + if (include_schema_name is True) and self.get_schema(schema_name): + super_types.insert(0, schema_name) + return list(super_types) @lru_cache(maxsize=100) def get_schema_subtype_names(self, type_name: str) -> List[str]: From 63d8917558d5970b21e9d011ac02e72625f49870 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Wed, 5 Mar 2025 08:38:12 -0500 Subject: [PATCH 03/10] - Added method portal_utils.get_schema_super_type_names (for use by smaht-submitr). --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1e47703b2..f692df5cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.1.1b1" # TODO: 8.18.2 +version = "8.18.1.1b2" # TODO: 8.18.2 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 3fed1730fb47784226678c6f7aa20131a73200fc Mon Sep 17 00:00:00 2001 From: David Michaels Date: Wed, 5 Mar 2025 08:39:21 -0500 Subject: [PATCH 04/10] - Added method portal_utils.get_schema_super_type_names (for use by smaht-submitr). --- dcicutils/portal_utils.py | 3 ++- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dcicutils/portal_utils.py b/dcicutils/portal_utils.py index d123dbce2..5dde8614d 100644 --- a/dcicutils/portal_utils.py +++ b/dcicutils/portal_utils.py @@ -479,9 +479,10 @@ def get_schema_super_type_names(self, schema_name: str, include_schema_name: boo for super_type_name in super_type_map: if schema_name in super_type_map[super_type_name]: super_types.add(super_type_name) + super_types = list(super_types) if (include_schema_name is True) and self.get_schema(schema_name): super_types.insert(0, schema_name) - return list(super_types) + return super_types @lru_cache(maxsize=100) def get_schema_subtype_names(self, type_name: str) -> List[str]: diff --git a/pyproject.toml b/pyproject.toml index f692df5cf..ecad15c22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.1.1b2" # TODO: 8.18.2 +version = "8.18.1.1b3" # TODO: 8.18.2 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From fa2ece7ed201dbf1be2fbf6f191630ca51d78699 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 21 Mar 2025 10:40:01 -0400 Subject: [PATCH 05/10] version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ecad15c22..7695be114 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.1.1b3" # TODO: 8.18.2 +version = "8.18.2" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From caabd7db2ec5dd649fa610933bbf170c8ddf205d Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 21 Mar 2025 14:32:58 -0400 Subject: [PATCH 06/10] version-8.18.3 --- CHANGELOG.rst | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a229435f9..f206702b4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,7 +6,7 @@ dcicutils Change Log ---------- -8.18.2 +8.18.3 ====== * dmichaels / 2025-03-05 / branch: dmichaels-20250305-add-portal-get-schema-super-types / PR-328 - Added method portal_utils.get_schema_super_type_names (for use by smaht-submitr). diff --git a/pyproject.toml b/pyproject.toml index 7695be114..6e2a22878 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.2" +version = "8.18.3" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 67b8544f429f39a4a3e79309335595b9c0eb0d41 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 21 Mar 2025 14:34:30 -0400 Subject: [PATCH 07/10] last minute change to custom_excel.py for smaht-submitr --- dcicutils/submitr/custom_excel.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dcicutils/submitr/custom_excel.py b/dcicutils/submitr/custom_excel.py index fdf8b5cbb..3e52b1658 100644 --- a/dcicutils/submitr/custom_excel.py +++ b/dcicutils/submitr/custom_excel.py @@ -95,7 +95,8 @@ def sheet_reader(self, sheet_name: str) -> ExcelSheetReader: return CustomExcelSheetReader(self, sheet_name=sheet_name, workbook=self._workbook, custom_column_mappings=self._custom_column_mappings) - def effective_sheet_name(self, sheet_name: str) -> str: + @staticmethod + def effective_sheet_name(sheet_name: str) -> str: if (underscore := sheet_name.find("_")) > 1: return sheet_name[underscore + 1:] return sheet_name @@ -151,11 +152,19 @@ def __init__(self, *args, **kwargs) -> None: ARGUMENT_NAME_CUSTOM_COLUMN_MAPPINGS = "custom_column_mappings" self._custom_column_mappings = None if ARGUMENT_NAME_CUSTOM_COLUMN_MAPPINGS in kwargs: + def lookup_custom_column_mappings(custom_column_mappings: dict, sheet_name: str) -> Optional[dict]: + if isinstance(custom_column_mappings, dict) and isinstance(sheet_name, str): + if isinstance(found_custom_column_mappings := custom_column_mappings.get(sheet_name), dict): + return found_custom_column_mappings + if (effective_sheet_name := CustomExcel.effective_sheet_name(sheet_name)) != sheet_name: + if isinstance(found_custom_column_mappings := custom_column_mappings.get(effective_sheet_name), dict): + return found_custom_column_mappings + return None custom_column_mappings = kwargs[ARGUMENT_NAME_CUSTOM_COLUMN_MAPPINGS] del kwargs[ARGUMENT_NAME_CUSTOM_COLUMN_MAPPINGS] if not (isinstance(custom_column_mappings, dict) and isinstance(sheet_name := kwargs.get(ARGUMENT_NAME_SHEET_NAME, None), str) and - isinstance(custom_column_mappings := custom_column_mappings.get(sheet_name), dict)): + isinstance(custom_column_mappings := lookup_custom_column_mappings(custom_column_mappings, sheet_name), dict)): custom_column_mappings = None self._custom_column_mappings = custom_column_mappings super().__init__(*args, **kwargs) From a8514f33f75616ac331d1676fb8116d872414e1b Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 21 Mar 2025 14:38:10 -0400 Subject: [PATCH 08/10] flake8 fix --- dcicutils/submitr/custom_excel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dcicutils/submitr/custom_excel.py b/dcicutils/submitr/custom_excel.py index 3e52b1658..9f4ea5291 100644 --- a/dcicutils/submitr/custom_excel.py +++ b/dcicutils/submitr/custom_excel.py @@ -157,14 +157,16 @@ def lookup_custom_column_mappings(custom_column_mappings: dict, sheet_name: str) if isinstance(found_custom_column_mappings := custom_column_mappings.get(sheet_name), dict): return found_custom_column_mappings if (effective_sheet_name := CustomExcel.effective_sheet_name(sheet_name)) != sheet_name: - if isinstance(found_custom_column_mappings := custom_column_mappings.get(effective_sheet_name), dict): + if isinstance(found_custom_column_mappings := + custom_column_mappings.get(effective_sheet_name), dict): return found_custom_column_mappings return None custom_column_mappings = kwargs[ARGUMENT_NAME_CUSTOM_COLUMN_MAPPINGS] del kwargs[ARGUMENT_NAME_CUSTOM_COLUMN_MAPPINGS] if not (isinstance(custom_column_mappings, dict) and isinstance(sheet_name := kwargs.get(ARGUMENT_NAME_SHEET_NAME, None), str) and - isinstance(custom_column_mappings := lookup_custom_column_mappings(custom_column_mappings, sheet_name), dict)): + isinstance(custom_column_mappings := + lookup_custom_column_mappings(custom_column_mappings, sheet_name), dict)): custom_column_mappings = None self._custom_column_mappings = custom_column_mappings super().__init__(*args, **kwargs) From 54e21deaee203f1ff3b60112a081d112827035ba Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 21 Mar 2025 14:44:18 -0400 Subject: [PATCH 09/10] version-update-beta --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6e2a22878..ce2e304a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.3" +version = "8.18.2.1b1" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT" From 2706725b2ae64ce7d1c44b7332ad7f8a343e0667 Mon Sep 17 00:00:00 2001 From: David Michaels Date: Fri, 21 Mar 2025 14:54:00 -0400 Subject: [PATCH 10/10] version-8.18.3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ce2e304a9..6e2a22878 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.18.2.1b1" +version = "8.18.3" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"