granta mi: mi:scriptingtoolkit for python › wp-content › uploads › 2019 › ... · demo •...
TRANSCRIPT
www.grantadesign.com
GRANTA MI:MI:Scripting Toolkit for Python
Introductory Training Webinar9th January 2018
Trainer: Jan Girman (Consultant, Services)
CONFIDENTIAL
Webinar Agenda
• DEMO – Export/Import Script• Introducing the MI:Scripting Toolkit for Python (slides):
– What is it and what services are available?– How to connect the local Python environment to Granta MI?– How to use the documentation?
• Exploring the available services (Jupyter Notebooks)– Search Service– Browse Service– Export Service– Import Service
CONFIDENTIAL
Objectives
You will understand:– How the Python Scripting Toolkit
connects to the GRANTA MI system
– The services accessible via the Toolkit
– How to use the Scripting Toolkit documentation
By the end of this session…
You will be able to:– Connect your python script to
Granta MI– Navigate the Python Scripting
Toolkit Documentation– Browse Granta MI through
Python– Search Granta MI through
Python– Export data from Granta MI to
your Python script– Import data from your Python
script to Granta MI
CONFIDENTIAL
Granta MI Python Scripting Toolkit Training Workshop
DEMO• Using PyCharm,
• Export of Statistically-evaluated UTS for a temperature range from a set of records (MI:Training),
• Plot UTS vs. Temperature and apply a polynomial fit,
• Import the data as a multi-series functional attribute to a new Design Data record (MI:Training).
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
Granta MI Python Scripting Toolkit Training Workshop
Introduction: MI: Scripting Toolkit• What is it and what are the available services?
• How to connect the local Python environment to Granta MI?
• How to use the documentation?
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
What is the MI: Scripting Toolkit?
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
GRANTA MI Software Development Kits
Server Side
Client Side
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
GRANTA MI Software Development Kits
MI:Scripting
MI:Scripting
SQL Server
C++ Toolkit
C Binding
MATLAB Python ...
MI:Server
MI C# API
Web Platform services
Custom Reports
Custom ToolMI:Service Layer
MI:Materials Gateway
Custom Tool
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
MI:Scripting Toolkit Services
• SEARCH– Simple text search– Criteria (Attribute-based) search
• BROWSE– Information about the
folders and records– *BUT* none of the data
itself
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
MI:Scripting Toolkit Services
• DATA EXPORT– Exports attribute and meta-
attribute data from target records
• DATA IMPORT– Update and import attribute
and meta-attribute data into the GRANTA MI database
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
MI:Scripting Toolkit Services
• ENGINEERING DATA SERVICE– Run pre-configured FE
(Text) Exporters
DEMO 1 Introduction Exploring Services DEMO 2
CONFIDENTIAL
Connecting to the MI database
• The base object for the GRANTA_MIScripting toolkit. • This creates a connection to a GRANTA MI Server via a GRANTA MI:ServiceLayer.• Arguments:
– url - url of your GRANTA MI:ServiceLayer installation– username - your GRANTA MI username– password - your GRANTA MI password– domain - your GRANTA MI user domain
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
Connecting to the MI database
• If you use Windows Authentication for logging into Granta MI, it can also be used in the Toolkit (instead of hard-coded credentials)
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
MI Scripting Toolkit Documentation
• Navigating the documentation:• Navigate to the documentation page:• Select the service you need (e.g. Browse
Service)• Find the function which describes what you
want to do (e.g. Get Tables)
• Click on the arguments to see what arguments you must pass into the function when creating the session request
• Click on the returns to see what you should expect as a response
Docs
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
Granta MI Python Scripting Toolkit Training Workshop
Exploring the available Services• Browse Service
• Search Service
• Data Export Service
• Data Import Service
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
DEMO 1 Introduction Exploring Services
The principle of using the Services
Steps to use the browseService, searchService, dataExportService, dataImportService:
1. Create a Request object
2. Create a Response object3. Work with the lists and properties in the Response object
A request method, which includes data such as database keys, record references, and lists of objects. Note: this is not a session property!
CONFIDENTIAL
Browse Service
• Let’s look at:– GetDatabases– GetUnitSystems– GetTables– GetSubsets– GetAttributeDetails
• Many others available e.g.:– GetChildNodes– GetTreeRecords– GetRecordAttributes– GetMetaAttributes– GetLinkedRecords
For information you would expect to find in the Browse tree or record properties
DEMO
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
DEMO 1 Introduction Exploring Services
Search Service
• Let’s look at:– CriteriaSearch
• Also available:– SimpleTextSearch
DEMO
CONFIDENTIAL
Data Export Service
• GetRecordAttributesByRef– To export all the data in an attribute / record combination
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
Data Export Request
Takes a list of Record References and a list of Attribute References (and optionally Unit System information)
Returns a list of Record Data objects, each of which has:• one Record Reference• a list of Attribute Value Objects
DEMO
DEMO 1 Introduction Exploring Services
CONFIDENTIAL
Data Import Service
• SetRecordAttributes function,• The request takes a list of ImportRecord objects:
• recordName = ‘some string’• isFolder = True/False• importAttributeValues = [import attribute value objects]• importRecordMode = Create/Update• releaseRecord = True/False• subsetReferences = [subset refs]• existingRecord = reference to the record/folder or table where to import to
DEMO
DEMO 1 Introduction Exploring Services
ImportAttributeValue• Class arguments depend on the attribute type• Must contain an attribute reference and the
value• If unitted, need information about the unit• If parameterised, need information about each
parameter (reference, value, unit)
CONFIDENTIAL
Objectives
You will understand:– How the Python Scripting Toolkit
connects to the GRANTA MI system
– The services accessible via the Toolkit
– How to use the Scripting Toolkit documentation
By the end of this session…
You will be able to:– Connect your python script to
Granta MI– Navigate the Python Scripting
Toolkit Documentation– Browse the MI:Training
database through Python– Search the MI:Training
database through Python– Export data from the
MI:Training database to your Python script
– Import data from your Python script to Granta MI
CONFIDENTIAL
Any Questions?
GRANTA MI Monthly Online Training Archive
Find previous sessions by logging in to My Granta: https://mygranta.grantadesign.com/TrainingVideos
Training schedule
http://www.grantadesign.com/products/mi/training.htm
Next training is in February 13th 2018 – Topic TBC