Administration
Data To Compute
June 25-28, 2019
iRODS User Group Meeting 2019
Utrecht, Netherlands
Daniel Moore
Applications Engineer
iRODS Consortium
Administration
Data To Compute
Integrating iRODS with a compute environment
In order of increasing complexity and integration...
iRODS as a compute orchestrator
- Launch a job via irule, or as part of a PEP
- Implement a Landing Zone for product capture
iRODS as part of a compute job script
- Stage the source data via replication for the application
- Capture the products and ingest them into iRODS
iRODS as part of the compute application
- Compute application directly leverages the iRODS API to open, read, and write data
The Data to Compute Use Case
Focus on the right side of the picture
iRODS is out of the data path for computation
Goal - Develop generic interface concept for compute
-
Develop a metadata-driven interface to drive path for input data and compute results. Utilize it to
- push data to the proper storage resource
- get a name for the host on which to launch compute job(s)
-
Separate configuration from implementation
- Keep deployment specifics in configuration files
- Keep rule-base, scripts, and modules free of hard-wired values
Goal - Develop a thumbnailing service for iRODS
Interface is through iRODS and SLURM (compute job scheduler):
- Replicate the data to the compute resource
- Send a job to the compute scheduler to generate thumbnails
- Register the thumbnails into the catalog
- Replicate the thumbnails back to long term storage
- Trim replicas on compute resource
Components of the System
System Component
Job Scheduler
Job Launching Script
Tools to Execute
Job Endpoint
Implementation
SLURM
bash
Image Magick convert
iRODS Rule Base
(user extension of the iRODS API)
and SLURM prolog / epilog
Getting Started
Installing Image Magick
sudo apt-get update
sudo apt-get -y install imagemagick
Installing the PRC (Python iRODS-Client) module
Installing the python rule engine plugin
sudo apt-get -y install irods-rule-engine-plugin-python
sudo apt-get -y install python-pip
sudo pip install python-irodsclient
Getting Started
Get the irods_training repository
cd git clone https://github.com/irods/irods_training sudo apt-get -y install irods-externals-cmake3.5.2-0 irods-dev export PATH=/opt/irods-externals/cmake3.5.2-0/bin/:$PATH
cd mkdir build_data_to_compute cd build_data_to_compute cmake ../irods_training/advanced/hpc_data_to_compute/ make package sudo dpkg -i ./irods-hpc-data-to-compute-example_4.2.6~xenial_amd64.deb
Build and Install MUNGE and SLURM (job scheduler)
Build and Install the Data to Compute package
cd ~/irods_training/advanced/hpc_data_to_compute/ ./ubuntu_16/install_munge_and_slurm.sh
Package Contents
$ dpkg -c ./irods-hpc-data-to-compute-example_4.2.6~xenial_amd64.deb
drwxrwxr-x root/root 0 2019-10-23 12:31 ./var/ drwxrwxr-x root/root 0 2019-10-23 12:31 ./var/lib/ drwxrwxr-x root/root 0 2019-10-23 12:31 ./var/lib/irods/ drwxrwxr-x root/root 0 2019-10-23 12:31 ./var/lib/irods/compute/ -r--r--r-- root/root 0 2019-01-11 16:46 ./var/lib/irods/compute/__init__.py -r--r--r-- root/root 11425 2019-10-22 11:42 ./var/lib/irods/compute/common.py -r--r--r-- root/root 2578 2019-10-22 14:08 ./var/lib/irods/compute/irods_compute_functions -r--r--r-- root/root 658 2019-10-22 11:29 ./var/lib/irods/compute/job_params.json drwxrwxr-x root/root 0 2019-10-23 12:31 ./var/lib/irods/msiExecCmd_bin/ -r-xr-xr-x root/root 1869 2019-10-22 14:12 ./var/lib/irods/msiExecCmd_bin/convert.SLURM -r-xr-xr-x root/root 3418 2019-10-22 11:39 ./var/lib/irods/msiExecCmd_bin/submit_thumbnail_jobs.py -r--r--r-- root/root 816 2019-10-22 14:15 ./var/lib/irods/spawn_remote_slurm_jobs.r
Configure the rule engine
As the irods user, add an additional rule base to
/etc/irods/server_config.json :
"rule_engines": [
...
"re_rulebase_set": [
"data_to_compute",
"core"
],
...
]
(Remember that order matters!)
Add in a small python rule-base:
As the irods user, create an /etc/irods/core.py with
the following content:
import sys
sys.path.insert(0,'/var/lib/irods')
from compute.util import pyParseRoleSpec
Python Rule Engine Configuration (re-ordering)
Edit rule engine order in /etc/irods/server_config.json :
- insert the python plugin configuration stanza after the iRODS Rule Language plugin
- if it already exists elsewhere in the config, move (cut/paste) it from that location, but it must occur only once.
- for this exercise, native rule code must supersede python!
"rule_engines": [
{ "instance_name": "irods_rule_engine_plugin-irods_rule_language-instance",
...
},
{
"instance_name" : "irods_rule_engine_plugin-python-instance",
"plugin_name" : "irods_rule_engine_plugin-python",
"plugin_specific_configuration" : {}
},
Configure the LTS and Image Processing Resources
As the irods user:
Make two unix file system resources
iadmin mkresc lts_resc unixfilesystem `hostname`:/tmp/irods/lts_resc iadmin mkresc img_resc unixfilesystem `hostname`:/tmp/irods/img_resc
Annotate them with appropriate metadata given their roles
- defined in the configuration as part of the contract
imeta add -R lts_resc COMPUTE_RESOURCE_ROLE LONG_TERM_STORAGE imeta add -R img_resc COMPUTE_RESOURCE_ROLE IMAGE_PROCESSING
cp ~/irods_training/stickers.jpg /tmp
sudo mkdir -p /tmp/irods/thumbnails
sudo chown -R irods:irods /tmp/irods
As the ubuntu user:
Stage data and destination directory for thumbnail creation
The configuration interface
Define interfaces for any necessary conventions
-
Metadata attributes and values
-
Metadata values for implemented roles
-
Interface to job scheduler for launching compute
Single Point of Truth - allows for the use of the same 'end-points' for various metadata standards and naming conventions
Users may utilize metadata conventions to provide inputs to a given compute job
The configuration interface
For the thumbnail service we will need to
-
Get the metadata attribute string that holds the role
-
Get the tag for an Image Compute resource
-
Get the tag for a Long Term Storage resource
-
Get the logical collection name for thumbnails
-
Get the physical path for a thumbnail
-
Get the name of a thumbnail
-
Get a list of desired thumbnail sizes
The configuration interface
iRODS rule file provides interface for job submission
main_rule { *host = host_for_resource_role ( *key, *val ) writeLine ("stdout", "host=[*host]") if (*host == "") { writeLine("stderr", "null host - please define COMPUTE_RESOURCE_ROLE metadata") } else { remote(*host, "") { msiExecCmd("submit_thumbnail_jobs.py","--input '*default_input'", "null","null","null", *OUT) } } } host_for_resource_role (*key, *value) { *host = "" foreach (*h in select RESC_LOC where META_RESC_ATTR_NAME = '*key' and META_RESC_ATTR_VALUE = '*val') { *host = *h.RESC_LOC } *host } INPUT *default_input="/$rodsZoneClient/home/$userNameClient/stickers.jpg", *key="COMPUTE_RESOURCE_ROLE", *val="IMAGE_PROCESSING" OUTPUT ruleExecOut
The configuration interface
Abstraction of job submission via Python script
#!/bin/env/python
# -- arguments: --input <input_image_logical_path>
import common
params = common.jobParams()
Input_image_logical_path= # ... read from command_line and validate
scratch_resc = common.rescName_from_role_KVP( params["imageCompute_resc"] )
(Path,Basename) = Input_image_logical_path.rsplit("/",1)
(Filename,Extension) = Basename.rsplit(".",1)
env_constants = dict (os.environ, **{
PARAM_input_image_collection' : Path + '/' + params["relative_path_for_output"],
# .. other fields as necessary
})
SBATCH_OPTIONS="--export ALL -o /tmp/slurm-%j.out"
for size_string in params["thumbnail_size_list"]:
common.replicate_to_resource (Input_image_logical_path, scratch_resc)
p = Popen( ['/usr/local/bin/sbatch'] + SBATCH_OPTIONS.split() + [SCRIPT] + convert_args,
env = dict(env_constants, PARAM_thumbnail_size = size_string) )
Full script at: /var/lib/irods/msiExecCmd_bin/submit_thumbnail_jobs.py
With support code at: /var/lib/irods/compute/common.py
Thumbnail Service - testing
irods@icat:~$ COMPUTE_RESC=$(iquest %s " select RESC_NAME where META_RESC_ATTR_NAME = \ 'COMPUTE_RESOURCE_ROLE' and META_RESC_ATTR_VALUE = 'IMAGE_PROCESSING' " )
irods@icat:~$ iput /tmp/stickers.jpg irods@icat:~$ ils -l /tempZone/home/rods: rods 0 demoResc 2157087 2019-06-20.22:07 & stickers.jpg irods@icat:~$ irule -F spawn_remote_slurm_jobs.r irods@icat:~$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 2 debug convert. irods R 0:05 1 icat 3 debug convert. irods R 0:05 1 icat 4 debug convert. irods R 0:05 1 icat 5 debug convert. irods R 0:05 1 icat
irods@icat:~$ squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
irods@icat:~$ iquest "%s : %s/%s" "select RESC_NAME,COLL_NAME,DATA_NAME where DATA_NAME like '%thumbnail%'"
lts_resc : /tempZone/home/rods/stickers_thumbnails/stickers_thumbnail_1024x1024.jpg
lts_resc : /tempZone/home/rods/thumbnails/stickers_128x128.jpg
lts_resc : /tempZone/home/rods/thumbnails/stickers_256x256.jpg
lts_resc : /tempZone/home/rods/thumbnails/stickers_512x512.jpg
(Wait for the SLURM job queue to be empty: )
As the irods user, position the input data and start the thumbnail jobs:
Extending iRODS with the Rule Engine
All rules should be created and tested in user space before being installed as a rule base
Rules may be refactored into a microservice plugin
Rules may be refactored into a C++ rule engine plugin
Rules may be refactored into an API plugin
Copy of UGM 2019 - Administration Data to Compute
By Daniel Moore
Copy of UGM 2019 - Administration Data to Compute
iRODS User Group Meeting 2019 - Administration Training Module
- 1,081