Skip to content

Marvin Actions

Marvin Actions help you to interact with Marvin RPA functions.

Actions

marvin.execute

Add a new process to Marvin execution queue

Parameters:

script - name of the automation script to be executed.

vars - variables to be setted on script start.

robotKey - robotKey of the robot to execute the script. If the execution is at the same robot, keep it as None

robotSecret - robotSecret of the robot to execute the script. If the execution is at the same robot, keep it as None

Returns:

executionId - ID of the execution added to robots queue.

Usage Example
script.mvn
marvin.execute("another-process", {'email': '[email protected]', 'name': 'John'})
prompt.alert('Execution ID: ' + $executionId)

marvin.import_module

Imports Python modules that are not natively included with Marvin. Does the same as the import module and from package import module in Python.

Parameters:

import_name - name of the module to be imported. Here will be putted the part of the import of Python syntax.

from_name - used when the Python import contains from. Here will be putted the from part of Python syntax.

version - specific version of the module (optional). Ex: "1.2.3", ">=1.2.0", "~=1.2.0". If specified, the module will be automatically installed before import.

Returns:

<import_name> - return the requested module, with the same name as the given import_name.

Exceptions:

ModuleNotInstalled - when the requested module was not installed previously, or the module is not present on Marvin. Check marvin.install_module action for further informations.

Usage Example - Simple Import
script.mvn
marvin.import_module("pandas")
prompt.alert('Version: ' + ($pandas).__version__)
Usage Example - Import with Specific Version
script.mvn
# Install and import a specific version
result = marvin.import_module("requests", version="2.28.0")
prompt.alert('Version: ' + ($requests).__version__)
Usage Example - From Import
script.mvn
result = marvin.import_module('BeautifulSoup', 'bs4')

BeautifulSoup = $BeautifulSoup
soup = BeautifulSoup("<html>data</html>")
prompt.alert(soup.html.string)
Usage Example - From Import with Version
script.mvn
# Install and import specific class from package with version
result = marvin.import_module('BeautifulSoup', 'bs4', version='4.11.0')

BeautifulSoup = $BeautifulSoup
soup = BeautifulSoup("<html>data</html>")
prompt.alert(soup.html.string)
Usage Example - Version Operators
script.mvn
# Install version greater than or equal to 1.5.0
result = marvin.import_module("pandas", version=">=1.5.0")

# Install version compatible with 1.2.x
result = marvin.import_module("numpy", version="~=1.2.0")

# Install version different from 2.0.0
result = marvin.import_module("requests", version="!=2.0.0")

marvin.install_module

Install modules that are not natively included with Marvin. This is a analog function to pip install <module> on Python.

Parameters:

module_name - name of the module to be installed for your process.

version - specific version of the module (optional). Ex: "1.2.3", ">=1.2.0", "~=1.2.0", "!=2.0.0".

Returns:

This action has no return

Usage Example - Install Latest Version
script.mvn
marvin.install_module('beautifulsoup4')
result = marvin.import_module('BeautifulSoup', 'bs4')

BeautifulSoup = $BeautifulSoup
soup = BeautifulSoup("<html>data</html>")
prompt.alert(soup.html.string)
Usage Example - Install Specific Version
script.mvn
# Install specific version
marvin.install_module('requests', '2.28.0')
result = marvin.import_module('requests')

prompt.alert('Installed version: ' + ($requests).__version__)
Usage Example - Install with Version Operators
script.mvn
# Install version greater than or equal to 1.5.0
marvin.install_module('pandas', '>=1.5.0')

# Install version compatible with 1.2.x (>=1.2.0, <1.3.0)
marvin.install_module('numpy', '~=1.2.0')

# Install version less than or equal to 2.0.0
marvin.install_module('requests', '<=2.0.0')

# Install any version except 2.0.0
marvin.install_module('flask', '!=2.0.0')

Important: sometimes the module name used on Python import is the same name as used for module instalation. If some error occurs, check if your informations are correct.

Version Note: The system supports PEP 440 version operators: - == - exact version (automatically added if not specified) - >= - version greater than or equal - <= - version less than or equal
- ~= - compatible version (ex: ~=1.2.0 = >=1.2.0, <1.3.0) - != - different version

Compatibility: The functions maintain compatibility with existing code. If no version is specified, the behavior will be the same as before (installation of the latest version).