-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
55 lines (46 loc) · 1.86 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''
Here happens all the magic
'''
import pandas as pd
import scripts.auxillary as aux
import scripts.iodata as iod
import typer
from pathlib import Path
from classes.classes import KosherType
# default absolute pathway
MEAL_LIST = "data/meal_list.csv"
absolute_path = Path(__file__).parent / MEAL_LIST
def main(
data: str = typer.Option(MEAL_LIST, help="csv file with the meal data"),
rank: bool = typer.Option(
False, help="uses weights from the rank feature for random meal"),
TA: bool = typer.Option(
None, "--ta/--no-ta",
help='''True: chooses only from takeaway,
False: from everythin except TA,
no-flag: choose from everything including TA'''),
inp: bool = typer.Option(
False, help="Add a new meal to the meal DB, by questions to the audience"),
kosher: KosherType = typer.Option(KosherType.fleisch, case_sensitive=False, help="NOT YET IMPLEMENTED."),
#mock: bool = typer.Option("Mock try for testing and developing, will not prompt for saving.", case_sensitive=False)
mock: bool = typer.Option(False, help="Mock try for testing and developing, will not prompt for saving.")
):
# load data
meals_db = pd.read_csv(absolute_path, index_col=0)
#meals_db = aux.filter_kosher(meals_db, kosher)
#filterd_meals = aux.filter_kosher(meals_db, kosher)
# adding new meal to db or randomly suggesting one
if inp:
new_meal = iod.meal_questions(meals_db)
meals_db = iod.add_meal(meals_db, new_meal)
else:
filterd_meals = aux.filter_kosher(meals_db, kosher)
_, chosen_one, chosen_idx = aux.choose_random(meals_db, rank, TA)
if mock == False:
iod.write_to_log(chosen_one)
aux.make_this_meal(meals_db,chosen_idx)
# save changes
if mock == False:
iod.save_data(meals_db, absolute_path)
if __name__ == "__main__":
typer.run(main)