From 419a43d135e16d28e58b93821fd0a4eb4ee1f848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Wed, 8 Nov 2023 18:00:18 +0100 Subject: [PATCH] fix: minor fixes to build_dashboard.py (still broken) --- scripts/build_dashboard.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/build_dashboard.py b/scripts/build_dashboard.py index 9514e73..33913da 100644 --- a/scripts/build_dashboard.py +++ b/scripts/build_dashboard.py @@ -1,3 +1,9 @@ +""" +This is an old script that was used to generate a HTML dashboard. + +It has fallen into disrepair and is no longer used, but it is kept here for reference. +""" + import argparse import glob import json @@ -7,8 +13,9 @@ from datetime import datetime, timedelta from pathlib import Path +import aw_research + cache_dir = Path(".cache").absolute() -aw_research_dir = Path("aw-research").absolute() env = os.environ.copy() @@ -57,9 +64,8 @@ def _build_category_sunburst(): dt = now - offset dt_str = dt.strftime("%Y-%m-%d") p = subprocess.run( - f"pipenv run python3 -m aw_research classify --start {dt_str} summary_plot --save {cache_dir}/{name}-sunburst.png", + f"poetry run python3 -m aw_research classify --start {dt_str} summary_plot --save {cache_dir}/{name}-sunburst.png", shell=True, - cwd=aw_research_dir, env=env, capture_output=True, ) @@ -83,9 +89,8 @@ def _build_category_timeplot(): dt_str = dt.strftime("%Y-%m-%d") for cat in timeplot_cats: p = subprocess.run( - f"pipenv run python3 -m aw_research classify --start {dt_str} cat_plot '{cat}' --save '{cache_dir}/last60d-{cat}.png'", + f"poetry run python3 -m aw_research classify --start {dt_str} cat_plot '{cat}' --save '{cache_dir}/last60d-{cat}.png'", shell=True, - cwd=aw_research_dir, env=env, capture_output=True, ) @@ -101,7 +106,7 @@ def _build_location_plot(): dt_str = dt.strftime("%Y-%m-%d") for name in people_colocate: p = subprocess.run( - f"pipenv run python3 scripts/location.py {name} --start {dt_str} --save {cache_dir}/last60d-location-{name}.png", + f"poetry run quantifiedme locate {name} --start {dt_str} --save {cache_dir}/last60d-location-{name}.png", shell=True, env=env, capture_output=True, @@ -126,9 +131,8 @@ def _build_qslang_plots(): dt_str = dt.strftime("%Y-%m-%d") for cat in qslang_cats: p = subprocess.run( - f"pipenv run python3 main.py --start {dt_str} --save ../.cache/last60d-substances-{cat.strip('#')}.png plot --count --daily --days '{cat}'", + f"poetry run quantifiedme qslang plot --start {dt_str} --save ../.cache/last60d-substances-{cat.strip('#')}.png plot --count --daily --days '{cat}'", shell=True, - cwd="QSlang/", env=env, capture_output=True, ) @@ -235,6 +239,7 @@ def _parse_args(): def main(): args = _parse_args() if args.clear: + aw_research_dir = Path(aw_research.__file__).parent shutil.rmtree(aw_research_dir / ".cache/joblib", ignore_errors=True) html = build(args.what) with open("dashboard.html", "w") as f: