ansys / pymapdl

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

Can not use arbitrary string for the version parameter when creating remote server with PIM #2506

Closed jerome-blanche closed 9 months ago

jerome-blanche commented 9 months ago

🤓 Before submitting the issue

🔍 Description of the bug

Any string should be allowed for the version parameter (e.g. "latest") when launching a MADPL server on Ansys Lab, with PIM. Bug can be reproduced in the Seattle project @germa89

Traceback:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [1], in <cell line: 6>()
      3 from ansys.mapdl.core import launch_mapdl
      5 # start mapdl
----> 6 mapdl = launch_mapdl(version="latest")

File /opt/conda/lib/python3.9/site-packages/ansys/mapdl/core/launcher.py:1408, in launch_mapdl(exec_file, run_location, jobname, nproc, ram, mode, override, loglevel, additional_switches, start_timeout, port, cleanup_on_exit, start_instance, ip, clear_on_connect, log_apdl, remove_temp_files, remove_temp_dir_on_exit, verbose_mapdl, license_server_check, license_type, print_com, add_env_vars, replace_env_vars, version, **kwargs)
   1405 if version is None:
   1406     version = os.getenv("PYMAPDL_MAPDL_VERSION", None)
-> 1408 version = _verify_version(version)  # return a int version or none
   1410 # Start MAPDL with PyPIM if the environment is configured for it
   1411 # and the user did not pass a directive on how to launch it.
   1412 if _HAS_PIM and exec_file is None and pypim.is_configured():

File /opt/conda/lib/python3.9/site-packages/ansys/mapdl/core/launcher.py:1850, in _verify_version(version)
   1843         version = [
   1844             key
   1845             for key, value in SUPPORTED_ANSYS_VERSIONS.items()
   1846             if value == version.upper().strip()
   1847         ][0]
   1849 if version is not None and version not in SUPPORTED_ANSYS_VERSIONS.keys():
-> 1850     raise ValueError(
   1851         f"MAPDL version must be one of the following: {list(SUPPORTED_ANSYS_VERSIONS.keys())}"
   1852     )
   1854 return version

ValueError: MAPDL version must be one of the following: [232, 231, 222, 221, 212, 211, 202, 201, 195, 194, 193, 192, 191]

🕵️ Steps To Reproduce

ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(version="latest")

💻 Which Operating System are you using?

Linux

🐍 Which Python version are you using?

3.9

📝 PyMAPDL Report

Show the Report! ```text PyMAPDL Software and Environment Report Packages Requirements ********************* Core packages ------------- ansys.mapdl.core : 0.67.0 numpy : 1.26.1 platformdirs : 3.10.0 scipy : 1.8.0 grpc : Package not found ansys.api.mapdl.v0 : Package not found ansys.mapdl.reader : 0.52.20 google.protobuf : Package not found pexpect : 4.8.0 Optional packages ----------------- matplotlib : 3.8.0 pyvista : 0.41.0 pyiges : 0.3.1 tqdm : 4.63.0 Ansys Installation ****************** Unable to locate any Ansys installations Ansys Environment Variables *************************** ANSYS_LAB_RELEASE_TYPE internal ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG /home/jovyan/.pypim.json ```

📝 Installed packages

