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

start_instance set silently to False when using PYMAPDL_IP env var #2910

Closed
germa89 opened this issue Mar 18, 2024 · 1 comment
Closed

start_instance set silently to False when using PYMAPDL_IP env var #2910

germa89 opened this issue Mar 18, 2024 · 1 comment

Comments

@germa89
Copy link
Collaborator

germa89 commented Mar 18, 2024

Current behaviour

If the env var PYMAPDL_IP is set, the start_instance is set to False silently. Because PyMAPDL assumes that if you are using an IP, you are not launching MAPDL, just connecting to a remote instance. If you were going to connect to a local instance, already launched, the natural choice is to set start_instance to False, such as:

mapdl = launch_mapdl(start_instance=False, port=50052) # port is optional

WSL edge case

When working on WSL (MAPDL installed in Windows, and PyMAPDL running on WSL), you can have a bit of a contradicting case, where you need to launch MAPDL in another IP.

from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl(
    exec_file="/mnt/c/Program Files/ANSYS Inc/v231/ANSYS/bin/winx64/ANSYS231.exe",
)

For more info check: https://mapdl.docs.pyansys.com/version/stable/getting_started/wsl.html#launch-mapdl-in-the-windows-host-os

Internally, PyMAPDL sets start_instance equal to

Issues

Clearly, setting the start_instance to False silently is a problem. PyMAPDL should be more explicit.

Options

Option A:

Raise an exception.
If PYMAPDL_IP is used and start_instance=True is passed to launch_mapdl or the env var PYMAPDL_START_INSTANCE is present.

Option B:

Just print a warning, it makes sense if you are using PYMAPDL_IP you want to connect.

Option C:

If you are using start_instance=True is clear you want to start PyMAPDL, forget about the PyMAPDL_IP env var.

Option D:

Dont assume the start instance is False

Collorary

What should the expected output from this code:

mapdl = launch_mapdl(start_instance=True, ip="127.2.0.12")

should it raise an exception? should it connect to the given instance IP?

TL,DR

Which should have priority and override the other arguments?
a) Env vars have the priority
b) The script arguments (i.e. launch_mapdl(start_instance=False))

@germa89
Copy link
Collaborator Author

germa89 commented Mar 18, 2024

While writing this issue I realised what the right behaviour:

Solution

Regarding parameters/env var conflict

If both env vars or arguments are given:

export PYMAPDL_START_INSTANCE=True
export PYMAPDL_IP="123.11.22.33"
python my_script.py

or

mapdl = launch_mapdl(start_instance=True, ip="12.22.33.44")  # and not on WSL

then, PyMAPDL will raise an exception. I think this is a consistent behaviour.

Priority

The priority should be given to the env vars.

This was an stupid question, CICD depends on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant