Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor parsing of extra mounts #199

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

danielhollas
Copy link
Contributor

@danielhollas danielhollas commented Jan 24, 2024

I noticed we can reuse the docker API logic when parsing the mount strings (such as /home/user/extra_mount/:/opt/:rw). Interestingly, the API is more forgiving than we were so we keep the extra validation. Overall the goal of this refactor was to make the code a bit more robust.

This PR was motivated by a bug in a test suite that I found (and fixed here as well).

@danielhollas danielhollas force-pushed the refactor-mount-parsing branch 2 times, most recently from 89dd9aa to d54031d Compare January 24, 2024 07:23
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3d2cfb1) 85.85% compared to head (b680fa5) 85.93%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #199      +/-   ##
==========================================
+ Coverage   85.85%   85.93%   +0.07%     
==========================================
  Files           9        9              
  Lines         919      924       +5     
==========================================
+ Hits          789      794       +5     
  Misses        130      130              
Flag Coverage Δ
py-3.10 85.82% <100.00%> (+0.07%) ⬆️
py-3.11 85.82% <100.00%> (+0.07%) ⬆️
py-3.12 85.82% <100.00%> (+0.07%) ⬆️
py-3.8 85.77% <100.00%> (+0.07%) ⬆️
py-3.9 85.88% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@danielhollas danielhollas marked this pull request as ready for review February 4, 2024 08:03
@danielhollas danielhollas changed the title WIP: Refactor parsing of extra mounts Refactor parsing of extra mounts Feb 4, 2024
@@ -142,8 +142,11 @@ def instance(docker_client, profile):

def remove_extra_mounts():
for extra_mount in instance.profile.extra_mounts:
extra_volume, _, _ = instance.profile.parse_extra_mount(extra_mount)
docker_client.volumes.get(str(extra_volume)).remove()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a bug in the test suite - we were trying to remove bind mounts as if they were volumes, see the new code below.

@unkcpz
Copy link
Member

unkcpz commented Feb 6, 2024

Not sure it is related or not, @edan-bainglass mentioned he encountered an issue that when an extra mount path was deleted, the aiidalab-launch profile will immediately throw an error.

@danielhollas
Copy link
Contributor Author

Yes, the current behaviour is that the path to the extra bind mount must exist, otherwise we through the error. The assumption was that this prevents user mistakes.

If we want to change that behaviour, @edan-bainglass please submit an issue on this repo. I'd be keen to learn about how you are using the extra mounts (my original implementation was driven by the need to have a closed-source QM program available inside the container).

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.

2 participants