User guide#

Migrate from AsyncJobs#

The import and export tools in PyGranta JobQueue were previously available in the Granta MI Scripting Toolkit AsyncJobs submodule, which this documentation refers to as AsyncJobs. As of the Granta MI 2024 R2 release, however, these import and export tools are available only in PyGranta JobQueue.

In addition to providing a summary of the differences between AsyncJobs and PyGranta JobQueue, this section shows how to modify your existing AsyncJobs scripts to work in PyGranta JobQueue.

Note

Because PyGranta JobQueue is PEP 561-compliant, you can use Mypy or most modern Python IDEs to statically validate AsyncJobs scripts against PyGranta JobQueue. This highlights issues without needing to run the code.

Connect to Granta MI#

AsyncJobs relied on an existing Granta MI Scripting Toolkit connection to connect to the job queue. PyGranta JobQueue uses the PyGranta approach to creating a client.

Your existing AsyncJobs code looks like this:

from GRANTA_MIScriptingToolkit import granta as mpy

mi = mpy.connect('http://my_grantami_server/mi_servicelayer', autologon=True)
job_queue = mi.get_async_job_queue()

Replace the preceding code with this code:

from ansys.grantami.jobqueue import Connection

server_url = "http://my_grantami_server/mi_servicelayer"
client = Connection(server_url).with_autologon().connect()

For information on how to connect to Granta MI using other authentication methods, see Granta MI connection in the API reference documentation.

Create a job request#

There are some minor modifications to the JobRequest object and its concrete subclasses:

  • Only the pathlib.Path object and string values for file inputs are permitted. File objects are no longer allowed.

  • The templates keyword argument has changed to template and only accepts a single value.

Submit a job request to the queue#

The AsyncJobQueue methods for creating jobs are renamed to reflect that jobs can be import or export jobs:

Query the job queue#

Two AsyncJob attributes for querying the job queue have changed type:

The jobs_where() method, which accepted str values for the job_type and status keyword arguments, are changed to enumerations. Thus, you must provide members of the JobType and JobStatus classes.