Ansys Platform Instance Management (PyPIM)

1.1.2 · active · verified Thu Apr 16

PyPIM (ansys-platform-instancemanagement) is a Python wrapper that provides a Pythonic interface to communicate with the Ansys Product Instance Management (PIM) API. This library enables users to programmatically start Ansys products in remote environments and interact with their APIs. It's designed to simplify the management of service-oriented applications within the Ansys ecosystem. The library is currently at version 1.1.2 and maintains an active release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to connect to the Ansys PIM API using PyPIM. A crucial step is configuring the environment externally via a JSON file and the `ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG` environment variable, as PyPIM is not self-configuring. The example includes checking if the environment is configured and establishing a connection.

import ansys.platform.instancemanagement as pypim
import os

# --- IMPORTANT: External configuration is required ---
# Create a JSON config file (e.g., 'pypim_config.json'):
# {
#   "version": 1,
#   "pim": {
#     "uri": "dns:pim.svc.com:80", # Replace with your PIM API URI
#     "headers": {"metadata-info": "value"}, # Optional headers
#     "tls": false # Set to true if using TLS
#   }
# }
# Set environment variable pointing to this file:
# export ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG="/path/to/pypim_config.json"
# os.environ['ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG'] = '/path/to/pypim_config.json' # For in-code setting

# Ensure the environment is configured before connecting
if pypim.is_configured():
    try:
        with pypim.connect() as client:
            print("Successfully connected to PyPIM.")
            # Example: Create an instance (requires compatible PyAnsys product library)
            # with client.create_instance(product_name="mapdl", product_version="221") as instance:
            #     instance.wait_for_ready()
            #     print(f"MAPDL instance started with URI: {instance.uri}")
    except pypim.errors.NotConfiguredError:
        print("PyPIM environment not configured. Please set ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG.")
    except Exception as e:
        print(f"An error occurred: {e}")
else:
    print("PyPIM is not configured. Please set the ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG environment variable.")

view raw JSON →