automation.job.TrainsJob

class trains.automation.job.TrainsJob

Create a new Task based in a base_task_id with a different set of parameters

Parameters
  • base_task_id (str) – Base task id to clone from.

  • parameter_override (dict) – Dictionary of parameters and values to set fo the cloned task.

  • task_overrides (dict) – Task object specific overrides.

  • tags (list) – Additional tags to add to the newly cloned task.

  • parent (str) – Set newly created Task parent task field, default: base_tak_id.

  • kwargs (dict) – Additional Task creation parameters.

abort()

Abort currently running job (can be called multiple times)

elapsed()

Return the time in seconds since job started. Return -1 if job is still pending

Returns

Seconds from start.

get_console_output(number_of_reports=1)

Return a list of console outputs reported by the Task. Returned console outputs are retrieved from the most updated console outputs.

Parameters

number_of_reports (int) – The number of reports to return, default 1, the last (most updated) console output.

Returns

List of strings each entry corresponds to one report.

get_metric(title, series)

Retrieve a specific scalar metric from the running Task.

Parameters
  • title (str) – Graph title (metric)

  • series (str) – Series on the specific graph (variant)

Returns

A tuple of min value, max value, last value

is_aborted()

Return True, if job is has executed and aborted.

Returns

True the task is currently in aborted state

is_completed()

Return True, if job is has executed and completed successfully.

Returns

True the task is currently in completed or published state

is_failed()

Return True, if job is has executed and failed.

Returns

True the task is currently in failed state

is_pending()

Return True, if job is waiting for execution.

Returns

True the task is currently is currently queued.

is_running()

Return True, if job is currently running (pending is considered False).

Returns

True, if the task is currently in progress.

is_stopped()

Return True, if job is has executed and is not any more.

Returns

True the task is currently one of these states, stopped / completed / failed / published.

iterations()

Return the last iteration value of the current job. ``-1 ``if job has not started yet.

Returns

Task last iteration.

launch(queue_name=None)

Send Job for execution on the requested execution queue

Parameters

queue_name (str) –

started()

Return True, if job already started, or ended. False, if created/pending.

Returns

False, if the task is currently in draft mode or pending.

status()

Return the Job Task current status, see Task.TaskStatusEnum

Returns

Task status Task.TaskStatusEnum in string.

task_id()

Return the Task id.

Returns

The Task ID.

wait(timeout=None, pool_period=30.0)

Wait until the task is fully executed (i.e., aborted/completed/failed)

Parameters
  • timeout – The maximum time (minutes) to wait for Task to finish.

  • pool_period – Check task status every pool_period seconds.

Returns

True, if Task finished.

worker()

Return the current worker id executing this Job. If job is pending, returns None.

Returns

ID of the worker executing / executed the job, or None if job is still pending.