Upgrading from MI Scripting Toolkit Version 4.2
Package
- Moved MI Scripting Toolkit to new packages
ansys-grantami-coreandansys-grantami-backend-soap. - Added compatibility package
GRANTA_MIScriptingToolkit, which is deprecated from v5.0. - Removed Async Job Queue stubs: module
mi_async_jobs, methodSession.get_async_job_queueand error handling in thegrantanamespace.
Session
- Added
SessionBuilderto createSessionobjects.Sessionis no longer supported unless imported viaGRANTA_MIScriptingToolkit. - Removed Streamlined API function
connect(). - Removed methods
Session.can_connect(),Session.assert_can_run_parallelized(). - Removed
Session.spawn_session. Create foundation layer sessions usingansys.grantami.backend.soap.GRANTA_MISession. Sessionobjects that are instantiated with URLs that do not specify a protocol now default to HTTPS. To use HTTP, provide the full URL including thehttpprotocol.
Database
- Removed
Database.get_table()andDatabase.get_table_by_guid()argumentssubsets,unit_system, andabsolute_temperatures. - Removed
Database.get_all_link_details_where,Database.get_link_detail, andDatabase.link_details. UseDatabase.record_link_groupsfor available record link groups. - Removed
Database.set_unit_system. UseDatabase.unit_systemandDatabase.absolute_temperatures. Database.get_table()no longer resets the active subsets of the returnedTableobject.
Table
- Removed
Table.path_from()andTable.paths_from()argumentend_node. Create records usingTable.create_record().
Bulk methods
- Removed
paralleliseargument from methodsSession.bulk_fetch_release_states(),Session.bulk_delete_or_withdraw_records(),Table.bulk_fetch(),Table.bulk_link_fetch(),Table.bulk_fetch_associated_records(), andTable.bulk_fetch_data_revision_history(). Use the argumentparallelize. - Removed class
BulkRecordDeleterWithdrawerfrom public API. UseSession.bulk_delete_or_withdraw_records()to delete and withdraw records in bulk. - Removed class
ReleaseStateFetcherfrom public API. UseSession.bulk_fetch_release_states()to fetch release states in bulk. - Removed class
AttributeFetcherfrom public API. UseTable.bulk_fetch()to fetch attribute values in bulk. - Removed class
AssociatedRecordFetcherfrom public API. UseTable.bulk_fetch_associated_records()to fetch associated records in bulk. - Removed class
LinkFetcherfrom public API. UseTable.bulk_link_fetch()to fetch links in bulk. - Removed class
DataRevisionHistoryFetcherfrom public API. UseTable.bulk_fetch_data_revision_history()to fetch data revision history in bulk. - Removed module
mi_bulk_utilitiesfrom public API.
Attribute definitions
- Renamed
AttributeDefinitionDatetimetoAttributeDefinitionDate. AttributeDefinitionDate.minandAttributeDefinitionDate.maxnow returndateobjects instead ofdatetimeobjects set to midnight on the appropriate date.- Removed the
axis_nameproperty from all attribute definition classes exceptAttributeDefinitionFloatFunctional. - Removed the
unitproperty from all attribute definition classes exceptAttributeDefinitionRange,AttributeDefinitionFloatFunctional, andAttributeDefinitionPoint.
Records
- Removed
Record.all_children. UseRecord.get_descendants(). - Removed support for setting
Record.typeto a string. Set to aRecordTypevalue. - Removed support for record color and record type
SearchCriterionusingstrcriterion values. Define the criterion value using the enumerationsRecordColorandRecordType. - Removed deprecated method
refetch_pseudos(). Use the alternativeRecord.refetch_pseudo_attributes(). - Removed support for deprecated argument names
include_metasandinclude_pseudosonRecord.get_attributes(). Useinclude_meta_attributesandinclude_pseudo_attributes. - Removed deprecated attribute
Record.pseudo_attributes. Pseudo-attributes are available as individualRecordproperties. - The behavior when invalid operations are performed on staged records has been standardized. All methods and properties
now raise
InvalidRecordStateErrorwhen called on staged records in circumstances where this is not permitted.
Float functional attribute values
FunctionalSerieshas been split intoAttributeFunctionalSeriesPointandAttributeFunctionalSeriesRange.FunctionalGridhas been split intoAttributeFunctionalGridPointandAttributeFunctionalGridRange.FunctionalSeries.hide_graphhas been renamed toshow_as_table.- Removed
AttributeFunctionalSeries.series_linestylesandAttributeFunctionalGrid.linestyle. Use thedecorationproperty. - Removed
AttributeFunctional.clear(). Set the.valuetoNone. - The
unitproperty on functional attribute classes now returnsNonefor dimensionless attributes, instead of an empty string. AttributeFunctional.xaxis_parameterhas been removed. To access x-axis parameter information, use thex_axisandparametersproperties.- The mapping
AttributeFunctional.xaxishas been removed. Usewith_new_x_axis(), to create an attribute value with a different x-axis. - The
parametersproperty now returns a mapping of parameter names toFunctionalValueParameterobjects.
Tabular attribute values
- The
.valueproperty onAttributeTabularis now read-only, replicating where possible the v 4.2 interface. Use the newAttributeTabular.rows-based interface for making changes to tabular data. - The
.add_rowmethod onAttributeTabularhas been renamed toAttributeTabular.append_row(), to better reflect its behavior. - The
.unitsproperty has been removed fromAttributeTabular. To access the units as defined on the column, use theAttributeDefinitionTabular.column_unitsproperty. To access the unit for a specific cell, use theRangeValue.unitorPointValue.unitproperty on the cell. - Direct indexing of the tabular attribute value to access rows has been removed.
- Operations which can cause data loss for users of Data Updater have been disabled by default. To enable them for a
specific attribute value, call
AttributeTabular.enable_destructive_editing(). - New classes
ShortTextValue,LongTextValue,LogicalValue,IntegerValue,DateValue,PictureValue, andFileValuerepresent individual linked cells in a tabular attribute value. The corresponding Local versions of these classes are used to represent local cells.
Other attribute values
AttributePointhas been split intoAttributePointSingleandAttributePointMulti.- The
AttributePointunitproperty now returnsNonefor dimensionless attributes, instead of an empty string. AttributeDiscretehas been split intoAttributeDiscreteSingleandAttributeDiscreteMulti.AttributeDate.valuenow only supportsdateobjects.- Removed
AttributeDate.value_as_string. AttributeRange.valuecan now only be set to an instance ofRange.AttributeRange.unitnow returnsNonefor dimensionless attributes, instead of an empty string.- The property
.objecthas been removed fromAttributeHyperlink. Use the propertiesAttributeHyperlink.value,AttributeHyperlink.hyperlink_display, andAttributeHyperlink.hyperlink_descriptioninstead. - Properties
AttributeHyperlink.hyperlink_description,AttributeFile.description,AttributeFile.url, andAttributePicture.urlnow returnNoneif properties are not set, instead of an empty string.
Schema and supporting items
- Removed
ParameterDefinition.type. UseParameterDefinition.data_typeandParameterDefinition.restricted. - Removed support for creating
SearchCriterionobjects for datetime-based pseudo-attributes withstrvalues. Usedatetimevalues only. - Removed support for providing the
AttributeDefinition.search_criterion()between_datesargument as a non-tuple sequence ofstrvalues. Argument must be specified as a 2-tuple ofdatevalues.
Miscellaneous functions
- Removed method
mi_functions.log_to_file_in_local_app_data. Use the Python logging module, and obtain the built-in logger with the functionget_foundation_logger(). - Removed method
mi_functions.extract_parameter_value.
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
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’ and ‘AttributeFunctional.add_range’ methods now raise
KeyErrorexceptions if a dictionary with incorrect keys is provided. Note: these methods were removed with MI Scripting Toolkit v5.0. 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.objecthas been removed, use the properties on theAttributeHyperlinkobject instead.- 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.