Skip to content

Commit

Permalink
add concurrent run / add deco / add posibility to load opts from conf…
Browse files Browse the repository at this point in the history
…ig file
  • Loading branch information
sph3rex committed Jul 5, 2019
1 parent 0ebc1ad commit 36c9d31
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
27 changes: 23 additions & 4 deletions lib/cli/RLTraderCLI.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import argparse
import os
import multiprocessing
from configparser import ConfigParser


class RLTraderCLI:
def __init__(self):
config_parser = argparse.ArgumentParser(add_help=False)
config_parser.add_argument("-f", "--from-config", help="Specify config file", metavar="FILE")
args, remaining_argv = config_parser.parse_known_args()
defaults = {}

if args.from_config:
config = ConfigParser.SafeConfigParser()
config.read([args.from_config])
defaults = dict(config.items("Defaults"))

formatter = argparse.ArgumentDefaultsHelpFormatter
self.parser = argparse.ArgumentParser(description='Trainer', formatter_class=formatter)
self.parser = argparse.ArgumentParser(
formatter_class=formatter,
parents=[config_parser],
description=__doc__
)

self.parser.add_argument("--data-provider", "-o", type=str, default="static")
self.parser.add_argument("--input-data-path", "-t", type=str, default="data/input/coinbase-1h-btc-usd.csv")
Expand All @@ -15,7 +31,7 @@ def __init__(self):
self.parser.add_argument('--train-split-percentage', type=int, default=0.8, help='Train set percentage')
self.parser.add_argument('--verbose-model', type=int, default=1, help='Verbose model')
self.parser.add_argument('--params-db-path', type=str, default='sqlite:///data/params.db',
help='Params path')
help='Params path')
self.parser.add_argument(
'--tensor-board-path',
type=str,
Expand All @@ -32,12 +48,14 @@ def __init__(self):
opt_train_test_parser.add_argument('--train-epochs', type=int, default=10, help='Train for how many epochs')
opt_train_test_parser.add_argument('--no-render', action='store_false', help='Should render the model')
opt_train_test_parser.add_argument('--no-test', action='store_false', help='Should test the model')
opt_train_test_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(), help='How many processes to spawn')
opt_train_test_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(),
help='How many processes to spawn')

optimize_parser = subparsers.add_parser('optimize', description='Optimize model parameters')
optimize_parser.add_argument('--trials', type=int, default=1, help='Number of trials')
optimize_parser.add_argument('--parallel-jobs', type=int, default=1, help='How many jobs in parallel')
optimize_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(), help='How many processes to spawn')
optimize_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(),
help='How many processes to spawn')

optimize_parser.add_argument('--verbose-model', type=int, default=1, help='Verbose model', dest='model_verbose')

Expand All @@ -47,6 +65,7 @@ def __init__(self):
test_parser = subparsers.add_parser('test', description='Test model')
test_parser.add_argument('--model-epoch', type=int, default=1, help='Model epoch index')
test_parser.add_argument('--no-render', action='store_false', help='Do not render test')
self.parser.set_defaults(**defaults)

def get_args(self):
return self.parser.parse_args()
Expand Down
14 changes: 14 additions & 0 deletions requirements.base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
numpy
pandas
sklearn
matplotlib
gym
stable_baselines
optuna
ta
statsmodels==0.10.0rc2
empyrical
ccxt
psycopg2
deco
configparser
13 changes: 1 addition & 12 deletions requirements.no-gpu.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
numpy
pandas
sklearn
matplotlib
gym
stable_baselines
optuna
ta
statsmodels==0.10.0rc2
empyrical
-r requirements.base.yml
tensorflow
ccxt
deco
3 changes: 1 addition & 2 deletions requirements.tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
-r requirements.no-gpu.txt
pytest
deco
pytest
16 changes: 2 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
numpy
pandas
sklearn
matplotlib
gym
stable_baselines
optuna
ta
statsmodels==0.10.0rc2
empyrical
tensorflow-gpu
ccxt
psycopg2
deco
-r requirements.base.yml
tensorflow-gpu

0 comments on commit 36c9d31

Please sign in to comment.