Show the installed packages! ```text aiohttp==3.8.6 aiosignal==1.3.1 alabaster==0.7.13 alembic @ file:///home/conda/feedstock_root/build_artifacts/alembic_1647367721563/work ans.protocol.amk==0.1.0b8 ansys-additive-core==0.14.1 ansys-api-additive==1.3.0 ansys-api-assembly==0.2.15 ansys-api-fluent==0.3.5 ansys-api-geometry==0.2.9 ansys-api-mapdl==0.5.1 ansys-api-meshing-prime==0.1.1 ansys-api-platform-instancemanagement==1.0.0b3 ansys-api-pyensight==0.3.2 ansys-dpf-core==0.7.4 ansys-dpf-gate==0.3.1 ansys-dpf-gatebin==0.3.1 ansys-dpf-post==0.2.3 ansys-fluent-core==0.12.dev5 ansys-fluent-parametric==0.6.dev0 ansys-fluent-visualization==0.6.dev3 ansys-geometry-core==0.2.7 ansys-grpc-dpf==0.7.1 ansys-lab==0.1.64 ansys-mapdl-core==0.67.0 ansys-mapdl-reader==0.52.20 ansys-materials-manager==0.2.3 ansys-math-core==0.1.3 ansys-meshing-prime==0.4.1 ansys-nexus==0.1.0 ansys-observability==0.2.3 ansys-onscale-core==0.5.2 ansys-platform-instancemanagement==1.1.1 ansys-pyassembly==0.6.0 ansys-pyensight-core==0.6.2 ansys-simbuilder-core==2.52.0 ansys-tools-path==0.3.2 anyio @ file:///home/conda/feedstock_root/build_artifacts/anyio_1641898043316/work/dist appdirs==1.4.4 argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1640817743617/work argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1649500321618/work asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1618968359944/work async-generator==1.10 async-timeout==4.0.3 attrs==23.1.0 autobahn==22.2.2 Automat==20.2.0 Babel==2.9.1 backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work backoff==1.10.0 backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work beartype==0.14.0 beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1649463573192/work bleach==4.1.0 blinker==1.4 bokeh==3.2.2 boto3==1.28.18 botocore==1.31.18 brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1648854164373/work cachetools==5.0.0 cadquery==2.2.0b1 cadquery-ocp==7.5.3.0 Cartopy==0.22.0 casadi==3.5.5 certifi==2021.10.8 certipy==0.1.3 cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1636046055389/work charset-normalizer==3.3.1 click==8.1.3 clr-loader==0.2.3 colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1602866480661/work commonmark==0.9.1 conda==4.12.0 conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1649385069444/work constantly==15.1.0 contourpy==1.1.1 cryptography==36.0.1 cycler==0.12.1 debugpy==1.5.1 decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work Deprecated==1.2.13 dill==0.3.7 distro==1.8.0 docutils==0.18.1 dotnetcore2==3.1.23 ecdsa==0.18.0 entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1646044401614/work ezdxf==0.18.1 fastjsonschema @ file:///home/conda/feedstock_root/build_artifacts/python-fastjsonschema_1641751198313/work/dist flatbuffers==23.5.26 flit_core @ file:///home/conda/feedstock_root/build_artifacts/flit-core_1645629044586/work/source/flit_core fonttools==4.43.1 frozenlist==1.4.0 geomdl==5.3.1 gitdb==4.0.9 GitPython==3.1.27 gmsh==4.10.5 google-api-core==2.6.0 google-api-python-client==2.39.0 google-auth==2.6.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.53.0 greenlet @ file:///home/conda/feedstock_root/build_artifacts/greenlet_1648882382645/work grpc-interceptor==0.15.0 grpcio==1.50.0 grpcio-health-checking==1.48.2 h5py==3.7.0 httplib2==0.20.4 hyperlink==21.0.0 idna==3.4 imagesize==1.4.1 importlib-metadata==6.5.0 importlib-resources==6.1.0 incremental==21.3.0 ipycanvas==0.10.2 ipydatawidgets==4.2.0 ipyevents==2.0.1 ipykernel==6.9.1 ipython==8.1.1 ipython-genutils==0.2.0 ipyvtklink==0.2.2 ipywidgets==7.6.5 jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1649067096717/work Jinja2==3.0.3 jmespath==1.0.1 json5==0.9.6 jsonschema==4.4.0 jupyter-ansys-commands==0.1.68 jupyter-ansys-docmanager==0.1.2 jupyter-client==7.1.2 jupyter-core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1645024267147/work jupyter-server @ file:///home/conda/feedstock_root/build_artifacts/jupyter_server_1651092495905/work jupyter-server-mathjax==0.2.5 jupyter-server-proxy==3.2.2 jupyter-telemetry @ file:///home/conda/feedstock_root/build_artifacts/jupyter_telemetry_1605173804246/work jupyterhub @ file:///home/conda/feedstock_root/build_artifacts/jupyterhub-feedstock_1651846799684/work jupyterlab @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_1651606994235/work jupyterlab-ansys-theme==0.1.5 jupyterlab-git==0.36.0 jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-topbar==0.6.1 jupyterlab-widgets==1.0.2 kiwisolver==1.4.5 libmambapy @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1652294196376/work/libmambapy linkify-it-py==2.0.2 lxml==4.9.1 Mako @ file:///home/conda/feedstock_root/build_artifacts/mako_1649097013621/work mamba @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1652294196376/work/mamba Markdown==3.4.1 markdown-it-py==3.0.0 MarkupSafe==2.1.0 matplotlib==3.8.0 matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1631080358261/work mdit-py-plugins==0.4.0 mdurl==0.1.2 meshio==5.3.4 mistune @ file:///home/conda/feedstock_root/build_artifacts/mistune_1635844679781/work multidict==6.0.4 multimethod==1.9 nbclassic==0.5.1 nbclient==0.5.11 nbconvert==6.5.3 nbdime==3.1.1 nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1651607001005/work nest-asyncio==1.5.4 networkx==2.8 nlopt==2.7.1 notebook==6.4.8 notebook-shim @ file:///home/conda/feedstock_root/build_artifacts/notebook-shim_1646330736330/work nptyping==2.0.1 numpy==1.26.1 oauthlib @ file:///home/conda/feedstock_root/build_artifacts/oauthlib_1643507977997/work opentelemetry-api==1.12.0 opentelemetry-exporter-otlp-proto-grpc==1.12.0 opentelemetry-proto==1.12.0 opentelemetry-sdk==1.12.0 opentelemetry-semantic-conventions==0.33b0 packaging==23.2 pamela==1.0.0 pandas==1.5.3 pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work panel==1.2.3 param==1.12.2 parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work path==16.4.0 pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work Pillow==10.1.0 Pint==0.21 platformdirs==3.10.0 plotly==5.17.0 plumbum==1.7.2 pooch==1.6.0 prettytable==3.9.0 prometheus-client==0.13.1 prompt-toolkit==3.0.28 protobuf==3.20.3 protoc-gen-swagger==0.1.0 psutil==5.9.5 ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work pyaedt==0.6.53 pyansys-docker==5.0.4 pyansys-tools-versioning==0.3.3 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1649384802055/work pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work pycryptodome==3.18.0 pycurl==7.45.1 pydantic==1.10.2 PyGithub==1.58.1 Pygments==2.14.0 pyiges==0.3.1 PyJWT==2.6.0 PyNaCl==1.5.0 pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work pyparsing==3.1.1 pyproj==3.6.1 PyQt5==5.15.6 PyQt5-Qt5==5.15.2 PyQt5-sip==12.10.1 pyrsistent @ file:///home/conda/feedstock_root/build_artifacts/pyrsistent_1649013355209/work pyshp==2.3.1 PySide6==6.2.3 PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1648857263093/work python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work python-jose==3.3.0 python-json-logger @ file:///home/conda/feedstock_root/build_artifacts/python-json-logger_1602545356084/work pythonnet==3.0.1 pythreejs==2.3.0 pytz==2021.3 pyvista==0.41.0 pyvistaqt==0.7.0 pyviz-comms==2.2.1 PyYAML==6.0 pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1649055645150/work QtPy==2.1.0 requests==2.28.2 requests-toolbelt==1.0.0 rich==12.6.0 rpyc==5.3.1 rsa==4.8 ruamel-yaml-conda @ file:///home/conda/feedstock_root/build_artifacts/ruamel_yaml_1636009144459/work ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1649033202141/work ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1649013070954/work rustworkx==0.12.0 s3transfer==0.6.1 scikit-rf==0.25.0 scipy==1.8.0 scooby==0.5.12 semver==3.0.1 Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1628511208346/work shapely==2.0.1 shiboken6==6.2.3 simpervisor==0.4 simple-upload-server-client==0.0.1 six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work smmap==5.0.0 sniffio @ file:///home/conda/feedstock_root/build_artifacts/sniffio_1648819188507/work snowballstemmer==2.2.0 soupsieve==2.3.2.post1 Sphinx==6.2.1 sphinx-rtd-theme==1.2.2 sphinxcontrib-applehelp==1.0.4 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jquery==4.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 SQLAlchemy @ file:///home/conda/feedstock_root/build_artifacts/sqlalchemy_1651017976253/work stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1644872665635/work tenacity==8.0.1 terminado==0.13.2 tinycss2 @ file:///home/conda/feedstock_root/build_artifacts/tinycss2_1637612658783/work tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1648827245914/work tqdm==4.63.0 traitlets==5.1.1 traittypes==0.2.1 trame==3.2.8 trame-client==2.12.6 trame-server==2.12.0 trame-vtk==2.5.9 trame-vuetify==2.3.1 Twisted==22.2.0 txaio==22.2.1 typing==3.7.4.3 typing_extensions==4.7.1 typish==1.9.3 uc-micro-py==1.0.2 uritemplate==4.1.1 urllib3==1.26.8 vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-osmesa-9.1.0-cp39-cp39-linux_x86_64.whl wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work webencodings==0.5.1 websocket-client==1.3.1 websockets==11.0.3 widgetsnbextension==3.5.2 wrapt==1.13.3 wslink==1.12.4 xyzservices==2023.7.0 yarl==1.9.2 zipp==3.17.0 zope.interface==5.4.0 ```

