Skip to content

Commit 25ace59

Browse files
author
Mark A. Caprio
committed
Merge branch 'release-2.0.0'
2 parents c40ae0e + 056cec3 commit 25ace59

28 files changed

+910
-755
lines changed

INSTALL.md

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Department of Physics, University of Notre Dame
1313
+ 01/01/18 (pjf): Update for installation with `pip`.
1414
+ 02/06/18 (pjf): Update MCSCRIPT_SOURCE file path.
1515
+ 02/09/18 (mac): Overhaul configuration instructions.
16+
+ 07/10/23 (pjf): Update for `MCSCRIPT_CONFIG` variable.
1617

1718
----------------------------------------------------------------
1819

@@ -43,77 +44,74 @@ Department of Physics, University of Notre Dame
4344
Set up the package in your `PYTHONPATH` by running `pip`:
4445

4546
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46-
% python3 -m pip install --user --editable .
47+
% python3 -m pip install --user .
4748
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4849

4950
Note that the `.` here means to install the Python package defined by the code
50-
in the current directory.
51+
in the current directory. If you are actively developing `mcscript` itself,
52+
you may want to pass the `--editable` flag to `pip`. However, beware that
53+
this may result in a fragile installation, e.g., the wrong version of `qsubm`
54+
may be executed if you upgrade.
5155

5256
a. Subsequently updating source:
5357

5458
~~~~~~~~~~~~~~~~
5559
% git pull
56-
% python3 -m pip install --user --editable .
60+
% python3 -m pip install --user .
5761
~~~~~~~~~~~~~~~~
5862

59-
This subsequent `pip install`, when updating the source code, is a precaution
60-
in case, e.g., the package dependencies have changed.
61-
6263
# 2. Local configuration
6364

64-
The local configuration file provides functions which construct the batch
65+
The local configuration module provides functions which construct the batch
6566
submission (qsub, sbatch, etc.) command lines and and serial/parallel
6667
execution launch (mpiexec, srun, etc.) invocations appropriate to your
67-
cluster and running needs. You need to create a symbolic link `config.py` to
68-
point to the correct configuration file for the system or cluster you are
69-
running on.
68+
cluster and running needs. You must define the `MCSCRIPT_CONFIG` environment
69+
variable to specify the correct configuration module for the system or
70+
cluster you are running on.
7071

7172
If you are only doing *local* runs (i.e., no batch job submission) on your
72-
laptop/workstation, and if you are using with OpenMPI as your MPI
73-
implementation, you can use the generic configuration file config-ompi.py in
74-
mcscript/config:
73+
laptop/workstation, and if you are using with OpenMPI as your MPI
74+
implementation, you can use the generic configuration module
75+
`mcscript.config.ompi`:
7576

7677
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77-
% ln -s config/config-ompi.py config.py
78+
% export MCSCRIPT_CONFIG="mcscript.config.ompi"
7879
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7980

80-
Example local configuration files for Univa Grid Engine at the Notre
81-
Dame Center for Research Computing and SLURM at NERSC are included
82-
in the mcscript/config directory.
81+
Local configuration modules for several clusters are provided as part of the
82+
`mcscript` distribution:
8383

84-
>#### @NDCRC: ####
85-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86-
% ln -s config/config-uge-ndcrc.py config.py
87-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88-
89-
>#### @NERSC: ####
90-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91-
% ln -s config/config-slurm-nersc.py config.py
92-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84+
- `mcscript.config.uge_ndcrc` - Univa Grid Engine at CRC (Notre Dame)
85+
- `mcscript.config.slurm_nersc` - Slurm at NERSC (LBNL)
86+
- `mcscript.config.torque_oak` - Torque at UBC ARC (TRIUMF)
9387

9488
Otherwise, whenever you move to a new cluster, you will have to
95-
write such a file, to take into account the pecularities of the
89+
write such a module, to take into account the pecularities of the
9690
batch submission software and queue structure of that cluster.
97-
You can use the above example files as models to define your own configuration
98-
file appropriate to your own cluster and your own running needs.
91+
You can use the above example modules (distributed in `mcscript/config`) as
92+
models to define your own configuration module(s) appropriate to your own
93+
cluster(s) and your own running needs. In such a case, you can set
94+
`MCSCRIPT_CONFIG` to the full path of the configuration module file:
95+
96+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97+
% export MCSCRIPT_CONFIG="/home/alice/code/gadget_acme.py"
98+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99+
99100

