md_planning package

Submodules

md_planning.cli module

Console script for md_planning.

md_planning.md_planning module

md_planning main module.

class md_planning.md_planning.GanttDrawer(data)[source]

Bases: object

Gantt project representation from a yaml file definition.

see tests for project definition structure and class usage

budget() DataFrame[source]

budget records all the planned expenses

budget records for each day, each task and each resource, the use and associated cost in the project planning.

Returns

pandas.DataFrame with columns [“project”, “task”, “resource”, “category”, “subcategory”, “date”, “amount”]

Return type

pd.DataFrame

convert(resource: str, number_of_days: Optional[Union[int, float]] = None) float[source]

convert is a utility function at the project level that gets the daily price of a resource with units.

Parameters
  • resource (str) – resource name

  • number_of_days (Union[int, float, None], optional) – length of the associated task for resources that are time independant, defaults to None

Returns

a price in the user’s currency unit

Return type

float

define_alias(alias: str) None[source]

define_alias makes a new alias for an existing unit.

useful when using a unit in a multilingual and pluralized context

Parameters

alias (str) – alias definition, can start with “@alias” (full definition) or not (abbreviated syntax) (see pint documentation for more details)

define_unit(unit: str) None[source]

define_unit registers a new pint unit in the instance unit registry.

Parameters

unit (str) – unit definition (see pint documentation for syntax)

draw_resources(project: str, filename: Optional[str] = None, today: Optional[Union[date, str]] = None, start: Optional[Union[date, str]] = None, end: Optional[Union[date, str]] = None, resources: Optional[List[str]] = None, one_line_for_tasks: bool = False, scale: Optional[str] = None) None[source]

draw_resources creates a svg visualization of the resource use in the project.

Parameters
  • project (str) – name of the project

  • filename (Union[str, None], optional) – file name override. If None use the project name, defaults to None

  • today (Union[datetime.date, str, None], optional) – today’s date for resource use WIP evaluation, defaults to None

  • scale (Union[str, None], optional) – python_gantt scale enumeration see doc, defaults to None

draw_tasks(project: str, filename: Optional[str] = None, today: Optional[Union[date, str]] = None, start: Optional[Union[date, str]] = None, end: Optional[Union[date, str]] = None, scale: Optional[str] = None) None[source]

draw_tasks creates a svg visualization of the task execution in the project.

Parameters
  • project (str) – project name

  • filename (Union[str, None], optional) – file name override. If None, use the project name, defaults to None

  • today (Union[datetime.date, str, None], optional) – today’s date for task burn down evaluation, defaults to None

duration(task: str) float[source]

duration is a utility function at the project level to retrieve a task duration.

Parameters

task (str) – task name

Returns

task duration

Return type

float

get_bounds() Tuple[date, date][source]

get_bounds returns the start date and the end date of the whole file definition, all projects taken into consideration.

Returns

start_date, end_date

Return type

Tuple[date, date]

get_cost(task: str, resource: str, date: Union[str, date]) float[source]

get_cost returns the actual cost of a specific resource in a given task, on a given day.

Parameters
  • task (str) – task name

  • resource (str) – resource name

  • date (Union[str, datetime.date]) – date of consideration

Raises

ValueError – if the date format is not recognised by dateutil.parse

Returns

the cost in the user’s currency

Return type

float

get_price(resource: str) float[source]

get_price returns the price of the specified resource

Parameters

resource (str) – name of the resource

Returns

the price of the resource

Return type

float

get_unit(resource: str) str[source]

get_unit helper function for a project object to get a resource’s units

Parameters
  • project (str) – name of the project

  • resource (str) – name of the resource

get_usage(task: str, resource: str) float[source]

get_usage returns the amount of a specified resource that a task uses.

Parameters
  • task (str) – task name

  • resource (str) – resource name

Raises
  • ValueError – if the task name is not defined

  • ValueError – if the resource name is not defined

Returns

the amount used of specified resource by a task

Return type

float

is_active(task: str, date: Union[str, date]) bool[source]

is_active is a utility function at the project level that gets the activity status of a task in a project at a given date.

Parameters
  • task (str) – task name

  • date (Union[str, datetime.date]) – the date when the activity is considered

Raises

ValueError – if the date is not recognised by dateutil.parse

Returns

the task is active: True/False

Return type

bool

is_available(resource: str, date: Union[str, date]) bool[source]

is_available returns True if a specific resource is available to use on a specified date.

Parameters
  • resource (str) – resource name

  • date (Union[str, datetime.date]) – date at which availability is assessed

Raises

ValueError – _description_

Returns

True/False

Return type

