project
¶
Module Contents¶
-
project.
datetime_stats
(datetimes)¶ Gets the mean and variance of a collection of datetimes
Parameters: datetimes (iterable(datetime)) – The datetimes to compute the statistics on. Returns: - A dictionary containing keys for the mean and variance. The mean is a datetime, and the variance is a
- timedelta.
Return type: dict
-
project.
timedelta_stats
(timedeltas)¶ Gets the mean and variance of a collection of timedeltas
Parameters: timedeltas (iterable(timedelta)) – The timedeltas to compute the statistics on. Returns: A dictionary containing keys for the mean and variance. both the mean and variance are datetimes. Return type: dict
-
class
project.
TaskSample
(duration, earliest_start, latest_finish)¶ A wrapper for a sample of the derived statistics for a Task
-
duration
¶ timedelta – The sampled duration of the task
-
earliest_start
¶ datetime – The sampled earliest start date of the task
-
latest_finish
¶ datetime – The sampled latest finish date of the task
-
latest_start
¶ datetime – The latest start date of the task. Must be set independently of the constructor
-
earliest_finish
¶ datetime – The earliest finish date of the task. Must be set independently of the constructor.
Parameters: - duration (timedelta) – The sampled duration of the task
- earliest_start (datetime) – The sampled earliest start date of the task
- latest_finish (datetime) – The sampled latest finish date of the task
-
__init__
(duration, earliest_start, latest_finish)¶
-
total_float
()¶ timedelta: The total float of the task. Earliest finish mst be set before calculation.
-
-
class
project.
TaskStatistics
(latest_start, earliest_finish, total_float)¶ A container for the relevant derived statistics for a Task
-
latest_start
¶ dict – A dict containing the mean and variance of the latest start date of the task in ‘mean’ and ‘variance’ keys respectively.
-
earliest_finish
¶ dict – A dict containing the mean and variance of the earliest finish date of the task in ‘mean’ and ‘variance’ keys respectively.
-
total_float
¶ dict – A dict containing the mean and variance of the total float date of the task in ‘mean’ and ‘variance’ keys respectively.
Parameters: - latest_start (dict) – A dict containing the mean and variance of the latest start date of the task in ‘mean’ and ‘variance’ keys respectively.
- earliest_finish (dict) – A dict containing the mean and variance of the earliest finish date of the task in ‘mean’ and ‘variance’ keys respectively.
- total_float (dict) – A dict containing the mean and variance of the total float date of the task in ‘mean’ and ‘variance’ keys respectively.
-
__init__
(latest_start, earliest_finish, total_float)¶
-
from_samples
(samples)¶ Construct a TaskStatistics object from samples
Parameters: samples (iterable(TaskSample)) – The samples to compute the statistics from. Returns: The constructed TaskStatistics Return type: TaskStatistics
-
__repr__
()¶
-
-
class
project.
Project
(name, model=None, uid=None, tasks=None, dependencies=None)¶ A project
Note
This must be an acyclic graph.
-
name
¶ str – The name of the project
-
uid
¶ UUID – The UUID of the project
-
model
¶ A model used to predict the duration of tasks from their data
Parameters: - name (str) – The name of the project
- model (optional) – A model used to predict the duration of tasks from their data
- uid (UUID, optional) – The UUID of the project
- tasks (iterable(Task), optional) – A collections of Tasks associated with this project
- dependencies (iterable(dict), optional) – The dependencies associated with the project in the form of dicts of ‘source’ and ‘destination’ keys.
-
__init__
(name, model=None, uid=None, tasks=None, dependencies=None)¶
-
validate
()¶ Validates the Project meets the requirements to do inference
Checks: * The Project is a directed acyclic graph * Every terminal Task (one without successors) has a latest start date PDF
Raises: InvalidProject
– If the project does not conform to the requirements.
-
dependencies
()¶ list[tuple(Task, Task)]: The dependencies in the project where the first element of the tuple is the source task and the second element of the tuple is the dependent task.
-
tasks
()¶ iterable(Task): The tasks of this project
-
dependencies_summary
()¶ list[DependencySummary]: The dependencies of this project
-
get_task_from_id
(id_)¶ Gets a task from an id
Parameters: id (UUID) – The UUID of the project to get Returns: The task with the associated with the id or None if task is not found Return type: Task|None
-
add_task
(task)¶ Adds a Task to this Project and determines the duration PDF of the task from the model if not previously specified.
Parameters: task (Task) – The Task to add to the project
-
add_tasks
(tasks)¶ - Adds multiple Tasks to this Project and determines the duration PDF of the task from the model if not
- previously specified.
Parameters: tasks (iterable(Task)) – The Task to add to the project
-
add_dependency
(parent, child)¶ Adds a Task dependency to this Project
Parameters:
-
add_dependencies
(dependencies)¶ Adds multiple Task dependencies to this Project
Parameters: dependencies (list[tuple(Task, Task)]) – A list of tuples of Task dependencies in the form of (parent task, child task)
-
calculate_earliest_finish_times
(current_time=None, iterations=1000)¶ Generates samples of the earliest finish times for each uncompleted node in the project.
Parameters: - current_time (datetime) – the time at which to take the samples
- iterations (int, optional) – The number of samples to generate. Defaults to 1000
Returns: [datetime]}: A dictionary of the samples for each task.
Return type: dict{Task
-
earliest_finish_sample_func
(parents, children, samples, **kwargs)¶
-
calculate_latest_start_times
(iterations=1000)¶ Generates samples of the latest start times for each uncompleted node in the project.
Parameters: iterations (int, optional) – The number of samples to generate. Defaults to 1000 Returns: [datetime]}: A dictionary of the samples for each task. Return type: dict{Task
-
latest_start_sample_func
(parents, children, samples, **kwargs)¶
-
_get_samples
(forward_sample_func=None, backward_sample_func=None, iterations=1000, current_time=None, **kwargs)¶
-
_get_parents_and_children
(task)¶
-
calculate_task_statistics
(current_time=None, iterations=1000)¶
-
recommend_next
(current_time=None, constraints=None, iterations=1000, score_func=None, selection_func=None, min_number=1, max_number=1, batch_wait=False, selection_func_arguments=None, **score_func_arguments)¶ Get the recommended next tasks
Parameters: - current_time (datetime, optional) – The current time (in UTC) to query the project. Defaults to the current time.
- constraints (iterable(callable)) – A list of constraints to apply to the selected tasks. These must be functions which task in two parameters – the project (self) and the set of Tasks under consideration.
- iterations (int, optional) – The number of iterations to query the project for each considered set of Tasks. Defaults to 1000.
- score_func (func, optional) – The function used to score the results of a Task set. Defaults to a function which returns a dict containing the mean and precision (inverse variance) of the total float of each task weighted by the Tasks’ deadline weight. The function must take keyword arguments which can be specified as keyword arguments to this function (see score_func_arguments).
- selection_func (func, optional) – The function used to select which task set is best from the results returned from the score_func. Defaults to a function which scales the total float and precision each between 0 and 1 and sums them according to a weighting parameter (see selection_func_arguments). The function must accept a dict of Task set to score and keyword arguments which can be specified by the selection_func_arguments parameter of this function.
- min_number (int, optional) – The minimum number of tasks which can can be recommended. Defaults to 1.
- max_number (int, optional) – The maximum number of tasks which can be recommended. Defaults to 1.
- batch_wait (bool, optional) – Do all tasks for a proposed tuple of Tasks need to be completed before the next tasks can begin? Defaults to False.
- selection_func_arguments (dict, optional) – The arguments to be passed to the selection_func.
- **score_func_arguments – The arguments to pass to the score_func
Returns: The recommended tasks to complete next
Return type: tuple(Task)
-
recommendation_sample_func
(parents, children, samples, **kwargs)¶
-
_default_recommendation_score_func
(**kwargs)¶
-
_default_recommendation_selection_func
(**kwargs)¶
-
get_starting_and_terminal_tasks
()¶ Gets the starting tasks (ones without predecessors) and terminal tasks (ones without successors)
Returns: - The starting and terminal tasks in the form of
- (starting tasks, terminal tasks)
Return type: tuple(list[Task], list[Task])
-
update_from_dict
(data)¶ Updates the Project using a dictionary of new values
Parameters: data (dict) – The new values
-