Previous topic

stalker.models.tag.Tag

Next topic

stalker.models.task.TimeLog

This Page

stalker.models.task.Task

Inheritance diagram of stalker.models.task.Task

class stalker.models.task.Task(project=None, parent=None, depends=None, resources=None, watchers=None, start=None, end=None, duration=None, schedule_timing=None, schedule_unit='h', schedule_model=None, schedule_constraint=0, bid_timing=None, bid_unit=None, is_milestone=False, priority=500, **kwargs)[source]

Bases: stalker.models.entity.Entity, stalker.models.mixins.StatusMixin, stalker.models.mixins.ScheduleMixin, stalker.models.mixins.ReferenceMixin

Manages Task related data.

Introduction

Tasks are the unit of work that should be accomplished to complete a Project.

Stalker tries to follow the concepts stated in TaskJuggler.

Note

New in version 0.2.0:.

Parent-child relation in Tasks

Tasks can now have child Tasks. So you can create complex relations of Tasks to comply with your project needs.

Note

New in version 0.2.0:: References in Tasks

Tasks can now have References.

Initialization

A Task needs to be created with a Project instance. It is also valid if no project is supplied but there should be a parent Task passed to the parent argument. And it is also possible to pass both project and the parent task.

Because it will create an ambiguity, Stalker will raise a RuntimeWarning, if both project and task are given and the owner project of the given parent task is different then the supplied project instance. But again Stalker will warn the user but will continue to use the task as the parent and will correctly use the project of the given task as the project of the newly created task.

The following codes are a couple of examples for creating Task instances:

# with a project instance
task1 = Task(name='Schedule', project=proj1)

# with a parent task
task2 = Task(name='Documentation', parent=task1)

# or both
task3 = Task(name='Test', project=proj1, parent=task1)

# this will create a RuntimeWarning
task4 = Task(name='Test', project=proj2, parent=task1) # task1 is not a
                                                       # task of proj2
assert task4.project == proj1 # Stalker uses the task1.project for task4

# this will also create a RuntimeError
task3 = Task(name='Failure 2') # no project no parent, this is an orphan
                               # task.

Also initially Stalker will pin point the start value and then will calculate proper end and duration values by using the schedule_timing and schedule_unit attributes. But these values (start, end and duration) are temporary values for an unscheduled task. The final date values will be calculated by TaskJuggler in the auto scheduling phase.

Auto Scheduling

Stalker uses TaskJuggler for task scheduling. After defining all the tasks, Stalker will convert them to a single tjp file along with the recorded TimeLogs and let TaskJuggler to solve the scheduling problem.

During the auto scheduling (with TaskJuggler), the calculation of task duration, start and end dates are effected by the working hours setting of the Studio, the effort that needs to spend for that task and the availability of the resources assigned to the task.

A good practice for creating a project plan is to supply the parent/child and dependency relation between tasks and the effort and resource information per task and leave the start and end date calculation to TaskJuggler. It is also possible to use the length or duration values (set schedule_model to ‘effort’, ‘length’ or ‘duration’ to get the desired scheduling model).

The default schedule_model for Stalker tasks is ‘effort`, the default schedule_unit is hour and the default value of schedule_timing is defined by the stalker.config.Config.timing_resolution. So for a config where the timing_resolution is set to 1 hour the schedule_timing is 1.

To convert a Task instance to a TaskJuggler compatible string use the to_tjp` attribute. It will try to create a good representation of the Task by using the resources, schedule_model, schedule_timing and schedule_constraint attributes.

Task/Task Relation

A Task is called a container task if it has at least one child Task. And it is called a leaf task if it doesn’t have any children Tasks. Task which doesn’t have a parent called root_task.

The resources in a container task is meaningless, cause the resources are defined by the child tasks (Dev Note: this can still be used to populate the resource information to the children tasks as in TaskJuggler).

Although the values are not very important after TaskJuggler schedules a task, the start and end values for a container task is gathered from the child tasks. The start is equal to the earliest start value of the children tasks, and the end is equal to the latest end value of the children tasks. Of course, these values are going to be ignored by the TaskJuggler, but for interactive gantt charts these are good toy attributes to play with.

Stalker will check if there will be a cycle if one wants to parent a Task to a child Task of its own or the dependency relation creates a cycle.

In Gantt Charts the computed_start and computed_end attributes will be used if the task is_scheduled.

