MI Scripting Toolkit 4.2 release notes
Enhancements
SearchCriterionnow acceptsRecordColorandRecordTypeas criterion values for searches on record propertiesRecordProperties.colorRecordProperties.typerespectively.- Range cell data returned by
AttributeTabular.valuenow includes additional items,low_is_inclusiveandhigh_is_inclusive, to describe whether the low and high value are included in the range. Record.find_parent()no longer raises anIndexErrorif the user does not have sufficient permissions to access the parent record. It now raises aPermissionError.- Classes
AttributeDefinitionShortTextandAttributeDefinitionIntegernow include the.is_uniqueproperty which indicates whether the attribute values are required to be unique.
Bug fixes
Table.bulk_fetch_data_revision_history()no longer raises aTypeErrorwhenparallelize=Trueand the table contains meta-attributes.- Using
Table.set_display_unit()for attributes with a temperature based unit now correctly results in the data being exported in the requested unit. AttributeTabularnow correctly loads exported data in cases where the tabular attribute includes columns unavailable to the user, regardless of the order in which columns are defined.AttributeTabular.column_typesnow returns a list with the expected length in cases where the tabular attribute includes unavailable columns.- Modifying the number of rows in a tabular attribute value by modifying the shape of the
AttributeTabular.valueandTabularUnits.data(accessed asAttributeTabular.units.data) values directly is no longer permitted. Instead, theAttributeTabular.add_row()andAttributeTabular.delete_row()methods should be used to change the number of rows in the tabular attribute value. - Calling
AttributeTabular.load()on an emptyAttributeTabularnow correctly initialises the value. This fixes an issue where the tabular attribute__repr__incorrectly includednot loadedafter callingAttributeTabular.load(). - Editing existing tabular data no longer discards inclusiveness information of range cells.
ReleaseStateFetcher.fetch_release_states()andSession.bulk_fetch_release_states()now correctly populate the release state of versioned records that are not the latest version available to the user.ReleaseStateFetcher.fetch_release_states()andSession.bulk_fetch_release_states()now correctly populate the release state of records with identical guids in different databases.
Examples
There have been no changes to example scripts in MI Scripting Toolkit 4.2.Backwards incompatible API changes
There are no known backwards-incompatible changes in MI Scripting Toolkit 4.2.Foundation API changes
- Additional logging has been added to assist in debugging scripts, this is available via the
GDL.httplogger. - Logging has been reorganised to allow more granular control of message logging, existing request and
response log messages are now available via the
GDL.corelogger. GetRecordAttributesByRefRequest.tabularDataSettingsadded to control how tabular attributes are exported.
Known issues
-
If an attribute is exported with the
Table.bulk_fetch()method withinclude_binary_data=False, subsequent values returned by theAttributePicture.mime_file_typeproperty will always returnimage/png, regardless of the actual image format. The header returned when accessing the URL is unaffected and should be used instead. -
The behavior of
Table.get_record_by_lookup_value()when a non-unique lookup value is provided is dependent on the Granta MI version. In Granta MI 2025 R2 and later, if multiple matches are detected, no results are returned. In earlier Granta MI versions, an exception is raised. -
If an attribute is removed from the Granta MI database after the parent
Databaseis first accessed, calls toTable.refresh_attributes()raise aGRANTA_ServiceLayerError. UseDatabase.refresh_tables()instead. -
In version-controlled tables,
DataRevisionHistoryobjects have an ambiguous meaning. Thehistory.last_modified_datefor the following attribute types is updated when the release state of the parent record is modified:- Date
- Hyperlink
- Integer
- Logical
- Range
- Short text
history.last_modified_datefor the following attribute types is not updated when the release state of the parent record is modified:- Discrete
- File
- Functional
- Long text
- Picture
- Point
- Tabular
-
The following hyperlink display options available in MI Viewer are not supported by
Hyperlink.hyperlink_display:- Current pane
- Left browse pane
- Both panes below toolbar
hyperlink_displaywill be set toContent. If the attribute is subsequently re-imported, the display option in MI Viewer will be changed to “Right content pane”.
Planned changes and deprecations
This section describes deprecated functionality which will be removed or changed in a future release.Functionality deprecated with version 4.2
Functionality deprecated with version 4.1
Upgrading from earlier versions
This section summarizes all the breaking changes in previous versions of MI Scripting Toolkit.Upgrading from MI Scripting Toolkit Version 4.1
There are no changes required to upgrade from MI Scripting Toolkit Version 4.1.Upgrading from MI Scripting Toolkit Version 4.0
Attribute Values
- Property
AttributeDiscrete.valuenow validates the provided value against the attribute’s allowed discrete values. CheckAttributeDefinitionDiscrete.discrete_valuesfor available values. This validation is case-sensitive.
Parameters
- The attribute
parent_recordof the classParameterDefinitionhas been removed as the information is not currently available in Scripting Toolkit. Attempting to access this attribute will raise anAttributeError. - The
orderandparent_attributeproperties were previously implemented on theParameterDefinitionclass, and so were accessible for all parameter objects. However, these properties only have meaning when requested for an attribute parameter, and had undefined behavior for database parameters. These properties have been moved to theAttributeParameterclass. Attempting to access these properties from aDatabaseParameterobject will raise anAttributeError. - It is no longer permitted to provide database or attribute parameters to
Exporter.run_exporter(). The results of theExporter.get_parameters_required_for_export()method must be used to specify parameter values for export. If you do not use the results of theExporter.get_parameters_required_for_export()method aTypeErrorwill be raised.
Unit systems and absolute temperatures
This section describes the previous incorrect behavior and usages that are subject to behavior changes in version 4.1.-
If the
unit_systemandabsolute_temperaturearguments were never used, the default absolute temperature wasTrue. It now defaults toFalse. -
If only the
absolute_temperatureargument was provided, it was ignored and the absolute temperature scale was not updated on the database. -
If the
unit_systemargument was provided, it only had an effect if the provided value was not theDATABASE_UNIT_SYSTEMand if the provided value was different from the previously active unit system:
Upgrading from MI Scripting Toolkit for Python Version 3.x
Subsets
- If your code does not use the
Table.subsetsproperty and the default subset in your tables contain all records, you should see no behavior changes. This is the most common scenario. - If your code sets the
Table.subsetsproperty to the default subset, then you should disable this assignment from your code, since it now occurs automatically. - If your code sets the
Table.subsetsproperty to a non-default subset, then you should clear theTable.subsetsproperty withtable_object.subsets.clear()before setting the non-default subset. - If your code sets the
Table.subsetsproperty to a set containing more than one subset and you perform any subsequent record fetching or search operations, these operations will raise aValueError. They would previously not consider all applied subsets, and so would return incorrect results.
Searching and browsing for records
- All searches except
Database.search_for_records_by_text()now apply a subset filter when searching. If a table included in a search has multiple applied subsets, aValueErroris raised. - The
Table.search_for_records_where()list_of_criteriaparameter must now only contain criteria based on pseudo-attributes and attribute definitions from the table being searched. Otherwise aValueErroris raised. - The
Database.search_for_records_where()list_of_criteriaparameter must now only contain criteria based on pseudo-attributes and attribute definitions from at most one table within the database being searched. Otherwise aValueErroris raised. - Getting records based on the Granta MI tree is generally now subject to subset filtering. If a
table included in a record fetch operation has multiple applied subsets, a
ValueErroris raised.
Other changes
Session.records_from_string()now defaults touse_strict_version=True.get_records_by_idsandget_record_by_idmethods onSession,Database, andTableclasses no longer accept theidentityargument. Usehistory_identityinstead.Table.paths_from(),Table.path_from(), andTable.get_records_from_path()no longer supportstrandTableinputs. UseNoneto use the table root as starting node. All three methods now raise aValueErrorif the record specified asstarting_nodeis not in the current table, and raise aTypeErrorif the argument value is not aRecordorNone.Record.colorno longer supportsstrinputs. OnlyRecordColorobjects are supported.AttributeFunctional.add_point()andAttributeFunctional.add_range()methods now raiseKeyErrorexceptions if a dictionary with incorrect keys is provided.File.load(),File.save(),Picture.load(), andPicture.save()no longer acceptfile_nameas an argument. Provide the full path including the file name to thepathargument. For file attributes, the name of the file is part of the attribute value and can be accessed viaAttributeFile.file_nameorFile.file_nameto build a full path.File.namehas been removed. UseFile.file_name.Picture.namehas been removed.FileandPictureno longer acceptnameorloadas arguments. Provide the full path to the file/picture (including the file name) to the keyword only argumentpath.File.descriptionnow only supportsstrinputs.AttributeHyperlink.objectno longer supportsstrinputs. OnlyHyperlinkobjects are supported.- Any code which performs bulk export operations on file and picture attributes should be modified
either to access the binary data with an HTTP library such as
requests or httpx.
Alternatively, the binary data can be exported directly by specifying
include_binary_data = Truein the call toTable.bulk_fetch(). However, this is likely to be less performant for large amounts of data. - The
Record.idproperty has been renamed toRecord.history_identity.
AsyncJobs
The AsyncJobQueue functionality has been moved to a new PyAnsys package called PyGranta JobQueue. If you are using Granta MI 2024 R2 or later, you can use this package to import and export Excel files and import text data into Granta MI. If you are using Granta MI 2024 R1 or earlier and require Job Queue functionality, you should continue to use MI Scripting Toolkit v3.3.Upgrading from MI Scripting Toolkit for Python Version 2.X
New store_password option on the Session class
Old behavior: The password for a Session is used to connect to Granta MI once, and cannot be stored.
New behavior: The password assigned to a Session can be stored and used multiple times. You must
specify whether you want to store the password or not using the store_password property. If store_password is
missing, bulk operations will fail.