Skip to content

Making PIM package lazy #1151

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

Merged
merged 4 commits into from
May 31, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
import time
import warnings

import ansys.platform.instancemanagement as pypim
try:
import ansys.platform.instancemanagement as pypim

_HAS_PIM = True
except ModuleNotFoundError:
_HAS_PIM = False

import appdirs

from ansys.mapdl import core as pymapdl
Expand Down Expand Up @@ -547,6 +553,11 @@ def launch_remote_mapdl(
ansys.mapdl.core.mapdl._MapdlCore
An instance of Mapdl.
"""
if not _HAS_PIM:
raise ModuleNotFoundError(
"The package 'ansys-platform-instancemanagement' is required to use this function."
)

pim = pypim.connect()
instance = pim.create_instance(product_name="mapdl", product_version=version)
instance.wait_for_ready()
Expand Down Expand Up @@ -1249,7 +1260,7 @@ def launch_mapdl(

# Start MAPDL with PyPIM if the environment is configured for it
# and the user did not pass a directive on how to launch it.
if pypim.is_configured() and exec_file is None:
if _HAS_PIM and exec_file is None and pypim.is_configured():
LOG.info("Starting MAPDL remotely. The startup configuration will be ignored.")
return launch_remote_mapdl(cleanup_on_exit=cleanup_on_exit)

Expand Down