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.

Methods

create_module([name, description, source, ...])

Create a new module in MAS.

define_steps(module)

Map MAS steps to Python methods.

delete(*args, **kwargs)

Send a DELETE request.

delete_module(item)

Delete a module instance.

execute_module_step(module, step[, return_dict])

Call a module step with the given parameters.

get(*args, **kwargs)

Send a GET request.

get_link(obj, rel)

Get link information from a resource.

get_module(item[, refresh])

Return a module instance.

get_module_step(module, step)

Details of a single step in a given module.

head(*args, **kwargs)

Send a HEAD request.

info()

Version and build information for the service.

is_available()

Check if the service is currently available.

is_uuid(id_)

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

list_module_steps(module)

List all steps defined for a module.

list_modules([filter, start, limit])

List all modules available in the environment.

post(*args, **kwargs)

Send a POST request.

put(*args, **kwargs)

Send a PUT request.

request(verb, path[, session, format_])

Send an HTTP request with a session.

request_link(obj, rel, **kwargs)

Request a link from a resource.

update_module(item)

Update a module instance.

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

Create a new module in MAS.

Parameters:
namestr
descriptionstr
sourcestr
languagestr { ‘python’, ‘ds2’ }
scopestr { ‘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:
modulestr 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:
modulestr or dict

Name, id, or dictionary representation of a module

stepstr

Name of the step

return_dictbool, optional

Whether the results should be returned as a dictionary instead of a tuple

kwargsany

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:
itemstr or dict

Name, ID, or dictionary representation of the module.

refreshbool, 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:
modulestr or dict

Name, id, or dictionary representation of a module

stepstr

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:
modulestr 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:
filterstr, optional
startint, optional

Zero-based index of the first item to return. Defaults to 0.

limitint, 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:
itemdict
Returns:
None