mstrio > python_execution > runtime

class mstrio.python_execution.runtime.Runtime(connection, id=None, name=None)

Bases: EntityBase, DeleteMixin

Python representation of a Strategy Python execution runtime.

Parameters:
  • connection (Connection)

  • id (str | None)

  • name (str | None)

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod create(connection, name, description=None, whitelist=None, packages=None, resource=None, exec_timeout=600, min_cached_instances=None, max_cached_instances=None, runtime_version=None, others=None, execution_target=None, journal_comment=None)

Create a runtime.

Return type:

Runtime

Parameters:
  • connection (Connection)

  • name (str)

  • description (str | None)

  • whitelist (list[str] | None)

  • packages (list[RuntimePackage | dict] | None)

  • resource (RuntimeResource | dict | None)

  • exec_timeout (int)

  • min_cached_instances (int | None)

  • max_cached_instances (int | None)

  • runtime_version (str | None)

  • others (str | None)

  • execution_target (str | None)

  • journal_comment (str | None)

classmethod from_dict(source, connection, to_snake_case=True, with_missing_value=False)
Overrides Dictable.from_dict() to instantiate an object from

a dictionary without calling any additional getters.

Parameters:
  • cls – Class (type) of an object that should be created.

  • source (dict[str, Any]) – a dictionary from which an object will be constructed.

  • connection (Connection) – A Strategy Connection object.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case, default True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

An instance of the cls class.

classmethod to_csv(objects, name, path=None, properties=None)

Exports MSTR objects to a csv file.

Optionally, saves only the object properties specified in the properties parameter.

Parameters:
  • objects (T | list[T]) – List of objects of the same type that

  • exported. (will be)

  • name (str) – The name of the csv file ending with ‘.csv’

  • path (Optional[str], optional) – A path to the directory where the file will be saved. Defaults to None.

  • properties (Optional[list[str]], optional) – A list of object’s attribute names that should be included in the exported file. Defaults to None.

Raises:
  • TypeError – If objects is not of type T or list of type T

  • objects. –

Return type:

None

__init__(connection, id=None, name=None)

Initialize a Runtime by ID or name.

Parameters:
  • connection (Connection)

  • id (str | None)

  • name (str | None)

Return type:

None

alter(name=None, description=None, whitelist=None, packages=None, resource=None, exec_timeout=None, min_cached_instances=None, max_cached_instances=None, runtime_version=None, others=None, execution_target=None, journal_comment=None)

Alter runtime properties.

Return type:

None

Parameters:
  • name (str | None)

  • description (str | None)

  • whitelist (list[str] | None)

  • packages (list[RuntimePackage | dict] | None)

  • resource (RuntimeResource | dict | None)

  • exec_timeout (int | None)

  • min_cached_instances (int | None)

  • max_cached_instances (int | None)

  • runtime_version (str | None)

  • others (str | None)

  • execution_target (str | None)

  • journal_comment (str | None)

delete(force=False, journal_comment=None, **kwargs)

Delete object.

Parameters:
  • force (bool) – If True, then no additional prompt will be shown before deleting object.

  • journal_comment (str | None) – Comment to be added to the change journal for this deletion. If None, no comment is added.

  • **kwargs – Any additional arguments within overridden versions of this method in inheritance chain.

Returns:

bool – True on success. False otherwise.

Return type:

bool

fetch(attr=None)

Fetch the latest object’s state from the I-Server.

Note

This method can overwrite local changes made to the object.

Parameters:
  • attr (Optional[str]) – Attribute name to be fetched. If not specified

  • dictionary. (it will use all getters specified in _API_GETTERS)

  • None. (Defaults to)

Raises:

ValueError – If attr cannot be fetched.

Return type:

None

list_properties(excluded_properties=None)

Fetches all attributes from the server and converts all properties of the object to a dictionary.

Parameters:

excluded_properties (list[str], optional) – A list of object properties that should be excluded from the dict. Defaults to None.

Returns:

A dictionary which keys are object’s attribute names, and

which values are object’s attribute values.

Return type:

dict

print()

Pretty Print all properties of the object.

Return type:

None

to_dataframe()

Converts all properties of the object to a dataframe.

Returns:

A DataFrame object containing object properties.

Return type:

DataFrame

to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:
  • camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

  • whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.

  • skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

update_properties()

Save compatible local changes of the object attributes to the I-Server. Changes are retrieved from the self._altered_properties dictionary. After the process of update has finished, self._altered_properties is cleared. For this method to work properly, you must override the _alter_properties() method in a subclass.

Raises:

requests.HTTPError – If I-Server raises exception

Return type:

None

property connection: Connection

An object representation of Strategy connection specific to the object.

property folder_id: str | None
property id: str

The object’s id.

property type: ObjectTypes

The object’s type.

class mstrio.python_execution.runtime.RuntimePackage(name, version=None, description=None)

Bases: Dictable

Package installed in a runtime.

Parameters:
  • name (str)

  • version (str | None)

  • description (str | None)

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod from_dict(source, connection=None, to_snake_case=True, with_missing_value=False)

Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of an object that should be created.

  • source (Dict[str, Any]) – A dictionary from which an object will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

An object of type T.

Return type:

T

to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:
  • camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

  • whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.

  • skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

description: str | None = None
name: str
version: str | None = None
class mstrio.python_execution.runtime.RuntimeResource(cpu=None, mem=None, disk=None, proc_count=None)

Bases: Dictable

Resource limits assigned to a runtime.

Parameters:
  • cpu (str | None)

  • mem (int | None)

  • disk (int | None)

  • proc_count (int | None)

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod from_dict(source, connection=None, to_snake_case=True, with_missing_value=False)

Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of an object that should be created.

  • source (Dict[str, Any]) – A dictionary from which an object will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

An object of type T.

Return type:

T

to_dict(camel_case=True, whitelist_keys=None, skip_private_keys=False)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:
  • camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

  • whitelist_keys (list[str], optional) – List of keys to include in the resulting dictionary. If None, all keys (except hidden ones) are included. Defaults to None.

  • skip_private_keys (bool, optional) – If True, skips private keys in final dict representation.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

cpu: str | None = None
disk: int | None = None
mem: int | None = None
proc_count: int | None = None
mstrio.python_execution.runtime.get_runtime_versions(connection)

Get available runtime versions.

Return type:

list[str]

Parameters:

connection (Connection)

mstrio.python_execution.runtime.list_runtimes(connection, to_dictionary=False, limit=None, **filters)

Get runtimes.

Parameters:
  • connection (Connection) – Strategy connection object returned by connection.Connection().

  • to_dictionary (bool, optional) – If True, return dictionaries instead of Runtime objects. Defaults to False.

  • limit (int, optional) – Maximum number of runtimes to return.

  • **filters – Available filter parameters: id, name, and description.

Returns:

list[Runtime] | list[dict] – List of Runtime objects or dictionaries.

Return type:

list[Runtime] | list[dict]