Calculate Python Expression

Description

This functor runs an Python instance with the defined user expression. For an overview of how Dinamica and Python can be linked together check the documentation about Dinamica EGO and Python Coupling.

Inputs

Name	Type	Description
expression	Code	The expression that will run on Python.

Optional Inputs

None.

Outputs

Name	Type	Description
result	Struct	A struct containing the output values generated by the expression.

Notes

DinamicaEGO allows installing libraries from within python scripts:

Simply install and load the numpy library:

dinamica.package("numpy")

You can specify a version like you do on pip:

dinamica.package("numpy", "numpy==1.19.5")

You can install and load a library that has different name from its project, in this case the package is called “segment_anything_py” but it can only be imported “segment_anything”:

dinamica.package("segment_anything_py", "segment_anything_py", "segment_anything")

And you can also use all pip parameters as you want, for example installing from a remote wheel and loading dependencies from a custom repository “--index-url https://download.pytorch.org/whl/cu118”.

dinamica.package("segment_anything_py", "https://files.pythonhosted.org/packages/43/2f/dabe75d90a7eb54a0a609a0fc5c36d1933256319beaea5d6b2f176e213a2/segment_anything_py-1.0-py3-none-any.whl --index-url https://download.pytorch.org/whl/cu118", "segment_anything")

Or use it in a more complex pipeline. For example: install the “cython” and “numpy” dependencies to clone and compile a python library from a git repository: ( of course the git executable must be on the path for cloning a repository)

dinamica.package("cython")
dinamica.package("numpy")
dinamica.package("pycocotools", "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI")

Group

Integration

Internal Name

CalculatePythonExpression