pyfarm.models.task module

Task Models

Models and interface classes related to tasks

class pyfarm.models.task.Task(**kwargs)[source]

Bases: flask_sqlalchemy.Model, pyfarm.models.core.mixins.ValidatePriorityMixin, pyfarm.models.core.mixins.ValidateWorkStateMixin, pyfarm.models.core.mixins.WorkStateChangedMixin, pyfarm.models.core.mixins.UtilityMixins, pyfarm.models.core.mixins.ReprMixin

Defines a task which a child of a Job. This table represents rows which contain the individual work unit(s) for a job.

REPR_COLUMNS = ('id', 'state', 'frame', 'project')
REPR_CONVERT_COLUMN = {'state': functools.partial(<function repr_enum at 0x7f32c181e620>, enum=['done', 'failed', 'paused', 'running', None])}
STATE_DEFAULT = None
STATE_ENUM = ['done', 'failed', 'paused', 'running', None]
agent
agent_id

Foreign key which stores Job.id

attempts

The number of attempts which have been made on this task. This value is auto incremented when state changes to a value synonymous with a running state.

static clear_error_state(target, new_value, old_value, initiator)[source]

Sets last_error column to None if the task’s state is ‘done’

failures

The number of times this task has failed. This value is auto incremented when state changes to a value synonymous with a failed state.

frame

The frame this Task will be executing.

hidden

hides the task from queue and web ui

id

Provides an id for the current row. This value should never be directly relied upon and it’s intended for use by relationships.

static increment_attempts(target, new_value, old_value, initiator)[source]
job

relationship attribute which retrieves the associated job for this task

job_id

Foreign key which stores Job.id

last_error

This column may be set when an error is present. The agent typically sets this column when the job type either can’t or won’t run a given task. This column will be cleared whenever the task’s state is returned to a non-error state.

log_associations
priority

The priority of the job relative to others in the queue. This is not the same as task priority.

configured by: job.priority

static reset_agent_if_failed_and_retry(target, new_value, old_value, initiator)[source]
sent_to_agent

Whether this task was already sent to the assigned agent

state

The state of the job with a value provided by WorkState

time_finished

Time the job was finished. This will be set when the last task finishes and reset if a job is requeued.

time_started

The time this job was started. By default this value is set when state is changed to an appropriate value or when a job is requeued.

time_submitted

The time the job was submitted. By default this defaults to using datetime.datetime.utcnow() as the source of submission time. This value will not be set more than once and will not change even after a job is requeued.

static update_failures(target, new_value, old_value, initiator)[source]