Parameters:
  • parent – The parent Task or Project of this Task. Every Task in Stalker should be related with a Project instance. So if no parent task is desired, at least a Project instance should be passed as the parent of the created Task or the Task will be an orphan task and Stalker will raise a RuntimeError.
  • priority (int) – It is a number between 0 to 1000 which defines the priority of the Task. The higher the value the higher its priority. The default value is 500.
  • resources (list of User) – The Users assigned to this Task. A Task without any resource can not be scheduled.
  • bid_timing (int) – The initial bid for this Task. It can be used in measuring how accurate the initial guess was. It will be compared against the total amount of effort spend doing this task. Can be set to None, which will be set to the schedule_timing_day argument value if there is one or 0.
  • bid_unit (str) – The unit of the bid value for this Task. Should be one of the ‘min’, ‘h’, ‘d’, ‘w’, ‘m’, ‘y’.
  • depends (list of Task) – A list of Tasks that this Task is depending on. A Task can not depend to itself or any other Task which are already depending to this one in anyway or a CircularDependency error will be raised.
  • schedule_timing (int) – The value of the schedule timing.
  • schedule_unit (str) – The unit value of the schedule timing. Should be one of ‘min’, ‘h’, ‘d’, ‘w’, ‘m’, ‘y’.
  • schedule_constraint (int) – The schedule constraint. It is the index of the schedule constraints value in stalker.config.Config.task_schedule_constraints.
  • milestone (bool) – A bool (True or False) value showing if this task is a milestone which doesn’t need any resource and effort.
__init__(project=None, parent=None, depends=None, resources=None, watchers=None, start=None, end=None, duration=None, schedule_timing=None, schedule_unit='h', schedule_model=None, schedule_constraint=0, bid_timing=None, bid_unit=None, is_milestone=False, priority=500, **kwargs)[source]

Methods

__init__([project, parent, depends, ...])
round_time(dt) Round a datetime object to any time laps in seconds.

Attributes

bid_timing The value of the initial bid of this Task. It is an integer or
bid_unit The unit of the initial bid of this Task. It is a string value.
children
computed_duration it is the direct difference of computed_start and computed_end
computed_end
computed_start
computed_total_seconds returns the duration as seconds
created_by The User who has created this object.
created_by_id The id of the User who has created
date_created A datetime.datetime instance showing the creation date and time of this object.
date_updated A datetime.datetime instance showing the update date and time of this object.
dependent_of
depends A list of Tasks that this one is depending on.
description Description of this object.
duration Duration of the entity.
end The overridden end property.
entity_id
entity_type
generic_data This attribute can hold any kind of data which exists in SOM.
id
is_complete A bool value showing if this task is completed or not.
is_container Returns True if the Task has children Tasks
is_leaf Returns True if the Task has no children Tasks
is_milestone Specifies if this Task is a milestone.
is_root Returns True if the Task has no parent
is_scheduled A predicate which returns True if this task has both a
level Returns the level of this task.
metadata A collection of Table objects and their associated schema
name Name of this object
nice_name Nice name of this object.
notes All the Notess attached to this entity.
parent
parent_id
parents Returns all of the parents of this Task starting from the root
plural_class_name the plural name of this class
priority
project The owner Project of this task.
project_id
query ORM-level SQL construction object.
references
remaining_seconds returns the remaining amount of efforts, length or duration left
resources The list of Users assigned to this Task.
schedule_constraint
schedule_model
schedule_seconds returns the total effort, length or duration in seconds, for
schedule_timing It is the value of the schedule timing.
schedule_unit It is the unit of the schedule timing.
start The overridden start property.
status The current status of the object.
status_id
status_list
status_list_id
tags A list of tags attached to this object.
task_id
tasks
thumbnail
thumbnail_id
time_logs A list of TimeLog instances showing who and when spent how much effort on this task.
timing_resolution The timing_resolution of this object.
tjp_abs_id returns the calculated absolute id of this task
tjp_id returns TaskJuggler compatible id
to_tjp TaskJuggler representation of this task
total_logged_seconds The total effort spent for this Task. It is the sum of all the
total_seconds returns the duration as seconds
type The type of the object.
type_id The id of the Type of this entity.
updated_by The User who has updated this object.
updated_by_id The id of the User who has updated
versions A list of Version instances showing the files created for this task.
watchers The list of Users watching this Task.
time_logs

A list of TimeLog instances showing who and when spent how much effort on this task.

versions

A list of Version instances showing the files created for this task.

