mstrio > server > job_monitor

enum mstrio.server.job_monitor.DeliveryType(value)

Bases: AutoName

Valid values are as follows:

RESERVED = DeliveryType.RESERVED
EMAIL = DeliveryType.EMAIL
FILE = DeliveryType.FILE
PRINTER = DeliveryType.PRINTER
CUSTOM = DeliveryType.CUSTOM
INBOX = DeliveryType.INBOX
CLIENT = DeliveryType.CLIENT
CACHE = DeliveryType.CACHE
MOBILE = DeliveryType.MOBILE
BLACKBERRY = DeliveryType.BLACKBERRY
IPHONE = DeliveryType.IPHONE
IPAD = DeliveryType.IPAD
CAMPAIGN = DeliveryType.CAMPAIGN
SNAPSHOT = DeliveryType.SNAPSHOT
FTP = DeliveryType.FTP
ANDROID = DeliveryType.ANDROID
LAST_ONE = DeliveryType.LAST_ONE
COUNT = DeliveryType.COUNT
ALL_INCLUDING_SNAPSHOT = DeliveryType.ALL_INCLUDING_SNAPSHOT
class mstrio.server.job_monitor.Job(connection, id)

Bases: EntityBase

Python representation of a Job object. Note: Some functionality is missing when working with 11.3.2 I-Server

versions. To use all functionality 11.3.3 and up will be required. There are also some differences between 11.3.2 and 11.3.3+ Job attributes values.

Parameters:
connection

A Strategy One connection object

id

Job information id

description

Description of the job

status

Status of the job

type

Type of the job

object_id

Id of object

object_name

Name of object

object_type

Type of object

parent_id

Parent ID

childs_ids

Array of children IDs

subscription_recipient

Subscription recipient of the job

subscription_type

Subscription delivery type of the job

processing_unit_priority

Job Processing Unit Priority

step_id

Step ID of the job

user

Full name of the job initiator

user_id

ID of the job initiator

username

Username of the job initiator

project_name

Name of the project in which the job is active

project_id

Id of the project in which the job is active

pu_name

Processing Unit name

creation_time

Creation time of the job

elapsed_time

Time elapsed since the creation of the job in milliseconds (11.3.3+) or seconds (11.3.2)

step_elapsed_time

Time elapsed since the creation of the step in milliseconds

memory_usage

Memory usage of the job in bytes

client_machine

Client machine running the job

total_tasks

Total tasks of the job

completed_tasks

Completed tasks of the job

error_message

Error message for the job

error_time

Error time of the job

filter_name

Name of the filter for the job

sql

SQL of the job

subscription_owner

Subscription owner

template_name

Name of the template for the job

step_statistics

Step statistics for the job

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

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

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 (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) – A Strategy One 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 object of type T.

Return type:

T

kill()

Kill the job.

Returns:

True if successfully killed job, False otherwise.

Return type:

bool

list_properties(excluded_properties=None)

List Job object properties.

Parameters:

excluded_properties (list[str] | None) –

Return type:

dict

print()

Pretty Print all properties of the object.

Return type:

None

refresh_status()

Refresh the job status.

Return type:

None

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

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)

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

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

enum mstrio.server.job_monitor.JobStatus(value)

Bases: AutoName

Valid values are as follows:

READY = JobStatus.READY
EXECUTING = JobStatus.EXECUTING
WAITING = JobStatus.WAITING
COMPLETED = JobStatus.COMPLETED
ERROR = JobStatus.ERROR
CANCELING = JobStatus.CANCELING
STOPPED = JobStatus.STOPPED
WAITING_ON_GOVERNOR = JobStatus.WAITING_ON_GOVERNOR
WAITING_FOR_AUTOPROMPT = JobStatus.WAITING_FOR_AUTOPROMPT
WAITING_FOR_PROJECT = JobStatus.WAITING_FOR_PROJECT
WAITING_FOR_CACHE = JobStatus.WAITING_FOR_CACHE
WAITING_FOR_CHILDREN = JobStatus.WAITING_FOR_CHILDREN
WAITING_FOR_RESULTS = JobStatus.WAITING_FOR_RESULTS
LOADING_PROMPT = JobStatus.LOADING_PROMPT
RESOLVING_DESTINATION = JobStatus.RESOLVING_DESTINATION
DELIVERING = JobStatus.DELIVERING
EXPORTING = JobStatus.EXPORTING
CACHE_READY = JobStatus.CACHE_READY
WAITING_FOR_DI_FILE = JobStatus.WAITING_FOR_DI_FILE
WAITING_FOR_CONFLICT_RESOLVE = JobStatus.WAITING_FOR_CONFLICT_RESOLVE
STEP_PAUSING = JobStatus.STEP_PAUSING
enum mstrio.server.job_monitor.JobType(value)

