From a2d1a5d2e661c9a2df03f66a012c7b336c77b93f Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 17 Jun 2024 13:58:36 +0200 Subject: [PATCH 1/5] really allow in-range validator for txt just enabling the linter https://github.com/galaxyproject/galaxy/pull/18403 was not sufficient --- lib/galaxy/tools/parameters/validation.py | 2 +- test/unit/app/tools/test_parameter_validation.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/parameters/validation.py b/lib/galaxy/tools/parameters/validation.py index cf02d86c56b5..6334fd95f8b8 100644 --- a/lib/galaxy/tools/parameters/validation.py +++ b/lib/galaxy/tools/parameters/validation.py @@ -165,7 +165,7 @@ def __init__(self, message, range_min, range_max, exclude_min=False, exclude_max op1 = "<" if self.exclude_max: op2 = "<" - expression = f"float('{self.min}') {op1} value {op2} float('{self.max}')" + expression = f"float('{self.min}') {op1} float(value) {op2} float('{self.max}')" if message is None: message = f"Value ('%s') must {'not ' if negate == 'true' else ''}fulfill {expression}" super().__init__(message, expression, negate) diff --git a/test/unit/app/tools/test_parameter_validation.py b/test/unit/app/tools/test_parameter_validation.py index bddb0e325309..8442f435a083 100644 --- a/test/unit/app/tools/test_parameter_validation.py +++ b/test/unit/app/tools/test_parameter_validation.py @@ -217,11 +217,11 @@ def test_InRangeValidator(self): ) p.validate(10) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < value <= float\('20'\)" + ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" ): p.validate(15) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < value <= float\('20'\)" + ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" ): p.validate(20) p.validate(21) From b7a4a5f2add533dc47d7f0c528a0fc222d7de01f Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 17 Jun 2024 23:08:03 +0200 Subject: [PATCH 2/5] Add TypedDict for JobsSummary Fixes: ``` lib/galaxy/managers/jobs.py:866: error: Unsupported target for indexed assignment ("object") [index] rval["states"][row[0]] = row[1] ``` in mypy. --- lib/galaxy/managers/jobs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/managers/jobs.py b/lib/galaxy/managers/jobs.py index dd877c582592..546085b26a2e 100644 --- a/lib/galaxy/managers/jobs.py +++ b/lib/galaxy/managers/jobs.py @@ -8,6 +8,7 @@ cast, Dict, List, + Optional, ) import sqlalchemy @@ -26,6 +27,7 @@ ) from sqlalchemy.orm import aliased from sqlalchemy.sql import select +from typing_extensions import TypedDict from galaxy import model from galaxy.exceptions import ( @@ -824,7 +826,14 @@ def merge_states(component_states): return rval -def summarize_jobs_to_dict(sa_session, jobs_source): +class JobsSummary(TypedDict): + populated_state: str + states: Dict[str, int] + model: str + id: int + + +def summarize_jobs_to_dict(sa_session, jobs_source) -> Optional[JobsSummary]: """Produce a summary of jobs for job summary endpoints. :type jobs_source: a Job or ImplicitCollectionJobs or None @@ -833,7 +842,7 @@ def summarize_jobs_to_dict(sa_session, jobs_source): :rtype: dict :returns: dictionary containing job summary information """ - rval = None + rval: Optional[JobsSummary] = None if jobs_source is None: pass elif isinstance(jobs_source, model.Job): From 5297fa3137ed9eb3585500fd2013323650047f48 Mon Sep 17 00:00:00 2001 From: M Bernt Date: Tue, 18 Jun 2024 09:59:33 +0200 Subject: [PATCH 3/5] Apply suggestions from code review --- test/unit/app/tools/test_parameter_validation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/app/tools/test_parameter_validation.py b/test/unit/app/tools/test_parameter_validation.py index 8442f435a083..23df864ae3e4 100644 --- a/test/unit/app/tools/test_parameter_validation.py +++ b/test/unit/app/tools/test_parameter_validation.py @@ -217,11 +217,11 @@ def test_InRangeValidator(self): ) p.validate(10) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" + ValueError, r"Parameter blah: Value \('15'\) must not fulfill float\('10'\) < float\(value\) <= float\('20'\)" ): p.validate(15) with self.assertRaisesRegex( - ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < float(value) <= float\('20'\)" + ValueError, r"Parameter blah: Value \('20'\) must not fulfill float\('10'\) < float\(value\) <= float\('20'\)" ): p.validate(20) p.validate(21) From f090fbf9b5ad441857a2f388f44b9887f3077c1b Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:27:53 +0200 Subject: [PATCH 4/5] Serialize purged flag for DCEObjects --- client/src/api/schema/schema.ts | 2 ++ lib/galaxy/managers/collections_util.py | 1 + lib/galaxy/schema/schema.py | 1 + 3 files changed, 4 insertions(+) diff --git a/client/src/api/schema/schema.ts b/client/src/api/schema/schema.ts index f592e3f59745..e1c907c09a97 100644 --- a/client/src/api/schema/schema.ts +++ b/client/src/api/schema/schema.ts @@ -6119,6 +6119,8 @@ export interface components { * @constant */ model_class: "HistoryDatasetAssociation"; + /** Purged */ + purged: boolean; /** * State * @description The current state of this dataset. diff --git a/lib/galaxy/managers/collections_util.py b/lib/galaxy/managers/collections_util.py index 0896c2f82dfc..d0ca89f61626 100644 --- a/lib/galaxy/managers/collections_util.py +++ b/lib/galaxy/managers/collections_util.py @@ -186,6 +186,7 @@ def dictify_element_reference( else: object_details["state"] = element_object.state object_details["hda_ldda"] = "hda" + object_details["purged"] = element_object.purged if isinstance(element_object, model.HistoryDatasetAssociation): object_details["history_id"] = element_object.history_id object_details["tags"] = element_object.make_tag_string_list() diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index c624bab55df5..632ae5af53e6 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -950,6 +950,7 @@ class HDAObject(Model, WithModelClass): tags: List[str] copied_from_ldda_id: Optional[EncodedDatabaseIdField] = None accessible: Optional[bool] = None + purged: bool model_config = ConfigDict(extra="allow") From c4d124b13846088628da67d55cf4a0e89d191dc5 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:46:43 +0200 Subject: [PATCH 5/5] Adapt unit test to include purged flag --- client/src/stores/collectionElementsStore.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/stores/collectionElementsStore.test.ts b/client/src/stores/collectionElementsStore.test.ts index af3096c49a4d..6af9a98f5d57 100644 --- a/client/src/stores/collectionElementsStore.test.ts +++ b/client/src/stores/collectionElementsStore.test.ts @@ -151,6 +151,7 @@ function mockElement(collectionId: string, i: number): DCESummary { history_id: "1", tags: [], accessible: true, + purged: false, }, }; }