Skip to main content

A Python wrapper for Ansys platform instancemanagement

Project description

PyAnsys PyPI Code Coverage GitHub Workflow Status (branch) MIT License black

PyPIM exposes a Pythonic interface to communicate with the Product Instance Management (PIM) API.

What is the PIM API?

The PIM API is a gRPC API enabling library and application developers to start a product in a remote environment and communicate with its API.

The PIM API is intended to be as simple as possible to be adaptable in a variety of network and software infrastructures. Using this API does not require any knowledge of its infrastructure. You need only know which product to start and which API the product exposes. The PIM API itself exposes very few features and assumes that all the configuration is set on a server.

The PIM API is not intended to manage stateless services, to be a job management system, or a fully featured service orchestration API. Its purpose is to expose a minimum feature set for managing service-oriented applications.

Getting Started

To use PyPIM, you must have access to the PIM API.

PyPIM itself is pure Python and relies on gRPC.

Installation

The ansys-platform-instancemanagement package is tested for Python 3.7 through Python 3.10 on Windows and Linux.

pip install ansys-platform-instancemanagement

Configuration

By default, PyPIM is configured externally instead of via code. Anywhere in the local storage, create a configuration file with the following format:

{
    "version": 1,
    "pim": {
        "uri": "dns:pim.svc.com:80",
        "headers": {
            "metadata-info": "value"
        },
        "tls": false
    }
}

Then, define the environment variable ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG to point to this file.

Usage

PyPIM is a single module called ansys.platform.instancemanagement, shortened to pypim.

To start MAPDL and communicate with PyPIM:

import ansys.platform.instancemanagement as pypim
from ansys.mapdl.core import Mapdl

if pypim.is_configured():
    with pypim.connect() as pim:
        with pim.create_instance(product_name="mapdl", product_version="221") as instance:
            instance.wait_for_ready()
            channel = instance.build_grpc_channel(options=[("grpc.max_receive_message_length", 8*1024**2)])
            mapdl = Mapdl(channel=channel)
            mapdl.prep7()
            ...

You can also use PyPIM without the with statement:

import ansys.platform.instancemanagement as pypim
from ansys.mapdl.core import Mapdl

if pypim.is_configured():
    pim = pypim.connect()
    instance = pim.create_instance(product_name="mapdl", product_version="221")
    channel = instance.build_grpc_channel(options=[("grpc.max_receive_message_length", 8*1024**2)])
    mapdl = Mapdl(channel=channel)
    mapdl.prep7()
    ...
    instance.delete()
    pim.close()

Integration

PyPIM can be integrated in PyAnsys libraries to transparently switch to a remote instance in a suitable environment. This process is described in the integration topic.

For example, starting MAPDL with PyPIM is as simple as:

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()

PyPIM is integrated in the following libraries:

Library

Product Name

Version Scheme

PyMAPDL

mapdl

Unified 3 digits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansys-platform-instancemanagement-1.0.2.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file ansys-platform-instancemanagement-1.0.2.tar.gz.

File metadata

File hashes

Hashes for ansys-platform-instancemanagement-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cc6e0a60ba93b53b6d885b94843cf9d01a6d5d75689b768a4244de4405843cd5
MD5 fc57dc1d243dd7cb56f5d8bef207c4a4
BLAKE2b-256 9fe876c35f23c4b567ca14cbdc3aa6d57f49a2b1b5d9ccfead68c9034dee8de1

See more details on using hashes here.

File details

Details for the file ansys_platform_instancemanagement-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ansys_platform_instancemanagement-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 639317f588fa2d62d2718ae2804efa311f7aac7b5a041a9ae64a1dd559aae2ba
MD5 88943e4c32f659eb91cfef3889a168a7
BLAKE2b-256 edf1639a0b1b208e3185ff3af5f44a9d67ad2b0a7e56f18664a16345e08f3ddb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page