📝 Logger output file

Show the logger output file. ```text # PASTE HERE THE CONTENT OF THE LOGGER OUTPUT FILE. ```
jerome-blanche commented 9 months ago

The list_definitions method of the pim client can be used to retrieve the list of versions that the PIM server supports. possible_versions = [ definition.product_version for definition in pim_client.list_definitions(product_name="mapdl") ]

germa89 commented 9 months ago

I would say... that if version='latest' and using PIM, I would just pass latest to the PIM client.

If not using PIM, PyMAPDL should use latest which is the default... hence we should probably discard that argument.

jerome-blanche commented 9 months ago

I would say... that if version='latest' and using PIM, I would just pass latest to the PIM client.

If not using PIM, PyMAPDL should use latest which is the default... hence we should probably discard that argument.

"latest" is only an example of which arbitrary string can be passed as the version. It can be anything else, like "232-40cpus" or "231-large" or ...
As the list of possible values for the versions can be retrieved from PIM, I would validate the version that the user wants to use against this list @germa89

germa89 commented 9 months ago

mmhhh... I see.

Well... locally we are not really interested in having versions different than MAPDL versions. The whole concept of version argument is about MAPDL versions, not system configurations like you seems to imply. And I don't think a "system configuration" argument makes sense in PyMAPDL.

However, I do understand your need. So far, in #2515 I'm moving the version check to be done after the PIM launcher. So you could pass any string to the PIM client (you might want to sanitize that on your side).

Ideally we should have a totally different argument for system configuration (aka 231-large, etc). Let me know if you need that and I can implement it. We should discuss then the name of the argument.