Skip to content

Commit

Permalink
Fix mypy errors, add type
Browse files Browse the repository at this point in the history
Can't reuse variable for different types: mypy complains.
  • Loading branch information
jdavcs committed Apr 12, 2024
1 parent 61fc667 commit e96b00c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
4 changes: 3 additions & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,9 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable):
history: Mapped[Optional["History"]] = relationship(back_populates="jobs")
library_folder: Mapped[Optional["LibraryFolder"]] = relationship()
parameters = relationship("JobParameter")
input_datasets = relationship("JobToInputDatasetAssociation", back_populates="job")
input_datasets: Mapped[List["JobToInputDatasetAssociation"]] = relationship(
"JobToInputDatasetAssociation", back_populates="job"
)
input_dataset_collections: Mapped[List["JobToInputDatasetCollectionAssociation"]] = relationship(
back_populates="job"
)
Expand Down
58 changes: 32 additions & 26 deletions lib/galaxy/model/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2076,67 +2076,73 @@ def export_jobs(
if include_job_data:
self.add_dataset(assoc.dataset)

for assoc in job.output_datasets:
for assoc2 in job.output_datasets:
# Optional data inputs will not have a dataset.
if assoc.dataset:
name = assoc.name
if assoc2.dataset:
name = assoc2.name
if name not in output_dataset_mapping:
output_dataset_mapping[name] = []

output_dataset_mapping[name].append(self.exported_key(assoc.dataset))
output_dataset_mapping[name].append(self.exported_key(assoc2.dataset))
if include_job_data:
self.add_dataset(assoc.dataset)
self.add_dataset(assoc2.dataset)

for assoc in job.input_dataset_collections:
for assoc3 in job.input_dataset_collections:
# Optional data inputs will not have a dataset.
if assoc.dataset_collection:
name = assoc.name
if assoc3.dataset_collection:
name = assoc3.name
if name not in input_dataset_collection_mapping:
input_dataset_collection_mapping[name] = []

input_dataset_collection_mapping[name].append(self.exported_key(assoc.dataset_collection))
input_dataset_collection_mapping[name].append(self.exported_key(assoc3.dataset_collection))
if include_job_data:
self.export_collection(assoc.dataset_collection)
self.export_collection(assoc3.dataset_collection)

for assoc in job.input_dataset_collection_elements:
if assoc.dataset_collection_element:
name = assoc.name
for assoc4 in job.input_dataset_collection_elements:
if assoc4.dataset_collection_element:
name = assoc4.name
if name not in input_dataset_collection_element_mapping:
input_dataset_collection_element_mapping[name] = []

input_dataset_collection_element_mapping[name].append(
self.exported_key(assoc.dataset_collection_element)
self.exported_key(assoc4.dataset_collection_element)
)
if include_job_data:
if assoc.dataset_collection_element.is_collection:
self.export_collection(assoc.dataset_collection_element.element_object)
if assoc4.dataset_collection_element.is_collection:
assert isinstance(
assoc4.dataset_collection_element.element_object, model.DatasetCollection
)
self.export_collection(assoc4.dataset_collection_element.element_object)
else:
self.add_dataset(assoc.dataset_collection_element.element_object)
assert isinstance(
assoc4.dataset_collection_element.element_object, model.DatasetInstance
)
self.add_dataset(assoc4.dataset_collection_element.element_object)

for assoc in job.output_dataset_collection_instances:
for assoc5 in job.output_dataset_collection_instances:
# Optional data outputs will not have a dataset.
# These are implicit outputs, we don't need to export them
if assoc.dataset_collection_instance:
name = assoc.name
if assoc5.dataset_collection_instance:
name = assoc5.name
if name not in output_dataset_collection_mapping:
output_dataset_collection_mapping[name] = []

output_dataset_collection_mapping[name].append(
self.exported_key(assoc.dataset_collection_instance)
self.exported_key(assoc5.dataset_collection_instance)
)

for assoc in job.output_dataset_collections:
if assoc.dataset_collection:
name = assoc.name
for assoc6 in job.output_dataset_collections:
if assoc6.dataset_collection:
name = assoc6.name

if name not in implicit_output_dataset_collection_mapping:
implicit_output_dataset_collection_mapping[name] = []

implicit_output_dataset_collection_mapping[name].append(
self.exported_key(assoc.dataset_collection)
self.exported_key(assoc6.dataset_collection)
)
if include_job_data:
self.export_collection(assoc.dataset_collection)
self.export_collection(assoc6.dataset_collection)

job_attrs["input_dataset_mapping"] = input_dataset_mapping
job_attrs["input_dataset_collection_mapping"] = input_dataset_collection_mapping
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def common_problems(
for job_input_assoc in job.input_datasets:
input_dataset_instance = job_input_assoc.dataset
if input_dataset_instance is None:
continue
continue # type:ignore[unreachable] # TODO if job_input_assoc.dataset is indeed never None, remove the above check
if input_dataset_instance.get_total_size() == 0:
has_empty_inputs = True
input_instance_id = input_dataset_instance.id
Expand Down

0 comments on commit e96b00c

Please sign in to comment.