Skip to content

Commit

Permalink
Merge pull request #1394 from sanjaysrikakulam/update_galaxy_jwd_type
Browse files Browse the repository at this point in the history
update galaxy_jwd script to skip if the backend is not of type disk and if backend is removed from the object_store_conf file
  • Loading branch information
sanjaysrikakulam authored Feb 11, 2025
2 parents 1165174 + 19c94ea commit 8134e62
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions roles/usegalaxy-eu.bashrc/files/galaxy_jwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,14 @@ def parse_object_store(object_store_conf: str) -> dict:
backends = {}
for backend in dom.getElementsByTagName("backend"):
backend_id = backend.getAttribute("id")
backends[backend_id] = {}
backend_type = backend.getAttribute("type")
backends[backend_id] = {"type": backend_type, "job_work_path": None}

# Get the extra_dir's path for each backend if type is "job_work"
for extra_dir in backend.getElementsByTagName("extra_dir"):
if extra_dir.getAttribute("type") == "job_work":
backends[backend_id] = extra_dir.getAttribute("path")
backends[backend_id]["job_work_path"] = \
extra_dir.getAttribute("path")
return backends


Expand Down Expand Up @@ -346,28 +349,30 @@ def decode_path(
Args:
job_id: Job id.
metadata: List of object_store_id and update_time.
backends_dict: Dictionary of backend id and path of type 'job_work'.
backends_dict: Dictionary of backend id with its type and path of type
'job_work'.
job_runner_name: Name of the job runner. Defaults to None.
Returns:
Path to the JWD.
"""
job_id = str(job_id)
object_store_id = metadata[0]
backend_info = backends_dict.get(object_store_id)

# Check if object_store_id exists in our object store config
if metadata[0] not in backends_dict.keys():
raise ValueError(
f"Object store id '{metadata[0]}' does not exist in the "
f"object_store_conf.xml file."
)
if not backend_info:
print(f"Skipping backend '{object_store_id}' as it does not exist in"
f" the object_store_conf.xml file.")
return None

# Pulsar embedded jobs uses the staging directory and this has a different
# path structure
if (job_runner_name or "").startswith("pulsar_embedded"):
jwd_path = f"{backends_dict['pulsar_embedded']}/{job_id}"
else:
jwd_path = (
f"{backends_dict[metadata[0]]}/"
f"{backend_info['job_work_path']}/"
f"0{job_id[0:2]}/{job_id[2:5]}/{job_id}"
)

Expand Down

0 comments on commit 8134e62

Please sign in to comment.