Remove visualizations from dataset serialization test, run prettier, fix tests

This commit is contained in:
guerler
2022-02-12 11:40:36 -05:00
parent 7bbaba700f
commit 1b65da81cf
7 changed files with 104 additions and 86 deletions
+3 -3
View File
@@ -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;
+12 -3
View File
@@ -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()
+83 -70
View File
@@ -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)
-2
View File
@@ -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
+1 -1
View File
@@ -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]
+3 -6
View File
@@ -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
@@ -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