Bases: AutoName

Valid values are as follows:

INTERACTIVE = JobType.INTERACTIVE
SUBSCRIPTION = JobType.SUBSCRIPTION
PREDICTIVE_CACHE = JobType.PREDICTIVE_CACHE
enum mstrio.server.job_monitor.ObjectType(value)

Bases: AutoName

Valid values are as follows:

OTHERS = ObjectType.OTHERS
REPORT = ObjectType.REPORT
CUBE = ObjectType.CUBE
DOCUMENT = ObjectType.DOCUMENT
DASHBOARD = ObjectType.DASHBOARD
enum mstrio.server.job_monitor.PUName(value)

Bases: AutoName

Valid values are as follows:

BROWSING = PUName.BROWSING
RESOLUTION = PUName.RESOLUTION
QUERY_EXECUTIONS = PUName.QUERY_EXECUTIONS
ANALYTICAL = PUName.ANALYTICAL
SQL_ENGINE = PUName.SQL_ENGINE
DATA_FORMATTING = PUName.DATA_FORMATTING
NCS = PUName.NCS
REST_ASYNCHRONOUS = PUName.REST_ASYNCHRONOUS
enum mstrio.server.job_monitor.SortBy(value)

Bases: Enum

Valid values are as follows:

ID_ASC = <SortBy.ID_ASC: '+id'>
ID_DESC = <SortBy.ID_DESC: '-id'>
TYPE_ASC = <SortBy.TYPE_ASC: '+type'>
TYPE_DESC = <SortBy.TYPE_DESC: '-type'>
STATUS_ASC = <SortBy.STATUS_ASC: '+status'>
STATUS_DESC = <SortBy.STATUS_DESC: '-status'>
USER_ASC = <SortBy.USER_ASC: '+user'>
USER_DESC = <SortBy.USER_DESC: '-user'>
DESCRIPTION_ASC = <SortBy.DESCRIPTION_ASC: '+description'>
DESCRIPTION_DESC = <SortBy.DESCRIPTION_DESC: '-description'>
OBJECT_TYPE_ASC = <SortBy.OBJECT_TYPE_ASC: '+objectType'>
OBJECT_TYPE_DESC = <SortBy.OBJECT_TYPE_DESC: '-objectType'>
OBJECT_ID_ASC = <SortBy.OBJECT_ID_ASC: '+objectId'>
OBJECT_ID_DESC = <SortBy.OBJECT_ID_DESC: '-objectId'>
SUBSCRIPTION_TYPE_ASC = <SortBy.SUBSCRIPTION_TYPE_ASC: '+subscriptionType'>
SUBSCRIPTION_TYPE_DESC = <SortBy.SUBSCRIPTION_TYPE_DESC: '-subscriptionType'>
PROCESSING_UNIT_PRIORITY_ASC = <SortBy.PROCESSING_UNIT_PRIORITY_ASC: '+processingUnitPriority'>
PROCESSING_UNIT_PRIORITY_DESC = <SortBy.PROCESSING_UNIT_PRIORITY_DESC: '-processingUnitPriority'>
CREATION_TIME_ASC = <SortBy.CREATION_TIME_ASC: '+creationTime'>
CREATION_TIME_DESC = <SortBy.CREATION_TIME_DESC: '-creationTime'>
COMPLETED_TASKS_ASC = <SortBy.COMPLETED_TASKS_ASC: '+completedTasks'>
COMPLETED_TASKS_DESC = <SortBy.COMPLETED_TASKS_DESC: '-completedTasks'>
PROJECT_ID_ASC = <SortBy.PROJECT_ID_ASC: '+projectId'>
PROJECT_ID_DESC = <SortBy.PROJECT_ID_DESC: '-projectId'>
PROJECT_NAME_ASC = <SortBy.PROJECT_NAME_ASC: '+projectName'>
PROJECT_NAME_DESC = <SortBy.PROJECT_NAME_DESC: '-projectName'>
SUBSCRIPTION_RECIPIENT_ASC = <SortBy.SUBSCRIPTION_RECIPIENT_ASC: '+subscriptionRecipient'>
SUBSCRIPTION_RECIPIENT_DESC = <SortBy.SUBSCRIPTION_RECIPIENT_DESC: '-subscriptionRecipient'>
MEMORY_USAGE_ASC = <SortBy.MEMORY_USAGE_ASC: '+memoryUsage'>
MEMORY_USAGE_DESC = <SortBy.MEMORY_USAGE_DESC: '-memoryUsage'>
ELAPSED_TIME_ASC = <SortBy.ELAPSED_TIME_ASC: '+elapsedTime'>
ELAPSED_TIME_DESC = <SortBy.ELAPSED_TIME_DESC: '-elapsedTime'>
enum mstrio.server.job_monitor.SortByV1(value)

