Skip to content

Commit

Permalink
add current forecast line
Browse files Browse the repository at this point in the history
lint

lint
  • Loading branch information
womullan committed Oct 15, 2022
1 parent ed2bbda commit ba06fff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
7 changes: 1 addition & 6 deletions milestones.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def parse_args():
default=milestones.get_local_data_path(),
)
parser.add_argument("--verbose", "-v", action="count", default=0)
parser.add_argument("--forecast", "-f", action="store_true", help="Use end_date")

subparsers = parser.add_subparsers(title="Output targets")

Expand Down Expand Up @@ -144,13 +143,9 @@ def parse_args():
if __name__ == "__main__":
args = parse_args()
print("Working with "+args.pmcs_data)
milestones = milestones.load_milestones(args.pmcs_data, args.local_data,
args.forecast)
milestones = milestones.load_milestones(args.pmcs_data, args.local_data)
if "months" in args and args.months > 0:
fpath = get_pmcs_path_months(args.pmcs_data, args.months)
load_f2due_pmcs_excel(fpath, milestones)

if args.forecast:
args.output = f"fcast_{args.output}"

args.func(args, milestones)
9 changes: 7 additions & 2 deletions milestones/burndown.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,21 @@ def burndown(args, milestones):
model = []
actual = []
fcast = []
f2cast = []
for date in month_starts:
fcast_remain = model_remain = actual_remain = len(milestones)
f2cast_remain = fcast_remain = model_remain = actual_remain = len(milestones)
for ms in milestones:
if dofcastline and ms.f2due <= date:
f2cast_remain -= 1
if ms.fdue <= date:
fcast_remain -= 1
if ms.due <= date:
model_remain -= 1
if ms.completed and ms.completed <= date:
actual_remain -= 1

model.append(model_remain)
f2cast.append(f2cast_remain)
fcast.append(fcast_remain)
actual.append(actual_remain)

Expand All @@ -60,7 +64,8 @@ def burndown(args, milestones):

plt.plot(month_starts, model, label="Baseline")
if dofcastline:
plt.plot(month_starts, fcast, label=f"-{args.months}m Forecast")
plt.plot(month_starts, f2cast, label=f"-{args.months}m Forecast")
plt.plot(month_starts, fcast, label="Forecast")

achieved_months = [mnth for mnth in month_starts if mnth <= last_achieved_month]
# Need to acount for year wrap
Expand Down
15 changes: 6 additions & 9 deletions milestones/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def extract_fcast(task_sheet, milestones):
return milestones


def extract_task_details(task_sheet, forecast=False):
def extract_task_details(task_sheet):
assert task_sheet.name == TASK_SHEET_NAME
milestones = list()
fetcher = CellFetcher(task_sheet.row(0))
Expand All @@ -90,11 +90,9 @@ def extract_task_details(task_sheet, forecast=False):
# will be the same as the end_date for zero duration
# activities like milestones.
#
# We use the first available. Unless we want forecast
# We use the first available.

date_order = ["base_end_date", "end_date", "start_date"]
if forecast:
date_order = ["end_date", "base_end_date", "start_date"]

for date_field in (date_order):
d = fetcher(date_field, task_sheet.row(rownum))
Expand All @@ -110,10 +108,9 @@ def extract_task_details(task_sheet, forecast=False):
base_end_date = fetcher("base_end_date", task_sheet.row(rownum))
start_date = fetcher("start_date", task_sheet.row(rownum))
end_date = fetcher("end_date", task_sheet.row(rownum))
try:

if (end_date):
fdue = extract_date(end_date)
except ValueError:
fdue = due

completed = None
if status == "Completed":
Expand Down Expand Up @@ -149,9 +146,9 @@ def set_successors(milestones, relation_sheet):
ms.predecessors.add(preds[i])


def load_pmcs_excel(path, forecast):
def load_pmcs_excel(path):
workbook = xlrd.open_workbook(path, logfile=sys.stderr)
milestones = extract_task_details(workbook.sheets()[0], forecast)
milestones = extract_task_details(workbook.sheets()[0])
set_successors(milestones, workbook.sheets()[1])
return milestones

Expand Down
4 changes: 2 additions & 2 deletions milestones/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def add_rst_citations(text, cite_handles=DOC_HANDLES):
return add_citations(text, cite_handles, r"\1 :cite:`\1`")


def load_milestones(pmcs_filename, local_data_filename, forecast=False):
def load_milestones(pmcs_filename, local_data_filename):
logger = logging.getLogger(__name__)

logger.info(f"Loading PMCS data from: {pmcs_filename}")
logger.info(f"Loading local annotations from: {local_data_filename}")
milestones = load_pmcs_excel(pmcs_filename, forecast)
milestones = load_pmcs_excel(pmcs_filename)

with open(local_data_filename) as f:
local = yaml.safe_load(f)
Expand Down

0 comments on commit ba06fff

Please sign in to comment.