-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
33 lines (24 loc) · 1.06 KB
/
utils.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
import argparse
import fastai
import fastprogress
from fastprogress.fastprogress import force_console_behavior
master_bar, progress_bar = fastai.core.master_bar, fastai.core.progress_bar
def get_files():
parser = argparse.ArgumentParser()
parser.add_argument('--cgm', default='data/GlucoseValues.csv', help='location of cgm data file')
parser.add_argument('--meals', default='data/Meals.csv', help='location of meals data file')
args = parser.parse_args()
return args.cgm, args.meals
class ProgressBarCtx:
"""Context manager to disable the progress update bar."""
def __init__(self, learn, show=True):
self.learn = learn
self.show = show
def __enter__(self):
if not self.show:
# silence progress bar
fastprogress.fastprogress.NO_BAR = True
fastai.basic_train.master_bar, fastai.basic_train.progress_bar = force_console_behavior()
return self.learn
def __exit__(self, *args):
fastai.basic_train.master_bar, fastai.basic_train.progress_bar = master_bar, progress_bar