100101
# 3. Environment variables
101102

102-
You will also need to add the `mcscript\tools` directory to your command path.
103-
Furthermore, the mcscript job submission utility "qsubm" expects certain
104-
environment variables to be defined at submission time:
103+
The `mcscript` package expects certain environment variables to be defined
104+
at both submission and run time:
105105

106-
> MCSCRIPT_DIR specifies the directory in which the mcscript package is
107-
> installed, i.e., the directory where the file qsubm.py is found. (Note
108-
> that qsubm uses this information to locate certain auxiliary script files
109-
> used as part of the job submission process.)
106+
> `MCSCRIPT_CONFIG` (described above) specifies the cluster configuration
107+
> module.
110108
111-
> MCSCRIPT_INSTALL_HOME specifies the directory in which executables are
109+
> `MCSCRIPT_INSTALL_HOME` specifies the directory in which executables are
112110
> found.
113111
114-
> MCSCRIPT_RUN_HOME specifies the directory in which job files are found.
112+
> `MCSCRIPT_RUN_HOME` specifies the directory in which job files are found.
115113
116-
> MCSCRIPT_WORK_HOME specifies the parent directory in which run scratch
114+
> `MCSCRIPT_WORK_HOME` specifies the parent directory in which run scratch
117115
> directories should be made. This will normally be on a fast scratch
118116
> filesystem.
119117
@@ -126,23 +124,21 @@ Department of Physics, University of Notre Dame
126124

127125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128126
# mcscript
129-
setenv MCSCRIPT_DIR ${HOME}/code/mcscript
127+
setenv MCSCRIPT_CONFIG mcscript.config.ompi
130128
setenv MCSCRIPT_INSTALL_HOME ${HOME}/code/install
131129
setenv MCSCRIPT_RUN_HOME ${HOME}/runs
132130
setenv MCSCRIPT_WORK_HOME ${SCRATCH}/runs
133-
setenv PATH ${MCSCRIPT_DIR}/tools:${PATH}
134131
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135132

136133
Alternatively, if you are a bash user, you would add something like the
137134
following to your .bashrc file:
138135

139136
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140137
# mcscript
141-
export MCSCRIPT_DIR=${HOME}/code/mcscript
138+
export MCSCRIPT_CONFIG=mcscript.config.ompi
142139
export MCSCRIPT_INSTALL_HOME=${HOME}/code/install
143140
export MCSCRIPT_RUN_HOME=${HOME}/runs
144141
export MCSCRIPT_WORK_HOME=${SCRATCH}/runs
145-
export PATH=${MCSCRIPT_DIR}/tools:${PATH}
146142
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147143

148144
You may also need to set environment variables expected by the scripting for
@@ -152,7 +148,7 @@ Department of Physics, University of Notre Dame
152148
To tell mcscript about this file, make sure you set MCSCRIPT_SOURCE
153149
at the time you submit the job, i.e., before calling qsubm:
154150

155-
> MCSCRIPT_SOURCE (optional) should give the full qualified
151+
> `MCSCRIPT_SOURCE` (optional) should give the full qualified
156152
> filename (i.e., including path) to any shell code which should
157153
> be "sourced" at the beginning of the batch job. This should be
158154
> sh/bash-compatible code.
File renamed without changes.

