Setup and usage of md workflow
These instructions describe the setup and the usage of the workflow WP3-P3-workflow/md. This can be used directly or as a template for a new workflow.
Setup
This guide assumes that you have PyCOMPSs installed.
- Fork this repo:
- Setup Python environment
- (Optional) Adapt the workflow and configure execution environment
- Run the workflow
Python environment
Load the same Python that was used to install PyCOMPSs. If you followed the installation, load the compss module with the Python interpreter as dependency. The precise procedure changes from cluster to cluster, it can be as simple as ml compss. Then, create a Python virtual environment using:
--system-site-packages is fundamental to make the PyCOMPSs package available when the venv is sourced.
Add to the requirements.txt file the Python packages required by your workflow. Then, install them:
uv or conda are also possible.
What if your cluster does not have nodes with internet connection?
Find the precise Python version and architecture. In the cluster, get:
Give the requirements and the system info, download locally (or in the machine with internet connection) the required wheels:
pip download -d index \
--only-binary=:all: \
--platform manylinux2014_x86_64 \
--implementation cp --python-version 3.12.1 --abi cp312 \
dill guppy3 numpy pyyaml rocrate pytz pdb-tools
Then, move the downloaded wheels inside a directory (e.g., index) from the local machine to the cluster:
Finally, on the cluster install the wheels inside a venv and specifying to pip where to find the pre-downloaded wheels:
Shell environment or "Does you cluster have a setup md/wrapper/env_setup_XXX.sh file?"
To prepare the shell environment for a workflow submition, a file md/wrapper/env_setup_XXX.sh, where XXX is the nickname of your cluster, it sourced before anything (more details on repository structure). In a nutshell, this bash file contains:
- setup to use
enqueue_compss: this can be a module load or sourcing thecompssenvfile - setup to use
gmx: same as above - configuration of various Slurm and COMPSs flags
- etc.
In the repo, setup files are present for various clusters (Leonardo Booster, Marenostrum5 ACC, Dardel gpu, Lumi-G), however these files need to be adapted to the user own environment. For new clusters, use the above mentioned files as templates. We suggest to test the setup on an interactive shell session before try to submit workflows.
Usage
Submit a workflow
Using default arguments:
Info
Every Python file inside md/workflow can be called by make, just use the script name without .py
Using custom arguments:
Just type make to have more info or inspect the Makefile.
Remove output files
If you used custom keywords, you might need to specify them.Input directory structure
The workflow expects input directories organized as follows:
dataset/
├── protein1/
│ ├── structure.pdb
│ ├── select.txt
│ ├── emin-charmm.mdp
│ ├── nvt-charmm.mdp
│ ├── npt-charmm.mdp
│ └── md-charmm.mdp
├── protein2/
│ ├── structure.pdb
│ ├── select.txt
│ ├── emin-charmm.mdp
│ ├── nvt-charmm.mdp
│ ├── npt-charmm.mdp
│ └── md-charmm.mdp
- One PDB file (the input structure)
select.txt(selection file forpdb2gmx)- MD parameter files:
emin-charmm.mdp,nvt-charmm.mdp,npt-charmm.mdp,md-charmm.mdp
See the example directory for more info.
Monitor workflow execution
To monitor a running workflow locally, use the COMPSs Monitor Runner. Hence, from your local machine (not the cluster!):
Repository structure
Info
This part refers to the md directory
This repo uses a simplified approach to execute PyCOMPSs workflows. The following table summarizes the role of each file in the workflow definition and execution.
Levels represent the order of call when submitting a workflow (or, alternatively, the "distance" between the user issuing make and the workflow definition).
| level | file | description | For more info | Target |
|---|---|---|---|---|
| 0 | Makefile |
Interface to easily handle workflow submission. Arguments that change often can be passed directly to make |
type make |
Wrapper |
| 1 | md/wrapper/submit_workflow.sh |
Wrapper to the enqueue_compss program. |
type make |
PyCOMPSs |
| 1 | md/wrapper/env_config_<cluster>.sh |
Configuration file sourced by submit_workflow.sh. This bash describes the shell environment in which the workflow will be executed. |
Check the file | Shell environment, Slurm |
| 2 | md/workflow/md.py |
Tasks and pipeline implementation. This file controls the whole workflow. | Check the file | Workflow |
| 3 | md/workflow/md-provenance.yaml |
Configuration for Data Provenance. | Check the file | Workflow |
In this setup, the workflow is managed through a Makefile.
The arguments that change often (such as input/output directories, number of cores per task, workflow name etc) are passed directly to make while more "stable" arguments are configured in ./wrapper.
The main files for the workflow specification are stored inside ./wrapper/env_config_<cluster>.sh and ./wrapper/submit_workflow.sh.
Warning
Currently, not all Slurm or COMPSs arguments are wrapped. To modify this aspect, see how to do it.
All arguments that are not set either in make nor env_config_<cluster>.sh use the default values as expressed in the COMPSs queue config file $COMPSS_HOME/Runtime/scripts/queues/supercomputers/default.cfg. See COMPSs documentation for more info.
Miscellaneous notes
Note
These are some notes for version 3.3.3 for edge cases or non-standard behaviors.
- the
binargumentworking_dircan lead to problems even if the file passed as arguments of the function are described by absolute paths. The example is usingpdb_delhetatom, in which specifying the working dir as the parent to the input and output directories, messes up the paths even though in themainfunction these are passed asstrof the absolute, resolved, path. (still don't know why). - the explicitely defined arguments to a binary inside the
binarydecorator is cleaner, hence it is best practice, than defining arguments through the python function arguments. Seemd.py. - shell scripts can be used to wrap another program/binary that does not a flag/way to specify which and how many files it produces (nor a directory where it outputs).
- the
constraintdecorator instruct the task on the OMP threads to allocate for the task, among many other things. This implies that it set theOMP_NUM_THREADSenvironmental variable that, otherwise, cannot be exported before theenqueue_compssinvocation. - when using
gmx mdrunyou should always check themdpfile that starts the simulation to know which file will be produced. A common error is the fact that, if you don't specify the keywordsnstxoutand similar, you won't get a trajectory file. Only a checkpoint file will be produced. Hence, if in the workflow you specified to output atrrfile but it does not appear, COMPSs will exit with an error, causing you headaches. - COMPSs search for checkpoints and loads them! It avoids running the same task multiple times
- you have to pass to the
enqueue_compssthe checkpoint related flags, specificallycheckpoint_folder. - you can run the workflow one time configuring checkpoints. When you run it again with the same checkpoint folder config you'll see in the
runtime.log(inside.COMPSsdir) the loading of the checkpoints. - in the summary, obtained through the
--summaryflag, you can see that in the second run no computations are performed. - one unresolved issues (as in the 3.3.3 version): in the second identical run, the runtime waits indefinetly with the line
[LAUNCH_COMPSS] Waiting for application completionincompss-[id-job].out. printstatements in the main code that write on the STOUT, are catched by the.COMPSs/jobs/job-[JOBID].outfiles.
Adapt the workflow at your needs
Adapt the workflow
Typically, one starts modifying the Python scripts in workflow in which a high-level description of the workflow divided in tasks is detailed.
After that, one specifies the environment in which the workflow will be executed. The latter is controlled by bash scripts in wrapper and the Makefile.
The procedure is usually the following:
- Workflow definition: define a Python script controlling the main pipeline. The tasks involved in the workflow can be defined in the same file or in separate ones. All these are stored in
workflow. The main Python file has a name that will be used to call PyCOMPSs. In this repo, tasks and pipeline are detailed insidemd/workflow/md.py. Hence, the name of the workflow ismd. - Setup the execution environment: open
md/wrapper/env_config_<cluster>.shand customize Slurm variables, modules to load before execution and everything to prepare the shell for workflow execution. This bash is sourced before launchingenqueue_compss, which is called inmd/wrapper/submit_workflow.sh. Customize the latter to adjustenqueue_compssflags.
Some references to get started with PyCOMPSs
Add more Slurm or COMPSs arguments to the wrappers
Example on how to modify level <= 1 (see table): implement a new COMPSs argument.
Firstly, decide whether the argument has to be specified at the Makefile level or at the env_config_<cluster>.sh level. In the two cases:
Makefile
- Update the
Makefileadding the argument on top and on the wrapper call - Modify
submit_workflow.shto catch the new argument from the command line (attention to the sanity checks), add description and add it to the other variables - In the same file, add the argument to the
enqueue_compsscall
env_config_<cluster>.sh
- Update the file in the relevant section
- In
submit_workflow.sh, add the argument to theenqueue_compsscall