Context

Context defines all properties, dataframes, models and other data passed through pipeline steps.

  • properties are accessible on properties property.
  • output dataframe(s) use return statement.
  • input dataframe(s) get them by parameters or use dataframe property directly.
  • for model use the set_model statement : support only one model per script.
  • for plot use the set_model statement : support only one plot per script.
  • dataframes, models and additional plots used within the pipelines can also be accessed, read-only.

Attributes

NameTypeDescription
apiApiInterfaceapi instance with limited functionality accessible during runner execution.
configdictall Wizata custom.ini configuration keys.
dataframepandas.Dataframesingle instance of pandas Dataframe inputted as parameter.
dataframesdictdict of all dataframes parameters and generated by previously executed steps.
datapointsdictwizata_dsapi.Datapoint for each name (key) used in queries.
execution_iduuid.UUIDExecution ID currently processed.
grafana_apigrafana_client.GrafanaApiinstance of grafana api.
modelsdictdict of all models generated by previously executed steps.
nowdatetimeNow timestamp as used by the pipeline.
pipeline_iduuid.UUIDPipeline ID associated with the ongoing execution.
plotsdictdict of all plots generated by previously executed steps.
propertiesdictproperties dictionary containing useful information such as variables.
stepPipelineStepCurrently processed step definition.
templateTemplateTemplate if set on the pipeline.
registrationTwinRegistrationRegistration associated with the pipeline and the twin currently processed.
warningslistall warnings and error messages.

Methods

append()

append an object (pandas.Dataframe or any properties)

NameTypeDefaultDescription
keystrdictionary identifier - name inside your pipeline.
objML Model, Dataframe or any properties (must be JSON serializable type).
overwriteboolTrueby default - allow modifying an existing object. can be set to false.

current_dataframes()

current dataframes a dictionary with all current named dataframes specific for this script.

dataframes contains all accessible dataframes for the pipeline mapped.

single dataframe context is accessible with context.dataframe and is not named

get()

get key from either dataframes, models, plots or properties.

NameTypeDefaultDescription
keystr

return: None if not found.

get_model()

get model to be added to the context.

get_model_config()

extract model configuration from the context.

get_plot()

get plot set to be added to the context.

get_script_config()

extract script configuration from the context.

notify_execution()

notify the listeners and watchers on current execution status.

NameTypeDefaultDescription
executionExecution

notify_step()

notify the listeners and watchers on current step status.

NameTypeDefaultDescription
step_logExecutionStepLog

reset()

reset context between step execution - remove all step info, but keep all data.

set_model()

set model to be added to the context.

NameTypeDefaultDescription
trained_modelTrained Model to be stored as a pickled object.
input_columns
output_columnsNone
has_anomaliesFalse
scalerNoneScaler to be stored if necessary.

return: ML Model object prepared.

set_plot()

set plot to be added to the context.

NameTypeDefaultDescription
figurePlotly figure.
nameUnkwownName of the plot.

return: Plot object prepared.

write_log()

write log in console (only in experiment mode) - if running locally it will print in the console.

NameTypeDefaultDescription
messagestrmessage to write.
levelint7from 7=DEBUG, 6=INFO, 3=ERROR to 1=CRITICAL