mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Return DatasetChainModel
Fixes failure to serialize the response.
This commit is contained in:
@@ -47,7 +47,7 @@ from galaxy.webapps.galaxy.api.common import (
|
||||
)
|
||||
from galaxy.webapps.galaxy.services.datasets import (
|
||||
ConvertedDatasetsMap,
|
||||
DatasetInheritanceChainEntry,
|
||||
DatasetInheritanceChain,
|
||||
DatasetsService,
|
||||
DatasetStorageDetails,
|
||||
DatasetTextContentDetails,
|
||||
@@ -122,7 +122,7 @@ class FastAPIDatasets:
|
||||
trans=DependsOnTrans,
|
||||
dataset_id: EncodedDatabaseIdField = DatasetIDPathParam,
|
||||
hda_ldda: DatasetSourceType = DatasetSourceQueryParam,
|
||||
) -> List[DatasetInheritanceChainEntry]:
|
||||
) -> DatasetInheritanceChain:
|
||||
return self.service.show_inheritance_chain(trans, dataset_id, hda_ldda)
|
||||
|
||||
@router.get(
|
||||
|
||||
@@ -104,6 +104,13 @@ class DatasetInheritanceChainEntry(Model):
|
||||
)
|
||||
|
||||
|
||||
class DatasetInheritanceChain(Model):
|
||||
__root__: List[DatasetInheritanceChainEntry] = Field(
|
||||
default=[],
|
||||
title="Dataset inheritance chain",
|
||||
)
|
||||
|
||||
|
||||
class ExtraFilesEntryClass(str, Enum):
|
||||
Directory = "Directory"
|
||||
File = "File"
|
||||
@@ -310,7 +317,7 @@ class DatasetsService(ServiceBase, UsesVisualizationMixin):
|
||||
trans: ProvidesHistoryContext,
|
||||
dataset_id: EncodedDatabaseIdField,
|
||||
hda_ldda: DatasetSourceType = DatasetSourceType.hda,
|
||||
) -> List[DatasetInheritanceChainEntry]:
|
||||
) -> DatasetInheritanceChain:
|
||||
"""
|
||||
Display inheritance chain for the given dataset.
|
||||
"""
|
||||
@@ -321,7 +328,7 @@ class DatasetsService(ServiceBase, UsesVisualizationMixin):
|
||||
for dep in inherit_chain:
|
||||
result.append(DatasetInheritanceChainEntry(name=f"{dep[0].name}", dep=dep[1]))
|
||||
|
||||
return result
|
||||
return DatasetInheritanceChain(__root__=result)
|
||||
|
||||
def update_permissions(
|
||||
self,
|
||||
|
||||
@@ -163,7 +163,7 @@ class HistoryContentsApiTestCase(ApiTestCase):
|
||||
self._assert_status_code_is(show_response, 200)
|
||||
self.__assert_matches_hda(hda1, show_response.json())
|
||||
|
||||
def test_hda_copy(self):
|
||||
def _create_copy(self):
|
||||
hda1 = self.dataset_populator.new_dataset(self.history_id)
|
||||
create_data = dict(
|
||||
source='hda',
|
||||
@@ -173,7 +173,18 @@ class HistoryContentsApiTestCase(ApiTestCase):
|
||||
assert self.__count_contents(second_history_id) == 0
|
||||
create_response = self._post(f"histories/{second_history_id}/contents", create_data, json=True)
|
||||
self._assert_status_code_is(create_response, 200)
|
||||
assert self.__count_contents(second_history_id) == 1
|
||||
return create_response.json()
|
||||
|
||||
def test_hda_copy(self):
|
||||
response = self._create_copy()
|
||||
assert self.__count_contents(response['history_id']) == 1
|
||||
|
||||
def test_inheritance_chain(self):
|
||||
response = self._create_copy()
|
||||
inheritance_chain_response = self._get(f"datasets/{response['id']}/inheritance_chain")
|
||||
self._assert_status_code_is_ok(inheritance_chain_response)
|
||||
inheritance_chain = inheritance_chain_response.json()
|
||||
assert len(inheritance_chain) == 1
|
||||
|
||||
def test_library_copy(self):
|
||||
ld = self.library_populator.new_library_dataset("lda_test_library")
|
||||
|
||||
Reference in New Issue
Block a user