Bases: Enum

Valid values are as follows:

JOB_TYPE = <SortByV1.JOB_TYPE: 'jobType'>
USER_FULL_NAME = <SortByV1.USER_FULL_NAME: 'userFullName'>
OBJECT_ID = <SortByV1.OBJECT_ID: 'objectId'>
STATUS = <SortByV1.STATUS: 'status'>
PROJECT_ID = <SortByV1.PROJECT_ID: 'projectId'>
PROJECT_NAME = <SortByV1.PROJECT_NAME: 'projectName'>
CREATION_TIME = <SortByV1.CREATION_TIME: 'creationTime'>
DESCRIPTION = <SortByV1.DESCRIPTION: 'description'>
JOB_ID = <SortByV1.JOB_ID: 'jobId'>
enum mstrio.server.job_monitor.SubscriptionType(value)

Bases: AutoName

Valid values are as follows:

RESERVED = SubscriptionType.RESERVED
EMAIL = SubscriptionType.EMAIL
PRINTER = SubscriptionType.PRINTER
CUSTOM = SubscriptionType.CUSTOM
INBOX = SubscriptionType.INBOX
CLIENT = SubscriptionType.CLIENT
CACHE = SubscriptionType.CACHE
MOBILE = SubscriptionType.MOBILE
MOBILE_BLACKBERRY = SubscriptionType.MOBILE_BLACKBERRY
MOBILE_IPHONE = SubscriptionType.MOBILE_IPHONE
MOBILE_IPAD = SubscriptionType.MOBILE_IPAD
CAMPAIGN = SubscriptionType.CAMPAIGN
SNAPSHOT = SubscriptionType.SNAPSHOT
FTP = SubscriptionType.FTP
MOBILE_ANDROID = SubscriptionType.MOBILE_ANDROID
LAST_ONE = SubscriptionType.LAST_ONE
COUNT = SubscriptionType.COUNT
ALL = SubscriptionType.ALL
ALL_INCLUDING_SNAPSHOT = SubscriptionType.ALL_INCLUDING_SNAPSHOT
mstrio.server.job_monitor.kill_all_jobs(connection, user=None, description=None, type=None, status=None, object_id=None, object_type=None, project=None, pu_name=None, subscription_type=None, subscription_recipient=None, memory_usage=None, elapsed_time=None, force=False, **filters)

Kill jobs filtered by passed fields

