Skip to content

Commit 2ffc9a2

Browse files
authored
Merge pull request #720 from avigna/JOSS_pythonSubmit
Joss python submit
2 parents 5afc942 + fac0bdf commit 2ffc9a2

File tree

15 files changed

+443
-1672
lines changed

15 files changed

+443
-1672
lines changed

docs/compasHPC.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ to your `~/.bash_profile` or equivalent.
7979
Make a copy of the `stroopwafelInterface.py` file in the `defaults/` folder into your current directory, and set the `run_on_helios` parameter to `True`.
8080
Set any other stroopwafel parameters as you see fit.
8181

82-
If you have many non-default COMPAS arguments, you are encouraged to set them in a `pythonSubmit.py` file in the same directory,
83-
and set the `usePythonSubmit` parameter to `True`.
82+
If you have many non-default COMPAS arguments, you are encouraged to set them in a `runSubmit.py` file in the same directory,
83+
and set the `usePythonSubmit` parameter to `True`, and adapt `stroopwafelInterface.py` accordingly, given that is still under development.
8484

8585
See sampling.md for details.
8686

docs/docker.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,23 @@ To see all available versions, go to the TeamCOMPAS docker hub page [here](https
4141

4242
### Running
4343

44-
COMPAS can still be configured via command line arguments passed to the COMPAS executable or via a `pythonSubmit.py` file.
44+
COMPAS can still be configured via command line arguments passed to the COMPAS executable or via a `runSubmit.py` file.
45+
The `runSubmit.py` file read the options defined in the `compasConfigDefault.yaml`, which overwrite the COMPAS defaults.
4546

46-
#### Run pythonSubmit.py
47+
#### Execute runSubmit.py
4748

48-
To run COMPAS via a `pythonSubmit.py` file, the command is a little more complex.
49+
To run COMPAS via a `runSubmit.py` file, the command is a little more complex.
4950

5051
```
5152
docker run \
5253
--rm \
5354
-it \
5455
-v $(pwd)/compas-logs:/app/COMPAS/logs \
55-
-v $(pwd)/pythonSubmit.py:/app/starts/pythonSubmit.py \
56+
-v $(pwd)/runSubmit.py:/app/starts/runSubmit.py \
5657
-e COMPAS_EXECUTABLE_PATH=/app/COMPAS/bin/COMPAS \
5758
-e COMPAS_LOGS_OUTPUT_DIR_PATH=/app/COMPAS/logs \
5859
teamcompas/compas \
59-
python3 /app/starts/pythonSubmit.py
60+
python3 /app/starts/runSubmit.py
6061
```
6162

6263
Breaking down this command:
@@ -74,7 +75,7 @@ short for [-i and -t](https://docs.docker.com/engine/reference/run/#foreground)
7475
`-v <path-on-host>:<path-in-container>`
7576
[Bind mounts](https://docs.docker.com/storage/bind-mounts/)
7677
mount `<path-on-host>` to `<path-in-container`>
77-
This time we not only want to get the output from COMPAS on the host machine, we also want to supply a `pythonSubmit.py` to the container from the host machine.
78+
This time we not only want to get the output from COMPAS on the host machine, we also want to supply a `runSubmit.py` to the container from the host machine.
7879

7980
`-e VAR_NAME=value`
8081
[Environment variables](https://docs.docker.com/engine/reference/run/#env-environment-variables)
@@ -83,13 +84,13 @@ set the environment variable `VAR_VAME` to `value`
8384
`teamcompas/compas`
8485
the image to run
8586

86-
`python3 /app/starts/pythonSubmit.py`
87+
`python3 /app/starts/runSubmit.py`
8788
the command to run when the container starts
8889

8990

9091
#### Run the COMPAS executable
9192

92-
To run the COMPAS executable directly (i.e. without `pythonSubmit.py`)
93+
To run the COMPAS executable directly (i.e. without `runSubmit.py`)
9394
```
9495
docker run \
9596
--rm \
@@ -136,12 +137,12 @@ More info on `docker run` [here](https://docs.docker.com/engine/reference/run/)
136137

137138
NOTE 1:
138139

139-
Two new environment variables have been added, both of these apply to `pythonSubmit.py` only and are non-breaking changes.
140+
Two new environment variables have been added, both of these apply to `runSubmit.py` only and are non-breaking changes.
140141

141-
`COMPAS_EXECUTABLE_PATH` is an addition to the default `pythonSubmit.py` that overrides where `pythonSubmit.py` looks for the compiled COMPAS.
142+
`COMPAS_EXECUTABLE_PATH` is an addition to the default `runSubmit.py` that overrides where `runSubmit.py` looks for the compiled COMPAS.
142143
This override exists purely for ease-of-use from the command line.
143144

144-
`COMPAS_LOGS_OUTPUT_DIR_PATH` is also an addition to the default `pythonSubmit.py` that overrides where logs are placed.
145+
`COMPAS_LOGS_OUTPUT_DIR_PATH` is also an addition to the default `runSubmit.py` that overrides where logs are placed.
145146
The override exists because the mounted directory (option `-v`) is created before COMPAS runs. COMPAS sees that the directory where it's supposed to put logs already exists, so it created a different (i.e. non-mapped) directory to deposit logs in.
146147

147148

@@ -154,16 +155,16 @@ All container output will be hidden.
154155
An example where this would be useful is if you were running 4 instances of COMPAS at once.
155156
You could copy/paste the following into the terminal...
156157
```
157-
docker run --rm -d -v $(pwd)/compas-logs/run_0:/app/COMPAS/logs -v $(pwd)/pythonSubmitMMsolar_01.py:/app/starts/pythonSubmit.py teamcompas/compas python3 /app/starts/pythonSubmit.py &
158+
docker run --rm -d -v $(pwd)/compas-logs/run_0:/app/COMPAS/logs -v $(pwd)/runSubmitMMsolar_01.py:/app/starts/runSubmit.py teamcompas/compas python3 /app/starts/runSubmit.py &
158159
159-
docker run --rm -d -v $(pwd)/compas-logs/run_1:/app/COMPAS/logs -v $(pwd)/pythonSubmitMMsolar_02.py:/app/starts/pythonSubmit.py teamcompas/compas python3 /app/starts/pythonSubmit.py &
160+
docker run --rm -d -v $(pwd)/compas-logs/run_1:/app/COMPAS/logs -v $(pwd)/runSubmitMMsolar_02.py:/app/starts/runSubmit.py teamcompas/compas python3 /app/starts/runSubmit.py &
160161
161-
docker run --rm -d -v $(pwd)/compas-logs/run_2:/app/COMPAS/logs -v $(pwd)/pythonSubmitMMsolar_03.py:/app/starts/pythonSubmit.py teamcompas/compas python3 /app/starts/pythonSubmit.py &
162+
docker run --rm -d -v $(pwd)/compas-logs/run_2:/app/COMPAS/logs -v $(pwd)/runSubmitMMsolar_03.py:/app/starts/runSubmit.py teamcompas/compas python3 /app/starts/runSubmit.py &
162163
163-
docker run --rm -d -v $(pwd)/compas-logs/run_3:/app/COMPAS/logs -v $(pwd)/pythonSubmitMMsolar_04.py:/app/starts/pythonSubmit.py teamcompas/compas python3 /app/starts/pythonSubmit.py
164+
docker run --rm -d -v $(pwd)/compas-logs/run_3:/app/COMPAS/logs -v $(pwd)/runSubmitMMsolar_04.py:/app/starts/runSubmit.py teamcompas/compas python3 /app/starts/runSubmit.py
164165
```
165166

166-
...which would run 4 separate instances of COMPAS, each with its own `pythonSubmit.py` file and logging directory, and all console output supressed.
167+
...which would run 4 separate instances of COMPAS, each with its own `runSubmit.py` file and logging directory, and all console output supressed.
167168

168169
You may want to check the console output to see how far into the run COMPAS is.
169170
The command for this is `docker logs <container_id>`.
@@ -235,7 +236,7 @@ Make COMPAS using a specific makefile (more below) and as many cores as possible
235236
[RUN](https://docs.docker.com/engine/reference/builder/#run) docs
236237

237238
Dockerfiles will usually end with a `CMD` directive that specifies what command should run when the container is started.
238-
COMPAS doesn't have a `CMD` directive because some users will want to run the executable directly and some will want to use `pythonSubmit.`.
239+
COMPAS doesn't have a `CMD` directive because some users will want to run the executable directly and some will want to use `runSubmit.`.
239240
[CMD](https://docs.docker.com/engine/reference/builder/#cmd) docs
240241

241242

docs/getting_started.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
+ [1.3 Setting up the Makefile and Compiling](#13-setting-up-the-makefile-and-compiling)
99
+ [1.4 Installing Python](#14-installing-python)
1010
* [2. Evolving your first binary](#2-evolving-your-first-binary)
11-
+ [2.1 Running COMPAS from a grid file](#21-running-compas-from-a-grid-file)
12-
+ [2.2 Examining detailed output](#22-examining-detailed-output)
11+
+ [2.1 Running COMPAS out-of-the-box](#21-running-compas-out-of-the-box)
12+
+ [2.2 Running COMPAS from a grid file](#22-running-compas-from-a-grid-file)
13+
+ [2.3 Examining detailed output](#23-examining-detailed-output)
1314
* [3. Further queries](#3-further-queries)
1415

1516
## 1. Installing COMPAS and Dependencies
@@ -124,15 +125,53 @@ If you do not have python3 installed, install it by following the instructions b
124125

125126

126127
## 2. Evolving your first binary
127-
To start using COMPAS, you will need the python script `pythonSubmitDemo.py`, which specifies all the program options (physics assumptions, output types) and runs COMPAS in the terminal. Although the primary functionality of COMPAS is to evolve a whole population of binary stars rapidly, for now, let's focus on evolving a single stellar system and examining the detailed output.
128+
129+
### 2.1 Running COMPAS out-of-the-box
130+
To start using COMPAS, and after the source code has been compiled, you need to go to `$COMPAS_ROOT_DIR/preProcessing/` and run the `runSubmit.py`, which reads the options from `compasConfigDefault.yaml` and overwrite the COMPAS defaults when specified.
131+
The `compasConfigDefault.yaml` specifies all the program options (physics assumptions, output types) and runs COMPAS in the terminal.
132+
Your output should be similar to following.
133+
134+
$ python3 runSubmit.py
135+
python_version = 3
136+
compas_executable_override None
137+
grid_filename None
138+
$COMPAS_ROOT_DIR/src/COMPAS --LONG-COMMAND-LINE
139+
140+
COMPAS v02.25.10
141+
Compact Object Mergers: Population Astrophysics and Statistics
142+
by Team COMPAS (http://compas.science/index.html)
143+
A binary star simulator
144+
145+
Start generating binaries at DATE
146+
147+
0: Unbound binary: (Main_Sequence_>_0.7 -> Neutron_Star) + (Main_Sequence_>_0.7 -> Main_Sequence_>_0.7)
148+
149+
Generated 1 of 1 binaries requested
150+
151+
Simulation completed
152+
153+
End generating binaries at DATE
154+
155+
Clock time = 0.264009 CPU seconds
156+
Wall time = 0000:00:00 (hhhh:mm:ss)
157+
158+
If that is the case, you have succesfully installed COMPAS and ran your fist binary.
159+
160+
As of v02.25.10, the `runSubmit.py` and `compasConfigDefault.yaml` combo are the preferred way to set up runs using python, instead of the prevously used `pythonSubmit.py` (and their adaptations).
161+
We will eventually update the documentation to reflect this, but for now the references to `pythonSubmit.py` or `pythonSubmitDemo.py` refer to the combined options and commands python script that has been tested and used in releases previous than v02.25.10, including those of the methods paper.
162+
The `pythonSubmit.py`, `pythonSubmitDemo.py`, and their functionality, will eventually be fully replaced by the `runSubmit.py` and `compasConfigDefault.yaml` combo.
163+
164+
### 2.2 Running COMPAS from a grid file
165+
166+
We will now try to run a binary using a grid file. For this, you will need the python script `pythonSubmitDemo.py`, which specifies all the program options (physics assumptions, output types) and runs COMPAS in the terminal. For now, let's focus on evolving a single stellar system and examining the detailed output.
128167

129168
To start, change to the `examples/methods_paper_plots/detailed_evolution/` directory:
130169

131170
cd $COMPAS_ROOT_DIR/examples/methods_paper_plots/detailed_evolution/
132171

133-
Here, you will find the script `pythonSubmitDemo.py` for this demo.
172+
Here, you will find the script `pythonSubmitDemo.py` for this demo. This file is an older version of the `runSubmit.py` and `compasConfigDefault.yaml`
173+
134174

135-
### 2.1 Running COMPAS from a grid file
136175
In population synthesis, the initial stellar population is usually generated by drawing the primary mass, secondary mass, semi-major axis, and eccentricity from their respective distributions specified in the program options. However, we illustrate COMPAS's ability to specify a grid of initial values for single and binary star evolution using COMPAS's grid functionality.
137176

138177
An example grid file, `Grid_demo.txt`, has been included in the current `detailed_evolution` directory. Open it with a text editor to view it:
@@ -144,7 +183,7 @@ An example grid file, `Grid_demo.txt`, has been included in the current `detaile
144183

145184
It should be clear that this grid file specifies a binary of zero-age main sequence stars with primary mass 35.4 Msol, secondary mass 29.3 Msol, metallicity 0.001, zero eccentricity, semi-major axis of 1.02 AU, and kick velocities for each component. For more detailed documentation of COMPAS's grid functionality for both single and binary stars, please see [Specifications](./COMPAS_Doc.pdf).
146185

147-
To tell the python submit script to take its input from this grid file, you usually need to open `$COMPAS_ROOT_DIR/preProcessing/pythonSubmit.py` with a text editor, and specify the grid filename `grid_filename = 'Grid_demo.txt'`. And to print the time evolution of binary properties, we need to turn on detailed output: `detailed_output = True`. COMPAS can produce logfiles of different types: HDF5, CSV, TSV, and TXT, which can be chosen by editing the line `logfile_type = 'HDF5'` (the default type is HDF5). For this demo, this has all been done for you in the file `pythonSubmitDemo.py` found in the current directory.
186+
To tell the python submit script to take its input from this grid file, you usually need to open `$COMPAS_ROOT_DIR/preProcessing/compasConfigDefault.yaml` with a text editor, and specify the grid filename `grid: 'Grid_demo.txt'`. And to print the time evolution of binary properties, we need to turn on detailed output: `detailed-output: True`. COMPAS can produce logfiles of different types: HDF5, CSV, TSV, and TXT, which can be chosen by editing the line `logfile-type = 'HDF5'` (the default type is HDF5). For this demo, you can use the `pythonSubmitDemo.py` found in the current directory; this is a good option for v02.25.10 and previous releases. Alternatively, for more recent releases, you could choose to try and adapt the same options from the `$COMPAS_ROOT_DIR/preProcessing/compasConfigDefault.yaml` and the run via `$COMPAS_ROOT_DIR/preProcessing/runSubmit.py` script.
148187

149188
Now let's run COMPAS!
150189

@@ -172,7 +211,7 @@ Now let's run COMPAS!
172211
Congratulations! You've just made a binary black hole. And it didn't even take a second.
173212

174213

175-
### 2.2 Examining detailed output
214+
### 2.3 Examining detailed output
176215
The COMPAS run just now produces a new directory `COMPAS_Output`, inside which you will find the following files/directories (here we assume `logfile_type = 'h5'` in the python submit file):
177216

178217
* `COMPAS_Output.h5`: The primary output file, containing hdf5 data groups for the relevant output physics. By default, and for a sufficiently large simulation, this will include `BSE_Common_Envelopes`, `BSE_Double_Compact_Objects`, `BSE_Supernovae`, and `BSE_System_Parameters`.

examples/methods_paper_plots/chirpmass_distribution/pythonSubmit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
import subprocess
99
from subprocess import call
1010

11+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
12+
#### that has been replaced by the `runSubmit.py` and
13+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
14+
#### The `pythonSubmit.py` format will eventually become deprecated.
15+
1116
# Check if we are using python 3
1217
python_version = sys.version_info[0]
1318
print("python_version =", python_version)

examples/methods_paper_plots/detailed_evolution/pythonSubmitDemo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
import ntpath
99
from subprocess import call
1010

11+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
12+
#### that has been replaced by the `runSubmit.py` and
13+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
14+
#### The `pythonSubmit.py` format will eventually become deprecated.
15+
1116
#### NOTE: For this demo, we use the Grid_demo.txt grid file.
1217
#### The values in that file will override many of the defaults
1318
#### listed here, but in order to reproduce the example in Fig. 9

examples/methods_paper_plots/fig_5_HR_diagram/pythonSubmit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import ntpath
66
from subprocess import call
77

8+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
9+
#### that has been replaced by the `runSubmit.py` and
10+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
11+
#### The `pythonSubmit.py` format will eventually become deprecated.
12+
813
# Check if we are using python 3
914
python_version = sys.version_info[0]
1015
print("python_version =", python_version)

examples/methods_paper_plots/fig_6_max_R/pythonSubmit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import ntpath
66
from subprocess import call
77

8+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
9+
#### that has been replaced by the `runSubmit.py` and
10+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
11+
#### The `pythonSubmit.py` format will eventually become deprecated.
12+
813
# Check if we are using python 3
914
python_version = sys.version_info[0]
1015
print("python_version =", python_version)

examples/methods_paper_plots/fig_8_initial_core_final_mass_relations/pythonSubmitDefaults.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import ntpath
66
from subprocess import call
77

8+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
9+
#### that has been replaced by the `runSubmit.py` and
10+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
11+
#### The `pythonSubmit.py` format will eventually become deprecated.
12+
813
# Check if we are using python 3
914
python_version = sys.version_info[0]
1015
print("python_version =", python_version)

examples/methods_paper_plots/fig_8_initial_core_final_mass_relations/pythonSubmitFryerRapid.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import ntpath
66
from subprocess import call
77

8+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
9+
#### that has been replaced by the `runSubmit.py` and
10+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
11+
#### The `pythonSubmit.py` format will eventually become deprecated.
12+
813
# Check if we are using python 3
914
python_version = sys.version_info[0]
1015
print("python_version =", python_version)

examples/methods_paper_plots/fig_8_initial_core_final_mass_relations/pythonSubmitMandelMueller.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import ntpath
66
from subprocess import call
77

8+
#### DISCLAIMER: This script uses the `pythonSubmit.py` format
9+
#### that has been replaced by the `runSubmit.py` and
10+
#### `compasConfigDefault.yaml` combo as of v02.25.10.
11+
#### The `pythonSubmit.py` format will eventually become deprecated.
12+
813
# Check if we are using python 3
914
python_version = sys.version_info[0]
1015
print("python_version =", python_version)

0 commit comments

Comments
 (0)