-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
28 lines (25 loc) · 971 Bytes
/
run.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
import argparse
import mymodule.mycode as sk
import logging
def initialize():
parser = argparse.ArgumentParser(description='MySoftware')
parser.add_argument('--epochs', type=int, nargs='?', help='Int, >0, Epochs')
parser.add_argument('--imageroot', type=str, nargs='?', help='Directory containing images')
args = parser.parse_args()
configuration = {'epochs':20, 'imageroot':'.'}
for k in configuration:
try:
argk = getattr(args, k)
if argk is not None:
configuration[k] = argk
except AttributeError as e:
continue
return configuration
if __name__ == "__main__":
FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
logging.basicConfig(format=FORMAT)
lgr = logging.getLogger('global')
lgr.setLevel(logging.INFO)
config = initialize()
lgr.info("Starting with config P{}".format(config))
lgr.info("{}".format(sk.myfunction([2])))