From 79e735e38f9b0808a612ffdcd124631ac2c4800b Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 10 Aug 2020 21:23:37 +0200 Subject: [PATCH 1/2] Fix change_datatype PJA when dataset is not yet in object store --- lib/galaxy/datatypes/registry.py | 2 +- lib/galaxy/model/__init__.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index 3a06b5ee2ff..0ea271805e1 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -587,7 +587,7 @@ class Registry: # initialization. if data.has_data(): data.set_size() - data.init_meta(copy_from=data) + data.init_meta(copy_from=data) return data def load_datatype_converters(self, toolbox, installed_repository_dict=None, deactivate=False, use_cached=False): diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 4f0774cde28..6d3672b0b26 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2324,6 +2324,10 @@ class Dataset(StorableObject, RepresentById): self.sources = [] self.hashes = [] + @property + def is_new(self): + return self.state == self.states.NEW + def in_ready_state(self): return self.state in self.ready_states @@ -2447,7 +2451,7 @@ class Dataset(StorableObject, RepresentById): def has_data(self): """Detects whether there is any data""" - return self.get_size() > 0 + return not self.is_new and self.get_size() > 0 def mark_deleted(self): self.deleted = True From 43c117022cbc6c27ad0a23b6f6eb66a2054b1369 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 11 Aug 2020 12:11:44 +0200 Subject: [PATCH 2/2] Move test_assign_column_pja to own class --- lib/galaxy_test/api/test_workflows.py | 62 ++++++++++--------- .../test_change_datatype_with_store_by_id.py | 22 +++++++ 2 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 test/integration/test_change_datatype_with_store_by_id.py diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index 22447beb248..0fd70152360 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -201,12 +201,43 @@ class BaseWorkflowsApiTestCase(ApiTestCase): assert tool_state_value["__class__"] == "RuntimeValue" +class ChangeDatatypeTestCase(object): + + def test_assign_column_pja(self): + with self.dataset_populator.test_history() as history_id: + self.workflow_populator.run_workflow(""" +class: GalaxyWorkflow +inputs: + input1: data +steps: + first_cat: + tool_id: cat + in: + input1: input1 + outputs: + out_file1: + change_datatype: bed + set_columns: + chromCol: 1 + endCol: 2 + startCol: 3 +""", test_data=""" +input1: + value: 1.bed + type: File +""", history_id=history_id) + details_dataset_new_col = self.dataset_populator.get_history_dataset_details(history_id, hid=2, wait=True, assert_ok=True) + assert details_dataset_new_col["history_content_type"] == "dataset", details_dataset_new_col + assert details_dataset_new_col['metadata_endCol'] == 2 + assert details_dataset_new_col['metadata_startCol'] == 3 + + # Workflow API TODO: # - Allow history_id as param to workflow run action. (hist_id) # - Allow post to workflows//run in addition to posting to # /workflows with id in payload. # - Much more testing obviously, always more testing. -class WorkflowsApiTestCase(BaseWorkflowsApiTestCase): +class WorkflowsApiTestCase(BaseWorkflowsApiTestCase, ChangeDatatypeTestCase): def test_show_valid(self): workflow_id = self.workflow_populator.simple_workflow("dummy") @@ -3196,35 +3227,6 @@ input1: assert details1["history_content_type"] == "dataset_collection" assert details1["tags"][0] == "name:foo", details1 - @skip_without_tool("cat") - def test_assign_column_pja(self): - with self.dataset_populator.test_history() as history_id: - self._run_jobs(""" -class: GalaxyWorkflow -inputs: - input1: data -steps: - first_cat: - tool_id: cat - in: - input1: input1 - outputs: - out_file1: - change_datatype: bed - set_columns: - chromCol: 1 - endCol: 2 - startCol: 3 -""", test_data=""" -input1: - value: 1.bed - type: File -""", history_id=history_id) - details_dataset_new_col = self.dataset_populator.get_history_dataset_details(history_id, hid=2, wait=True, assert_ok=True) - assert details_dataset_new_col["history_content_type"] == "dataset", details_dataset_new_col - assert details_dataset_new_col['metadata_endCol'] == 2 - assert details_dataset_new_col['metadata_startCol'] == 3 - @skip_without_tool("collection_creates_pair") @skip_without_tool("cat") def test_run_remove_tag_on_collection_output(self): diff --git a/test/integration/test_change_datatype_with_store_by_id.py b/test/integration/test_change_datatype_with_store_by_id.py new file mode 100644 index 00000000000..a28a5015449 --- /dev/null +++ b/test/integration/test_change_datatype_with_store_by_id.py @@ -0,0 +1,22 @@ +from galaxy_test.api.test_workflows import ChangeDatatypeTestCase +from galaxy_test.base.populators import ( + DatasetPopulator, + WorkflowPopulator, +) +from galaxy_test.driver import integration_util + + +class ChangeDatatypeStoreByIdIntegrationTestCase(integration_util.IntegrationTestCase, ChangeDatatypeTestCase): + """Test changing datatype with object_store_store_by: id.""" + + framework_tool_and_types = True + + @classmethod + def handle_galaxy_config_kwds(cls, config): + config["object_store_store_by"] = "id" + config["retry_metadata_internally"] = False + + def setUp(self): + super().setUp() + self.dataset_populator = DatasetPopulator(self.galaxy_interactor) + self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)