Skip to content

Commit 2fa06c8

Browse files
jan-janssenpyiron-runnerpre-commit-ci[bot]
authored
[Feature] Validate resource_dict using pydantic (#933)
* [Fix] Validate resource_dict using pydantic * Format black * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * type fixes * fix * fix warnings * fix warning * add validation test * fix test * learn from jules * fix import in test * handle tests on windows * test validation error is raised * validate resource_dict * fix validation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add cache_key to resource_dict * reduce available keys in resource_dict * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * always validate resource dict variable * include slurm_cmd_args in validation * fix restart limit check * update documentation * Add remark about pydantic validation * update documentation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pyiron-runner <pyiron@mpie.de> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 813d6b5 commit 2fa06c8

20 files changed

Lines changed: 489 additions & 165 deletions

.ci_support/environment-docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ dependencies:
1515
- jupyter-book =1.0.0
1616
- mpi4py =4.1.1
1717
- python =3.12
18+
- pydantic =2.12.4
1819
- pyzmq =27.1.0

.ci_support/environment-integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- ipython =9.9.0
1818
- matplotlib =3.10.8
1919
- networkx =3.6.1
20+
- pydantic =2.12.4
2021
- pygraphviz =1.14
2122
- pysqa =0.3.5
2223
- pyzmq =27.1.0

.ci_support/environment-mpich.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies:
1111
- ipython =9.9.0
1212
- mpi4py =4.1.1
1313
- networkx =3.6.1
14+
- pydantic =2.12.4
1415
- pygraphviz =1.14
1516
- pysqa =0.3.5
1617
- pyzmq =27.1.0

.ci_support/environment-old.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- h5py =3.6.0
1111
- networkx =2.8.8
1212
- ipython =7.33.0
13+
- pydantic =2.5.3
1314
- pygraphviz =1.10
1415
- hatchling =1.27.0
1516
- hatch-vcs =0.4.0

.ci_support/environment-openmpi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies:
1111
- ipython =9.9.0
1212
- mpi4py =4.1.1
1313
- networkx =3.6.1
14+
- pydantic =2.12.4
1415
- pygraphviz =1.14
1516
- pysqa =0.3.5
1617
- pyzmq =27.1.0

.ci_support/environment-win.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ dependencies:
1111
- ipython =9.9.0
1212
- mpi4py =4.1.1
1313
- networkx =3.6.1
14+
- pydantic =2.12.4
1415
- pygraphviz =1.14
1516
- pyzmq =27.1.0

docs/trouble_shooting.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,26 @@ The resource dictionary parameter `resource_dict` can contain one or more of the
4242
* `threads_per_core` (int): number of OpenMP threads to be used for each function call
4343
* `gpus_per_core` (int): number of GPUs per worker - defaults to 0
4444
* `cwd` (str/None): current working directory where the parallel python task is executed
45-
* `openmpi_oversubscribe` (bool): adds the `--oversubscribe` command line flag (OpenMPI and SLURM only) - default False
45+
* `cache_key` (str): Rather than using the internal hashing of executorlib the user can provide an external `cache_key`
46+
to identify tasks on the file system. The initial file name is going to be `cache_key` + `_i.h5` and the final file
47+
name is going to be `cache_key` + `_o.h5`.
48+
* `num_nodes` (int): number of compute nodes used for the evaluation of the Python function.
49+
* `exclusive` (bool): boolean flag to reserve exclusive access to selected compute nodes - do not allow other tasks to
50+
use the same compute node.
51+
* `error_log_file` (str): path to the error log file, primarily used to merge the log of multiple tasks in one file.
52+
* `run_time_limit` (int): the maximum time the execution of the submitted Python function is allowed to take in seconds.
53+
* `priority` (int): the queuing system priority assigned to a given Python function to influence the scheduling.
4654
* `slurm_cmd_args` (list): Additional command line arguments for the srun call (SLURM only)
4755

4856
For the special case of the [HPC Job Executor](https://executorlib.readthedocs.io/en/latest/3-hpc-job.html)
4957
the resource dictionary parameter `resource_dict` can also include additional parameters define in the submission script
5058
of the [Python simple queuing system adatper (pysqa)](https://pysqa.readthedocs.io) these include but are not limited to:
51-
* `run_time_max` (int): the maximum time the execution of the submitted Python function is allowed to take in seconds.
5259
* `memory_max` (int): the maximum amount of memory the Python function is allowed to use in Gigabytes.
5360
* `partition` (str): the partition of the queuing system the Python function is submitted to.
5461
* `queue` (str): the name of the queue the Python function is submitted to.
5562

56-
All parameters in the resource dictionary `resource_dict` are optional.
63+
All parameters in the resource dictionary `resource_dict` are optional. When `pydantic` is installed as optional
64+
dependency the `resource_dict` is validated using `pydantic`.
5765

5866
## SSH Connection
5967
While the [Python simple queuing system adatper (pysqa)](https://pysqa.readthedocs.io) provides the option to connect to

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ cluster = [
5555
"pysqa==0.3.5",
5656
"h5py==3.15.1",
5757
]
58+
validation = [
59+
"pydantic==2.12.4",
60+
]
5861
all = [
5962
"mpi4py==4.1.1",
6063
"pysqa==0.3.5",
6164
"h5py==3.15.1",
65+
"pydantic==2.12.4",
6266
"pygraphviz==1.14",
6367
"networkx==3.6.1",
6468
"ipython==9.9.0",

src/executorlib/executor/flux.py

Lines changed: 104 additions & 51 deletions
Large diffs are not rendered by default.

src/executorlib/executor/single.py

Lines changed: 102 additions & 42 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)