From d4a08f0142f2054ecf301bb93f55cb0cbb51132b Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sun, 4 Aug 2019 16:54:12 +0200 Subject: [PATCH] Feat: Student report build --- recopytex.py | 26 ++++++++++++++++++++++---- templates/tpl_student.ipynb | 11 ++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/recopytex.py b/recopytex.py index af99a81..2afa1fa 100644 --- a/recopytex.py +++ b/recopytex.py @@ -33,23 +33,41 @@ def report(csv_file): sys.exit(1) csv_file = Path(csv_file) + tribe_dir = csv_file.parent csv_filename = csv_file.name.split(".")[0] + assessment = str(csv_filename).split("_")[-1].capitalize() - tribe = str(csv_file.parent).split("/")[-1] + tribe = str(tribe_dir).split("/")[-1] template = Path(config["templates"]) / "tpl_evaluation.ipynb" - dest = Path(config["output"]) / tribe / csv_filename / f"{assessment}.ipynb" - dest.parent.mkdir(parents=True, exist_ok=True) + dest = Path(config["output"]) / tribe / csv_filename + dest.mkdir(parents=True, exist_ok=True) + click.echo(f"Building {assessment} report") pm.execute_notebook( str(template), - str(dest), + str(dest / f"{assessment}.ipynb"), parameters=dict( tribe=tribe, assessment=assessment, csv_file=str(csv_file.absolute()) ), ) + with open(csv_file.parent / "description.yml") as f: + tribe_desc = yaml.load(f, Loader=yaml.FullLoader) + + template = Path(config["templates"]) / "tpl_student.ipynb" + dest = Path(config["output"]) / tribe / csv_filename / "students" + dest.mkdir(parents=True, exist_ok=True) + + for st in tribe_desc["students"]: + click.echo(f"Building {st} report on {assessment}") + pm.execute_notebook( + str(template), + str(dest / f"{st}.ipynb"), + parameters=dict(tribe=tribe, student=st, source=str(tribe_dir.absolute())), + ) + if __name__ == "__main__": cli() diff --git a/templates/tpl_student.ipynb b/templates/tpl_student.ipynb index 82612b3..72fe9e4 100644 --- a/templates/tpl_student.ipynb +++ b/templates/tpl_student.ipynb @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 10, "metadata": { "tags": [ "parameters" @@ -22,24 +22,25 @@ "outputs": [], "source": [ "tribe = 30\n", - "student = \"ABDOU Asmahane\"" + "student = \"ABDOU Asmahane\"\n", + "source = Path(f\"./sheets/{tribe}/\")" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ - "# ABDOU Asmahane en 308" + "# ABDOU Asmahane en 30" ], "text/plain": [ "" ] }, - "execution_count": 9, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" }