is_milestone

Specifies if this Task is a milestone.

Milestones doesn’t need any duration, any effort and any resources. It is used to create meaningful dependencies between the critical stages of the project.

is_complete

A bool value showing if this task is completed or not.

There is a good article about why not to use an attribute called percent_complete to measure how much the task is completed.

depends

A list of Tasks that this one is depending on.

A CircularDependencyError will be raised when the task dependency creates a circular dependency which means it is not allowed to create a dependency for this Task which is depending on another one which in some way depends to this one again.

resources

The list of Users assigned to this Task.

watchers

The list of Users watching this Task.

schedule_unit

It is the unit of the schedule timing. It is a string value. And should be one of ‘min’, ‘h’, ‘d’, ‘w’, ‘m’, ‘y’.

schedule_timing

It is the value of the schedule timing. It is a float value.

bid_timing

The value of the initial bid of this Task. It is an integer or a float.

bid_unit

The unit of the initial bid of this Task. It is a string value. And should be one of ‘min’, ‘h’, ‘d’, ‘w’, ‘m’, ‘y’.

computed_total_seconds

returns the duration as seconds

created_by

The User who has created this object.

created_by_id

The id of the User who has created this entity.

date_created

A datetime.datetime instance showing the creation date and time of this object.

date_updated

A datetime.datetime instance showing the update date and time of this object.

description

Description of this object.

duration

Duration of the entity.

It is a datetime.timedelta instance. Showing the difference of the start and the end. If edited it changes the end attribute value.

generic_data

This attribute can hold any kind of data which exists in SOM.

name

Name of this object

nice_name

Nice name of this object.

It has the same value with the name (contextually) but with a different format like, all the white spaces replaced by underscores (“_”), all the CamelCase form will be expanded by underscore (_) characters and it is always lower case.

notes

All the Notess attached to this entity.

It is a list of Note instances or an empty list, setting it None will raise a TypeError.

plural_class_name

the plural name of this class

round_time(dt)

Round a datetime object to any time laps in seconds.

Uses class property timing_resolution as the closest number of seconds to round to, defaults 1 hour.

Parameters:dt – datetime.datetime object, defaults now.

Based on Thierry Husson’s answer in Stackoverflow

Stackoverflow : http://stackoverflow.com/a/10854034/1431079

status

The current status of the object.

It is a Status instance which is one of the Statuses stored in the status_list attribute of this object.

tags

A list of tags attached to this object.

It is a list of Tag instances which shows the tags of this object

timing_resolution

The timing_resolution of this object.

Can be set to any value that is representable with datetime.timedelta. The default value is 1 hour. Whenever it is changed the start, end and duration values will be updated.

tjp_id

returns TaskJuggler compatible id

total_seconds

returns the duration as seconds

type

The type of the object.

It is an instance of Type with a proper target_entity_type.

type_id

The id of the Type of this entity. Mainly used by SQLAlchemy to create a Many-to-One relates between SimpleEntities and Types.

updated_by

The User who has updated this object.

updated_by_id

The id of the User who has updated this entity.

start[source]

The overridden start property.

The start of the Task can not be changed if it is a container task. Works normally in other case.

end[source]

The overridden end property.

The end of the Task can not be changed if it is a container task. Works normally in other cases.

project

The owner Project of this task.

It is a read-only attribute. It is not possible to change the owner Project of a Task it is defined when the Task is created.

is_root[source]

Returns True if the Task has no parent

is_container[source]

Returns True if the Task has children Tasks

is_leaf[source]

Returns True if the Task has no children Tasks

parents[source]

Returns all of the parents of this Task starting from the root

tjp_abs_id[source]

returns the calculated absolute id of this task

to_tjp[source]

TaskJuggler representation of this task

level[source]

Returns the level of this task. It is a temporary property and will be useless when Stalker has its own implementation of a proper Gantt Chart. Write now it is used by the jQueryGantt.

is_scheduled[source]

A predicate which returns True if this task has both a computed_start and computed_end values

total_logged_seconds[source]

The total effort spent for this Task. It is the sum of all the TimeLogs recorded for this task as seconds.

Returns int:An integer showing the total seconds spent.
schedule_seconds[source]

returns the total effort, length or duration in seconds, for completeness calculation

remaining_seconds[source]

returns the remaining amount of efforts, length or duration left in this Task as seconds.

computed_duration[source]

it is the direct difference of computed_start and computed_end