-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add PyHPS CLI #3091
base: main
Are you sure you want to change the base?
Add PyHPS CLI #3091
Conversation
It works
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3091 +/- ##
==========================================
- Coverage 86.61% 79.74% -6.88%
==========================================
Files 52 54 +2
Lines 9528 10100 +572
==========================================
- Hits 8253 8054 -199
- Misses 1275 2046 +771 |
) | ||
|
||
if config_file is None: | ||
config_file = os.path.join(os.getcwd(), "hps_config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@germa89 should the config be in appdirs
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MMhhh... if we use a file in the root directory, we could point to different files.... and hence multiple configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But maybe you are right... maybe it is better to use appdirs
.... buttt... it might be a bit hidden for the user...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we have many options to be keep in the file:
{
"url": "https://10.231.106.91:3000/hps",
"user": "repuser",
"password": "repuser",
"python": "3.9",
"name": "my job",
"num_cores": 1,
"memory": 100,
"disk_space": 100,
"exclusive": false,
"max_execution_time": 1000
}
keeping so many important options hidden in a appdir
path might bring some complications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@germa89 use keyring for user/password. I don't think its secure enough to put that in plaintext like this. For everything else I would agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
max_execution_time=max_execution_time, | ||
) | ||
|
||
if save_config_file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@germa89 ideally there could be multiple configurations that can be saved so that users can switch between clusters easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can easily change the file path in config_file
to point to other configurations
src/ansys/mapdl/core/hpc/pyhps.py
Outdated
max_execution_time: int = None, | ||
): | ||
|
||
if python not in [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not 3.8+?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean 3.8.X ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, only major and minor needs to be specified in the bash command (python3.12 -m venv...
), hence we do not need to use the "patch" number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@germa89 no, I mean, why bother supporting python < 3.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some hpc clusters have old python versions. So i dont want to limitate the compatibility. But probably, HPS might force you to some python version minimal requirement.
src/ansys/mapdl/core/hpc/pyhps.py
Outdated
requirements_file = create_tmp_file("requirements.txt", content) | ||
logger.debug(f"Requirements file in: {requirements_file}") | ||
|
||
if not shell_file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell file is needed because pyhps doesn't support python jobs with a venv. I think we should see if that feature can be added to pyhps itself. Maybe using pip-run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we need to support venv within pyhps. Using pip-run
seems interesting. For flexibility I would keep an optional shell file though.
requirements_file: str = None, | ||
extra_files: Optional[Union[str, list]] = None, | ||
config_file: str = None, | ||
num_cores: int = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option to download the result files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware if we can do that from the PyHPS library... i will check it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It can be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com>
Adding project url print
(To be merged from top to bottom to main) |
* Adding inputs and outputs * Changing arguments order * Apply suggestions from code review Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> * Update src/ansys/mapdl/core/cli/hpc.py --------- Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com>
* Adding inputs and outputs * Supporting pure APDL jobs * Changing arguments order * Allowing force mode * Apply suggestions from code review Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> --------- Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com>
* Adding inputs and outputs * Supporting pure APDL jobs * Allowing force mode * Initial implementation. Making task object detachable * Apply suggestions from code review Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> * Added job definition bypasser * Adapting CLI * Adding option for output and wait * fixing python and cpu issues * Using dict for taskdefinition Allowing outputs in apdl mode * Adding `close_client` method --------- Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com>
|
||
pymapdl convert input_file.inp -o output_file.out ... | ||
|
||
For more information please visit: https://mapdl.docs.pyansys.com/version/dev/user_guide/cli.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more information please visit: https://mapdl.docs.pyansys.com/version/dev/user_guide/cli.html | |
For more information, see `PyMAPDL command line interface <https://mapdl.docs.pyansys.com/version/dev/user_guide/cli.html>`_. |
Is there a reason, you don't use a :ref: role for a link?
help="""URL where the HPS cluster is deployed. For example: "https://myserver:3000/hps" """, | ||
) | ||
@click.option( | ||
"--user", default=None, type=str, help="Username to login into the HPC cluster." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"--user", default=None, type=str, help="Username to login into the HPC cluster." | |
"--user", default=None, type=str, help="Username for logging into the HPC cluster." |
Input arguments for the simulation. You can specify several arguments by | ||
joining them with commas. Thus, strings defined in this way cannot contain | ||
commas. Only integers, floats and strings are allowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input arguments for the simulation. You can specify several arguments by | |
joining them with commas. Thus, strings defined in this way cannot contain | |
commas. Only integers, floats and strings are allowed. | |
Input arguments for the simulation. Because you can specify several arguments by | |
joining them with commas, strings defined in this way cannot contain | |
commas. Only integers, floats, and strings are allowed. |
help="""Output files to monitor. Because you use commas to separate | ||
the file names, the names cannot contain commas. For example, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="""Output files to monitor. Because you use commas to separate | |
the file names, the names cannot contain commas. For example, | |
help="""Output files to monitor. Because you use commas to separate | |
filenames, the names cannot contain commas. For example, |
help="""Optional created virtual environment to install with the | ||
libraries specified in this requirements file. If not, the activated virtual environment is | ||
cloned through a temporary ``pip list`` file. If you are using an editable package, | ||
you should attach your own requirement file using ``pip freeze`` """, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should attach your own requirement file using ``pip freeze`` """, | |
you should attach your own requirement file using ``pip freeze``.""", |
type=str, | ||
is_flag=False, | ||
flag_value=True, | ||
help="""Print the output values to the terminal as json. It requires to use ``--wait`` value too. """, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this: It requires to use --wait
value too.
type=bool, | ||
is_flag=False, | ||
flag_value=True, | ||
help="""Whether PyMAPDL is to print debug logging to the console output.""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="""Whether PyMAPDL is to print debug logging to the console output.""", | |
help="""Whether PyMAPDL is to print debug logging to the console.""", |
It doesn't seem output is needed.
} | ||
|
||
logger.debug( | ||
f"Saving the following configuration to the config file ({config_file}):\n{config}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"Saving the following configuration to the config file ({config_file}):\n{config}" | |
f"Saving the following configuration to the config file ({config_file}):\n{config}." |
proj = job.project | ||
if not output_to_json: | ||
print( | ||
f"You can check your project by visiting: {url}/projects#/projects/{proj.id}/jobs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messages should conclude with punctuation, but I don't enforce this when a colon is used to provide a URL or filename
As the title.
The idea is you can have:
$ pymapdl submit main_file.py $ pymapdl submit --name="my project" main_file.py --requirements_file=requirements.txt
The help shows: