Unverified Commit e6007c8c authored by Adam Fekete's avatar Adam Fekete Committed by GitHub
Browse files

Merge pull request #4 from modl-uclouvain/tuto_part1

Tuto part1
parents 725f92b6 953eb53d
# mongodb instance folder
db/
......@@ -5,6 +6,9 @@ db/
tutorials/flow_sic_relax
tutorials/launcher_*/
# VSCode IDE
.vscode
# https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
......
......@@ -24,7 +24,7 @@ RUN apt-get update \
WORKDIR /tmp
ARG abinit_version="9.4.0"
COPY configs/abinit_config.ac9 /tmp/abinit-${abinit_version}/build/abinit_config.ac9
COPY configs/abinit/abinit_config.ac9 /tmp/abinit-${abinit_version}/build/abinit_config.ac9
RUN wget -k "https://www.abinit.org/sites/default/files/packages/abinit-${abinit_version}.tar.gz" \
&& tar xzf abinit-${abinit_version}.tar.gz \
......@@ -38,11 +38,34 @@ RUN wget -k "https://www.abinit.org/sites/default/files/packages/abinit-${abinit
FROM jupyter/scipy-notebook
LABEL maintainer="Gian-Marco Rignanese <gian-marco.rignanese@uclouvain.be>"
# Setup slurm
# ===========
USER root
RUN apt-get update \
&& apt install -y --no-install-recommends \
slurmd slurm-client slurmctld \
&& rm -rf /var/lib/apt/lists/*
COPY configs/slurm/slurm.conf /etc/slurm-llnl/slurm.conf
COPY configs/slurm/start_slurm.sh /usr/local/bin/before-notebook.d/
# https://github.com/yuwata/slurm-fedora/blob/master/slurm-setuser.in
RUN mkdir -p /run/munge \
&& chown -R jovyan /run/munge /etc/munge /var/lib/munge /var/log/munge \
&& mkdir -p /var/run/slurm-llnl \
&& chown -R jovyan /var/run/slurm-llnl /var/lib/slurm-llnl /var/log/slurm-llnl
USER $NB_UID
# Abinit installation
# ===================
# # 1. MPI libraries - choice for Open MPI: mpi-default-bin openmpi-bin libopenmpi3
# # 2. math libraries - choice for lapack and blas: liblapack3 libblas3
# # 3. mandatory libraries: libhdf5-103 libnetcdf15 libnetcdff7 libpnetcdf0d libxc5 libfftw3-bin libxml2
# - MPI libraries - choice for Open MPI: mpi-default-bin openmpi-bin libopenmpi3
# - math libraries - choice for lapack and blas: liblapack3 libblas3
# - mandatory libraries: libhdf5-103 libnetcdf15 libnetcdff7 libpnetcdf0d libxc5 libfftw3-bin libxml2
USER root
......@@ -62,46 +85,34 @@ ENV PATH=/opt/abinit/bin:$PATH
# Install Python 3 packages
# =========================
# fireworks's depenecies: flask-paginate gunicorn pymongo
# pseudo_dojo's depenecies: periodic-table-plotter atomicfile
# Depenecies:
# - fireworks: flask-paginate gunicorn pymongo
# - pseudo_dojo: periodic-table-plotter atomicfile
RUN conda install --quiet --yes \
'abipy' \
'jupyter-server-proxy' \
'flask-paginate' 'gunicorn' 'pymongo' \
'periodic-table-plotter' 'atomicfile' \
&& pip install --no-cache-dir jupyter-jsmol fireworks \
&& pip install --no-cache-dir jupyter-jsmol \
&& pip install --no-cache-dir git+https://github.com/modl-uclouvain/fireworks.git \
&& pip install --no-cache-dir jupyter-fireworks-proxy \
&& pip install --no-cache-dir git+https://github.com/gpetretto/abiflows.git@develop \
&& conda clean --all -f -y \
&& fix-permissions "${CONDA_DIR}" \
&& fix-permissions "/home/${NB_USER}"
# Pseudo-dojo
# ===========
# Install a "lightweight" version of Pseudo-dojo
COPY --chown=$NB_UID:$NB_GID pseudo_dojo /opt/pseudo_dojo
WORKDIR /opt/pseudo_dojo
RUN pip install -e .
# Setup slurm
# ===========
USER root
RUN apt-get update \
&& apt install -y --no-install-recommends \
slurmd slurm-client slurmctld \
&& rm -rf /var/lib/apt/lists/*
COPY configs/slurm.conf /etc/slurm-llnl/slurm.conf
COPY configs/start_slurm.sh /usr/local/bin/before-notebook.d/
# https://github.com/yuwata/slurm-fedora/blob/master/slurm-setuser.in
RUN mkdir -p /run/munge \
&& chown -R jovyan /run/munge /etc/munge /var/lib/munge /var/log/munge \
&& mkdir -p /var/run/slurm-llnl \
&& chown -R jovyan /var/run/slurm-llnl /var/lib/slurm-llnl /var/log/slurm-llnl
# Setup home folder
# =================
USER $NB_UID
WORKDIR $HOME
COPY --chown=$NB_UID:$NB_GID configs/abipy .abinit/abipy
COPY --chown=$NB_UID:$NB_GID configs/fireworks .fireworks
COPY --chown=$NB_UID:$NB_GID tutorials tutorials
fw_policy:
autoparal: True
rerun_same_dir: False
allow_local_restart: False
mpirun_cmd: mpirun
max_restarts: 30
abipy_manager: /home/jovyan/.abinit/abipy/manager.yml
## Local runner ##############
# policy:
# autoparal: 0
hardware: &hardware
num_nodes: 1
sockets_per_node: 1
cores_per_socket: 4
mem_per_node: 16 Gb
job: &job
mpi_runner: "mpirun"
# pre_run: "export PATH=$HOME/git_repos/abinit/build_gcc/src/98_main:$PATH"
qadapters: # List of `qadapters` objects (just one in this simplified example)
- priority: 2
queue:
qtype: shell # "Submit" jobs via the shell.
qname: localhost # "Submit" to the localhost queue
# (it's a fake queue in this case)
limits:
timelimit: 01:00:00 # Time-limit for each task.
max_cores: 4 # Max number of cores that can be used by a single task.
hint_cores: 2
hardware: *hardware
job: *job
- priority: 1
queue:
qname: debug
qtype: slurm
limits:
timelimit: 2:00:0
min_cores: 1
max_cores: 2
min_mem_per_proc: 1
hardware: *hardware
job: *job
##############################
PRINT_FW_JSON: True
LAUNCHPAD_LOC: /home/jovyan/.fireworks/my_launchpad.yaml
FWORKER_LOC: /home/jovyan/.fireworks/my_fworker.yaml
QUEUEADAPTER_LOC: /home/jovyan/.fireworks/my_qadapter.yaml
SUBMIT_SCRIPT_NAME: FW_submit.script
QUEUE_UPDATE_INTERVAL: 3
EXCEPT_DETAILS_ON_RERUN: True
REMOVE_USELESS_DIRS: True
#!/bin/bash -l
#SBATCH --nodes=$${nodes}
#SBATCH --ntasks=$${ntasks}
#SBATCH --ntasks-per-node=$${ntasks_per_node}
#SBATCH --ntasks-per-core=$${ntasks_per_core}
#SBATCH --core-spec=$${core_spec}
#SBATCH --exclude=$${exclude_nodes}
#SBATCH --cpus-per-task=$${cpus_per_task}
#SBATCH --gpus-per-task=$${gpus_per_task}
#SBATCH --gres=$${gres}
#SBATCH --qos=$${qos}
#SBATCH --time=$${walltime}
#SBATCH --time-min=$${time_min}
#SBATCH --partition=$${queue}
#SBATCH --account=$${account}
#SBATCH --job-name=$${job_name}
#SBATCH --license=$${license}
#SBATCH --output=$${job_name}-%j.out
#SBATCH --error=$${job_name}-%j.error
#SBATCH --constraint=$${constraint}
#SBATCH --signal=$${signal}
#SBATCH --mem=$${mem}
#SBATCH --mem-per-cpu=$${mem_per_cpu}
#SBATCH --mail-type=$${mail_type}
#SBATCH --mail-user=$${mail_user}
$${pre_rocket}
cd $${launch_dir}
$${rocket_launch}
$${post_rocket}
name: jovyan_worker
category: ''
query: '{}'
_fw_name: CommonAdapter
_fw_q_type: SLURM
_fw_template_file: /home/jovyan/.fireworks/SLURM_template.txt
rocket_launch: rlaunch singleshot
ntasks: 1
walltime: '02:0:0'
queue: debug
account: null
job_name: null
pre_rocket: null
post_rocket: null
......@@ -45,5 +45,5 @@ SlurmctldLogFile=/var/log/slurm-llnl/slurmctld.log
SlurmdLogFile=/var/log/slurm-llnl/slurmd.log
# COMPUTE NODES
NodeName=localhost CPUs=1 State=UNKNOWN
NodeName=localhost CPUs=4 State=UNKNOWN
PartitionName=debug Nodes=localhost Default=YES MaxTime=INFINITE State=UP
version: '3.1'
services:
workflows-workshop:
# build: .
image: workflows-workshop:latest
restart: always
user: root
environment:
# - NB_UID=1001
- GRANT_SUDO=yes
- OMPI_MCA_btl_vader_single_copy_mechanism=none
ports:
- 8888:8888
- 5000:5000
depends_on:
- mongo
volumes:
- ./tutorials:/home/jovyan/tutorials
mongo:
image: mongo
restart: always
# environment:
# - MONGO_INITDB_ROOT_USERNAME=admin
# - MONGO_INITDB_ROOT_PASSWORD=secret
# ports:
# - 27017:27017 # opening port for development only!
volumes:
- ./db:/data/db
# mongo-express: # mongo-express only for development only!
# image: mongo-express
# restart: always
# ports:
# - 8081:8081
# environment:
# - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
# - ME_CONFIG_MONGODB_ADMINPASSWORD=secret
# depends_on:
# - mongo
......@@ -2,39 +2,15 @@ version: '3.1'
services:
workflows-workshop:
# build: .
image: workflows-workshop:latest
restart: always
user: root
environment:
# - NB_UID=1001
- GRANT_SUDO=yes
- OMPI_MCA_btl_vader_single_copy_mechanism=none
ports:
- 8888:8888
- 5000:5000
depends_on:
- mongo
volumes:
- ./tutorials:/home/jovyan/tutorials
mongo:
image: mongo
restart: always
# environment:
# - MONGO_INITDB_ROOT_USERNAME=admin
# - MONGO_INITDB_ROOT_PASSWORD=secret
# ports:
# - 27017:27017 # opening port for development only!
volumes:
- ./db:/data/db
# mongo-express: # mongo-express only for development only!
# image: mongo-express
# restart: always
# ports:
# - 8081:8081
# environment:
# - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
# - ME_CONFIG_MONGODB_ADMINPASSWORD=secret
# depends_on:
# - mongo
%% Cell type:markdown id:exempt-cloud tags:
# Abinit - quickstart
https://abinit.github.io/abipy/flow_gallery/run_sic_relax.html#sphx-glr-flow-gallery-run-sic-relax-py
%% Cell type:code id:necessary-budapest tags:
``` python
!abicheck.py
```
%% Cell type:markdown id:chronic-invention tags:
## Relaxation Flow
This example shows how to build a very simple Flow for the structural relaxation of SiC. One could use a similar logic to perform multiple relaxations with different input parameters…
%% Cell type:code id:handmade-dividend tags:
``` python
import abipy.abilab as abilab
import abipy.data as data
import abipy.flowtk as flowtk
def build_flow(workdir):
pseudos = data.pseudos("14si.pspnc", "6c.pspnc")
structure = data.structure_from_ucell("SiC")
# Initialize the input
relax_inp = abilab.AbinitInput(structure, pseudos=pseudos)
# Set variables
relax_inp.set_vars(
ecut=20,
paral_kgb=1,
iomode=3,
# Relaxation part
ionmov=2,
optcell=1,
strfact=100,
ecutsm=0.5, # Important!
dilatmx=1.15, # Important!
toldff=1e-6,
tolmxf=1e-5,
ntime=100,
)
# K-points sampling
shiftk = [
[0.5,0.5,0.5],
[0.5,0.0,0.0],
[0.0,0.5,0.0],
[0.0,0.0,0.5]
]
relax_inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=shiftk)
# Initialize the flow
flow = flowtk.Flow(workdir)
# Register the task.
flow.register_relax_task(relax_inp)
return flow
```
%% Cell type:markdown id:related-music tags:
Build and run the flow:
%% Cell type:code id:steady-fellowship tags:
``` python
flow = build_flow('flow_sic_relax')
flow.rmtree()
scheduler = flow.make_scheduler()
scheduler.start()
```
%% Cell type:markdown id:confirmed-space tags:
To visualize the evolution of the lattice parameters during the structura relaxation use:
%% Cell type:code id:raising-valuable tags:
``` python
abifile = abilab.abiopen('flow_sic_relax/w0/t0/outdata/out_HIST.nc')
abifile.plot();
```
%% Cell type:code id:changing-bennett tags:
``` python
```
%% Cell type:code id:passing-mineral tags:
``` python
```
%% Cell type:code id:prescribed-mexico tags:
``` python
```
## Local runner ##############
# policy:
# autoparal: 0
qadapters: # List of `qadapters` objects (just one in this simplified example)
- priority: 1
queue:
qtype: shell # "Submit" jobs via the shell.
qname: localhost # "Submit" to the localhost queue
# (it's a fake queue in this case)
job:
mpi_runner: "mpirun"
# pre_run: "export PATH=$HOME/git_repos/abinit/build_gcc/src/98_main:$PATH"
limits:
timelimit: 01:00:00 # Time-limit for each task.
max_cores: 4 # Max number of cores that can be used by a single task.
hint_cores: 2
hardware:
num_nodes: 1
sockets_per_node: 1
cores_per_socket: 4
mem_per_node: 16 Gb
##############################
%% Cell type:markdown id:metallic-supervisor tags:
%% Cell type:markdown id:northern-young tags:
# Fireworks (Five-minute quickstart)
# Five-minute quickstart
https://materialsproject.github.io/fireworks/quickstart.html
In this quickstart, you will:
%% Cell type:markdown id:australian-firewall tags:
* Add a simple workflow to the central database via the command line
* Run that workflow
* Monitor your job status with the FireWorks database
* Get a flavor of the Python API
Testing mongodb connection:
%% Cell type:code id:referenced-routine tags:
``` python
import pymongo
client = pymongo.MongoClient(
host='mongo',
username='',
password='',
authSource='admin'
)
client.list_database_names()
```
%% Cell type:markdown id:gorgeous-curve tags:
## Start FireWorks
If not already running, start MongoDB (if your MongoDB is hosted and maintained externally, follow the note below regarding lpad init):
A MongoDB database (containing the FireWorks database) is running in your docker.
Reset/Initialize the FireWorks database (the LaunchPad) using the command line:
%% Cell type:code id:electronic-essex tags:
```lpad reset```
``` python
# !lpad init
```
Note: All FireWorks commands come with built-in help. For example, type lpad -h or lpad reset -h. There often exist many different options for each command.
%% Cell type:code id:increasing-context tags:
Note2: Resetting the FireWorks removes all your workflows and jobs from your database. During this tutorial, you may use this "often" but when you are in production and actually using FireWorks, you will most likely almost never use this reset.
``` python
!cat my_launchpad.yaml
```
%% Cell type:markdown id:white-owner tags:
Reset/Initialize the FireWorks database (the LaunchPad):
%% Cell type:code id:entertaining-scotland tags:
``` python
! echo 'y' | lpad reset
```
%% Cell type:markdown id:numerous-regard tags:
## Add a Workflow
There are many ways to add Workflows to the database, including a Python API. Let’s start with an extremely simple example that can be added via the command line:
%% Cell type:code id:square-primary tags:
%% Cell type:code id:amended-jimmy tags:
``` python
!lpad add_scripts 'echo "hello"' 'echo "goodbye"' -n hello goodbye -w test_workflow
```
%% Cell type:markdown id:manufactured-bernard tags:
%% Cell type:markdown id:necessary-potato tags:
This added a two-job linear workflow. The first jobs prints hello to the command line, and the second job prints goodbye. We gave names (optional) to each step as “hello” and “goodbye”. We named the workflow overall (optional) as “test_workflow”.
%% Cell type:markdown id:mounted-audio tags:
Let’s look at our test workflow:
%% Cell type:code id:identical-international tags:
%% Cell type:code id:opponent-strip tags:
``` python
!lpad get_wflows -n test_workflow -d more
```
%% Cell type:markdown id:fuzzy-intellectual tags:
%% Cell type:markdown id:deadly-gravity tags:
We get back basic information on our workflows. The second step “goodbye” is waiting for the first one to complete; it is not ready to run because it depends on the first job.
%% Cell type:markdown id:useful-reviewer tags:
## Run all Workflows
You can run jobs one at a time (“singleshot”) or all at once (“rapidfire”). Let’s run all jobs:
%% Cell type:code id:excess-chosen tags:
%% Cell type:code id:destroyed-flooring tags:
``` python
!rlaunch --silencer rapidfire
!rlaunch rapidfire
```
%% Cell type:markdown id:dedicated-commerce tags:
%% Cell type:markdown id:pressing-spiritual tags:
Clearly, both steps of our workflow ran in the correct order.
%% Cell type:markdown id:joined-antique tags:
Let’s again look at our workflows:
%% Cell type:code id:conditional-henry tags:
%% Cell type:code id:presidential-macintosh tags:
``` python
!lpad get_wflows -n test_workflow -d more
```
%% Cell type:markdown id:lucky-failing tags:
%% Cell type:markdown id:designing-bruce tags:
FireWorks automatically created launcher_ directories for each step in the Workflow and ran them. We see that both steps are complete. Note that there exist options to choose where to run jobs, as well as to tear down empty directories after running jobs.
## Look at the web GUI
%% Cell type:markdown id:forward-client tags:
## Launch the web GUI
If you have a web browser, you can launch the web GUI to see your results:
If you have a web browser, you can launch the web GUI to see your workflows using ```lpad webgui```. In this tutorial, the web GUI is directly integrated in the jupyter: