-
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
Supporting SLURM env vars for launching MAPDL configuration #2754
base: main
Are you sure you want to change the base?
Conversation
Adding memory option
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
for more information, see https://pre-commit.ci
…sys/pymapdl into feat/supporting-slurm-manager
Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>
cc @greschd . This might be related to your interest in launcher configuration |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2754 +/- ##
==========================================
- Coverage 86.64% 84.07% -2.57%
==========================================
Files 52 52
Lines 9553 9632 +79
==========================================
- Hits 8277 8098 -179
- Misses 1276 1534 +258 |
@@ -1165,10 +1165,13 @@ These are described in the following table: | |||
| | export PYMAPDL_MAPDL_VERSION=22.2 | | |||
| | | | |||
+---------------------------------------+---------------------------------------------------------------------+ | |||
| :envvar:`PYMAPDL_ON_SLURM` | With this environment variable set to ``FALSE``, you can avoid | | |||
| | PyMAPDL to detect that it is running on a SLURM 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.
| | PyMAPDL to detect that it is running on a SLURM HPC cluster. | | |
| | PyMAPDL from detecting that it is running on a SLURM HPC cluster. | |
Sorry for messing up your table formatting with this needed correction!
| | PRNSOL or NLIST, raise this. In bytes, | | ||
| | defaults to 256 MB. | |
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.
| | PRNSOL or NLIST, raise this. In bytes, | | |
| | defaults to 256 MB. | | |
| | PRNSOL or NLIST, raise this. The default message | | |
| | length in bytes is 256 MB. | |
@@ -1165,10 +1165,13 @@ These are described in the following table: | |||
| | export PYMAPDL_MAPDL_VERSION=22.2 | | |||
| | | | |||
+---------------------------------------+---------------------------------------------------------------------+ | |||
| :envvar:`PYMAPDL_ON_SLURM` | With this environment variable set to ``FALSE``, you can avoid | | |||
| | PyMAPDL to detect that it is running on a SLURM HPC cluster. | | |||
+---------------------------------------+---------------------------------------------------------------------+ | |||
| :envvar:`PYMAPDL_MAX_MESSAGE_LENGTH` | Maximum gRPC message length. If your | | |||
| | connection terminates when running | | |||
| | PRNSOL or NLIST, raise this. In bytes, | | |||
| | defaults to 256 MB. | | |||
| | | | |||
| | Only for developing purposes. | |
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.
This should be a complete sentence.
# Unless the env var is false, it will be true. | ||
ON_SLURM = not (ON_SLURM.lower() == "false") | ||
|
||
# Let's require the following env vars to exists to go into slurm mode. |
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.
# Let's require the following env vars to exists to go into slurm mode. | |
# Let's require the following env vars to exist to go into slurm mode. |
ON_SLURM = True # Using this as main variable | ||
else: | ||
ON_SLURM = False | ||
|
||
if remove_temp_files is not None: | ||
warnings.warn( | ||
"The option ``remove_temp_files`` is being deprecated and it will be removed by PyMAPDL version 0.66.0.\n" |
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.
"The option ``remove_temp_files`` is being deprecated and it will be removed by PyMAPDL version 0.66.0.\n" | |
"The ``remove_temp_files`` option is being deprecated. It is to be removed in PyMAPDL version 0.66.0.\n" |
I'm not sure if you were trying to avoid being specific by saying "by PyMAPDL version 0.66.0" because it could be before then? Perhaps "It is to be removed sometime before PyMAPDL version 0.66.0."
raise NotEnoughResources | ||
if machine_cores < int(nproc): | ||
raise NotEnoughResources( | ||
f"The machine has {machine_cores} cores and PyMAPDL is asking for {nproc} cores." |
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"The machine has {machine_cores} cores and PyMAPDL is asking for {nproc} cores." | |
f"The machine has {machine_cores} cores. PyMAPDL is asking for {nproc} cores." |
|
||
except Exception as e: | ||
LOG.info( | ||
f"The machines list could not be obtained.\nFollowing error happened:\n{str(e)}" |
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"The machines list could not be obtained.\nFollowing error happened:\n{str(e)}" | |
f"The machines list could not be obtained.\nThis error occurred:\n{str(e)}" |
@@ -455,6 +455,31 @@ def run_before_and_after_tests_2(request, mapdl): | |||
assert prev == mapdl.is_local | |||
|
|||
|
|||
@pytest.fixture(scope="function") | |||
def set_env_var(request, monkeypatch): | |||
"""Set an environment variable from given requests, this fixture must be used with `parametrize`""" |
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.
"""Set an environment variable from given requests, this fixture must be used with `parametrize`""" | |
"""Set an environment variable from given requests. This fixture must be used with ``parametrize``.""" |
|
||
@pytest.fixture(scope="function") | ||
def set_env_var_context(request, monkeypatch): | ||
"""Set MY_VARIABLE environment variable, this fixture must be used with `parametrize`""" |
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.
"""Set MY_VARIABLE environment variable, this fixture must be used with `parametrize`""" | |
"""Set ``MY_VARIABLE`` environment variable. This fixture must be used with ``parametrize``.""" |
id="Testing NPROCS only", | ||
), | ||
pytest.param( | ||
# This test does not do probably a good memory mapping between |
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.
# This test does not do probably a good memory mapping between | |
# This test probably does not do a good memory mapping between |
As the title.
The idea is that on SLURM HPC clusters, PyMAPDL will read the SLURM job through the env vars that the SLURM manager creates, so it can launch MAPDL with the appropriate number of cores.
You can see in the code:
which is the way I use to decide how many cores should MAPDL instance use.
Same with memory:
I do not use the MAPDL
-machines
argument to specify the machines used. I don't think it is needed/compatible.