Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring PyHPS implementation #3117

Merged
merged 13 commits into from
May 31, 2024
40 changes: 36 additions & 4 deletions src/ansys/mapdl/core/cli/hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@

@main.command(
short_help="Submit jobs to an HPC cluster using PyHPS.",
help="""Submit jobs to an HPC cluster using PyHPS.
help="""
Submit jobs to an HPC cluster using PyHPS.


Example
-------

$ pymapdl submit my_file_01.py --requirements_file=requirements.txt --shell_file=main.sh --name="my job" --url="https://123.456.789.101:3000/hps" --user=user --password=password --python=3.9
$ pymapdl submit my_file_01.py --requirements_file=requirements.txt --shell_file=main.sh --name="my job" --user=user --password=password --url="https://123.456.789.101:3000/hps"
""",
)
@click.argument("main_file")
Expand Down Expand Up @@ -72,11 +73,26 @@
help="""Python version to use to create the virtual environment and
run the Python file. Python3 is used by default in the cluster.""",
)
@click.option(
"--inputs",
default=None,
type=str,
help="""
Input arguments for the simulation. You can specify several arguments by joining them with commas, therefore, strings defined this way cannot contain commas.
PyMAPDL will try to convert, whenever possible, these inputs to ints or floats, otherwise, they remind as strings. These arguments can be changed in the HPS website. For example: --inputs="force=123,value='mystring'"
""",
)
@click.option(
"--outputs",
default=None,
type=str,
help="""Output parameters. You can specify several arguments by joining them with commas. For example: --outputs="displacements,nodes".""",
)
@click.option(
"--output_files",
default=None,
type=str,
help="""Output files to monitor.""",
help="""Output files to monitor. They can be specified as comma separated file names (so their names cannot contain commas). For example: --output_files="results.out,data.xls". """,
)
@click.option(
"--shell_file",
Expand Down Expand Up @@ -158,6 +174,16 @@
submitting the job. The default is ``False``. If ``True``, the configuration file is overwritten.
You use the ``config_file`` argument to give the path for the configuration file.""",
)
@click.option(
"--mode",
default=None,
type=str,
help="""
Force the job submission to behave as if the main file was a python,
shell or APDL file, regardless of its extension type. Allowed values are: "python", "shell", and "apdl".
By default, PyMAPDL detects the type of file from its extension.
""",
)
@click.option(
"--debug",
default=False,
Expand All @@ -173,6 +199,8 @@ def submit(
user: str = None,
password: str = None,
python: Optional[float] = None,
inputs: Optional[str] = None,
outputs: Optional[str] = None,
output_files: Optional[Union[str, list]] = None,
shell_file: str = None,
requirements_file: str = None,
Expand All @@ -186,6 +214,7 @@ def submit(
wait: bool = False,
save_config_file: bool = False,
debug: bool = False,
mode: Optional[Union["python", "shell", "apdl"]] = None,
):
import json

Expand Down Expand Up @@ -229,6 +258,8 @@ def submit(
user=user,
password=password,
python=python,
inputs=inputs,
outputs=outputs,
output_files=output_files,
shell_file=shell_file,
requirements_file=requirements_file,
Expand All @@ -239,6 +270,7 @@ def submit(
disk_space=disk_space,
exclusive=exclusive,
max_execution_time=max_execution_time,
mode=mode,
)

if save_config_file:
Expand Down
Loading
Loading