Skip to main content
MI Scripting Toolkit 5.0 is a major release. Support has been added for import and export of precision information for point and range values, and is described in Trailing zeros and precision. Additionally, significant improvements have been made to existing functionality in the following areas:

Trailing zeros and precision

Support has been added for precision information on point and range attributes. This allows both the export of trailing zero information from Granta MI databases and the import of values with specified significant figures.

Export of trailing zero information

Trailing zero information can be exported from point and range attributes via the following properties: These properties return TrailingZeroInformation objects, which describe how many digits in the float value are significant.

Import of values with significant figures

Attribute values with significant figures can be imported to point and range attributes via the following properties: These properties now accept ValueWithPrecision instances as alternative inputs to float values. The number of significant figures ValueWithPrecision.significant_figures, evaluated from the provided ValueWithPrecision.value and ValueWithPrecision.number_of_digits, is added to the attribute value during import. See Data with Precision for examples of the new functionality.

Installation and imports

The MI Scripting Toolkit streamlined API is now provided by ansys-grantami-core. This package has a dependency on the Foundation API, which is provided by ansys-grantami-backend-soap. Both packages are delivered together. See Getting started for how to install the packages, and Package overview for more detail on how MI Scripting Toolkit is structured. The GRANTA_MIScriptingToolkit package (referred to as the compatibility package) is provided for backwards compatibility purposes and may be installed if required. It will be installed by default if upgrading an existing installation.

Streamlined API

The streamlined API should be accessed by importing ansys.grantami.core. Imports from GRANTA_MIScriptingToolkit.granta are allowed if the compatibility package is installed, but are deprecated. Imports from GRANTA_MIScriptingToolkit.granta subpackages are not allowed:
  • from GRANTA_MIScriptingToolkit import granta as mpy is permitted, but emits an APIDeprecationWarning.
  • from GRANTA_MIScriptingToolkit.granta import Record is permitted, but emits an APIDeprecationWarning.
  • from GRANTA_MIScriptingToolkit.granta.mi_record_classes import Record is no longer allowed and raises an ImportError.

Foundation API

The foundation API should be accessed by importing ansys.grantami.backend.soap. Imports from GRANTA_MIScriptingToolkit are allowed if the compatibility package is installed, but are deprecated. Imports from GRANTA_MIScriptingToolkit subpackages are not allowed:
  • import GRANTA_MIScriptingToolkit as gdl is permitted, but emits an APIDeprecationWarning.
  • from GRANTA_MIScriptingToolkit import RecordReference is permitted, but emits an APIDeprecationWarning.
  • from GRANTA_MIScriptingToolkit.RecordReference import RecordReference is no longer allowed and raises an ImportError.

Session construction

Connecting to Granta MI is now done with a SessionBuilder class. Once the connection is complete, a Session object is returned. New OIDCSessionBuilder and SessionConfiguration classes have also been introduced to support the SessionBuilder class. Direct use of the Session constructor is available if importing the Streamlined API via the compatibility package, but is deprecated.

Attribute values

Significant changes have been made to AttributeValue in this release, to better represent the underlying Granta MI behavior. These changes bring the following benefits:
  • Better client-side validation. More checks are performed when the Python objects are modified, ensuring the data is compatible with Granta MI when imported.
  • More representative classes for attribute sub-types, for example multi-value vs single-value attributes and series vs grid functional data. The allowed types are now narrower and more specific, making the streamlined API easier to use.
  • More predictable behavior via the use of immutable types. Attribute values now make use of tuples instead of lists, which allows for additional validation and fewer side effects.
The following attribute values have changed significantly in this release and are described in the following sub-sections: Additionally, the following changes have been made to other attribute values:

AttributeDate

AttributeDate.value now only supports date objects:
  • Values exported from Granta MI are represented as date objects instead of datetime objects set to midnight on the appropriate date.
  • Values to be imported to Granta MI must be specified as date objects. datetime and str objects are no longer supported.
The following additional enhancements have been made to AttributeDate:
  • The AttributeDate.value_as_string property has been removed. Instead, use isoformat() on the output of AttributeDate.value.
  • Setting a date attribute to a value earlier than 1st January 1753 now raises a ValueError immediately. Previously, a non-descriptive error would be raised on import.

AttributePoint

AttributePoint has been split into AttributePointSingle and AttributePointMulti. AttributePointSingle represents attribute values for point attributes defined as not allowing multiple values: AttributePointMulti represents attribute values for point attributes defined as allowing multiple values: The following additional enhancements have been made to point attribute values:

AttributeDiscrete

AttributeDiscrete has been split into AttributeDiscreteSingle and AttributeDiscreteMulti. AttributeDiscreteSingle represents attribute values for discrete attributes defined as not allowing multiple values: AttributeDiscreteMulti represents attribute values for discrete attributes defined as allowing multiple values: The following additional enhancements have been made to discrete attribute values:

AttributeRange

The interface for range attribute values has changed significantly since the previous release.

WARNING

Any code that uses the v4.2 AttributeRange class will need to be modified when upgrading to v5.0. AttributeRange.value can now only be set to an instance of Range: The following additional enhancements have been made to AttributeRange:

Float functional attributes

The interface for float functional attribute values has changed significantly since the previous release.

WARNING

Any code that uses the v4.2 AttributeFunctional class will need to be modified when upgrading to v5.0. These changes were required for the following reasons:
  • To support series functional data where multiple series share the same set of parameter values. In previous versions, it was not possible to determine which data points belonged to which series.
  • To support enhanced validation. In previous versions, it was possible to create invalid functional data objects that would only fail when import was attempted.
  • To support greater control over datum-level parameter settings. In previous versions, it was not possible to fully specify datum-level parameter settings, or to determine if a parameter setting was inherited or set directly.
As a result of these changes, there is now a greater reliance on immutable data types in the functional data interface. Immutable data types allow for enhanced validation of the data, because the data can be validated when it is assigned to the attribute, and cannot subsequently be modified to an invalid state. New classes have been defined to represent grid and series functional data for both point and range data types. These classes ensure that the data provided is compatible with the schema definition of the attribute. See Float Functional Data for an example of interacting with the new float functional data interface.

Attribute value changes

X-axis changes

Parameter changes

AttributeTabular

The interface for tabular attribute values has changed significantly since the previous release.

WARNING

Any code that uses the v4.2 AttributeTabular class will need to be modified when upgrading to v5.0. These changes were required to allow a more granular and efficient way to edit and import data. In previous versions of MI Scripting Toolkit, tabular data was imported as a whole object, even when updating a single cell. This could cause a large overhead when interacting with tabular attributes with many rows, and with binary columns. As a result of these changes, the interface now provides more information about rows and cells, and improves performance in scenarios where only a subset of the table data is modified. New classes have been added to represent tabular rows and cells. These ensure that data provided is consistent with the schema definition of the attribute.

Attribute value changes

Cell changes

Invalid operations on staged records

The behavior when invalid operations are performed on staged records has been standardized. The following methods and properties now all raise InvalidRecordStateError when called on staged records: