ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
423 stars 120 forks source link

Better way to handle licensing errors #1686

Closed Gillaugh closed 1 year ago

Gillaugh commented 1 year ago

Description of the feature

There needs to be a better way of handling licensing errors when launching mapdl using launch_mapdl().

For example, when running launch_mapdl() with -mpi INTELMPI, it looks like the licensing arguments were swallowed. Here is the traceback:

  Input In [6] in <cell line: 1>
    mapdl = launch_mapdl(additional_switches='-mpi INTELMPI -p mech_1')

  File ~\anaconda3\lib\site-packages\ansys\mapdl\core\launcher.py:1655 in launch_mapdl
    lic_check.check()

  File ~\anaconda3\lib\site-packages\ansys\mapdl\core\licensing.py:452 in check
    raise LicenseServerConnectionError("\n".join(self._license_file_msg))

LicenseServerConnectionError: 2022/12/12 14:29:48    DENIED              mech_1                          22.1 (2021.1108)             1/0/0/0                 1/1/1/1   17260:FEAT_ANSYS:GillaughD@B018L10033128:winx64            6908:192.168.4.22   
        Insufficient Ansys Mechanical Pro licenses available.
        Licensed number of users already reached.
        Feature:       mech_1
        License path:  1055@B018L10033128;
        FlexNet Licensing error:-4,132

2022/12/12 14:29:48    DENIED              FEAT_MECH_1                     22.1 (2021.1108)             1/0/0/0                 1/1/1/1   17260:FEAT_ANSYS:GillaughD@B018L10033128:winx64            6908:192.168.4.22   
        Failover feature 'Ansys Mechanical Pro' is not available.
        Insufficient Ansys Mechanical Pro licenses available.
        Licensed number of users already reached.
        Feature:       mech_1
        License path:  1055@B018L10033128;
        FlexNet Licensing error:-4,132
2022/12/12 14:29:48    CLIENT_EXIT                                                                                              0/1/1/1   17260:FEAT_ANSYS:GillaughD@B018L10033128:winx64            6908:192.168.4.22

Steps for implementing the feature

Someone programs it.

Useful links and references

No response

germa89 commented 1 year ago

Hi @Gillaugh

I'm not sure I get the error here. You are using -p mech_1 which is the one which is shown in the traceback.

Could you specify a bit more what do you expect/would like to see?

mikerife commented 1 year ago

Hi @Gillaugh Like @germa89 I too am wondering what you would like the behavior to be as what is shown is standard MAPDL behavior, even not using PyMAPDL.

There is a native launch_mapdl() option "license_type" that you could use instead of the "-p" additional command line flag. If neither are used then the license server should cycle through the list of available licenses for checkout. If you only have one increment of one type of license then this would not be very useful...otherwise might be an option to try.

Mike

Gillaugh commented 1 year ago

Thanks for the comments. When using launch_mapdl() or launch_mapdl(additional_switches='-p mech_1'), I get the above error message. I only have a single license of ANSYS on this PC, and i think a potential error could be a license manager issue.

The only way that I am able to use launch_mapdl() successfully is by manually opening the ANSYS Product Launcher, going into Customization/Preferences, using -grpc under additional parameters and running. Once I run this launcher, than launch_mapdl(additional_switches='-p mech_1') runs successfully within python.

germa89 commented 1 year ago

@Gillaugh

It seems to me a license issue. What type of license do you have? You can check that by going to the Ansys License Manager app, Reporting > View current license usage. You can look for mechanical there:

image

Also

Once I run this launcher, than launch_mapdl(additional_switches='-p mech_1') runs successfully within python.

Actually you could avoid the additional switch because the instance is already running.

germa89 commented 1 year ago

Closing issue. Feel free to reopen if you want to add something more.