forked from okfn-brasil/serenata-de-amor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·39 lines (28 loc) · 1.21 KB
/
setup
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
#!/usr/bin/env python3
import os
import pip
import argparse
from shutil import copyfile, which
RESEARCH_DIR = 'research'
DATA_DIR = os.path.join(RESEARCH_DIR, 'data')
parser = argparse.ArgumentParser(
description='Setup serenata-de-amor using serenata-toolbox.')
parser.add_argument('--all', dest='all', action='store_true',
help='Force all datasets from serenata-toolbox \
to be downloaded')
args = parser.parse_args()
if not os.path.exists('config.ini'):
copyfile('config.ini.example', 'config.ini')
requirements = os.path.join(RESEARCH_DIR, 'requirements.txt') # local install
if not os.path.exists(requirements):
requirements = 'requirements.txt' # Docker
pip.main(['install', '--upgrade', '-r', requirements])
if which('unzip') is None:
print('The following executables are needed and were not found: unzip')
print('Downloading datasets (this might take several minutes \
depending on your internet connection)')
# This is imported here because serenata_toolbox is only
# installed when pip.main is called (line 27)
from serenata_toolbox.datasets import fetch_latest_backup
os.makedirs(DATA_DIR, exist_ok=True)
fetch_latest_backup(DATA_DIR, force_all=args.all)