Skip to content

Rewrite resolved container image path via the compute environment#23129

Open
natefoo wants to merge 2 commits into
galaxyproject:devfrom
natefoo:pulsar-container-image-compute-rewrite
Open

Rewrite resolved container image path via the compute environment#23129
natefoo wants to merge 2 commits into
galaxyproject:devfrom
natefoo:pulsar-container-image-compute-rewrite

Conversation

@natefoo

@natefoo natefoo commented Jul 15, 2026

Copy link
Copy Markdown
Member

When a job is dispatched to Pulsar with rewrite_parameters (i.e. a PulsarComputeEnvironment is in use), route the resolved container image path through the same ComputeEnvironment.unstructured_path_rewrite() that already rewrites unstructured tool parameters. This lets a destination file_actions/file_action_config rewrite rule remap the image to a compute-node path.

Container resolution runs against the Galaxy-side filesystem (where e.g. /cvmfs exists), but singularity reads the image on the compute node, which may expose CVMFS at a different path (cvmfsexec mountrepo mode). Previously the image path was the only container path not routed through the compute environment (working directory and volumes already are), so it required a bespoke rewrite on the Pulsar server. It is now handled by the same mechanism as every other path.

Unmatched unstructured paths resolve to a NoneAction, so this is a no-op unless a matching rewrite rule is configured; rewrite is a non-staging action, so the image is never uploaded.

Corresponding Pulsar PR: galaxyproject/pulsar#475

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

When a job is dispatched to Pulsar with rewrite_parameters (i.e. a
PulsarComputeEnvironment is in use), route the resolved container image
path through the same ComputeEnvironment.unstructured_path_rewrite() that
already rewrites unstructured tool parameters. This lets a destination
`file_actions`/`file_action_config` `rewrite` rule remap the image to a
compute-node path.

Container resolution runs against the Galaxy-side filesystem (where e.g.
/cvmfs exists), but singularity reads the image on the compute node, which
may expose CVMFS at a different path (cvmfsexec mountrepo mode). Previously
the image path was the only container path not routed through the compute
environment (working directory and volumes already are), so it required a
bespoke rewrite on the Pulsar server. It is now handled by the same
mechanism as every other path.

Unmatched unstructured paths resolve to a NoneAction, so this is a no-op
unless a matching `rewrite` rule is configured; `rewrite` is a non-staging
action, so the image is never uploaded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread lib/galaxy/jobs/runners/pulsar.py Outdated
"""
if container is None or compute_environment is None:
return
rewritten_container_id = compute_environment.unstructured_path_rewrite(container.container_id)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what that is for - we have a lot of structure here and we should leverage it. This should be a new action type I assume if we actually want to use the path rewriter actions. Also I assume we can do better at figuring out if container_id might be a path - is it possible to determine if we expect it to be.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test it, but does the latest look better?

Address review feedback on galaxyproject#23129:

- Instead of routing the resolved container image through
  `unstructured_path_rewrite` (meant for tool-parameter/tool-data paths), add a
  first-class `ComputeEnvironment.container_path_rewrite()` backed by the new
  `container` path type in the Pulsar file action mapper. A destination
  `file_actions` rule with `path_types: container` remaps the image without
  sharing a namespace with unstructured tool-parameter rewrites.

- Only attempt the rewrite when the container image identifier is actually a
  filesystem path. Add `Container.image_identifier_is_path` (False for
  docker/registry references; `os.path.isabs()` for Singularity/Apptainer, so
  `docker://`, `library://`, `shub://`, `oras://` and registry refs are
  excluded) and guard on it in the runner.

Depends on a pulsar-galaxy-lib release providing the `container` path type.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
natefoo added a commit to natefoo/pulsar that referenced this pull request Jul 20, 2026
Introduce a first-class `container` path type in the file action mapper so a
resolved container image path (e.g. a Singularity/Apptainer image on CVMFS) can
be rewritten for the compute node via a `file_actions` `rewrite` rule with
`path_types: container`, rather than overloading the `unstructured`
tool-parameter path type.

Like `unstructured`, `container` is not an ACTION_DEFAULT_PATH_TYPE, so its
default action is `none` (no-op) and it is never staged -- container images live
on CVMFS or in a registry. `PathMapper.check_for_container_rewrite()` applies a
matching `rewrite` action and is a no-op otherwise.

Consumed by Galaxy's PulsarComputeEnvironment.container_path_rewrite (dependent
Galaxy PR galaxyproject/galaxy#23129).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants