From 1b65da81cf7c38ce2cd0bf47dc9dc6c42625976d Mon Sep 17 00:00:00 2001 From: guerler Date: Thu, 10 Feb 2022 17:59:06 -0500 Subject: [PATCH] Remove visualizations from dataset serialization test, run prettier, fix tests --- client/src/components/History/History.vue | 6 +- lib/galaxy/managers/hdcas.py | 15 +- lib/galaxy/schema/schema.py | 153 ++++++++++-------- lib/galaxy_test/api/test_datasets.py | 2 - lib/galaxy_test/api/test_history_contents.py | 2 +- test/unit/app/managers/test_HDAManager.py | 9 +- .../unit/app/managers/test_markdown_export.py | 3 +- 7 files changed, 104 insertions(+), 86 deletions(-) diff --git a/client/src/components/History/History.vue b/client/src/components/History/History.vue index 9ff6508bc95..171165e7c7a 100644 --- a/client/src/components/History/History.vue +++ b/client/src/components/History/History.vue @@ -136,9 +136,9 @@ export default { }, computed: { dataUrl() { - return `api/histories/${this.historyId}/contents/before/${this.maxHid + this.maxNew}/${this.pageSize}?view=detailed&${ - this.queryString - }`; + return `api/histories/${this.historyId}/contents/before/${this.maxHid + this.maxNew}/${ + this.pageSize + }?view=detailed&${this.queryString}`; }, historyId() { return this.history.id; diff --git a/lib/galaxy/managers/hdcas.py b/lib/galaxy/managers/hdcas.py index c3f87ad2533..14bd2edde38 100644 --- a/lib/galaxy/managers/hdcas.py +++ b/lib/galaxy/managers/hdcas.py @@ -256,6 +256,7 @@ class HDCASerializer(DCASerializer, taggable.TaggableSerializerMixin, annotatabl "type_id", "name", "history_id", + "collection_id", "hid", "history_content_type", "collection_type", @@ -264,20 +265,28 @@ class HDCASerializer(DCASerializer, taggable.TaggableSerializerMixin, annotatabl "element_count", "job_source_id", "job_source_type", + "job_state_summary", "name", "type_id", "deleted", - # 'purged', "visible", "type", "url", "create_time", "update_time", - "tags", # TODO: detail view only (maybe), + "tags", "contents_url", ], ) - self.add_view("detailed", ["populated", "elements"], include_keys_from="summary") + self.add_view( + "detailed", + [ + "populated", + "elements", + "elements_datatypes", + ], + include_keys_from="summary", + ) def add_serializers(self): super().add_serializers() diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index 968712cdab5..3a22ddf5579 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -656,6 +656,76 @@ class DCDetailed(DCSummary): elements: List[DCESummary] = ElementsField +class HDCJobStateSummary(Model): + """Overview of the job states working inside a dataset collection.""" + + all_jobs: int = Field( + 0, + title="All jobs", + description="Total number of jobs associated with a dataset collection.", + ) + new: int = Field( + 0, + title="New jobs", + description="Number of jobs in the `new` state.", + ) + waiting: int = Field( + 0, + title="Waiting jobs", + description="Number of jobs in the `waiting` state.", + ) + running: int = Field( + 0, + title="Running jobs", + description="Number of jobs in the `running` state.", + ) + error: int = Field( + 0, + title="Jobs with errors", + description="Number of jobs in the `error` state.", + ) + paused: int = Field( + 0, + title="Paused jobs", + description="Number of jobs in the `paused` state.", + ) + deleted_new: int = Field( + 0, + title="Deleted new jobs", + description="Number of jobs in the `deleted_new` state.", + ) + resubmitted: int = Field( + 0, + title="Resubmitted jobs", + description="Number of jobs in the `resubmitted` state.", + ) + queued: int = Field( + 0, + title="Queued jobs", + description="Number of jobs in the `queued` state.", + ) + ok: int = Field( + 0, + title="OK jobs", + description="Number of jobs in the `ok` state.", + ) + failed: int = Field( + 0, + title="Failed jobs", + description="Number of jobs in the `failed` state.", + ) + deleted: int = Field( + 0, + title="Deleted jobs", + description="Number of jobs in the `deleted` state.", + ) + upload: int = Field( + 0, + title="Upload jobs", + description="Number of jobs in the `upload` state.", + ) + + class HDCASummary(HistoryItemCommon): """History Dataset Collection Association summary information.""" @@ -682,7 +752,17 @@ class HDCASummary(HistoryItemCommon): title="Job Source Type", description="The type of job (model class) that produced this dataset collection. Used to track the state of the job.", ) + job_state_summary: Optional[HDCJobStateSummary] = Field( + None, + title="Job State Summary", + description="Overview of the job states working inside the dataset collection.", + ) contents_url: RelativeUrl = ContentsUrlField + collection_id: EncodedDatabaseIdField = Field( + ..., + title="Collection ID", + description="The encoded ID of the dataset collection associated with this HDCA.", + ) class HDCADetailed(HDCASummary): @@ -690,6 +770,9 @@ class HDCADetailed(HDCASummary): populated: bool = PopulatedField elements: List[DCESummary] = ElementsField + elements_datatypes: Set[str] = Field( + ..., description="A set containing all the different element datatypes in the collection." + ) class HistoryBase(BaseModel): @@ -1154,76 +1237,6 @@ class JobIdResponse(BaseModel): ) -class HDCJobStateSummary(Model): - """Overview of the job states working inside a dataset collection.""" - - all_jobs: int = Field( - 0, - title="All jobs", - description="Total number of jobs associated with a dataset collection.", - ) - new: int = Field( - 0, - title="New jobs", - description="Number of jobs in the `new` state.", - ) - waiting: int = Field( - 0, - title="Waiting jobs", - description="Number of jobs in the `waiting` state.", - ) - running: int = Field( - 0, - title="Running jobs", - description="Number of jobs in the `running` state.", - ) - error: int = Field( - 0, - title="Jobs with errors", - description="Number of jobs in the `error` state.", - ) - paused: int = Field( - 0, - title="Paused jobs", - description="Number of jobs in the `paused` state.", - ) - deleted_new: int = Field( - 0, - title="Deleted new jobs", - description="Number of jobs in the `deleted_new` state.", - ) - resubmitted: int = Field( - 0, - title="Resubmitted jobs", - description="Number of jobs in the `resubmitted` state.", - ) - queued: int = Field( - 0, - title="Queued jobs", - description="Number of jobs in the `queued` state.", - ) - ok: int = Field( - 0, - title="OK jobs", - description="Number of jobs in the `ok` state.", - ) - failed: int = Field( - 0, - title="Failed jobs", - description="Number of jobs in the `failed` state.", - ) - deleted: int = Field( - 0, - title="Deleted jobs", - description="Number of jobs in the `deleted` state.", - ) - upload: int = Field( - 0, - title="Upload jobs", - description="Number of jobs in the `upload` state.", - ) - - class JobBaseModel(Model): id: EncodedDatabaseIdField = EncodedEntityIdField model_class: str = ModelClassField(JOB_MODEL_CLASS_NAME) diff --git a/lib/galaxy_test/api/test_datasets.py b/lib/galaxy_test/api/test_datasets.py index a9b0e79698a..87afb2857ce 100644 --- a/lib/galaxy_test/api/test_datasets.py +++ b/lib/galaxy_test/api/test_datasets.py @@ -189,7 +189,6 @@ class DatasetsApiTestCase(ApiTestCase): original_hda = self._get(f"histories/{self.history_id}/contents/{hda_id}").json() assert original_hda["extension"] == "txt" assert original_hda["data_type"] == "galaxy.datatypes.data.Text" - assert "scatterplot" not in [viz["name"] for viz in original_hda["visualizations"]] inputs = { "input1": {"src": "hda", "id": hda_id}, @@ -214,7 +213,6 @@ class DatasetsApiTestCase(ApiTestCase): ).json() assert successful_updated_hda_response["extension"] == "tabular" assert successful_updated_hda_response["data_type"] == "galaxy.datatypes.tabular.Tabular" - assert "scatterplot" in [viz["name"] for viz in successful_updated_hda_response["visualizations"]] invalidly_updated_hda_response = self._put( # try updating with invalid datatype f"histories/{self.history_id}/contents/{hda_id}", data={"datatype": "invalid"}, json=True diff --git a/lib/galaxy_test/api/test_history_contents.py b/lib/galaxy_test/api/test_history_contents.py index 1679fefa3f1..8c965c5105e 100644 --- a/lib/galaxy_test/api/test_history_contents.py +++ b/lib/galaxy_test/api/test_history_contents.py @@ -819,7 +819,7 @@ class HistoryContentsApiTestCase(ApiTestCase): def _assert_collection_has_expected_elements_datatypes(self, history_id, collection_name, expected_datatypes): contents_response = self._get( - f"histories/{history_id}/contents?v=dev&view=betawebclient&q=name-eq&qv={collection_name}" + f"histories/{history_id}/contents?v=dev&view=detailed&q=name-eq&qv={collection_name}" ) self._assert_status_code_is(contents_response, 200) collection = contents_response.json()[0] diff --git a/test/unit/app/managers/test_HDAManager.py b/test/unit/app/managers/test_HDAManager.py index b3377c7f026..07e66a0bbb3 100644 --- a/test/unit/app/managers/test_HDAManager.py +++ b/test/unit/app/managers/test_HDAManager.py @@ -417,8 +417,8 @@ class HDASerializerTestCase(HDATestCase): self.assertKeys(serialized, self.hda_serializer.views["summary"] + ["uuid"]) self.log("should be able to use keys on their own") - serialized = self.hda_serializer.serialize_to_view(hda, keys=["file_path", "visualizations"]) - self.assertKeys(serialized, ["file_path", "visualizations"]) + serialized = self.hda_serializer.serialize_to_view(hda, keys=["file_path"]) + self.assertKeys(serialized, ["file_path"]) def test_serializers(self): hda = self._create_vanilla_hda() @@ -459,7 +459,6 @@ class HDASerializerTestCase(HDATestCase): self.assertIsInstance(serialized["resubmitted"], bool) self.assertIsInstance(serialized["display_apps"], list) self.assertIsInstance(serialized["display_types"], list) - self.assertIsInstance(serialized["visualizations"], list) # remapped self.assertNullableBasestring(serialized["misc_info"]) @@ -523,9 +522,7 @@ class HDASerializerTestCase(HDATestCase): self.log("file_name should be included if app configured to do so") self.dataset_manager.permissions.set_private_to_one_user(dataset1, owner) # request random crap - serialized = self.hda_serializer.serialize_to_view( - item1, view="detailed", keys=["file_path", "visualizations"], user=non_owner - ) + serialized = self.hda_serializer.serialize_to_view(item1, view="detailed", keys=["file_path"], user=non_owner) self.assertEqual(sorted(keys_in_inaccessible_view), sorted(serialized.keys())) # TODO: test extra_files_path as well diff --git a/test/unit/app/managers/test_markdown_export.py b/test/unit/app/managers/test_markdown_export.py index 6b591f13980..d2659c93cd5 100644 --- a/test/unit/app/managers/test_markdown_export.py +++ b/test/unit/app/managers/test_markdown_export.py @@ -378,7 +378,8 @@ history_dataset_collection_display(history_dataset_collection_id=1) from galaxy.managers.hdcas import HDCASerializer with mock.patch.object(HDCASerializer, "url_for", return_value="http://google.com"): - export, extra_data = self._ready_export(example) + with mock.patch.object(HDCASerializer, "serialize_job_state_summary", return_value={}): + export, extra_data = self._ready_export(example) assert "history_dataset_collections" in extra_data assert len(extra_data.get("history_dataset_collections")) == 1