mstrio.project_objects.datasets package¶
Submodules¶
mstrio.project_objects.datasets.cube module¶
- class mstrio.project_objects.datasets.cube.CubeStates(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
- ACTIVE = 2¶
- DIRTY = 16¶
- DIRTY_INFO = 8¶
- FOREIGN = 2048¶
- IMPORTED = 1024¶
- LOADED = 32¶
- LOAD_PENDING = 128¶
- PENDING_FOR_ENGINE = 512¶
- PERSISTED = 4¶
- PROCESSING = 1¶
- READY = 64¶
- RESERVED = 0¶
- UNKNOWN1 = 4096¶
- UNKNOWN2 = 8192¶
- UNKNOWN3 = 16384¶
- UNLOAD_PENDING = 256¶
- classmethod show_status(status: int) list[str] ¶
Show states of a cube calculated from numerical value of its state. Additionally list of those states’ names is returned.
- Parameters:
status (integer) – numerical value of cube’s status
- Returns:
List with names of cube’s states.
- mstrio.project_objects.datasets.cube.list_all_cubes(connection: Connection, name: str | None = None, search_pattern: mstrio.object_management.search_enums.SearchPattern | int = SearchPattern.CONTAINS, project_id: str | None = None, project_name: str | None = None, to_dictionary: bool = False, limit: int | None = None, **filters) list[OlapCube | SuperCube] | list[dict] ¶
Get list of Cube objects (OlapCube or SuperCube) or dicts with them. Optionally filter cubes by specifying ‘name’.
Optionally use to_dictionary to choose output format.
- Wildcards available for ‘name’:
? - any character * - 0 or more of any characters e.g. name = ?onny will return Sonny and Tonny
Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted.
Note
When project_id is None and project_name is None, then its value is overwritten by project_id from connection object.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection()
name (string, optional) – value the search pattern is set to, which will be applied to the names of cubes being searched
search_pattern (SearchPattern enum or int, optional) – pattern to search for, such as Begin With or Contains. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is BEGIN WITH (4).
project_id (string, optional) – Project ID
project_name (str, optional) – Project name
to_dictionary (bool, optional) – If True returns dict, by default (False) returns SuperCube/OlapCube objects
limit (integer, optional) – limit the number of elements returned. If None all object are returned.
**filters – Available filter parameters: [‘id’, ‘name’, ‘type’, ‘subtype’, ‘date_created’, ‘date_modified’, ‘version’, ‘owner’, ‘ext_type’, ‘view_media’, ‘certified_info’]
- Returns:
list with OlapCubes and SuperCubes or list of dictionaries
- mstrio.project_objects.datasets.cube.load_cube(connection: Connection, cube_id: str | None = None, cube_name: str | None = None, folder_id: str | None = None, folder_path: str | None = None, instance_id: str | None = None) OlapCube | SuperCube | list[OlapCube | SuperCube] ¶
Load single cube specified by either ‘cube_id’ or both ‘cube_name’ and ‘folder_id’.
It is also possible to load cube by providing only cube_name, but in that case we may retrieve more than one cube as cube’s name is unique only within a folder.
instance_id is used only when a single cube is retrieved.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection()
cube_id (string, optional) – ID of cube
cube_name (string, optional) – name of cube
folder_id (string, optional) – ID of folder in which the cube is stored
folder_path (str, optional) –
Path of the folder in which the cube is stored. Can be provided as an alternative to folder_id parameter. If both are provided, folder_id is used.
- the path has to be provided in the following format:
- if it’s inside of a project, example:
/MicroStrategy Tutorial/Public Objects/Metrics
- if it’s a root folder, example:
/CASTOR_SERVER_CONFIGURATION/Users
instance_id (str, optional) – Identifier of an instance if cube instance has been already initialized. Will be used if only one cube is found. None by default.
- Returns:
object of type OlapCube or SuperCube based on the subtype of a cube returned from metadata.
- Raises:
ValueError when neither cube_id nor cube_name are provided. –
mstrio.project_objects.datasets.cube_cache module¶
- class mstrio.project_objects.datasets.cube_cache.CubeCache(connection: Connection, cache_id: str, cube_cache_dict: dict | None = None)¶
Bases:
Cache
Manage cube cache.
- activate()¶
Activate cube cache.
- deactivate()¶
Deactivate cube cache.
- delete(force: bool = False)¶
Delete cube cache.
- Parameters:
force – If True, then no additional prompt will be shown before deleting CubeCache.
- Returns:
True for success. False otherwise.
- fetch()¶
- classmethod from_dict(connection: Connection, caches: list[dict]) list['CubeCache'] ¶
- get_manipulation_status(manipulation_id: str) dict ¶
Get manipulation status of cube cache.
- list_properties()¶
List properties for cube cache.
- load()¶
Load cache.
- unload()¶
Unload cache.
- mstrio.project_objects.datasets.cube_cache.delete_cube_cache(connection: Connection, id: str, force: bool = False)¶
Delete single cube cache.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection().
id (string) – cube cache ID
force (bool, optional) – If True, then no additional prompt will be shown before deleting caches for given cube. Default is False.
- Returns:
True for success. False otherwise.
- mstrio.project_objects.datasets.cube_cache.delete_cube_caches(connection: Connection, loaded: bool = False, force: bool = False, nodes: list[str] | str | None = None, cube_id: str | None = None, db_connection_id: str | None = None) dict | None ¶
Delete all cube caches on a given node.
Optionally it is possible to specify for which cube or for which database connection caches will be deleted. It is also possible to delete only loaded caches.
You can specify from which nodes caches will be deleted. If nodes are None then all nodes are retrieved from cluster.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection().
nodes (list of strings or string, optional) – names of nodes from which caches will be deleted. By default it equals None and in that case all nodes names are loaded from the cluster.
cube_id (string, optional) – When provided, only caches for the cube with given ID will be deleted (if any).
db_connection_id (string, optional) – When provided, only caches for the database connection with given ID will be deleted (if any).
loaded (bool, optional) – If True then only loaded caches will be deleted. Otherwise all cubes will be returned.
force (bool, optional) – If True, then no additional prompt will be shown before deleting caches for given cube. Default is False.
- Returns:
‘succeeded’ - list with IDs of caches which were deleted
’failed’ - list with IDS of caches which were not deleted
or None when user doesn’t agree for deletion when prompted
- Return type:
Dictionary with two keys
- mstrio.project_objects.datasets.cube_cache.list_cube_caches(connection: Connection, nodes: list[str] | str | None = None, cube_id: str | None = None, loaded: bool | None = False, db_connection_id: str | None = None, project_ids: list[str] | None = None, to_dictionary: bool | None = False, limit: int | None = None) list['CubeCache'] | list[dict] ¶
List cube caches. You can filter them by cube (cube_id), database connection (db_connection_id) and projects (project_ids). You can also obtain only loaded caches (loaded=True).
You can specify from which nodes caches will be retrieved. If nodes are None then all nodes are retrieved from the cluster.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection().
nodes (list of strings or string, optional) – names of nodes on which caches will be searched. By default it equals None and in that case all nodes’ names are loaded from the cluster.
cube_id (string, optional) – When provided, only caches for the cube with given ID will be returned (if any).
loaded (bool, optional) – If True then only loaded caches will be retrieved. Otherwise all cubes will be returned.
db_connection_id (string, optional) – When provided, only caches for the database connection with given ID will be returned (if any).
project_ids (list of string, optional) – When provided only caches for projects with given IDs will be returned (if any).
to_dictionary (bool, optional) – If True returns dict, by default (False) returns CubeCache objects
limit (integer, optional) – Cut-off value for the number of objects returned. Default value is None which means no limit.
- Returns:
List of CubeCache objects when parameter to_dictionary is set to False (default value) or list of dictionaries otherwise.
mstrio.project_objects.datasets.helpers module¶
- class mstrio.project_objects.datasets.helpers.AdvancedProperties(metric_join_types: list[mstrio.project_objects.datasets.helpers.MetricJoinType] = <factory>, attribute_join_types: list[mstrio.project_objects.datasets.helpers.AttributeJoinType] = <factory>)¶
Bases:
Dictable
Class representation of advanced properties containing joining information.
- metric_join_types¶
List containing joining information for each metric that appears in the template.
- Type:
list[MetricJoinType], optional
- attribute_join_types¶
List containing joining information for each attribute that appears in the template.
- Type:
list[AttributeJoinType], optional
- attribute_join_types: list[mstrio.project_objects.datasets.helpers.AttributeJoinType]¶
- metric_join_types: list[mstrio.project_objects.datasets.helpers.MetricJoinType]¶
- to_dict(camel_case: bool = True) dict ¶
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.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.project_objects.datasets.helpers.AttributeFormReference(id: str, name: str | None = None)¶
Bases:
Dictable
Class representation of single attribute form.
- id¶
ID of the referenced attribute.
- Type:
str
- name¶
Name of attribute.
- Type:
str, optional
- id: str¶
- name: str | None = None¶
- class mstrio.project_objects.datasets.helpers.AttributeJoinType(attribute: SchemaObjectReference, no_participation_in_preserve_row: bool, resolved_location: ResolvedLocation = ResolvedLocation.DEFAULT, is_inherited: bool = True, next_no_participation_in_preserve_row: bool | None = None, next_resolved_location: mstrio.utils.vldb_mixin.ResolvedLocation | None = None)¶
Bases:
Dictable
Class representation of single joining operation for attribute.
- attribute¶
Reference to the attribute used for joining.
- Type:
- no_participation_in_preserve_row¶
Value corresponding to the targeted VLDB setting of given attribute.
- Type:
bool
- resolved_location¶
Type of location where value of related VLDB setting was last time resolved.
- Type:
ResolvedLocation, optional
- is_inherited¶
Whether the related VLDB setting value is inherited from other objects or not. If False value is set on the object. If True, value is inherited from other objects.
- Type:
bool, optional
- next_no_participation_in_preserve_row¶
Previously set value of attribute targeted VLDB setting.
- Type:
bool, optional
- next_resolved_location¶
Previously set resolved_location.
- Type:
ResolvedLocation, optional
- attribute: SchemaObjectReference¶
- is_inherited: bool = True¶
- next_no_participation_in_preserve_row: bool | None = None¶
- next_resolved_location: mstrio.utils.vldb_mixin.ResolvedLocation | None = None¶
- no_participation_in_preserve_row: bool¶
- resolved_location: ResolvedLocation = 'default'¶
- class mstrio.project_objects.datasets.helpers.AttributeTemplateUnit(id: str, name: str | None = None, alias: str | None = None, forms: list[mstrio.project_objects.datasets.helpers.AttributeFormReference] | None = None)¶
Bases:
TemplateUnit
Class representation of single attribute template unit.
- id¶
ID of the referenced attribute.
- Type:
str
- name¶
Name of attribute.
- Type:
str, optional
- alias¶
Alias for attribute.
- Type:
str, optional
- forms¶
Referenced attribute forms.
- Type:
list[AttributeFormReference], optional
- alias: str | None = None¶
- forms: list[mstrio.project_objects.datasets.helpers.AttributeFormReference] | None = None¶
- id: str¶
- name: str | None = None¶
- class mstrio.project_objects.datasets.helpers.CubeOptions(data_languages: ~mstrio.project_objects.datasets.helpers.DataLanguages = <factory>, data_refresh: ~mstrio.project_objects.datasets.helpers.DataRefreshType = DataRefreshType.REPLACE, data_partition: ~mstrio.project_objects.datasets.helpers.DataPartition = <factory>)¶
Bases:
Dictable
Class representation of cube options for cube.
- data_languages¶
Information related to data languages configuration.
- Type:
DataLanguages, optional
- data_refresh¶
Type of data refresh operation, default ‘DataRefreshType.REPLACE’.
- Type:
DataRefreshType, optional
- data_partition¶
Object which represents information about data partition.
- Type:
DataPartition, optional
- data_languages: DataLanguages¶
- data_partition: DataPartition¶
- data_refresh: DataRefreshType = 'replace'¶
- class mstrio.project_objects.datasets.helpers.DataLanguageType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of data language configuration type.
- ALL_PROJECT_DATA_LANGUAGE = 'all_project_data_language'¶
- PROJECT_DEFAULT = 'project_default'¶
- SPECIFIC_LANGUAGES = 'specific_languages'¶
- class mstrio.project_objects.datasets.helpers.DataLanguages(data_language_type: ~mstrio.project_objects.datasets.helpers.DataLanguageType = DataLanguageType.PROJECT_DEFAULT, selected_languages: list[str] | None = <factory>)¶
Bases:
Dictable
Class representation of data language configuration.
- data_language_type¶
Type of used data language configuration.
- Type:
- selected_languages¶
List with selected languages passed as abbreviations.
- Type:
list[str], optional
- data_language_type: DataLanguageType = 'project_default'¶
- selected_languages: list[str] | None¶
- class mstrio.project_objects.datasets.helpers.DataPartition(partition_attribute: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, number_of_partitions: int | None = None, fetch_data_slices_in_parallel: bool = False)¶
Bases:
Dictable
Class representation of data partition.
- partition_attribute¶
Reference to attribute used in partition.
- Type:
SchemaObjectReference, optional
- number_of_partitions¶
Number of data partitions.
- Type:
int, optional
- fetch_data_slices_in_parallel¶
Bool indicating whether to fetch data in parallel, default False.
- Type:
bool, optional
- fetch_data_slices_in_parallel: bool = False¶
- classmethod from_dict(source: dict[str, Any], connection: Optional[Connection] = None, to_snake_case: bool = True) T ¶
Initialize DataPartition object from dictionary.
- number_of_partitions: int | None = None¶
- partition_attribute: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- to_dict(camel_case: bool = True) dict ¶
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.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.project_objects.datasets.helpers.DataRefreshType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of data refresh operation.
- ADD = 'add'¶
- DYNAMIC_REFRESH = 'dynamic_refresh'¶
- REPLACE = 'replace'¶
- UPSERT = 'upsert'¶
- class mstrio.project_objects.datasets.helpers.JoinType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of metric joining operation.
- INNER = 'inner'¶
- OUTER = 'outer'¶
- class mstrio.project_objects.datasets.helpers.MetricElement(id: str, name: str | None = None, alias: str | None = None)¶
Bases:
Dictable
Class representation of single metric element.
- id¶
ID of the referenced metric.
- Type:
str
- name¶
Name of metric.
- Type:
str, optional
- alias¶
Alias for metric.
- Type:
str, optional
- alias: str | None = None¶
- id: str¶
- name: str | None = None¶
- to_dict(camel_case: bool = True) dict ¶
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.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.project_objects.datasets.helpers.MetricJoinType(metric: SchemaObjectReference, join_type: JoinType, resolved_location: ResolvedLocation = ResolvedLocation.DEFAULT, is_inherited: bool = True, next_join_type: mstrio.project_objects.datasets.helpers.JoinType | None = None, next_resolved_location: mstrio.utils.vldb_mixin.ResolvedLocation | None = None)¶
Bases:
Dictable
Class representation of single joining operation for metric.
- metric¶
Reference to the metric used for joining.
- Type:
- resolved_location¶
Type of location where value of related VLDB setting was last time resolved.
- Type:
ResolvedLocation, optional
- is_inherited¶
Whether the related VLDB setting value is inherited from other objects or not. If False value is set on the object. If True, value is inherited from other objects.
- Type:
bool, optional
- next_resolved_location¶
Previously set resolved_location.
- Type:
ResolvedLocation, optional
- is_inherited: bool = True¶
- metric: SchemaObjectReference¶
- next_join_type: mstrio.project_objects.datasets.helpers.JoinType | None = None¶
- next_resolved_location: mstrio.utils.vldb_mixin.ResolvedLocation | None = None¶
- resolved_location: ResolvedLocation = 'default'¶
- class mstrio.project_objects.datasets.helpers.MetricTemplateUnit(elements: list[mstrio.project_objects.datasets.helpers.MetricElement])¶
Bases:
TemplateUnit
Class representation of single metric element.
- elements¶
List containing metric elements used in template.
- Type:
list[MetricElement]
- elements: list[mstrio.project_objects.datasets.helpers.MetricElement]¶
- class mstrio.project_objects.datasets.helpers.Template(rows: list[mstrio.project_objects.datasets.helpers.TemplateUnit] = <factory>, columns: list[mstrio.project_objects.datasets.helpers.TemplateUnit] = <factory>, page_by: list[mstrio.project_objects.datasets.helpers.TemplateUnit] = <factory>)¶
Bases:
Dictable
Class representation of single template.
- rows¶
List containing attribute and metric elements used in template rows.
- Type:
list[TemplateUnit], optional
- columns¶
List containing attribute and metric elements used in template columns.
- Type:
list[TemplateUnit], optional
- page_by¶
List containing attribute elements used in template for paging.
- Type:
list[TemplateUnit], optional
- columns: list[mstrio.project_objects.datasets.helpers.TemplateUnit]¶
- page_by: list[mstrio.project_objects.datasets.helpers.TemplateUnit]¶
- class mstrio.project_objects.datasets.helpers.TemplateUnit¶
Bases:
Dictable
Class representation of single template unit.
- static dispatch(source, connection: mstrio.connection.Connection | None = None) type[mstrio.project_objects.datasets.helpers.TemplateUnit] ¶
- to_dict(camel_case: bool = True) dict ¶
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.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.project_objects.datasets.helpers.TemplateUnitType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of single template unit.
- ATTRIBUTE = 'attribute'¶
- CONSOLIDATION = 'consolidation'¶
- CUSTOM_GROUP = 'custom_group'¶
- DIMENSION = 'dimension'¶
- METRICS = 'metrics'¶
- PROMPT = 'prompt'¶
- RAW_UNIT = 'raw_unit'¶
- class mstrio.project_objects.datasets.helpers.TimeBasedSettings(timezone: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, calendar: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, enable_timezone_and_calendar_reporting: bool = True)¶
Bases:
Dictable
Class representation of time based settings.
- timezone¶
Reference to timezone object or None.
- Type:
SchemaObjectReference, optional
- calendar¶
Reference to calendar object or None.
- Type:
SchemaObjectReference, optional
- enable_timezone_and_calendar_reporting¶
Bool indicating whether to enable timezone and calendar reporting, default True.
- Type:
bool, optional
- calendar: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- enable_timezone_and_calendar_reporting: bool = True¶
- classmethod from_dict(source: dict[str, Any], connection: Optional[Connection] = None, to_snake_case: bool = True) T ¶
Initialize TimeBasedSettings object from dictionary.
- timezone: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
mstrio.project_objects.datasets.olap_cube module¶
- class mstrio.project_objects.datasets.olap_cube.OlapCube(connection: Connection, id: str, name: str | None = None, instance_id: str | None = None, parallel: bool = True, progress_bar: bool = True, show_expression_as: mstrio.modeling.expression.enums.ExpressionFormat | str = ExpressionFormat.TREE, show_filter_tokens: bool = False)¶
Bases:
ModelVldbMixin
,_Cube
Manage single table cube - according to EnumDSSXMLObjectSubTypes its subtype is 776 (DssXmlSubTypeReportCube). It inherits all properties from Cube.
- connection¶
MicroStrategy connection object returned by connection.Connection().
- id¶
Identifier of a pre-existing cube.
- Type:
str
- instance_id¶
Identifier of a cube instance if already initialized, None by default.
- Type:
str
- name¶
Name of the OlapCube.
- Type:
str
- size¶
Size of cube.
- Type:
int
- status¶
Status of cube.
- Type:
int
- path¶
Full path of the cube on environment.
- Type:
str
- owner_id¶
ID of cube’s owner.
- Type:
str
- attributes¶
All attributes of cube.
- Type:
list
- metrics¶
All metrics of cube.
- Type:
list
- attr_elements¶
All attributes elements of cube.
- Type:
list
- selected_attributes¶
IDs of filtered attributes.
- Type:
list
- selected_metrics¶
IDs of filtered metrics.
- Type:
list
- selected_attr_elements¶
IDs of filtered attribute elements.
- Type:
list
- dataframe¶
Content of a cube extracted into a Pandas DataFrame.
- Type:
DataFrame
- template¶
Template defining OLAP Cube structure with references to attributes in rows and to metrics in columns.
- Type:
- filter¶
Filtering element for OLAP Cube, needs to be in either ‘tree’ or ‘tokens’ format. If both are provided, only ‘tree’ is used.
- Type:
- options¶
Options specifying the behavior of cube. Includes possibilities for setting languages, refresh of data and partitioning by attribute.
- Type:
- advanced_properties¶
Properties containing metric join type for every metric and attribute join type for every attribute provided in the template.
- Type:
- time_based_settings¶
Settings of timezone and calendar objects specified with references by ID.
- Type:
- show_expression_as¶
Specify how expressions should be presented, default ‘ExpressionFormat.TREE’. Available values: - ExpressionFormat.TREE.
(expression is returned in text and tree formats)
- ExpressionFormat.TOKENS.
(expression is returned in text and tokens formats)
- Type:
- show_filter_tokens¶
Specify whether ‘filter’ is returned in ‘tokens’ format, along with text and tree formats, default False. - If omitted or False, only text and tree formats are
returned.
If True, all text, ‘tree’ and tokens formats are returned.
- Type:
bool
- alter(name: str | None = None, description: str | None = None, abbreviation: str | None = None, template: mstrio.project_objects.datasets.helpers.Template | dict | None = None, filter: mstrio.modeling.expression.expression.Expression | dict | None = None, options: mstrio.project_objects.datasets.helpers.CubeOptions | dict | None = None, time_based_settings: mstrio.project_objects.datasets.helpers.TimeBasedSettings | dict | None = None) None ¶
Alter OLAP Cube properties by providing new name, description, abbreviation, template, filter, options or time_based_settings parameters.
Note
All types of expressions can be represented in the form of tokens, but some expressions with type predicate are yet not supported to be used for creation or modification in tokens form. For example: ‘expression_nodes.ElementListPredicate’ or ‘expression_nodes.FilterQualificationPredicate’ and some cases other involving embedded objects. Expected errors while be thrown in such cases.
- Parameters:
name (str, optional) – New name for the OLAP Cube.
description (str, optional) – New description for the OLAP Cube.
abbreviation (str, optional) – New abbreviation for the OLAP Cube.
template (Template, dict, str, optional) – Template defining OLAP Cube structure with references to attributes in rows and to metrics in columns.
filter (Expression, dict, optional) – Filtering element for OLAP Cube, needs to be in either ‘tree’ or ‘tokens’ format. If both are provided, only ‘tree’ is used.
options (CubeOptions, dict, optional) – Options specifying the behavior of cube. Includes possibilities for setting languages, refresh of data and partitioning by attribute.
time_based_settings (TimeBasedSettings, dict, optional) – Settings of timezone and calendar objects specified with references by ID.
- Raises:
ValueError – When arguments for altering were not provided or given template is empty.
helper.IServerError – When there was an error on IServer side when trying to alter an OLAP Cube.
- Returns:
None
- classmethod available_attribute_forms(connection: Connection, basic_info_only: bool = True, to_dataframe: bool = False) list[dict] | list[pandas.core.frame.DataFrame] ¶
Get all attribute forms available on I-Server. :param connection: MicroStrategy connection object returned by
connection.Connection()
- Parameters:
basic_info_only (boolean, optional) – When True (default value) only values of id, name and type will be returned for each attribute form. When False, then all properties of each attribute form will be returned.
to_dataframe – When False (default value) then attribute forms are returned as a list of dictionaries. When True then attribute forms are returned as Pandas ‘DataFrame’.
- Returns:
List of attribute forms or attribute forms as Pandas DataFrame.
- classmethod available_attributes(connection: Connection, basic_info_only: bool = True, to_dataframe: bool = False) list[dict] | list[pandas.core.frame.DataFrame] ¶
Get all attributes available on I-Server. :param connection: MicroStrategy connection object returned by
connection.Connection()
- Parameters:
basic_info_only (boolean, optional) – When True (default value) only values of id, name and type will be returned for each attribute. When False, then all properties of each attribute will be returned.
to_dataframe – When False (default value) then attributes are returned as a list of dictionaries. When True then attributes are returned as Pandas ‘DataFrame’.
- Returns:
List of attributes or attributes as Pandas DataFrame.
- classmethod available_metrics(connection: Connection, basic_info_only: bool = True, to_dataframe: bool = False) list[dict] | list[pandas.core.frame.DataFrame] ¶
Get all metrics available on I-Server. :param connection: MicroStrategy connection object returned by
connection.Connection()
- Parameters:
basic_info_only (boolean, optional) – When True (default value) only values of id, name and type will be returned for each metric. When False, then all properties of each metric will be returned.
to_dataframe – When False (default value) then metrics are returned as a list of dictionaries. When True then metrics are returned as Pandas ‘DataFrame’.
- Returns:
List of attributes or attributes as Pandas DataFrame.
- classmethod create(connection: Connection, name: str, folder_id: str, description: str | None = None, template: mstrio.project_objects.datasets.helpers.Template | dict | None = None, filter: mstrio.modeling.expression.expression.Expression | dict | None = None, options: mstrio.project_objects.datasets.helpers.CubeOptions | dict | None = None, advanced_properties: mstrio.project_objects.datasets.helpers.AdvancedProperties | dict | None = None, time_based_settings: mstrio.project_objects.datasets.helpers.TimeBasedSettings | dict | None = None, template_cube: Optional[Union[OlapCube, str]] = None, show_expression_as: mstrio.modeling.expression.enums.ExpressionFormat | str = ExpressionFormat.TREE, show_filter_tokens: bool = False) mstrio.project_objects.datasets.olap_cube.OlapCube | None ¶
Create an OLAP Cube by defining its name, destination folder ID, description, attributes and metrics or template from ‘Template’ class to specify structure of cube additionally providing filter, options, advanced properties and time based settings.
Note
All types of expressions can be represented in the form of tokens, but some expressions with type predicate are yet not supported to be used for creation or modification in tokens form. For example: ‘expression_nodes.ElementListPredicate’ or ‘expression_nodes.FilterQualificationPredicate’ and some cases other involving embedded objects. Expected errors while be thrown in such cases.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection().
name (str) – OLAP Cube name.
folder_id (str) – ID of the folder where OLAP Cube should be saved.
description (str, optional) – OLAP Cube description.
template (Template, dict, optional) – Template defining OLAP Cube structure with references to attributes in rows and to metrics in columns.
filter (Expression, dict, optional) – Filtering element for OLAP Cube, needs to be in either ‘tree’ or ‘tokens’ format. If both are provided, only ‘tree’ is used.
options (CubeOptions, dict, optional) – Options specifying the behavior of cube. Includes possibilities for setting languages, refresh of data and partitioning by attribute.
advanced_properties (AdvancedProperties, dict, optional) – Properties containing metric join type for every metric and attribute join type for every attribute provided in the template.
time_based_settings (TimeBasedSettings, dict, optional) – Settings of timezone and calendar objects specified with references by ID.
template_cube (OlapCube, str, optional) – If specified, a newly created OLAP Cube will inherit its template from a provided OlapCube object. A filter of the referenced cube will be used in the case when a ‘filter’ parameter was not specified.
show_expression_as (ExpressionFormat, str, optional) –
Specify how expressions should be presented, default ‘ExpressionFormat.TREE’. Available values: - None.
(expression is returned in ‘text’ format)
- ExpressionFormat.TREE or tree.
(expression is returned in text and tree formats)
- ExpressionFormat.TOKENS or tokens.
(expression is returned in text and tokens formats)
show_filter_tokens (bool, optional) –
Specify whether ‘filter’ is returned in ‘tokens’ format, along with text and tree formats, default False. - If omitted or False, only text and tree formats are
returned.
If True, all text, ‘tree’ and tokens formats are returned.
- Raises:
ValueError – When provided template is empty.
- Returns:
- Newly created OLAP Cube or None in case of incorrectly provided
arguments.
- export_sql_view()¶
Export SQL View of an OLAP Cube. :returns: SQL View of an OLAP Cube.
- list_attribute_forms() list[dict[list[tuple], str]] ¶
Listing forms for every attribute specified in template. If default forms for attribute were used, string indicating that will be returned instead of forms.
- Returns:
List with dicts containing attribute name as key and forms as values or string indicating that they are default.
- publish() Job ¶
Publish an OLAP Cube. Request to publish an OLAP Cube is an asynchronous operation, so the result of it can be seen after calling method refresh_status() inherited from Cube class. :returns: Job instance.
- remove_partition_attribute() None ¶
Remove assigned to OLAP Cube partition attribute.
- Returns:
None
- set_partition_attribute(attribute: mstrio.modeling.schema.attribute.attribute.Attribute | str) None ¶
Assign new partition attribute to OLAP Cube.
- Parameters:
attribute (Attribute, str) – Partition attribute that will be set, could be provided by ID or with ‘Attribute’ object.
- Returns:
None
- mstrio.project_objects.datasets.olap_cube.list_olap_cubes(connection: Connection, name: str | None = None, search_pattern: mstrio.object_management.search_enums.SearchPattern | int = SearchPattern.CONTAINS, project_id: str | None = None, project_name: str | None = None, to_dictionary: bool = False, limit: int | None = None, **filters) list[mstrio.project_objects.datasets.olap_cube.OlapCube] | list[dict] ¶
Get list of OlapCube objects or dicts with them. Optionally filter cubes by specifying ‘name’. Optionally use to_dictionary to choose output format. Wildcards available for ‘name’:
? - any character * - 0 or more of any characters e.g. name = ?onny will return Sonny and Tonny
Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted. .. note:
When `project_id` is `None` and `project_name` is `None`, then its value is overwritten by `project_id` from `connection` object.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection()
name (string, optional) – value the search pattern is set to, which will be applied to the names of olap cubes being searched
search_pattern (SearchPattern enum or int, optional) – pattern to search for, such as Begin With or Contains. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is BEGIN WITH (4).
project_id (str, optional) – Project ID
project_name (str, optional) – Project name
to_dictionary (bool, optional) – If True returns dict, by default (False) returns OlapCube objects
limit (integer, optional) – limit the number of elements returned. If None all object are returned.
**filters – Available filter parameters: [‘id’, ‘name’, ‘type’, ‘subtype’, ‘date_created’, ‘date_modified’, ‘version’, ‘owner’, ‘ext_type’, ‘view_media’, ‘certified_info’]
- Returns:
list with OlapCubes or list of dictionaries
mstrio.project_objects.datasets.super_cube module¶
- class mstrio.project_objects.datasets.super_cube.SuperCube(connection: Connection, id: str | None = None, name: str | None = None, description: str | None = None, instance_id: str | None = None, progress_bar: bool = True, parallel: bool = True)¶
Bases:
_Cube
,CertifyMixin
Manage multiple table cube (MTDI aka Super Cube) - according to EnumDSSXMLObjectSubTypes its subtype is 779 (DssXmlSubTypeReportEmmaCube). It inherits all properties from Cube.
- connection¶
MicroStrategy connection object returned by connection.Connection().
- id¶
Identifier of a pre-existing cube.
- instance_id¶
Identifier of a cube instance if already initialized, None by default.
- Type:
str
- name¶
Name of the SuperCube.
- description¶
Description given to the SuperCube.
- id¶
Unique identifier for the super cube. Used to update a existing super cube or generated after creating a new super cube. (deprecated)
- upload_body¶
upload body of super cube
- Type:
string
- session_id¶
ID of session used for uploading and publishing super cube
- Type:
string
- size¶
size of cube
- Type:
integer
- status¶
status of cube
- Type:
integer
- path¶
full path of the cube on environment
- Type:
string
- owner_id¶
ID of cube’s owner
- Type:
string
- attributes¶
all attributes of cube
- Type:
list
- metrics¶
all metrics of cube
- Type:
list
- attr_elements¶
all attributes elements of cube
- Type:
list
- selected_attributes¶
IDs of filtered attributes
- Type:
list
- selected_metrics¶
IDs of filtered metrics
- Type:
list
- selected_attr_elements¶
IDs of filtered attribute elements
- Type:
list
- dataframe¶
content of a cube extracted into a Pandas DataFrame
- Type:
object
- table_definition¶
- add_table(name, data_frame, update_policy, to_metric=None, to_attribute=None)¶
Add a Pandas.DataFrame to a collection of tables which are later used to populate the MicroStrategy super cube with data.
- Parameters:
name (str) – Logical name of the table that is visible to users of the super cube in MicroStrategy.
data_frame (
pandas.DataFrame
) – Pandas DataFrame to add or update.update_policy (str) – Update operation to perform. One of ‘add’ (inserts new, unique rows), ‘update’ (updates data in existing rows and columns), ‘upsert’ (updates existing data and inserts new rows), or ‘replace’ (replaces the existing data with new data).
to_metric (optional,
list
of str) – By default, Python numeric data types are treated as metrics while character and date types are treated as attributes. For example, a column of integer-like strings (“1”, “2”, “3”) would, by default, be an attribute. If the intent is to format this data as a metric, provide the respective column name as a string in a list to the to_metric parameter.to_attribute (optional,
list
of str) – Logical opposite of to_metric. Helpful for formatting an integer-based row identifier as a primary key in the super cube.
- create(folder_id: str | None = None, auto_upload: bool = True, auto_publish: bool = True, chunksize: int = 100000, force: bool = False, attribute_forms: list[mstrio.project_objects.datasets.super_cube.SuperCubeAttribute] | None = None) None ¶
Create a new super cube and initialize cube object after successful creation. This function does not return new super cube, but it updates object inplace.
- Parameters:
folder_id (str, optional) – ID of the shared folder in which the super cube will be created. If None, defaults to the user’s My Reports folder.
auto_upload (bool, optional) – If True, automatically uploads the data to the I-Server. If False, simply creates the super cube definition but does not upload data to it.
auto_publish (bool, optional) – If True, automatically publishes the data used to create the super cube definition. If False, simply creates the super cube but does not publish it. To publish the super cube, data has to be uploaded first.
chunksize (int, optional) – Number of rows to transmit to the I-Server with each request when uploading.
force (bool, optional) – If True, skip checking if a super cube already exist in the folder with the given name. Defaults to False.
attribute_forms (list[SuperCubeAttribute], optional) – list
SuperCubeAttribute (of instances of) –
to (it contains mapping of columns) –
not (different forms of the same attribute. If this argument is) –
provided (name. If it is) –
column (a separate attribute is created for every distinct) –
provided –
to –
that (attributes as different form of an attribute. For all columns) –
expression (are not part of any attribute's form) –
attribute (separate) –
created. (will be) –
- export_sql_view() str ¶
Export SQL View of a Super Cube.
- Returns:
SQL View of a Super Cube.
- publish() bool ¶
Publish the uploaded data to the selected super cube.
Note
A super cube can be published just once.
- Returns:
True if the data was published successfully, else False.
- publish_status()¶
Check the status of data that was uploaded to a super cube.
- Returns: status: The status of the publication process as a dictionary.
In the ‘status’ key, “1” denotes completion.
- remove_table(name)¶
Removes a table from a collection of tables which are later used to populate the MicroStrategy super cube with data.
- Note: this operation is executed locally and is used only to prepare
data before sending it to server. You can check current state of tables with property tables.
- Parameters:
name (str) – Logical name of the table that is visible to users of the super cube in MicroStrategy.
- reset_session()¶
Reset upload session.
- save_as(name: str, description: str | None = None, folder_id: str | None = None, table_name: str | None = None) SuperCube ¶
Creates a new single-table cube with the data frame stored in the SuperCube instance SuperCube.dataframe.
- Parameters:
name (str) – Name of cube.
description (str) – Description of the cube.
folder_id (str, optional) – ID of the shared folder that the super cube should be created within. If None, defaults to the user’s My Reports folder.
table_name (str, optional) – Name of the table. If None (default), the first table name of the original cube will be used.
- update(chunksize: int = 100000, auto_publish: bool = True)¶
Updates a super cube with new data.
- Parameters:
chunksize (int, optional) – Number of rows to transmit to the server with each request.
auto_publish – If True, automatically publishes the data used to update the super cube definition to the super cube. If False, simply updates the super cube but does not publish it.
- static upload_status(connection: Connection, id: str, session_id: str)¶
Check the status of data that was uploaded to a super cube.
- Parameters:
connection (Optional[Connection]) – MicroStrategy connection object returned by connection.Connection().
id (Optional[str]) – Identifier of a pre-existing super cube.
session_id (Optional[str]) – Identifier of the server session used for collecting uploaded data.
- Returns:
- The status of the publication process as a dictionary. In
the ‘status’ key, “1” denotes completion.
- Return type:
status
- class mstrio.project_objects.datasets.super_cube.SuperCubeAttribute(name: str, forms: list[mstrio.project_objects.datasets.super_cube.SuperCubeAttributeForm])¶
Bases:
object
A class representing a multiform attribute for Super Cubes.
- name¶
a name of multiform attribute
- Type:
str
- forms¶
a list of attribute forms
- Type:
list[SuperCubeAttributeForm]
- name: str¶
- to_dict()¶
- class mstrio.project_objects.datasets.super_cube.SuperCubeAttributeForm(category: str, expressions: list[mstrio.project_objects.datasets.super_cube.SuperCubeFormExpression])¶
Bases:
object
A class representing an attribute form for used to define multiform attributes for Super Cubes.
- category¶
form’s category
- Type:
str
- expressions¶
list of form expressions
- Type:
list[SuperCubeFormExpressions]
- category: str¶
- expressions: list[mstrio.project_objects.datasets.super_cube.SuperCubeFormExpression]¶
- to_dict()¶
- class mstrio.project_objects.datasets.super_cube.SuperCubeFormExpression(table: str, column: str)¶
Bases:
object
A class representing a form expression used to define multiform attributes for Super Cubes. Links an attribute form to the column in the table.
- table¶
name of a table
- Type:
str
- column¶
name of a column
- Type:
str
- column: str¶
- table: str¶
- to_dict()¶
- mstrio.project_objects.datasets.super_cube.list_super_cubes(connection: Connection, name: str | None = None, search_pattern: mstrio.object_management.search_enums.SearchPattern | int = SearchPattern.CONTAINS, project_id: str | None = None, project_name: str | None = None, to_dictionary: bool = False, limit: int | None = None, **filters) list[mstrio.project_objects.datasets.super_cube.SuperCube] | list[dict] ¶
Get list of SuperCube objects or dicts with them. Optionally filter cubes by specifying ‘name’.
Optionally use to_dictionary to choose output format.
- Wildcards available for ‘name’:
? - any character * - 0 or more of any characters e.g. name = ?onny will return Sonny and Tonny
Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted.
Note
When project_id is None and project_name is None, then its value is overwritten by project_id from connection object.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection()
name (string, optional) – value the search pattern is set to, which will be applied to the names of super cubes being searched
search_pattern (SearchPattern enum or int, optional) – pattern to search for, such as Begin With or Contains. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is BEGIN WITH (4).
project_id (string, optional) – Project ID
project_name (string, optional) – Project name
to_dictionary (bool, optional) – If True returns dict, by default (False) returns SuperCube objects
limit (integer, optional) – limit the number of elements returned. If None all object are returned.
**filters – Available filter parameters: [‘id’, ‘name’, ‘type’, ‘subtype’, ‘date_created’, ‘date_modified’, ‘version’, ‘owner’, ‘ext_type’, ‘view_media’, ‘certified_info’]
- Returns:
list with SuperCubes or list of dictionaries