Introduction
This example demonstrates how to use the Granta MI JobQueue library with the Scripting Toolkit. The JobQueue library replaces the AsyncJobQueue component previously available within the MI Scripting Toolkit, and allows interaction with the Granta MI Job Queue via Python. The JobQueue library supports import and export operations. This example demonstrates how to use the MI Scripting Toolkit to define the records exported to Excel using an Excel template. This example does not cover all aspects of the JobQueue package. Full API documentation and additional examples are available here.Info:Running this notebook requires the
ansys-grantami-jobqueue package.
See the ‘PyGranta Dependencies’ section of the ‘Example Notebooks’
documentation page for more details.Define the records to export
First create an MI Scripting Toolkit session.Create an ‘ansys-grantami-jobqueue’ client
Use theConnection class to connect to create a JobQueue client.
Export the records to Excel
All JobQueue operations are performed by first creating aJobRequest object, and then submitting
that object to the server.
An ExcelExportJobRequest object requires the following:
- A name and description
- The path to an Excel export template, provided as either a string or a
pathlib.Pathobject - A list of
ExportRecordobjects, which contain a record history identity and optionally a record version - The database key for the provided
ExportRecordobjects
ExportRecord objects from the list of Record objects.
JobQueue.create_job_and_wait method to submit the ExcelExportJobRequest
object to the server. This method returns once the job is complete.
Access the exported data
Once the job is complete, the list of files generated as part of the operation can be accessed via theoutput_file_names property.
get_file_content method, or
alternatively the file can be saved to disk with the download_file method. See the JobQueue
API documentation for a demonstration of these methods.