deepinsight.timer package

Submodules

deepinsight.timer.step module

exception deepinsight.timer.step.StepFailedException(message)

Bases: Exception

class deepinsight.timer.step.StepHandle(step, fail_fatal)

Bases: object

Handle to a timer step running in DeepInsight. To get a Step object, call run_step() on a Timer object, or call one of its step launching methods.

get_result()
is_done()

Checks whether a running step is finished

run()

Fully runs the step synchronously and returns its result.

If the step failed, and fail_fatal is True, an Exception is raised.

start()

Launches the execution of the step

wait_for_completion(step_future=None)

Awaits the termination of the step and returns its result. If the step failed, an Exception is raised.

class deepinsight.timer.step.StepResult(data)

Bases: object

count_warnings()
get_data()

Returns the raw data for the result of this step. Note that the returned object does not have any stable guaranteed structure

get_error_message()
get_outcome()
get_warnings_count_by_type()

deepinsight.timer.timer module

class deepinsight.timer.timer.Timer

Bases: object

Handle to the current (running) timer.

execute_sql(connection, sql, step_name=None, vasync=False, fail_fatal=True)

Executes a sql query

Parameters:
  • connection – name of the DeepInsight connection to run the query one
  • sql – the query to run
get_all_variables()

Returns a dictionary of all variables (including the timer-specific values)

get_previous_steps_outputs()

Returns the results of the steps previously executed in this timer run. For example, if a SQL step ran before in the timer, and its name is ‘the_sql’, then the list returned by this function will be like:

[
    ...
    {
        'stepName': 'the_sql',
        'result': {
            'success': True,
            'hasResultset': True,
            'columns': [ {'type': 'int8', 'name': 'a'}, {'type': 'varchar', 'name': 'b'} ],
            'totalRows': 2,
            'rows': [
                        ['1000', 'min'],
                        ['2500', 'max']
                    ],
            'log': '',
            'endedOn': 0,
            'totalRowsClipped': False
        }
    },
    ...
]
run_step(step, vasync=False, fail_fatal=True)

Run a step in this timer.

There are 2 behaviors, depending on the value of the parameter ‘vasync’:

  • if vasync=False (the default), then the function waits until the step has finished running and returns the result of the step
  • if vasync=True, then the function launches a step run and returns immediately a StepHandle object, on which the user will need to call is_done() or wait_for_completion()
set_project_variables(project_id=None, step_name=None, vasync=False, fail_fatal=True, **kwargs)

Sets variables on the project. The variables are passed as named parameters to this function. For example:

s.set_project_variables(‘PROJ’, var1=’value1’, var2=True)

will add 2 variables var1 and var2 in the project’s variables, with values ‘value1’ and True respectively

set_timer_variables(**kwargs)

Define additional variables in this timer run

deepinsight.timer.trigger module

trigger.py : callbacks for custom triggers Copyright (c) 2013-2015 Dataiku SAS. All rights reserved.

class deepinsight.timer.trigger.Trigger

Bases: object

fire(state=None, params=None)

Activate the trigger. Optionally, a new value for the state can be passed in the ‘state’ parameter, and parameters for the timer run in the ‘params’ parameter. The state is saved by deepinsight and will be returned by get_trigger_state() in subsequent executions of the trigger.

get_trigger()

Returns the trigger definition

get_trigger_state()

Returns the current trigger state

Module contents

deepinsight.timer.get_data_home()