Getting started#
Software requirements#
To use the PyGranta Data Flow Extensions package, you need access to a deployment of Granta MI 2023 R2 or later with an MI Data Flow Advanced edition license.
Python must be installed system-wide, as opposed to a per-user installation. This option is available during Python installation, and can only be modified by uninstalling and reinstalling Python.
Installation#
System-wide#
Install the package system-wide on the Granta MI application server for production use or for integration testing.
To install the latest release as a system-wide package, run this command as an administrator:
python -m pip install ansys-grantami-dataflow-extensions
Note
To install packages into the system-wide Python installation directly, you must run the preceding command with
administrator rights. Otherwise, pip install
will install the package for the current user only and will
display the warning:
Defaulting to user installation because normal site-packages is not writeable
A common symptom of this issue is a script that works when testing outside of Data Flow, but fails with an import error when running from within Data Flow.
There are three options to address this issue:
Re-run the command above as a user with administrator privileges. This will ensure the package is installed system-wide.
Re-run the command as the same user that runs MI Data Flow. This will install the package such that the Data Flow user can access it, and will suppress the user installation warning.
Follow the instructions in the Virtual environment to use a Virtual environment.
Virtual environment#
Install the package in a virtual environment:
On a local development environment, for script development and debugging
On the Granta MI application server, when it is not possible to install system-wide packages
To install the package in a virtual environment, first create a new virtual environment:
python -m venv C:\path\to\my\venv
Where C:\path\to\my\venv
is the path to the location where you would like the venv to be located. This should be a
location that all users can access.
Then activate the virtual environment and install the packages:
C:\path\to\my\venv\Scripts\activate
pip install ansys-grantami-dataflow-extensions
If installing in a virtual environment on the Granta MI application server, Data Flow must be configured with details of the virtual environment to be used:
Create a backup copy of the
web.config
file. By default, this file is located atC:\inetpub\wwwroot\mi_dataflow
.Open the
web.config
file in a text editor, and find the line<add key="PythonPath" value="python.exe" />
Replace the string
python.exe
withC:\path\to\my\venv\Scripts\python.exe
, whereC:\path\to\my\venv
is the path to the virtual environment specified above.Save the modified
web.config
file. If you see a permissions error, you may need to open the text editor with administrator privileges.Reload the Data Flow worker process in IIS Manager. Warning: This stops any running Workflow processes.
Installing a development version#
To install the latest release from the PyGranta Data Flow Extensions repository, run this command:
python -m pip install git+https://github.com/ansys/grantami-dataflow-extensions.git
To install a local development version with Git and Poetry, run these commands:
git clone https://github.com/ansys/grantami-dataflow-extensions
cd grantami-dataflow-extensions
poetry install
The preceding commands install the package in development mode so that you can modify it locally. Your changes are reflected in your Python setup after restarting the Python kernel. This option should only be used when making changes to this package, and should not be used when developing code based on this package.
Verify your installation#
To verify that your installation has been successful, run this code:
>>> from ansys.grantami import dataflow_extensions
>>> print(dataflow_extensions.__version__)
0.0.1
If you see a version number, your PyGranta Data Flow Extensions is installed.
Useful links#
For best practice around developing scripts that interact with Data Flow, see the User guide.
For examples, see the Examples.
For comprehensive information on the API, see API reference.