idmtools-platform-general 0.0.0.dev0__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- idmtools_platform_general-0.0.3/.bumpversion.cfg +39 -0
- idmtools_platform_general-0.0.3/LICENSE.TXT +3 -0
- idmtools_platform_general-0.0.3/MANIFEST.in +3 -0
- idmtools_platform_general-0.0.3/Makefile +13 -0
- idmtools_platform_general-0.0.3/PKG-INFO +81 -0
- idmtools_platform_general-0.0.3/README.md +53 -0
- idmtools_platform_general-0.0.3/VERSION +1 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/__init__.py +18 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/assets/__init__.py +77 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/assets/_run.sh.jinja2 +47 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/assets/batch.sh.jinja2 +24 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/assets/run_simulation.sh +8 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/cli/__init__.py +5 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/cli/file.py +185 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/file_operations/__init__.py +4 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/file_operations/file_operations.py +298 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/file_operations/operations_interface.py +74 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/file_platform.py +288 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/__init__.py +5 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/asset_collection_operations.py +172 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/experiment_operations.py +314 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/json_metadata_operations.py +320 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/simulation_operations.py +212 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/suite_operations.py +243 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/platform_operations/utils.py +461 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/plugin_info.py +82 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/tools/__init__.py +4 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/tools/job_history.py +334 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/tools/status_report/__init__.py +4 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/tools/status_report/status_report.py +222 -0
- idmtools_platform_general-0.0.3/idmtools_platform_file/tools/status_report/utils.py +159 -0
- idmtools_platform_general-0.0.3/idmtools_platform_general.egg-info/PKG-INFO +81 -0
- idmtools_platform_general-0.0.3/idmtools_platform_general.egg-info/SOURCES.txt +56 -0
- idmtools_platform_general-0.0.3/idmtools_platform_general.egg-info/entry_points.txt +6 -0
- idmtools_platform_general-0.0.3/idmtools_platform_general.egg-info/requires.txt +13 -0
- idmtools_platform_general-0.0.3/idmtools_platform_general.egg-info/top_level.txt +2 -0
- idmtools_platform_general-0.0.3/idmtools_platform_process/__init__.py +17 -0
- idmtools_platform_general-0.0.3/idmtools_platform_process/platform_operations/__init__.py +5 -0
- idmtools_platform_general-0.0.3/idmtools_platform_process/platform_operations/experiment_operations.py +53 -0
- idmtools_platform_general-0.0.3/idmtools_platform_process/plugin_info.py +80 -0
- idmtools_platform_general-0.0.3/idmtools_platform_process/process_platform.py +52 -0
- idmtools_platform_general-0.0.3/pyproject.toml +76 -0
- {idmtools_platform_general-0.0.0.dev0 → idmtools_platform_general-0.0.3}/setup.cfg +4 -4
- idmtools_platform_general-0.0.3/tests/Makefile +11 -0
- idmtools_platform_general-0.0.3/tests/__init__.py +5 -0
- idmtools_platform_general-0.0.3/tests/input/hello.sh +2 -0
- idmtools_platform_general-0.0.3/tests/pytest.ini +16 -0
- idmtools_platform_general-0.0.3/tests/test_folder.py +136 -0
- idmtools_platform_general-0.0.3/tests/test_folder_files_path_length.py +89 -0
- idmtools_platform_general-0.0.3/tests/test_get_methods.py +443 -0
- idmtools_platform_general-0.0.3/tests/test_hooks.py +88 -0
- idmtools_platform_general-0.0.3/tests/test_json_metadata_operations.py +398 -0
- idmtools_platform_general-0.0.3/tests/test_platform_file.py +286 -0
- idmtools_platform_general-0.0.3/tests/test_platform_process.py +235 -0
- idmtools_platform_general-0.0.3/tests/test_singularity_fileplatform.py +62 -0
- idmtools_platform_general-0.0.3/tests/test_singularity_processplatform.py +62 -0
- idmtools_platform_general-0.0.3/tests/test_symlink.py +106 -0
- idmtools_platform_general-0.0.0.dev0/PKG-INFO +0 -41
- idmtools_platform_general-0.0.0.dev0/README.md +0 -21
- idmtools_platform_general-0.0.0.dev0/idmtools_platform_general/__init__.py +0 -8
- idmtools_platform_general-0.0.0.dev0/idmtools_platform_general.egg-info/PKG-INFO +0 -41
- idmtools_platform_general-0.0.0.dev0/idmtools_platform_general.egg-info/SOURCES.txt +0 -7
- idmtools_platform_general-0.0.0.dev0/idmtools_platform_general.egg-info/top_level.txt +0 -2
- idmtools_platform_general-0.0.0.dev0/pyproject.toml +0 -32
- {idmtools_platform_general-0.0.0.dev0 → idmtools_platform_general-0.0.3}/idmtools_platform_general.egg-info/dependency_links.txt +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[bumpversion]
|
|
2
|
+
current_version = 3.0.0+nightly
|
|
3
|
+
commit = False
|
|
4
|
+
tag = False
|
|
5
|
+
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?P<release>\+\w+)?(\.(?P<build>\d+))?
|
|
6
|
+
serialize =
|
|
7
|
+
{major}.{minor}.{patch}{release}.{build}
|
|
8
|
+
{major}.{minor}.{patch}{release}
|
|
9
|
+
{major}.{minor}.{patch}
|
|
10
|
+
|
|
11
|
+
[bumpversion:part:release]
|
|
12
|
+
optional_value = prod
|
|
13
|
+
first_value = prod
|
|
14
|
+
values =
|
|
15
|
+
prod
|
|
16
|
+
+nightly
|
|
17
|
+
|
|
18
|
+
[bumpversion:part:build]
|
|
19
|
+
|
|
20
|
+
[bumpversion:file:VERSION]
|
|
21
|
+
serialize = {major}.{minor}.{patch}
|
|
22
|
+
|
|
23
|
+
[bumpversion:file:./idmtools_platform_file/__init__.py]
|
|
24
|
+
search = __version__ = "{current_version}"
|
|
25
|
+
replace = __version__ = "{new_version}"
|
|
26
|
+
serialize = {major}.{minor}.{patch}{release}
|
|
27
|
+
{major}.{minor}.{patch}
|
|
28
|
+
|
|
29
|
+
[bumpversion:file:./idmtools_platform_process/__init__.py]
|
|
30
|
+
search = __version__ = "{current_version}"
|
|
31
|
+
replace = __version__ = "{new_version}"
|
|
32
|
+
serialize = {major}.{minor}.{patch}{release}
|
|
33
|
+
{major}.{minor}.{patch}
|
|
34
|
+
|
|
35
|
+
[bumpversion:file:./pyproject.toml]
|
|
36
|
+
search = version = "{current_version}"
|
|
37
|
+
replace = version = "{new_version}"
|
|
38
|
+
serialize = {major}.{minor}.{patch}{release}
|
|
39
|
+
{major}.{minor}.{patch}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
PACKAGE_NAME=idmtools_platform_file
|
|
2
|
+
include $(abspath ../dev_scripts/package_general.mk)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
help:
|
|
6
|
+
help-from-makefile -f ../dev_scripts/package_general.mk -f ./Makefile
|
|
7
|
+
|
|
8
|
+
# Release related rules
|
|
9
|
+
ssmt-image: ## Build SSMT Docker image
|
|
10
|
+
$(MAKE) -C ssmt_image docker
|
|
11
|
+
|
|
12
|
+
ssmt-image-release: ## Push image to staging
|
|
13
|
+
$(MAKE) -C ssmt_image docker-release-staging
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: idmtools_platform_general
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: General platform for IDM-Tools
|
|
5
|
+
Author-email: Zhaowei Du <zdu@idmod.org>, Sharon Chen <shchen@idmod.org>, Clinton Collins <ccollins@idmod.org>, Jen Schripsema <jschripsema@idmod.org>, Ross Carter <rcarter@idmod.org>
|
|
6
|
+
Project-URL: Homepage, https://github.com/InstituteforDiseaseModeling/idmtools
|
|
7
|
+
Keywords: modeling,IDM
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE.TXT
|
|
16
|
+
Requires-Dist: idmtools<1.0.0,>=0.0.0
|
|
17
|
+
Requires-Dist: idmtools_cli<1.0.0,>=0.0.0
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Requires-Dist: idmtools[test]; extra == "test"
|
|
20
|
+
Requires-Dist: idmtools_test; extra == "test"
|
|
21
|
+
Provides-Extra: packaging
|
|
22
|
+
Requires-Dist: flake8; extra == "packaging"
|
|
23
|
+
Requires-Dist: coverage; extra == "packaging"
|
|
24
|
+
Requires-Dist: bump2version; extra == "packaging"
|
|
25
|
+
Requires-Dist: twine; extra == "packaging"
|
|
26
|
+
Requires-Dist: natsort; extra == "packaging"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
# idmtools-platform-general
|
|
32
|
+
|
|
33
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
34
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
35
|
+
**Table of Contents**
|
|
36
|
+
|
|
37
|
+
- [Installing](#installing)
|
|
38
|
+
- [Development Tips](#development-tips)
|
|
39
|
+
- [Use Cases](#use-cases)
|
|
40
|
+
- [Feature Roadmap](#feature-roadmap)
|
|
41
|
+
|
|
42
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
43
|
+
|
|
44
|
+
## Installing
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install idmtools-platform-general --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
# Development Tips
|
|
51
|
+
|
|
52
|
+
There is a Makefile file available for most common development tasks. Here is a list of commands
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
clean - Clean up temproary files
|
|
56
|
+
lint - Lint package and tests
|
|
57
|
+
test - Run All tests
|
|
58
|
+
coverage - Run tests and generate coverage report that is shown in browser
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
On Windows, you can use `pymake` instead of `make`
|
|
62
|
+
|
|
63
|
+
# Use Cases
|
|
64
|
+
|
|
65
|
+
* Testing
|
|
66
|
+
* Test core functionality
|
|
67
|
+
* Performance Testing
|
|
68
|
+
* Integration with other systems
|
|
69
|
+
* Other HPC Systems
|
|
70
|
+
* Local Executions Systems
|
|
71
|
+
* Jupyter notebooks
|
|
72
|
+
* Basis for future local platforms
|
|
73
|
+
* Process
|
|
74
|
+
* Thread
|
|
75
|
+
* Dask
|
|
76
|
+
* Asyncio
|
|
77
|
+
|
|
78
|
+
# Feature Roadmap
|
|
79
|
+
|
|
80
|
+
* First Version
|
|
81
|
+
* Support for basic provisioning on a linux filesystem
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# idmtools-platform-general
|
|
4
|
+
|
|
5
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
6
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
7
|
+
**Table of Contents**
|
|
8
|
+
|
|
9
|
+
- [Installing](#installing)
|
|
10
|
+
- [Development Tips](#development-tips)
|
|
11
|
+
- [Use Cases](#use-cases)
|
|
12
|
+
- [Feature Roadmap](#feature-roadmap)
|
|
13
|
+
|
|
14
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
15
|
+
|
|
16
|
+
## Installing
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install idmtools-platform-general --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
# Development Tips
|
|
23
|
+
|
|
24
|
+
There is a Makefile file available for most common development tasks. Here is a list of commands
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
clean - Clean up temproary files
|
|
28
|
+
lint - Lint package and tests
|
|
29
|
+
test - Run All tests
|
|
30
|
+
coverage - Run tests and generate coverage report that is shown in browser
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
On Windows, you can use `pymake` instead of `make`
|
|
34
|
+
|
|
35
|
+
# Use Cases
|
|
36
|
+
|
|
37
|
+
* Testing
|
|
38
|
+
* Test core functionality
|
|
39
|
+
* Performance Testing
|
|
40
|
+
* Integration with other systems
|
|
41
|
+
* Other HPC Systems
|
|
42
|
+
* Local Executions Systems
|
|
43
|
+
* Jupyter notebooks
|
|
44
|
+
* Basis for future local platforms
|
|
45
|
+
* Process
|
|
46
|
+
* Thread
|
|
47
|
+
* Dask
|
|
48
|
+
* Asyncio
|
|
49
|
+
|
|
50
|
+
# Feature Roadmap
|
|
51
|
+
|
|
52
|
+
* First Version
|
|
53
|
+
* Support for basic provisioning on a linux filesystem
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.0
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
idmtools file platform.
|
|
3
|
+
|
|
4
|
+
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
|
|
5
|
+
"""
|
|
6
|
+
# flake8: noqa F821
|
|
7
|
+
try:
|
|
8
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
9
|
+
except ImportError:
|
|
10
|
+
# Python < 3.8
|
|
11
|
+
from importlib_metadata import version, PackageNotFoundError
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
__version__ = version("idmtools-platform-general") # Use your actual package name
|
|
15
|
+
except PackageNotFoundError:
|
|
16
|
+
# Package not installed, use fallback
|
|
17
|
+
__version__ = "0.0.0+unknown"
|
|
18
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utility functions to generate batch scripts.
|
|
3
|
+
|
|
4
|
+
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
|
|
5
|
+
"""
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from jinja2 import Template
|
|
8
|
+
from typing import TYPE_CHECKING, Optional
|
|
9
|
+
from idmtools.entities.experiment import Experiment
|
|
10
|
+
from idmtools.entities.simulation import Simulation
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from idmtools_platform_file.file_platform import FilePlatform
|
|
14
|
+
|
|
15
|
+
DEFAULT_TEMPLATE_FILE = Path(__file__).parent.joinpath("batch.sh.jinja2")
|
|
16
|
+
DEFAULT_SIMULATION_TEMPLATE = Path(__file__).parent.parent.joinpath("assets/_run.sh.jinja2")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def generate_script(platform: 'FilePlatform', experiment: Experiment, max_job: int = None, run_sequence: bool = None,
|
|
20
|
+
**kwargs) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Generate batch file batch.sh.
|
|
23
|
+
Args:
|
|
24
|
+
platform: File Platform
|
|
25
|
+
experiment: idmtools Experiment
|
|
26
|
+
max_job: int
|
|
27
|
+
run_sequence: bool
|
|
28
|
+
kwargs: keyword arguments used to expand functionality
|
|
29
|
+
Returns:
|
|
30
|
+
None
|
|
31
|
+
"""
|
|
32
|
+
output_target = platform.get_directory(experiment).joinpath("batch.sh")
|
|
33
|
+
with open(output_target, "w") as tout:
|
|
34
|
+
with open(DEFAULT_TEMPLATE_FILE) as tin:
|
|
35
|
+
t = Template(tin.read())
|
|
36
|
+
tvars = dict(
|
|
37
|
+
platform=platform,
|
|
38
|
+
max_job=max_job if max_job is not None else platform.max_job,
|
|
39
|
+
run_sequence=run_sequence if run_sequence is not None else platform.run_sequence
|
|
40
|
+
)
|
|
41
|
+
if platform.modules:
|
|
42
|
+
tvars['modules'] = platform.modules
|
|
43
|
+
if platform.extra_packages:
|
|
44
|
+
tvars['packages'] = platform.extra_packages
|
|
45
|
+
tout.write(t.render(tvars))
|
|
46
|
+
|
|
47
|
+
# Make executable
|
|
48
|
+
platform.update_script_mode(output_target)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def generate_simulation_script(platform: 'FilePlatform', simulation: Simulation, retries: Optional[int] = None,
|
|
52
|
+
**kwargs) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Generate batch file _run.sh.
|
|
55
|
+
Args:
|
|
56
|
+
platform: File Platform
|
|
57
|
+
simulation: idmtools Simulation
|
|
58
|
+
retries: int
|
|
59
|
+
extra_packages: List of extra packages to install
|
|
60
|
+
kwargs: keyword arguments used to expand functionality
|
|
61
|
+
Returns:
|
|
62
|
+
None
|
|
63
|
+
"""
|
|
64
|
+
sim_script = platform.get_directory(simulation).joinpath("_run.sh")
|
|
65
|
+
with open(sim_script, "w") as tout:
|
|
66
|
+
with open(DEFAULT_SIMULATION_TEMPLATE) as tin:
|
|
67
|
+
t = Template(tin.read())
|
|
68
|
+
tvars = dict(
|
|
69
|
+
platform=platform,
|
|
70
|
+
simulation=simulation,
|
|
71
|
+
retries=retries if retries else platform.retries,
|
|
72
|
+
ntasks=platform.ntasks
|
|
73
|
+
)
|
|
74
|
+
tout.write(t.render(tvars))
|
|
75
|
+
|
|
76
|
+
# Make executable
|
|
77
|
+
platform.update_script_mode(sim_script)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# define the handler function
|
|
4
|
+
term_handler()
|
|
5
|
+
{
|
|
6
|
+
# do whatever cleanup you want here
|
|
7
|
+
echo "-1" > job_status.txt
|
|
8
|
+
exit -1
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# Register cleanup function to handle SIGINT and SIGTERM signals
|
|
12
|
+
trap 'term_handler' SIGINT SIGTERM
|
|
13
|
+
|
|
14
|
+
n=0
|
|
15
|
+
{% set mpi_command = "mpirun -n " + ntasks|string if ntasks > 1 else "" %}
|
|
16
|
+
|
|
17
|
+
until [ "$n" -ge {{retries}} ]
|
|
18
|
+
do
|
|
19
|
+
echo "100" > job_status.txt
|
|
20
|
+
{% if simulation.task.sif_path is defined and simulation.task.sif_path %}
|
|
21
|
+
{% if simulation.task.command.cmd.startswith('singularity') %}
|
|
22
|
+
{{ mpi_command }} {{simulation.task.command.cmd}} &
|
|
23
|
+
{% else %}
|
|
24
|
+
singularity exec {{simulation.task.sif_path}} {{ mpi_command }} {{simulation.task.command.cmd}} &
|
|
25
|
+
{% endif %}
|
|
26
|
+
{% else %}
|
|
27
|
+
exec -a "SIMULATION:{{simulation.id}}" {{ mpi_command }} {{simulation.task.command.cmd}} &
|
|
28
|
+
{% endif %}
|
|
29
|
+
|
|
30
|
+
child_pid=$!
|
|
31
|
+
echo "Running simulation with PID: $child_pid"
|
|
32
|
+
# Wait for the child process to complete
|
|
33
|
+
wait $child_pid
|
|
34
|
+
|
|
35
|
+
RESULT=$?
|
|
36
|
+
if [ $RESULT -eq 0 ]; then
|
|
37
|
+
echo "0" > job_status.txt
|
|
38
|
+
exit 0
|
|
39
|
+
elif [ $RESULT -eq 255 ] || [ $RESULT -eq -1 ]; then # Normalize -1 or 255 to 1 to avoid process abort
|
|
40
|
+
echo "-1" > job_status.txt
|
|
41
|
+
echo "_run.sh exiting with code: $RESULT" >> exit_code.log
|
|
42
|
+
exit 1
|
|
43
|
+
fi
|
|
44
|
+
n=$((n+1))
|
|
45
|
+
done
|
|
46
|
+
echo "-1" > job_status.txt
|
|
47
|
+
exit $RESULT
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
chmod +x run_simulation.sh
|
|
4
|
+
|
|
5
|
+
{% if packages is defined and packages is not none and packages|length > 0 %}
|
|
6
|
+
echo "Installing custom packages"
|
|
7
|
+
|
|
8
|
+
{% for package in packages %}
|
|
9
|
+
echo "Installing {{ package }}" 1>> stdout.txt 2>> stderr.txt
|
|
10
|
+
pip install {{ package }} --extra-index-url=https://packages.idmod.org/api/pypi/pypi-production/simple --upgrade 1>> stdout.txt 2>> stderr.txt
|
|
11
|
+
{% endfor %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if modules is defined and modules is not none and modules|length > 0 %}
|
|
15
|
+
{% for m in modules %}
|
|
16
|
+
module load {{m}}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
{% endif %}
|
|
19
|
+
|
|
20
|
+
{% if run_sequence is defined and run_sequence %}
|
|
21
|
+
find $(pwd) -maxdepth 2 -name "_run.sh" -print0 | xargs -0 -I% dirname % | xargs -d "\n" -I% bash -c 'cd $(pwd) && $(pwd)/run_simulation.sh % 1>> stdout.txt 2>> stderr.txt'
|
|
22
|
+
{% else %}
|
|
23
|
+
find $(pwd) -maxdepth 2 -name "_run.sh" -print0 | xargs -0 -I% dirname % | xargs -d "\n" -P {{ max_job }} -I% bash -c 'cd $(pwd) && $(pwd)/run_simulation.sh % 1>> stdout.txt 2>> stderr.txt'
|
|
24
|
+
{% endif %}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""
|
|
2
|
+
idmtools FilePlatform CLI commands.
|
|
3
|
+
|
|
4
|
+
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
import click
|
|
8
|
+
from idmtools.core import ItemType
|
|
9
|
+
from idmtools.core.platform_factory import Platform
|
|
10
|
+
from idmtools_platform_file.tools.status_report.status_report import generate_status_report
|
|
11
|
+
from idmtools_platform_file.tools.status_report.utils import get_latest_experiment, check_status, clear_history
|
|
12
|
+
from logging import getLogger
|
|
13
|
+
|
|
14
|
+
user_logger = getLogger('user')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.group(short_help="File platform related commands.")
|
|
18
|
+
@click.argument('job-directory')
|
|
19
|
+
@click.pass_context
|
|
20
|
+
def file(ctx: click.Context, job_directory):
|
|
21
|
+
"""
|
|
22
|
+
Commands related to managing the File Platform.
|
|
23
|
+
|
|
24
|
+
job_directory: FilePlatform Working Directory
|
|
25
|
+
"""
|
|
26
|
+
ctx.obj = dict(job_directory=job_directory)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@file.command(help="Get simulation's report")
|
|
30
|
+
@click.option('--suite-id', default=None, help="Idmtools Suite id")
|
|
31
|
+
@click.option('--exp-id', default=None, help="Idmtools Experiment id")
|
|
32
|
+
@click.option('--status-filter', type=click.Choice(['0', '-1', '100']), multiple=True, help="list of status")
|
|
33
|
+
@click.option('--sim-filter', multiple=True, help="list of simulations")
|
|
34
|
+
@click.option('--verbose/--no-verbose', default=True, help="Enable verbose output in results")
|
|
35
|
+
@click.option('--display/--no-display', default=True, help="Display with working directory or not")
|
|
36
|
+
@click.option('--display-count', default=20, help="Display Count")
|
|
37
|
+
@click.pass_context
|
|
38
|
+
def status_report(ctx: click.Context, suite_id, exp_id, status_filter, sim_filter, verbose, display,
|
|
39
|
+
display_count):
|
|
40
|
+
"""
|
|
41
|
+
Build status report.
|
|
42
|
+
Args:
|
|
43
|
+
ctx: click.Context
|
|
44
|
+
suite_id: suite id
|
|
45
|
+
exp_id: experiment id
|
|
46
|
+
status_filter: status filter
|
|
47
|
+
sim_filter: simulation filter
|
|
48
|
+
verbose: bool True/False
|
|
49
|
+
display: bool True/False
|
|
50
|
+
display_count: how many to display
|
|
51
|
+
Returns:
|
|
52
|
+
None
|
|
53
|
+
"""
|
|
54
|
+
job_dir = ctx.obj['job_directory']
|
|
55
|
+
platform = Platform('FILE', job_directory=job_dir)
|
|
56
|
+
|
|
57
|
+
if suite_id is not None:
|
|
58
|
+
scope = (suite_id, ItemType.SUITE)
|
|
59
|
+
elif exp_id is not None:
|
|
60
|
+
scope = (exp_id, ItemType.EXPERIMENT)
|
|
61
|
+
else:
|
|
62
|
+
scope = None
|
|
63
|
+
|
|
64
|
+
generate_status_report(platform=platform, scope=scope,
|
|
65
|
+
status_filter=status_filter if len(status_filter) > 0 else None,
|
|
66
|
+
sim_filter=sim_filter if len(sim_filter) > 0 else None,
|
|
67
|
+
verbose=verbose, display=display, display_count=display_count)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@file.command(help="Get the latest experiment info")
|
|
71
|
+
@click.pass_context
|
|
72
|
+
def get_latest(ctx: click.Context):
|
|
73
|
+
"""
|
|
74
|
+
Get the latest experiment directory.
|
|
75
|
+
Args:
|
|
76
|
+
ctx: click.Context
|
|
77
|
+
Returns:
|
|
78
|
+
None
|
|
79
|
+
"""
|
|
80
|
+
job_dir = ctx.obj['job_directory']
|
|
81
|
+
platform = Platform('FILE', job_directory=job_dir)
|
|
82
|
+
|
|
83
|
+
result = get_latest_experiment(platform)
|
|
84
|
+
user_logger.info(json.dumps(result, indent=3))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@file.command(help="Get Suite/Experiment/Simulation directory")
|
|
88
|
+
@click.option('--sim-id', default=None, help="Idmtools Simulation id")
|
|
89
|
+
@click.option('--exp-id', default=None, help="Idmtools Experiment id")
|
|
90
|
+
@click.option('--suite-id', default=None, help="Idmtools Suite id")
|
|
91
|
+
@click.pass_context
|
|
92
|
+
def get_path(ctx: click.Context, sim_id, exp_id, suite_id):
|
|
93
|
+
"""
|
|
94
|
+
Get entity directory.
|
|
95
|
+
Args:
|
|
96
|
+
ctx: click.Context
|
|
97
|
+
sim_id: simulation id
|
|
98
|
+
exp_id: experiment id
|
|
99
|
+
suite_id: suite id
|
|
100
|
+
Returns:
|
|
101
|
+
None
|
|
102
|
+
"""
|
|
103
|
+
job_dir = ctx.obj['job_directory']
|
|
104
|
+
platform = Platform('FILE', job_directory=job_dir)
|
|
105
|
+
|
|
106
|
+
if sim_id is not None:
|
|
107
|
+
item_dir = platform.get_directory_by_id(sim_id, ItemType.SIMULATION)
|
|
108
|
+
elif exp_id is not None:
|
|
109
|
+
item_dir = platform.get_directory_by_id(exp_id, ItemType.EXPERIMENT)
|
|
110
|
+
elif suite_id is not None:
|
|
111
|
+
item_dir = platform.get_directory_by_id(suite_id, ItemType.SUITE)
|
|
112
|
+
else:
|
|
113
|
+
raise Exception('Must provide at least one: suite-id, exp-id or sim-id!')
|
|
114
|
+
|
|
115
|
+
user_logger.info(item_dir)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@file.command(help="Get status of Experiment/Simulation")
|
|
119
|
+
@click.option('--sim-id', default=None, help="Idmtools Simulation id")
|
|
120
|
+
@click.option('--exp-id', default=None, help="Idmtools Experiment id")
|
|
121
|
+
@click.pass_context
|
|
122
|
+
def get_status(ctx: click.Context, sim_id, exp_id):
|
|
123
|
+
"""
|
|
124
|
+
Retrieve status.
|
|
125
|
+
Args:
|
|
126
|
+
ctx: click.Context
|
|
127
|
+
sim_id: simulation id
|
|
128
|
+
exp_id: experiment id
|
|
129
|
+
Returns:
|
|
130
|
+
None
|
|
131
|
+
"""
|
|
132
|
+
job_dir = ctx.obj['job_directory']
|
|
133
|
+
platform = Platform('FILE', job_directory=job_dir)
|
|
134
|
+
|
|
135
|
+
if sim_id is not None:
|
|
136
|
+
status = platform.get_simulation_status(sim_id)
|
|
137
|
+
elif exp_id is not None:
|
|
138
|
+
exp = platform.get_item(exp_id, ItemType.EXPERIMENT)
|
|
139
|
+
status = exp.status
|
|
140
|
+
else:
|
|
141
|
+
raise Exception('Must provide at least one: exp-id or sim-id!')
|
|
142
|
+
|
|
143
|
+
user_logger.info(status.name if status else None)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@file.command(help="Get simulation's status")
|
|
147
|
+
@click.option('--exp-id', default=None, help="Idmtools Experiment id")
|
|
148
|
+
@click.option('--display/--no-display', default=False, help="Display with working directory or not")
|
|
149
|
+
@click.pass_context
|
|
150
|
+
def status(ctx: click.Context, exp_id, display):
|
|
151
|
+
"""
|
|
152
|
+
Get job status.
|
|
153
|
+
Args:
|
|
154
|
+
ctx: click.Context
|
|
155
|
+
exp_id: experiment id
|
|
156
|
+
display: bool True/False
|
|
157
|
+
Returns:
|
|
158
|
+
None
|
|
159
|
+
"""
|
|
160
|
+
job_dir = ctx.obj['job_directory']
|
|
161
|
+
platform = Platform('FILE', job_directory=job_dir)
|
|
162
|
+
|
|
163
|
+
check_status(platform=platform, exp_id=exp_id, display=display)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@file.command(help="Clear generated files/folders")
|
|
167
|
+
@click.option('--exp-id', default=None, help="Idmtools Experiment id")
|
|
168
|
+
@click.option('--sim-id', multiple=True, help="Idmtools Simulation id")
|
|
169
|
+
@click.option('--remove', multiple=True, help="list of files/folders to be removed from simulation")
|
|
170
|
+
@click.pass_context
|
|
171
|
+
def clear_files(ctx: click.Context, exp_id, sim_id, remove):
|
|
172
|
+
"""
|
|
173
|
+
Clear running history.
|
|
174
|
+
Args:
|
|
175
|
+
ctx: click.Context
|
|
176
|
+
exp_id: experiment id
|
|
177
|
+
sim_id: simulation id
|
|
178
|
+
remove: list of files/folders
|
|
179
|
+
Returns:
|
|
180
|
+
None
|
|
181
|
+
"""
|
|
182
|
+
job_dir = ctx.obj['job_directory']
|
|
183
|
+
platform = Platform('FILE', job_directory=job_dir)
|
|
184
|
+
|
|
185
|
+
clear_history(platform=platform, exp_id=exp_id, sim_id=sim_id, remove_list=remove)
|