Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias committed Jun 12, 2024
1 parent 069283b commit 88521b8
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
14 changes: 11 additions & 3 deletions lib/galaxy/job_execution/output_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def copy_dataset_permissions(self, init_from, primary_data):


class MetadataSourceProvider(AbstractMetadataSourceProvider):
def __init__(self, inp_data: Dict[str, Optional["DatasetInstance"]], inp_collections: Dict[str, Union["DatasetCollectionInstance", "DatasetCollection"]]):
def __init__(
self,
inp_data: Dict[str, Optional["DatasetInstance"]],
inp_collections: Dict[str, Union["DatasetCollectionInstance", "DatasetCollection"]],
):
self._inp_data = inp_data or {}
self._inp_collections = inp_collections or {}

Expand All @@ -116,10 +120,14 @@ def get_metadata_source(self, input_name: str) -> Optional["DatasetInstance"]:
elif input_name in self._inp_collections:
return self._inp_collections[input_name].dataset_instances[0]
else:
raise KeyError(f"Could not find metadata source '{input_name}' in {list(self._inp_data)} or {list(self._inp_collections)}")
raise KeyError(
f"Could not find metadata source '{input_name}' in {list(self._inp_data)} or {list(self._inp_collections)}"
)


def evaluate_source(source: str, output_collection_def: ToolOutputCollection, metadata_source_provider: AbstractMetadataSourceProvider) -> Optional[str]:
def evaluate_source(
source: str, output_collection_def: ToolOutputCollection, metadata_source_provider: AbstractMetadataSourceProvider
) -> Optional[str]:
source_name = getattr(output_collection_def, source)
if source_name is None:
return None
Expand Down
14 changes: 12 additions & 2 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,9 @@ def fail(message=job.info, exception=None):
if not extended_metadata:
# importing metadata will discover outputs if extended metadata
try:
self.discover_outputs(job, inp_data, inp_collections, out_data, out_collections, final_job_state=final_job_state)
self.discover_outputs(
job, inp_data, inp_collections, out_data, out_collections, final_job_state=final_job_state
)
except MaxDiscoveredFilesExceededError as e:
final_job_state = job.states.ERROR
job.job_messages = [
Expand Down Expand Up @@ -2071,7 +2073,15 @@ def fail(message=job.info, exception=None):
self.cleanup(delete_files=delete_files)
log.debug(finish_timer.to_str(job_id=self.job_id, tool_id=job.tool_id))

def discover_outputs(self, job, inp_data: Dict[str, Optional["DatasetInstance"]], inp_collections: Dict[str, Union["DatasetCollectionInstance", "DatasetCollection"]], out_data, out_collections, final_job_state):
def discover_outputs(
self,
job,
inp_data: Dict[str, Optional["DatasetInstance"]],
inp_collections: Dict[str, Union["DatasetCollectionInstance", "DatasetCollection"]],
out_data,
out_collections,
final_job_state,
):
"""
Try to just recover input_ext and dbkey from job parameters (used and set in
galaxy.tools.actions). Old jobs may have not set these in the job parameters
Expand Down
23 changes: 14 additions & 9 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,9 @@ def finished(self):

def io_dicts(self, exclude_implicit_outputs=False) -> IoDicts:
inp_data: Dict[str, Optional[DatasetInstance]] = {da.name: da.dataset for da in self.input_datasets}
inp_collections: Dict[str, Optional[HistoryDatasetCollectionAssociation]] = {obj.name: obj.dataset_collection for obj in self.input_dataset_collections}
inp_collections: Dict[str, Optional[HistoryDatasetCollectionAssociation]] = {
obj.name: obj.dataset_collection for obj in self.input_dataset_collections
}

out_data: Dict[str, DatasetInstance] = {da.name: da.dataset for da in self.output_datasets}
inp_data.update([(da.name, da.dataset) for da in self.input_library_datasets])
Expand Down Expand Up @@ -4289,10 +4291,12 @@ def _calculate_size(self) -> int:
return self.object_store.size(self) # type:ignore[unreachable]

@overload
def get_size(self, nice_size: Literal[False], calculate_size: bool = True) -> int: ...
def get_size(self, nice_size: Literal[False], calculate_size: bool = True) -> int:
...

@overload
def get_size(self, nice_size: Literal[True], calculate_size: bool = True) -> str: ...
def get_size(self, nice_size: Literal[True], calculate_size: bool = True) -> str:
...

def get_size(self, nice_size: bool = False, calculate_size: bool = True) -> Union[int, str]:
"""Returns the size of the data on disk"""
Expand Down Expand Up @@ -5977,7 +5981,6 @@ def to_dict(self, view="collection"):


class LibraryDatasetDatasetAssociation(DatasetInstance, HasName, Serializable):

def __init__(
self,
library_dataset=None,
Expand Down Expand Up @@ -7042,10 +7045,12 @@ def touch(self):
flag_modified(self.collection, "collection_type")

@overload
def to_hda_representative(self, multiple: Literal[False] = False) -> Optional[HistoryDatasetAssociation]: ...
def to_hda_representative(self, multiple: Literal[False] = False) -> Optional[HistoryDatasetAssociation]:
...

@overload
def to_hda_representative(self, multiple: Literal[True]) -> List[HistoryDatasetAssociation]: ...
def to_hda_representative(self, multiple: Literal[True]) -> List[HistoryDatasetAssociation]:
...

def to_hda_representative(
self, multiple: bool = False
Expand Down Expand Up @@ -7091,9 +7096,9 @@ def _serialize(self, id_encoder, serialization_options):
copied_from_history_dataset_collection_association_chain.append(
serialization_options.get_identifier(id_encoder, src_hdca)
)
rval["copied_from_history_dataset_collection_association_id_chain"] = (
copied_from_history_dataset_collection_association_chain
)
rval[
"copied_from_history_dataset_collection_association_id_chain"
] = copied_from_history_dataset_collection_association_chain
serialization_options.attach_identifier(id_encoder, self, rval)
return rval

Expand Down
9 changes: 8 additions & 1 deletion lib/galaxy/model/store/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,14 @@ def populate_collection_elements(
)

def _populate_elements(
self, chunk, name, root_collection_builder, metadata_source_name, default_format: Optional[str], final_job_state, change_datatype_actions
self,
chunk,
name,
root_collection_builder,
metadata_source_name,
default_format: Optional[str],
final_job_state,
change_datatype_actions,
):
element_datasets: Dict[str, List[Any]] = {
"element_identifiers": [],
Expand Down

0 comments on commit 88521b8

Please sign in to comment.