store_interface#

class predict_backend.store.store_interface.StoreInterface(flow_id, user, step_name=None, is_action=False, bucket_name=None, profile_name='govcloud')#

Bases: object

get_asset(label=None, type=None, name=None, time_created=None)#

Retrieve a saved Asset in Predict. :type label: Optional[str] :param label: The label of the Asset, defaults to None. :type type: Optional[AssetType] :param type: The type of asset, defaults to None. :type name: Optional[str] :param name: The name for the asset, defaults to None. :type time_created: Optional[str] :param time_created: The time the asset was created. This is especially optional and only necessary when you want

to receive an Asset by timestamp as well as other metadata, defaults to None.

Raises:

ValueError – If the asset label and type are both None.

Return type:

Asset

Returns:

The Asset object.

get_assets(label=None, type=None, name=None)#

Retrieve multiple saved Assets in Predict. Providing any of the attributes will filter all available assets to retrieve only the ones which match the given label, type, name, or combination of them. Providing none of these descriptors will retrieve all available assets.

Parameters:
  • label (Optional[str]) – The label of the Asset, defaults to None.

  • type (Optional[AssetType]) – The type of asset, defaults to None.

  • name (Optional[str]) – The name for the asset, defaults to None.

Return type:

List[Asset]

Returns:

List of Asset objects.

get_dataset(label=None, name=None)#

Get a Dataset Asset in Predict.

Parameters:
  • label (Optional[str]) – The label of the asset, defaults to None.

  • name (Optional[str]) – The name of the asset, defaults to None.

Return type:

Dataset

Returns:

The Dataset asset.

get_element(step_name, elem_title)#
Return type:

Element

get_element_by_id(step_name, elem_id)#
Return type:

Element

get_element_value(step_name, elem_title)#

Get the value of an element the user interacted with in Predict.

Parameters:
  • step_name (str) – The name of the step the element was in.

  • elem_title (str) – The title of the element to select.

Returns:

The value of that element interaction. This will differ by input element type.

get_explainer(label=None, name=None)#

Get a Explainer Asset in Predict.

Parameters:
  • label (Optional[str]) – The label of the asset, defaults to None.

  • name (Optional[str]) – The name of the asset, defaults to None.

Return type:

Explainer

Returns:

The Explainer asset.

get_input(name)#

Get a previously stored input value stored with save_output.

Parameters:

name (str) – The input name.

Raises:

ValueError – If the name is not not found in the database.

Returns:

The previously saved data.

get_model(label=None, name=None)#

Get a Model Asset in Predict.

Parameters:
  • label (Optional[str]) – The label of the asset, defaults to None.

  • name (Optional[str]) – The name of the asset, defaults to None.

Return type:

Model

Returns:

The Model asset.

get_page()#

Get the most up to date version of the page for this step.

Return type:

Page

Returns:

The most up to date Page for this step.

get_s3_asset(path)#

Retrieve an asset from a prespecified bucket. In order to use, please initialize the store interface with the bucket_name parameter.

Parameters:

path (str) – The path to the asset in the s3 bucket.

Returns:

returns the asset from s3

get_schema(label=None, name=None)#

Get a Schema Asset in Predict.

Parameters:
  • label (Optional[str]) – The label of the asset, defaults to None.

  • name (Optional[str]) – The name of the asset, defaults to None.

Return type:

Schema

Returns:

The Schema asset.

has_input(name)#
save_asset(asset)#
Save an Asset in Predict. This can be a Dataset or a Model or an “other” type asset.

This asset will persist across multiple flows in Predict.

Parameters:

asset (Asset) – The asset to save.

save_output(data, name)#

Save the intermediate value of some information for access in a later step

Parameters:
  • data (Union[DataFrame, Series, dict, int, float]) – The data to save.

  • name (str) – The label to use the access this data in a later step.

Raises:
  • ValueError – If the data passed in is no pickleable.

  • ValueError – An invalid persistence method is used.

update_page(page)#
Update a page.

This is usually called from within a step to dynamically update content on the page as the step is running.

Parameters:

page (Page) – The Page object containing updates.

update_page_from_input(user_input)#
update_page_from_live_card(section_title, card_id, **step_clients)#
Return type:

dict

update_progress(completion, message, page_update=False)#
Update the progress of the step as it’s running. It’s highly recommended

to use this when steps have operations that can take a long time.

Parameters:
  • completion – The progress to completion (0 to 100).

  • message – The message to show at this level of completion.

Returns:

True if the prgress message was sent sucessfully. False otherwise.

update_step_item(attribute, value)#
exception predict_backend.store.store_interface.TaskCancelledException#

Bases: Exception

message = 'This task has been cancelled'#
class predict_backend.store.store_interface.UnrestrictedStoreInterface(flow_id, user, step_name=None, is_action=False, bucket_name=None, profile_name='govcloud')#

Bases: StoreInterface

archive_flow(archive)#
cancel_step(page_update=False)#
check_user_inputs()#
delete_flow_instance()#
finalize_completed_flow()#
get_element_id(step_name, elem_title)#
Return type:

str

get_flow()#
get_previous_step_name()#
get_step()#
save_flow(flow_data)#
schedule_flow(scheduled_bool)#
update_current_step()#
update_flow_item_attributes(attributes)#
update_step_status(state, headless=False, page_update=False)#