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.
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 totemplate
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:
AsyncJobQueue.create_import_job_and_wait
is renamed toJobQueueApiClient.create_job_and_wait()
.AsyncJobQueue.create_import_job
is renamed toJobQueueApiClient.create_job()
.
Query the job queue#
Two AsyncJob
attributes for querying the job queue have changed type:
The
AsyncJob.status
attribute returns a member of theJobStatus
class instead of a string.The
AsyncJob.type
attribute returns a member of theJobType
class instead of a string.
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.