granta mi: mi:scriptingtoolkit for python › wp-content › uploads › 2019 › ... · demo •...

25
www.grantadesign.com GRANTA MI: MI:Scripting Toolkit for Python Introductory Training Webinar 9 th January 2018 Trainer: Jan Girman (Consultant, Services)

Upload: others

Post on 28-Jun-2020

66 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

www.grantadesign.com

GRANTA MI:MI:Scripting Toolkit for Python

Introductory Training Webinar9th January 2018

Trainer: Jan Girman (Consultant, Services)

Page 2: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 3: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 4: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 5: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 6: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

CONFIDENTIAL

What is the MI: Scripting Toolkit?

DEMO 1 Introduction Exploring Services

Page 7: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

CONFIDENTIAL

GRANTA MI Software Development Kits

Server Side

Client Side

DEMO 1 Introduction Exploring Services

Page 8: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 9: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 10: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 11: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

CONFIDENTIAL

MI:Scripting Toolkit Services

• ENGINEERING DATA SERVICE– Run pre-configured FE

(Text) Exporters

DEMO 1 Introduction Exploring Services DEMO 2

Page 12: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 13: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 14: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 15: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 16: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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!

Page 17: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 18: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

CONFIDENTIAL

DEMO 1 Introduction Exploring Services

Search Service

• Let’s look at:– CriteriaSearch

• Also available:– SimpleTextSearch

DEMO

Page 19: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

CONFIDENTIAL

Data Export Service

• GetRecordAttributesByRef– To export all the data in an attribute / record combination

DEMO 1 Introduction Exploring Services

Page 20: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 21: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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)

Page 22: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

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

Page 23: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

CONFIDENTIAL

Any Questions?

Page 24: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

GRANTA MI Monthly Online Training Archive

Find previous sessions by logging in to My Granta: https://mygranta.grantadesign.com/TrainingVideos

Page 25: GRANTA MI: MI:ScriptingToolkit for Python › wp-content › uploads › 2019 › ... · DEMO • Using PyCharm, • Export of Statistically -evaluated UTS for a temperature range

Training schedule

http://www.grantadesign.com/products/mi/training.htm

Next training is in February 13th 2018 – Topic TBC