Conversation
…nvironment in the launcher script
…pt commands - Add launcher_commands array to environments config.sh. If empty, a lite environment isn't setup - Add a command_cmd_v1 module file that points to the limited script directory, and the same squashfs as the full environment. It does not activate the environment when the module is loaded. - Move setting ENV_LAUNCHER_SCRIPT_PATH in the launcher script (used by payu) rather than the common launcher conf file
|
Thank you @jo-basevi for the explanation above. Please feel free to correct any mistakes or add up to my understandings below: In the current
If the above is true, I propose the following general solution: Practically:
What do you think about this approach? |
|
Thanks @atteggiani for looking into this.
Mostly yes, though I think I think
Ok so similar to the "lite" restricted command environment, but with separating the environments out? I think that sounds good! We will need to think about what to do for the payu environment used in CI repro testing, as currently it is virtual python environments build on top of a payu environment so the test environments can be light-weight. So it currently needs the python executable for the payu environments to build the virtual environment and then still have access to the payu commands. |
|
Thank you for the replies @jo-basevi.
With this, do you mean they have lines like
Hmm okay, this is definitely a problem to think about carefully.
Yes I think so. And the environments should be thought as being separate and independent, but of course if they are compatible among multiple tools, the same environment can be used by those multiple tools.
So the CI repo testing would need both access to the |
Yes, it has lines with "from payu import ...".
When payu submits a PBS job, it's submitting another payu command that runs within the PBS job - so the payu containerized environment is being launched on the PBS node. It then setups up for the model run, runs the
Yes, it uses "payu" cli commands, and also I think for the "access-om3" tests, they are importing "payu.model" to reuse a configuration parsing method..
We would still need a way to install test dependencies such as pytest, and the test package, but it could work, e.g.: |
Oh ok, well in that case this means that
Yes, alright. In this case we might have to find a good solution for this. The problem about the user-scripts is only related to the impossibility of loading another container (e.g., loading the
I think in general anything that needs
Yes, I think we can find ways to make that work in the best way for our use case. |
When running inside the container, it seems to have access to /g/data and /scratch directories that the user has access to. This might be a configured setting on gadi with singularity generally as I can't find any code matches to When running a python process inside a container, I don't know how to "break out" of the container to run shell commands but then return to the python process in the container if that makes sense?
Yes, it can't load another container. One way to get around it with the conda/analysis environments (as they use the same container setup), is to load all required modules before running anything inside a container. Each module prepends the environment squashfs files to |
Yes I get what you mean, you could do it within
Can you point me out to a containerised environment that is currently not possible to run within the |
|
Using This doesn't fix the other issues with containerised environment, but would make it possible loading a different conda environment (even containerised) in a user-script. |
|
Oh I did not know about
Currently conda/analysis3 would not work in a userscript - payu currently does not load modules on the pbs node before running the python code. |
I think by default apptainer has the same network namespace as the host, so I think from a PBS job In general, I would think about using
Are userscripts the only problematic part about loading another containerised environment? Are there any other use-cases where containerisation creates problem? |
Yeah I wonder if any commands would need some "state", e.g. environment variables set up or be in the same current working directory as the payu python process. So would need some testing.
I think userscripts are the only problematic part in payu about loading another containerised environment. Though if I remember about more use-cases I'll make sure to add an update! |
|
Note Apologies but I thought I had replied with a different message (like I'm doing here), but instead I had edited your previous message 😅 I didn't mean to do that. I rewrote your initial message.
Yes, in general there might be some minor set up steps to the commands, but in general I think such a scenario is achievable.
Ok, in this case running userscripts via |
Overall issue we are trying to solve is running these containers alongside conda environments. One way is to not activate the environment via the module file and restrict external launcher script commands to only the tool (e.g.
payu).To avoid activating the environment in the modulefile in 738442c, I tried replicating the modulefile insert that activates the conda environment - but instead write a script that be run as part of a launcher script. I don't think my solution here is that good. Alternative solutions to activate the environment in the launcher scripts could be:
${CONDA_EXE} run --prefix "${CONDA_BASE_ENVIRONMENT}" "${cmd_to_run[@]}". A downside is that none of the environments are currently dependent on the micromamba install at runtime as it's only used to create the environments, and this would add in that dependency.SINGULARITYENV_*variables so they are only set when container is launched. This might have an issue when multiple modules that setSINGULARITYENV_*are loaded at the same time, and it'll use the most recently loaded module values.In c96af86, I'm creating
-liteversion of the module that only activates the environment in the launcher script and exposes a limited set of commands. So there would apayu/$versionmodule, which works similar to before, and apayu/$version-litemodule. Both modules use the samesquashfsenvironment file. So it wouldn't add too much in terms of storage. The idea of keeping the original environment module is because it's used for creating virtual environments.This PR shouldn't be merged as hopefully there's a cleaner solution, and it is not necessary until the payu environment has limited tools installed which are only needed for running payu.