Parameters:
  • connection (object) –

    Strategy One connection object returned by

    connection.Connection()

    node(Node, str, optional): Node object or name, if not passed kill jobs

    on all nodes

  • user (User, str, optional) – Field to filter on job owner’s full name

  • match) ((exact) –

  • description (str, optional) – Field to filter on job description (partial match)

  • type (subscription) – Field to filter on job type (exact match),

  • status (JobStatus, optional) – Field to filter on job status (exact match)

  • object_id (str, optional) – Field to filter on object id (exact match)

  • object_type (ObjectType, optional) – Field to filter on object type (exact match)

  • project (Project, str, optional) – Field to filter on project name (exact match)

  • pu_name (PUName, optional) – Field to filter on processing unit name (exact match)

  • subscription_type (SubscriptionType, optional) – Field to filter on

  • type

  • subscription_recipient (User, str, optional) – Field to filter on subscription recipient’s full name (exact match)

  • memory_usage (str, optional) – Field to filter on the job elapsed time, for example ‘gt:100’ means filtering jobs with memory usage greater than to 100 MB. Valid operators are: gt - greater than lt - less than

  • elapsed_time (str, optional) – Field to filter on the job elapsed time, for example ‘gt:100’ means filtering jobs with elapsed time greater than 100 milliseconds(11.3.3+) or seconds(11.3.2). Valid operators: gt - greater than lt - less than

  • force (bool, optional) – Force flag

Returns:

object if all jobs were killed PartialSuccess: if not all jobs were killed MstrException: otherwise

Return type:

Success

mstrio.server.job_monitor.kill_jobs(connection, jobs)

Kill existing jobs by Job objects or job ids.

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

  • jobs (list[Union[Job, str]]) – List of Job objects or job ids to kill

Returns:

object if all jobs were killed PartialSuccess: if not all jobs were killed MstrException: otherwise

Return type:

Success

mstrio.server.job_monitor.list_jobs(connection, node=None, user=None, description=None, type=None, status=None, object_id=None, object_type=None, project=None, pu_name=None, subscription_type=None, subscription_recipient=None, memory_usage=None, elapsed_time=None, sort_by=None, to_dictionary=False, limit=None, **filters)

List jobs objects or job dictionaires. :param connection: Strategy One connection object returned by

connection.Connection()

Parameters:
  • node (Node, str, optional) – Node object or name, if not passed list jobs on all nodes

  • user (User, str, optional) – Field to filter on job owner’s full name

  • match) ((exact) –

  • description (str, optional) – Field to filter on job description (partial match)

  • type (subscription) – Field to filter on job type (exact match),

  • status (JobStatus, optional) – Field to filter on job status (exact match)

  • object_id (str, optional) – Field to filter on object type (exact match)

  • object_type (ObjectType, optional) – Field to filter on object type (exact match)

  • project (Project, str, optional) – Field to filter on project name (exact match)

  • pu_name (PUName, optional) – Field to filter on processing unit name (exact match)

  • subscription_type (SubscriptionType, optional) – Field to filter on

  • type

  • subscription_recipient (User, str, optional) – Field to filter on subscription recipient’s full name (exact match)

  • memory_usage (str, optional) – Field to filter on the job elapsed time, for example ‘gt:100’ means filtering jobs with memory usage greater than to 100 MB. Valid operators are: gt - greater than lt - less than

  • elapsed_time (str, optional) – Field to filter on the job elapsed time, for example ‘gt:100’ means filtering jobs with elapsed time greater than 100 milliseconds(11.3.3+) or seconds(11.3.2). Valid operators: gt - greater than lt - less than

  • sort_by (SortBy, optional) – Specify sorting criteria, for example SortBy.STATUS_ASC means sorting status is ascending order or SortBy.USER_DESC means sorting user in descending order. Currently, the server supports sorting only by single field.

  • to_dictionary (bool, optional) – if True, return Schedules as list of dicts

  • limit (int, optional) – maximum number of schedules returned

  • **filters (optional) – Local filter parameters

  • connection (object) –

Return type:

list[’Job’] | list[dict]

Examples

>>> list_jobs_v1(connection, duration='gt:100')
Returns:

list of Job objects or dictionaries.

Return type:

List[Job] | List[dict]

Parameters:
  • connection (Connection) –

  • node (Node | str | None) –

  • user (User | str | None) –

  • description (str | None) –

  • type (JobType | str | None) –

  • status (JobStatus | str | None) –

  • object_id (str | None) –

  • object_type (ObjectType | None) –

  • project (Project | str | None) –

  • pu_name (PUName | str | None) –

  • subscription_type (SubscriptionType | str | None) –

  • subscription_recipient (User | str | None) –

  • memory_usage (str | None) –

  • elapsed_time (str | None) –

  • sort_by (SortBy | str | None) –

  • to_dictionary (bool) –

  • limit (int | None) –

mstrio.server.job_monitor.list_jobs_v1(connection, node=None, project=None, status=None, job_type=None, user=None, object_id=None, sort_by=None, to_dictionary=False, limit=None, **filters)

List job objects or job dictionaries. Optionally filter list. NOTE: list_jobs can return up to 1024 jobs per request.

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

  • node (Node, str, optional) – Node object or name, if not passed list jobs on all nodes

  • project (str, Project, optional) – Project id or object to filter by

  • status (JobStatus, optional) – Job status to filter by

  • job_type (JobType, optional) – Job type to filter by

  • user (User, str, optional) – User object or full name to filter by

  • object_id (str, optional) – Object id to filter by

  • sort_by (SortBy, optional) – Specifies sorting criteria to sort by

  • to_dictionary (bool, optional) – if True, return Schedules as list of dicts

  • limit (int, optional) – maximum number of schedules returned.

  • **filters

    Available filter parameters:[id, description, status, jobType, duration, jobId, objectd] - duration(str, optional): Field to filter on the job elapsed time,

    for example ‘gt:100’ means filtering jobs with elapsed time greater than to 100 seconds. Valid operators: gt - greater than lt - less than

Return type:

list[’Job’] | list[dict]

Examples

>>> list_jobs_v1(connection, duration='gt:100')
Returns:

list of Job objects or dictionaries.

Return type:

List[Job] | List[dict]

Parameters:
  • connection (Connection) –

  • node (Node | str | None) –

  • project (Project | str | None) –

  • status (JobStatus | str | None) –

  • job_type (JobType | str | None) –

  • user (User | str | None) –

  • object_id (str | None) –

  • sort_by (SortBy | str | None) –

  • to_dictionary (bool) –

  • limit (int | None) –