Skip to content

Draft: Add BinaryApp application type and p47 example deployment #23

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

Closed
wants to merge 4 commits into from

Conversation

gilesknap
Copy link
Contributor

@gilesknap gilesknap commented Apr 23, 2025

This includes a fully working demo of p47 beamline. But, it needs to be run outside of the devcontainer because your user ID is needed for login to argocd.

To try it out do this on your host after doing a sync:

sudo ln -s /scratch/...(root of workspaces) /workspaces
export MODULEPATH=/workspaces/deploy-tools/demo-output/modulefiles
module load p47/dev
ec-login
ec ps
ec monitor

Some things to consider:

  • This project is really nicely written - adhering to our standard copier template, use of pydantic and devcontainers made it very easy for me to add this feature
  • I want to factor out all the things that are common to all beamlines and make the p47 one just have its couple of unique environment variables TODO: discuss with @MJGaughran
  • I added a binaries folder but we could equally just drop the binaries in entrypoints folder
    • saves on code changes and saves on long PATH additions: UPDATE - will combine both into bin
  • UPDATE: I implemented host_binaries instead - which finds binaries on the host by PATH and mounts them into /usr/bin. At present I'm adding the argocd in the container build as well as in the module binaries. I would prefer to mount the argocd binary into the apptainer, but to do that I need a way to know what the path to it will be here:

e.g.

      global_options:
        mounts:
          # places to get argocd config from
          - /dls/science/users/:/dls/science/users/
          - /scratch:/scratch
          - {module_root}/binaries/argocd:/usr/bin/argocd

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 47.50000% with 21 lines in your changes missing coverage. Please review.

Project coverage is 42.71%. Comparing base (32ef01f) to head (939af01).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/deploy_tools/app_builder.py 19.04% 17 Missing ⚠️
src/deploy_tools/layout.py 62.50% 3 Missing ⚠️
src/deploy_tools/module_builder.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   42.55%   42.71%   +0.15%     
==========================================
  Files          23       24       +1     
  Lines         860      899      +39     
==========================================
+ Hits          366      384      +18     
- Misses        494      515      +21     

☔ View full report in Codecov by Sentry.
📢 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.

@MJGaughran MJGaughran changed the title Add BinaryApp application type and p47 example deployment Draft: Add BinaryApp application type and p47 example deployment Apr 23, 2025
Copy link
Contributor

@MJGaughran MJGaughran left a comment

Choose a reason for hiding this comment

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

I know this PR is only a draft (it includes a bunch of unrelated changes), but I've still commented to help us figure out how to do it properly later on.

if h.hexdigest() != app.sha256:
raise RuntimeError(f"Downloaded Binary {app.url} digest failure")

binary_path.chmod(0o555)
Copy link
Contributor

Choose a reason for hiding this comment

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

Permissions should at least be a module constant. At the moment, it is all tidied away in templater.py, but this obviously breaks that and it may be sensible to move these permissions to another location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirely clear how you want to handle this. So I've left it as is for now in #26 - see #26 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added an extra comment there - I recommend at least a module-level constant.

Download a URL, validate it against its sha256, make it executable
and add it to PATH
"""
binary_folder = self._build_layout.get_binary_files_folder(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use the same folder for all entrypoints. Maybe even rename it to bin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool - lets do that.

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 is still todo - right now I'm using entrypoints only.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend calling it 'bin_folder' if you do decide to rename things, as 'binary_folder' isn't commonly used. I'm happy to make this change myself, later, if you want.

@gilesknap
Copy link
Contributor Author

gilesknap commented Apr 23, 2025

This is working beautifully now:

  • p47 is a minimal module which just:
    • sets a couple of environment variables specific p47
    • depends on edge-containers-cli
    • also depends on pollux - the cluster in which p47 lives and this pulls in the k8s binaries and config
  • all k8s binaries come from the host
    • this means we don't override any choices the cloud team made (in the pollux module)
  • the argocd binary which is currently not available anywhere else in dls is downloaded by deploy-tools

I'm going to split this work up into discrete PRs and eventually close this draft.

@gilesknap gilesknap marked this pull request as draft April 24, 2025 08:21
@gilesknap
Copy link
Contributor Author

gilesknap commented Apr 24, 2025

@MJGaughran I have 4 new PRS for you

  1. add schema checking test #24 - this makes the schema files current and adds a test to make sure the schema files match the python models
  2. Add the host_binaries feature #25 - adds the host_binaries feature plus example module using it, also adds a test that demonstrates this as well as all other features (by running and validating a sync)
  3. Add the host_binaries feature #25 - adds the binary app type and a demo in the form of an argocd module
  4. add BinaryApp app type #26 - combines all of the above, adds in the P47 example beamline - updates the tests to cover all of the demo modules (using test/generate_samples.sh)

I included the commits from 1. in 2. and 3. (with the misguided intention of avoiding merge conflicts). So you should merge it first and rebase 2,3 over main if you want a cleaner PR conversation.

Likewise 4. can be rebased after the others are all merged.

@gilesknap
Copy link
Contributor Author

Above PRs completed

@gilesknap gilesknap closed this Apr 26, 2025
@gilesknap gilesknap deleted the ec-cli branch April 26, 2025 19:50
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