sasctl.services.microanalytic_score#

A stateless, memory-resident, high-performance program execution service.

class sasctl._services.microanalytic_score.MicroAnalyticScore[source]#

Bases: Service

Micro Analytic Service (MAS) client.

classmethod create_module(name=None, description=None, source=None, language='python', scope='public')[source]#

Create a new module in MAS.

Parameters:
  • name (str)

  • description (str)

  • source (str)

  • language (str) – Choose from {'python','ds2'}

  • scope (str) – Choose from {'public','private'}

Returns:

RestObj

classmethod define_steps(module)[source]#

Map MAS steps to Python methods.

Defines python methods on a module that automatically call the corresponding MAS steps.

Parameters:

module (str or dict) – Name, id, or dictionary representation of a module

Returns:

RestObj – The module with additional methods defined.

classmethod delete_module(item)#

Delete a module instance.

Parameters:

item

Returns:

None

classmethod execute_module_step(module, step, return_dict=True, **kwargs)[source]#

Call a module step with the given parameters.

Parameters:
  • module (str or dict) – Name, id, or dictionary representation of a module

  • step (str) – Name of the step

  • return_dict (bool, optional) – Whether the results should be returned as a dictionary instead of a tuple

  • **kwargs – Passed as arguments to the module step

Returns:

Any – Results of the step execution. Returned as a dictionary if return_dict is True, otherwise returned as a tuple if more than one value is returned, otherwise the single value.

classmethod get_module(item, refresh=False)#

Return a module instance.

Parameters:
  • item (str or dict) – Name, ID, or dictionary representation of the module.

  • refresh (bool, optional) – Obtain an updated copy of the module.

Returns:

RestObj or None – A dictionary containing the module attributes or None.

Notes

If item is a complete representation of the module it will be returned unless refresh is set. This prevents unnecessary REST calls when data is already available on the client.

classmethod get_module_step(module, step)[source]#

Details of a single step in a given module.

Parameters:
  • module (str or dict) – Name, id, or dictionary representation of a module

  • step (str) – Name of the step

Returns:

RestObj

classmethod is_uuid(id_)[source]#

Check if the ID appears to be a valid MAS id.

Indicates whether id appears to be a correctly formatted ID. Does not check whether a module with id actually exists.

Parameters:

id (str)

Returns:

bool

Notes

Overrides the Service.is_uuid method since MAS modules do not currently use IDs that are actually UUIDs.

classmethod list_module_steps(module)[source]#

List all steps defined for a module.

Parameters:

module (str or dict) – Name, id, or dictionary representation of a module

Returns:

list – List of RestObj instances representing each step.

classmethod list_modules(filter=None, start=None, limit=None, **kwargs)#

List all modules available in the environment.

Parameters:
  • filter (str, optional)

  • start (int, optional) – Zero-based index of the first item to return. Defaults to 0.

  • limit (int, optional) – The maximum number of items to return. Defaults to 20.

Returns:

list – A list of dictionaries containing the modules.

Notes

See the filtering reference for details on the filter parameter.

classmethod update_module(item)#

Update a module instance.

Parameters:

item (dict)

Returns:

None