example/runex01.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
"""
1515

1616
import mcscript
17+
import mcscript.control
18+
import mcscript.parameters
19+
import mcscript.utils
1720

18-
mcscript.init()
21+
mcscript.control.init()
1922

2023
##################################################################
2124
# main body
@@ -55,7 +58,7 @@
5558

5659
# example of running an executable
5760
#
58-
# Note that mcscript.call is a wrapper to the subprocess
61+
# Note that mcscript.control.call is a wrapper to the subprocess
5962
# package, but does a lot more... It generates logging output, it
6063
# checks the return code and generates an exception on failure
6164
# (i.e., a nonzero return), it can provide input lines to the code
@@ -64,10 +67,10 @@
6467
#
6568
# See the docstring for mcscript.utils.call for further information.
6669

67-
mcscript.call(["/bin/cat","hello.txt"])
70+
mcscript.control.call(["/bin/cat","hello.txt"])
6871

6972
################################################################
7073
# termination
7174
################################################################
7275

73-
mcscript.termination()
76+
mcscript.control.termination()

example/runex02.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@
122122
# -- make available some functions for use in script
123123
# (including mcscript utility functions and mcscript.task task management)
124124
import mcscript
125-
mcscript.init()
125+
import mcscript.control
126+
import mcscript.task
127+
import mcscript.parameters
128+
import mcscript.utils
129+
import mcscript.exception
130+
mcscript.control.init()
126131

127132
##################################################################
128133
# build task list
@@ -214,7 +219,7 @@ def say_hello(task):
214219
# save results file to common results directory
215220
print("Saving renamed output file...")
216221
results_filename = "{}-hello-{:s}.txt".format(mcscript.parameters.run.name,task["metadata"]["descriptor"])
217-
mcscript.call(
222+
mcscript.control.call(
218223
[
219224
"cp",
220225
"--verbose",
@@ -255,7 +260,7 @@ def say_goodbye(task):
255260
# save results file to common results directory
256261
print("Saving renamed output file...")
257262
results_filename = "{}-goodbye-{:s}.txt".format(mcscript.parameters.run.name,task["metadata"]["descriptor"])
258-
mcscript.call(
263+
mcscript.control.call(
259264
[
260265
"cp",
261266
"--verbose",
@@ -283,4 +288,4 @@ def say_goodbye(task):
283288
# termination
284289
################################################################
285290

286-
mcscript.termination()
291+
mcscript.control.termination()

example/runex03.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
import os
3838

3939
import mcscript
40+
import mcscript.control
4041

41-
mcscript.init()
42+
mcscript.control.init()
4243

4344
##################################################################
4445
# main body
@@ -54,17 +55,17 @@
5455
# via standard input (optional parameter input_lines), and various
5556
# other possibilities depending on the optional parameters.
5657
#
57-
# See the docstring for mcscript.call for further information.
58+
# See the docstring for mcscript.control.call for further information.
5859

5960
# running an executable "unwrapped" -- no OpenMP/MPI setup
60-
mcscript.call(["lscpu"])
61+
mcscript.control.call(["lscpu"])
6162

6263
# running a "hybrid" exectuable -- use both OpenMP and MPI
6364
executable_filename = os.path.join(os.environ["MCSCRIPT_DIR"],"example","hello-hybrid")
64-
mcscript.call([executable_filename],mode=mcscript.CallMode.kHybrid)
65+
mcscript.control.call([executable_filename],mode=mcscript.control.CallMode.kHybrid)
6566

6667
################################################################
6768
# termination
6869
################################################################
6970

70-
mcscript.termination()
71+
mcscript.control.termination()

example/runex04.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
import os
1818

1919
import mcscript
20+
import mcscript.control
2021

21-
mcscript.init()
22+
mcscript.control.init()
2223

2324
print(64*"-")
2425
print("Python's environment (os.environ):")
@@ -28,21 +29,21 @@
2829

2930
print(64*"-")
3031
print("Local invocation of env:")
31-
mcscript.call(["env"],mode=mcscript.CallMode.kLocal)
32+
mcscript.control.call(["env"],mode=mcscript.control.CallMode.kLocal)
3233
print()
3334

3435
print(64*"-")
3536
print("Invocation of env as serial compute code:")
36-
mcscript.call(["env"],mode=mcscript.CallMode.kSerial)
37+
mcscript.control.call(["env"],mode=mcscript.control.CallMode.kSerial)
3738
print()
3839

3940
print(64*"-")
4041
print("Invocation of env as hybrid compute code:")
41-
mcscript.call(["env"],mode=mcscript.CallMode.kHybrid)
42+
mcscript.control.call(["env"],mode=mcscript.control.CallMode.kHybrid)
4243
print()
4344

4445
################################################################
4546
# termination
4647
################################################################
4748

48-
mcscript.termination()
49+
mcscript.control.termination()

example/runex05.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
"""
1414

1515
import mcscript
16+
import mcscript.control
17+
import mcscript.parameters
1618

17-
mcscript.init()
19+
mcscript.control.init()
1820

1921
##################################################################
2022
# main body
2123
##################################################################
2224

23-
mcscript.call(
25+
mcscript.control.call(
2426
["cat"],
2527
input_lines=[
2628
"",
@@ -39,4 +41,4 @@
3941
# termination
4042
################################################################
4143

42-
mcscript.termination()
44+
mcscript.control.termination()

mcscript/__init__.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

mcscript/config.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)