Feat: Module can be pip now

This commit is contained in:
Bertrand Benjamin 2019-08-04 21:11:46 +02:00
parent 7119fcdcdc
commit 9358c10b47
3 changed files with 35 additions and 6 deletions

View File

View File

@ -6,6 +6,7 @@ from pathlib import Path
import yaml import yaml
import sys import sys
import papermill as pm import papermill as pm
from datetime import datetime
CONFIGPATH = "recoconfig.yml" CONFIGPATH = "recoconfig.yml"
@ -41,6 +42,12 @@ def report(csv_file):
csv_filename = csv_file.name.split(".")[0] csv_filename = csv_file.name.split(".")[0]
assessment = str(csv_filename).split("_")[-1].capitalize() assessment = str(csv_filename).split("_")[-1].capitalize()
date = str(csv_filename).split("_")[0]
try:
date = datetime.strptime(date, "%y%m%d")
except ValueError:
date = None
tribe = str(tribe_dir).split("/")[-1] tribe = str(tribe_dir).split("/")[-1]
template = Path(config["templates"]) / "tpl_evaluation.ipynb" template = Path(config["templates"]) / "tpl_evaluation.ipynb"
@ -48,12 +55,12 @@ def report(csv_file):
dest = Path(config["output"]) / tribe / csv_filename dest = Path(config["output"]) / tribe / csv_filename
dest.mkdir(parents=True, exist_ok=True) dest.mkdir(parents=True, exist_ok=True)
click.echo(f"Building {assessment} report") click.echo(f"Building {assessment} ({date:%d/%m/%y}) report")
pm.execute_notebook( pm.execute_notebook(
str(template), str(template),
str(dest / f"{assessment}.ipynb"), str(dest / f"{assessment}.ipynb"),
parameters=dict( parameters=dict(
tribe=tribe, assessment=assessment, csv_file=str(csv_file.absolute()) tribe=tribe, assessment=assessment, date=f"{date:%d/%m/%y}", csv_file=str(csv_file.absolute())
), ),
) )
@ -72,7 +79,3 @@ def report(csv_file):
parameters=dict(tribe=tribe, student=st, source=str(tribe_dir.absolute())), parameters=dict(tribe=tribe, student=st, source=str(tribe_dir.absolute())),
) )
if __name__ == "__main__":
cli()

26
setup.py Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python
# encoding: utf-8
from setuptools import setup, find_packages
setup(
name='Recopytex',
version='0.1',
description='Assessment analysis',
author='Benjamin Bertrand',
author_email='',
packages=find_packages(),
include_package_data=True,
install_requires=[
'Click',
],
entry_points='''
[console_scripts]
recopytex=recopytex.scripts.recopytex:cli
''',
)
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del