bool

is_using(task: str, resource: str) bool[source]

is_using is a utility function at the project level to determine if the given task is using a specific resource.

Parameters
  • task (str) – task name

  • resource (str) – resource name

Returns

is task ABC using resource XYZ, True/False

Return type

bool

class md_planning.md_planning.PertDrawer(tasks: dict)[source]

Bases: object

PertParser takes a python dictionary in and extracts the pert data.

from it in order to assess project CPM.

It also cleans project data of PERT estimates in order to provide the proper durations for a gantt representation.

draw(project: Optional[str] = None, out: Optional[str] = None) None[source]

draw Draws the network of tasks in self.tasks.

Parameters
  • project (Union[str, None], optional) – name of the project otherwise all projects tasks will be analysed together, defaults to None

  • out (Union[str, None], optional) – prefix name of the files to output, will default to the name of the project to output “project_pert.pdf” and “project_pert.gv” (graphviz file)

get_critical_path(project: str)[source]

get_critical_path returns the critical path of tasks in a specific project.

Parameters

project (str) – name of the project

Raises

NotImplementedError – _description_

class md_planning.md_planning.ProjectReader(projstr: str, critical_color: Optional[str] = None)[source]

Bases: object

Utility for reading raw project data.

Reads yaml data and returns a representation of the projects suitable for a PERT and gantt analysis.

build_project() tuple[source]

build_project returns a tuple with gantt project data and pertchart data.

Returns

pos 0 gantt data, pos 1 pert chart data

Return type

tuple

md_planning.md_planning.get_dependencies(task: Any)[source]
md_planning.md_planning.get_dependencies(task: dict)
md_planning.md_planning.get_dependencies(task: list)

get_dependencies get the dependencies from a task definition.

Works on dict and list defined tasks

Parameters

task (Union[dict, list]) – the task definition

Raises

NotImplementedError – if the task definition is not recognised

md_planning.md_planning.get_duration(task: Any)[source]
md_planning.md_planning.get_duration(task: dict)
md_planning.md_planning.get_duration(task: list)

get_duration makes the duration of a task primarily from the estimated task durations and if not available, the actual duration data.

Parameters

task (Union[dict, list]) – the task definition

Raises

NotImplementedType – types other than dict and list will raise error

md_planning.md_planning.get_resources(task: Any)[source]
md_planning.md_planning.get_resources(task: dict)
md_planning.md_planning.get_resources(task: list)

get_resources is a helper function that returns the resources used in a task in a project compatible format.

Works on dict defined tasks and list defined tasks.

Parameters

task (Union[dict, list]) – the task description

Raises

NotImplementedError – if the task format is not recognised.

Returns

list of resource names

Return type

List[str]

md_planning.md_planning.get_task_type(item: Any) Optional[str][source]
md_planning.md_planning.get_task_type(item: Dict)
md_planning.md_planning.get_task_type(item: List)

get_task_type returns the name of the task type: milestone or task.

Parameters

item (Any) – item to be examined

Raises

NotImplementedError – if the item is different from a dict or list

Returns

the item tag type

Return type

str

md_planning.md_planning.is_nested(tasks: dict) bool[source]

is_nested recognizes the project format to determine if the tasks definition is in the flat or the nested format.

if any task is a milestone and contains another task then is_nested==True

Parameters

tasks (dict) – full project task definition

Returns

is it a nested definition T/F

Return type

bool

BUGFIX

E17FB6 and 39651C

md_planning.md_planning.normalize_task(task: Any)[source]
md_planning.md_planning.normalize_task(task: dict)
md_planning.md_planning.normalize_task(task: list)

normalize_task changes a list defined task to a dict defined task.

Parameters

task (list) – task defined as a list

Raises

NotImplementedError – if the task type is not a recognised format

md_planning.md_planning.rename(dict_in: dict, key_from: str, key_to: str, flexible: bool = False, flex_val: Optional[Any] = None) dict[source]

Forgiving function to rename keys in a dictionary.

Dict_in:

the input dictionary

Key_from:

the key to change

Key_to:

the key to rename to

Flexible:

raise error if key_from does not exist dict_in else assign None to key_to

md_planning.md_planning.suppress_stdout_stderr()[source]

suppress_stdout_stderr is a context manager that redirects stdout and stderr to devnull.

md_planning.md_planning.walk_project_tasks(tasks: dict)[source]

walk_project returns normalized tasks in a nested or flat project configuration

Parameters

tasks (dict) – project tasks

Returns

list of task_name, task_definition

Return type

List[Tuple(str, dict)]

Module contents

Top-level package for md-planning.