Skip to content

Add optional mounts - #83

Open
MichaelStubbings wants to merge 13 commits into
mainfrom
hla-1167-handle-invalid-mounts
Open

MichaelStubbings wants to merge 13 commits into
mainfrom
hla-1167-handle-invalid-mounts

Conversation

@MichaelStubbings

@MichaelStubbings MichaelStubbings commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Adds optional mounts.

When an optional mount is invalid, it will exclude it from the mount list so it does not cause an error. This handles all types of mounting syntax, such as:

  • /host/path
  • /host/path:/mount/path
  • /host/path:/mount/path:read-write-access

e.g. Using the options:

      global_options:
        mounts:
          - /dls/science/users/:/dls/science/users/:ro
          - /dls_sw/apps
        optional_mounts:
          - /broken/mount:/broken/mount
          - /really/broken/mount:/really/broken/mount:rw
          - /dls_sw/work

We see the following output:

$ ./demo-output/modules/phoebus/0.2/entrypoints/phoebus 
WARNING: Unable to mount /broken/mount: path does not exist
WARNING: Unable to mount /really/broken/mount: path does not exist

@MichaelStubbings MichaelStubbings self-assigned this Sep 18, 2026
@MichaelStubbings
MichaelStubbings marked this pull request as draft September 18, 2026 12:16
When defining a list of mounts, you can now specify an 'optional_mount'.
These are checked in the apptainer_entrypoint to see if the path exists.
If not, then a warning is sent to stderr and the mount is excluded from
the apptainer mount list.

@ptsOSL ptsOSL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the premise is good, just a few details to improve on

Comment thread src/deploy_tools/models/schemas/deployment.json Outdated
Comment thread src/deploy_tools/models/schemas/deployment.json Outdated
Comment thread src/deploy_tools/templates/apptainer_entrypoint Outdated
Comment thread src/deploy_tools/templates/apptainer_entrypoint Outdated
@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.19%. Comparing base (8343e3f) to head (5fbd1ec).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/deploy_tools/models/apptainer_app.py 82.35% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
- Coverage   99.48%   99.19%   -0.30%     
==========================================
  Files          27       27              
  Lines         978      995      +17     
==========================================
+ Hits          973      987      +14     
- Misses          5        8       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MichaelStubbings
MichaelStubbings marked this pull request as ready for review September 28, 2026 09:20
@MichaelStubbings MichaelStubbings changed the title DRAFT: Filter invalid mounts from apptainer_entrypoint and warn user Add optional mounts Sep 28, 2026
ptsOSL
ptsOSL previously approved these changes Sep 28, 2026

@ptsOSL ptsOSL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thats a nice and easy way to prioritise the local entrypoint mounts. I am happy with these changes. Is it worth adding a test to check that the local entrypoint mounts are prioritised?

] = []

optional_mounts: Annotated[
list[MountPoint],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to change this from list to set without affecting the configuration? Or would this be backwards-incompatible?

] = EntrypointOptions()

@model_validator(mode="after")
def prioritise_entrypoint_mounts(self) -> "ApptainerApp":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How does this work if you have multiple entrypoints with different mounts?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This does not work very well with multiple entrypoints. When an entrypoint is removed from mounts, it is removed for all entrypoints.

I will investigate a solution outside of the model_validator. Either in validate.py or app_builder.py

# Options and arguments to pass to command
command_args="{{ command_args }}"

{% if optional_mounts != None %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have you tested this with empty optional_mounts? The pattern I used in modulefile is: {% if dependencies|length %}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This worked when optional mounts was a part of mounts. Now it does not. I've updated to your format: 3c98cc1

done

mounts="${mounts},$(IFS=','; echo "${validated_mounts[*]}")"
{% endif %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is there no whitespace handling? The modulefile template has an example of this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added 5582a4c

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants