mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-08-29 02:26:59 +08:00
Fix new ruff 0.11.0 errors
Also: - Add and fix type annotations - Fix call of `object_store_allows_id_selection()` method
This commit is contained in:
@@ -17,7 +17,7 @@ import os
|
||||
import sys
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import parse_builds # noqa: I100,I202
|
||||
import parse_builds
|
||||
|
||||
from galaxy.util import requests
|
||||
|
||||
|
||||
+15
-10
@@ -17,6 +17,7 @@ import traceback
|
||||
from json import loads
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
@@ -1629,19 +1630,19 @@ class MinimalJobWrapper(HasResourceParameters):
|
||||
def set_job_destination(self, job_destination, external_id=None, flush=True, job=None):
|
||||
"""Subclasses should implement this to persist a destination, if necessary."""
|
||||
|
||||
def _set_object_store_ids(self, job):
|
||||
def _set_object_store_ids(self, job: Job):
|
||||
if job.object_store_id:
|
||||
# We aren't setting this during job creation anymore, but some existing
|
||||
# jobs may have this set. Skip this following code if that is the case.
|
||||
return
|
||||
|
||||
object_store = self.app.object_store
|
||||
if not object_store.object_store_allows_id_selection:
|
||||
if not object_store.object_store_allows_id_selection():
|
||||
self._set_object_store_ids_basic(job)
|
||||
else:
|
||||
self._set_object_store_ids_full(job)
|
||||
|
||||
def _set_object_store_ids_basic(self, job):
|
||||
def _set_object_store_ids_basic(self, job: Job):
|
||||
object_store_id = self.get_destination_configuration("object_store_id", None)
|
||||
object_store_populator = ObjectStorePopulator(self.app, job.user)
|
||||
require_shareable = job.requires_shareable_storage(self.app.security_agent)
|
||||
@@ -1662,11 +1663,11 @@ class MinimalJobWrapper(HasResourceParameters):
|
||||
job.object_store_id = object_store_populator.object_store_id
|
||||
self._setup_working_directory(job=job)
|
||||
|
||||
def _set_object_store_ids_full(self, job):
|
||||
def _set_object_store_ids_full(self, job: Job):
|
||||
user = job.user
|
||||
object_store_id = self.get_destination_configuration("object_store_id", None)
|
||||
split_object_stores = None
|
||||
object_store_id_overrides = None
|
||||
split_object_stores: Optional[Callable[[str], ObjectStorePopulator]] = None
|
||||
object_store_id_overrides: Optional[Dict[str, Optional[str]]] = None
|
||||
|
||||
if object_store_id is None:
|
||||
object_store_id = job.preferred_object_store_id
|
||||
@@ -1687,7 +1688,11 @@ class MinimalJobWrapper(HasResourceParameters):
|
||||
# directory?
|
||||
object_store_id = invocation_object_stores.preferred_outputs_object_store_id
|
||||
object_store_populator = intermediate_object_store_populator
|
||||
output_names = [o.output_name for o in workflow_invocation_step.workflow_step.unique_workflow_outputs]
|
||||
output_names = [
|
||||
o.output_name
|
||||
for o in workflow_invocation_step.workflow_step.unique_workflow_outputs
|
||||
if o.output_name
|
||||
]
|
||||
if invocation_object_stores.step_effective_outputs is not None:
|
||||
output_names = [
|
||||
o for o in output_names if invocation_object_stores.is_output_name_an_effective_output(o)
|
||||
@@ -1696,9 +1701,9 @@ class MinimalJobWrapper(HasResourceParameters):
|
||||
# we resolve the precreated datasets here with object store populators
|
||||
# but for dynamically created datasets after the job we need to record
|
||||
# the outputs and set them accordingly
|
||||
object_store_id_overrides = {o: preferred_outputs_object_store_id for o in output_names}
|
||||
object_store_id_overrides = dict.fromkeys(output_names, preferred_outputs_object_store_id)
|
||||
|
||||
def split_object_stores(output_name): # noqa: F811 https://github.com/PyCQA/pyflakes/issues/783
|
||||
def split_object_stores(output_name: str): # noqa: F811 https://github.com/PyCQA/pyflakes/issues/783
|
||||
if "|__part__|" in output_name:
|
||||
output_name = output_name.split("|__part__|", 1)[0]
|
||||
if output_name in output_names:
|
||||
@@ -1718,7 +1723,7 @@ class MinimalJobWrapper(HasResourceParameters):
|
||||
object_store_id = user.preferred_object_store_id
|
||||
|
||||
require_shareable = job.requires_shareable_storage(self.app.security_agent)
|
||||
if not split_object_stores:
|
||||
if split_object_stores is None:
|
||||
object_store_populator = ObjectStorePopulator(self.app, user)
|
||||
|
||||
if object_store_id:
|
||||
|
||||
@@ -54,7 +54,7 @@ def view_mapping(datatypes_registry: Registry) -> DatatypesMap:
|
||||
n = f"{c.__module__}.{c.__name__}"
|
||||
types = {n}
|
||||
visit_bases(types, c)
|
||||
class_to_classes[n] = {t: True for t in types}
|
||||
class_to_classes[n] = dict.fromkeys(types, True)
|
||||
return DatatypesMap(ext_to_class_name=ext_to_class_name, class_to_classes=class_to_classes)
|
||||
|
||||
|
||||
|
||||
@@ -1504,7 +1504,7 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable):
|
||||
params: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True)
|
||||
handler: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True)
|
||||
preferred_object_store_id: Mapped[Optional[str]] = mapped_column(String(255))
|
||||
object_store_id_overrides: Mapped[Optional[STR_TO_STR_DICT]] = mapped_column(JSONType)
|
||||
object_store_id_overrides: Mapped[Optional[Dict[str, Optional[str]]]] = mapped_column(JSONType)
|
||||
tool_request_id: Mapped[Optional[int]] = mapped_column(ForeignKey("tool_request.id"), index=True)
|
||||
|
||||
dynamic_tool: Mapped[Optional["DynamicTool"]] = relationship()
|
||||
@@ -8284,7 +8284,7 @@ class WorkflowStep(Base, RepresentById, UsesCreateAndUpdateTime):
|
||||
# Older Galaxy workflows may have multiple WorkflowOutputs
|
||||
# per "output_name", when serving these back to the editor
|
||||
# feed only a "best" output per "output_name.""
|
||||
outputs = {}
|
||||
outputs: Dict[str, WorkflowOutput] = {}
|
||||
for workflow_output in self.workflow_outputs:
|
||||
output_name = workflow_output.output_name
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ class ModelPersistenceContext(metaclass=abc.ABCMeta):
|
||||
default_object_store_id = job.object_store_id
|
||||
if not output_name:
|
||||
return default_object_store_id
|
||||
object_store_id_overrides: Dict[str, str] = job.object_store_id_overrides or {}
|
||||
object_store_id_overrides = job.object_store_id_overrides or {}
|
||||
return object_store_id_overrides.get(output_name, default_object_store_id)
|
||||
|
||||
@property
|
||||
|
||||
@@ -268,7 +268,7 @@ class WeblessApplicationStack(ApplicationStack):
|
||||
|
||||
@property
|
||||
def configured_pools(self):
|
||||
return {p: self.config.server_name for p in self.config.attach_to_pools}
|
||||
return dict.fromkeys(self.config.attach_to_pools, self.config.server_name)
|
||||
|
||||
def in_pool(self, pool_name):
|
||||
return pool_name in self.config.attach_to_pools
|
||||
|
||||
@@ -8,7 +8,7 @@ import optparse
|
||||
import time
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from common import ( # noqa: I100,I202
|
||||
from common import (
|
||||
get,
|
||||
post,
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
import sys
|
||||
from urllib.error import URLError
|
||||
|
||||
from common import display # noqa: I100,I202
|
||||
from common import display
|
||||
|
||||
try:
|
||||
display(*sys.argv[1:3])
|
||||
|
||||
@@ -59,7 +59,7 @@ from sqlalchemy import (
|
||||
|
||||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "lib")))
|
||||
|
||||
from cleanup_datasets import CleanupDatasetsApplication # noqa: I100
|
||||
from cleanup_datasets import CleanupDatasetsApplication
|
||||
|
||||
import galaxy.config
|
||||
import galaxy.util
|
||||
|
||||
@@ -18,7 +18,7 @@ try:
|
||||
except ImportError:
|
||||
raise Exception("BeautifulSoup4 library not found, please install it, e.g. with 'pip install BeautifulSoup4'")
|
||||
|
||||
from util import ( # noqa: I202
|
||||
from util import (
|
||||
get_bed_from_genbank,
|
||||
get_bed_from_GeneMark,
|
||||
get_bed_from_GeneMarkHMM,
|
||||
|
||||
Reference in New Issue
Block a user