forked from yfeng46/SongAnalytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
44 lines (31 loc) · 1.84 KB
/
run.py
File metadata and controls
44 lines (31 loc) · 1.84 KB
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
"""Enables the command line execution of multiple modules within src/
This module combines the argparsing of each module within src/ and enables the execution of the corresponding scripts
so that all module imports can be absolute with respect to the main project directory.
Current commands enabled:
To create a database for Tracks with an initial song:
`python run.py create --artist="Britney Spears" --title="Radar" --album="Circus"`
To add a song to an already created database:
`python run.py ingest --artist="Britney Spears" --title="Radar" --album="Circus"`
"""
import argparse
import logging.config
logging.config.fileConfig("config/logging/local.conf")
logger = logging.getLogger("run-penny-lane")
from src.add_songs import create_db, add_track
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Run components of the model source code")
subparsers = parser.add_subparsers()
# Sub-parser for creating a database
sb_create = subparsers.add_parser("create", description="Create database")
sb_create.add_argument("--artist", default="Britney Spears", help="Artist of song to be added")
sb_create.add_argument("--title", default="Radar", help="Title of song to be added")
sb_create.add_argument("--album", default="Circus", help="Album of song being added.")
sb_create.set_defaults(func=create_db)
# Sub-parser for ingesting new data
sb_ingest = subparsers.add_parser("ingest", description="Add data to database")
sb_ingest.add_argument("--artist", default="Emancipator", help="Artist of song to be added")
sb_ingest.add_argument("--title", default="Minor Cause", help="Title of song to be added")
sb_ingest.add_argument("--album", default="Dusk to Dawn", help="Album of song being added")
sb_ingest.set_defaults(func=add_track)
args = parser.parse_args()
args.func(args)