From 2fc7a1cbeecf64c8c75f845ca09addbb8fd18366 Mon Sep 17 00:00:00 2001 From: pzhokhov Date: Thu, 23 Aug 2018 13:20:01 -0700 Subject: [PATCH] Trigger benchmarks from buildkite (#40) * rig buildkite pipeline to run benchmarks when commit ends with RUN BENCHMARKS * fix the buildkite pipeline file * fix the buildkite pipeline file * fix the buildkite pipeline file * fix the buildkite pipeline file * fix the buildkite pipeline file * fix the buildkite pipeline file * fix the buildkite pipeline file - merge test and benchmark steps * fix the buildkite pipeline file - merge test and benchmark steps * fix buildkite pipeline file * fix buildkite pipeline file * dry RUN BENCHMARKS * dry RUN BENCHMARKS * dry not run BENCHMARKS * not run benchmarks * not running benchmarks * no running benchmarks * no running benchmarks * still not running benchmarks * dummy commit to RUN BENCHMARKS * trigger benchmarks from buildkite RUN BENCHMARKS * specifying RCALL_KUBE_CLUSTER RUN BENCHMARKS * remove rl-algs/run-benchmarks-new.py (moved to ci), merged baselines/common/console_util and baselines/common/util.py * added missing imports in console_util * clone subrepo over https --- baselines/common/console_util.py | 20 ++++++++++++- baselines/common/util.py | 49 -------------------------------- 2 files changed, 19 insertions(+), 50 deletions(-) delete mode 100644 baselines/common/util.py diff --git a/baselines/common/console_util.py b/baselines/common/console_util.py index 8adc3f8..e1237f2 100644 --- a/baselines/common/console_util.py +++ b/baselines/common/console_util.py @@ -2,6 +2,8 @@ from __future__ import print_function from contextlib import contextmanager import numpy as np import time +import shlex +import subprocess # ================================================================ # Misc @@ -37,7 +39,7 @@ color2num = dict( crimson=38 ) -def colorize(string, color, bold=False, highlight=False): +def colorize(string, color='green', bold=False, highlight=False): attr = [] num = color2num[color] if highlight: num += 10 @@ -45,6 +47,22 @@ def colorize(string, color, bold=False, highlight=False): if bold: attr.append('1') return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string) +def print_cmd(cmd, dry=False): + if isinstance(cmd, str): # for shell=True + pass + else: + cmd = ' '.join(shlex.quote(arg) for arg in cmd) + print(colorize(('CMD: ' if not dry else 'DRY: ') + cmd)) + + +def get_git_commit(cwd=None): + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=cwd).decode('utf8') + +def ccap(cmd, dry=False, env=None, **kwargs): + print_cmd(cmd, dry) + if not dry: + subprocess.check_call(cmd, env=env, **kwargs) + MESSAGE_DEPTH = 0 diff --git a/baselines/common/util.py b/baselines/common/util.py deleted file mode 100644 index 506e251..0000000 --- a/baselines/common/util.py +++ /dev/null @@ -1,49 +0,0 @@ -import subprocess -import shlex - -def colorize(string, color='green', bold=False, highlight=False): - """ - Return string surrounded by appropriate terminal color codes to - print colorized text. Valid colors: gray, red, green, yellow, - blue, magenta, cyan, white, crimson - """ - attr = [] - color2num = dict( - gray=30, - red=31, - green=32, - yellow=33, - blue=34, - magenta=35, - cyan=36, - white=37, - crimson=38 - ) - num = color2num[color] - if highlight: - num += 10 - attr.append(str(num)) - if bold: - attr.append('1') - attrs = ';'.join(attr) - return '\x1b[%sm%s\x1b[0m' % (attrs, string) - - -def print_cmd(cmd, dry=False): - if isinstance(cmd, str): # for shell=True - pass - else: - cmd = ' '.join(shlex.quote(arg) for arg in cmd) - print(colorize(('CMD: ' if not dry else 'DRY: ') + cmd)) - - -# this is here because a few other packages outside of rcall depend on it, but it should be removed -def get_git_commit(cwd=None): - return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=cwd).decode('utf8') - -def ccap(cmd, dry=False, env=None, **kwargs): - print_cmd(cmd, dry) - if not dry: - subprocess.check_call(cmd, env=env, **kwargs) - -