Commit 1169d76f authored by Philip ABBET's avatar Philip ABBET

Force 4-space indentation

parent 67664a03
......@@ -143,7 +143,7 @@ def pull(webapi, prefix, names, force, indentation, format_cache, lib_cache):
from .libraries import pull as libraries_pull
status, names = common.pull(webapi, prefix, 'algorithm', names,
['declaration', 'code', 'description'], force, indentation)
['declaration', 'code', 'description'], force, indentation)
if status != 0: return status
......@@ -159,10 +159,10 @@ def pull(webapi, prefix, names, force, indentation, format_cache, lib_cache):
# downloads any formats to which we depend on
df_status = dataformats_pull(webapi, prefix, dataformats, force,
indentation + 2, format_cache)
indentation + 2, format_cache)
lib_status = libraries_pull(webapi, prefix, libraries, force,
indentation + 2, lib_cache)
indentation + 2, lib_cache)
return status + df_status + lib_status
......@@ -296,13 +296,13 @@ def execute(prefix, cache, instructions_file):
else: # Analyzer
configuration['result'] = {}
configuration['result']['hash'] = hash.hashAnalyzer(
'block',
'block',
configuration['algorithm'],
algo.hash(),
configuration['parameters'],
configuration['environment'],
dict([(k, v['hash']) for k, v in configuration['inputs'].items()]),
)
)
configuration['result']['path'] = hash.toPath(configuration['result']['hash'], '')
# Sets up the execution
......@@ -359,18 +359,18 @@ def process(args):
elif args['pull']:
with common.make_webapi(args['config']) as webapi:
return pull(webapi, args['config'].path, args['<name>'],
args['--force'], 0, {}, {})
args['--force'], 0, {}, {})
elif args['push']:
with common.make_webapi(args['config']) as webapi:
return common.push(webapi, args['config'].path, 'algorithm',
args['<name>'], ['name', 'declaration', 'code', 'description'],
{}, args['--force'], args['--dry-run'], 0)
args['<name>'], ['name', 'declaration', 'code', 'description'],
{}, args['--force'], args['--dry-run'], 0)
elif args['diff']:
with common.make_webapi(args['config']) as webapi:
return common.diff(webapi, args['config'].path, 'algorithm',
args['<name>'][0], ['declaration', 'code', 'description'])
args['<name>'][0], ['declaration', 'code', 'description'])
elif args['status']:
with common.make_webapi(args['config']) as webapi:
......@@ -381,11 +381,11 @@ def process(args):
elif args['version']:
return common.new_version(args['config'].path, 'algorithm',
args['<name>'][0])
args['<name>'][0])
elif args['fork']:
return common.fork(args['config'].path, 'algorithm',
args['<src>'], args['<dst>'])
args['<src>'], args['<dst>'])
elif args['execute']:
if args['--examples']:
......@@ -400,7 +400,7 @@ def process(args):
return common.delete_remote(webapi, 'algorithm', args['<name>'])
else:
return common.delete_local(args['config'].path, 'algorithm',
args['<name>'])
args['<name>'])
# Should not happen
logger.error("unrecognized `algorithms' subcommand")
......
......@@ -104,7 +104,7 @@ def info(config, paths, sizes, index_start, index_end):
status = f.setup(fullpath, config.path, index_start, index_end)
if not status:
logger.error("cannot setup data source with `%s' and prefix `%s'",
fullpath, config.path)
fullpath, config.path)
return 1
logger.info(' dataformat: %s', f.dataformat.name)
......@@ -149,7 +149,7 @@ def view(config, paths, index_start, index_end):
status = f.setup(fullpath, config.path, index_start, index_end)
if not status:
logger.error("cannot setup data source with `%s' and prefix `%s'",
fullpath, config.path)
fullpath, config.path)
return 1
logger.info(' dataformat: %s', f.dataformat.name)
......@@ -173,12 +173,12 @@ def view(config, paths, index_start, index_end):
for name, value in json_data.items():
json_data[name] = common.stringify(value)
json_data = simplejson.dumps(json_data, indent=2,
cls=NumpyJSONEncoder).\
replace('"BEAT_LIST_DELIMITER[', '[')\
.replace(']BEAT_LIST_DELIMITER"', ']')\
.replace('"...",', '...')\
.replace('"BEAT_LIST_SIZE(', '(')\
.replace(')BEAT_LIST_SIZE"', ')')
cls=NumpyJSONEncoder).\
replace('"BEAT_LIST_DELIMITER[', '[')\
.replace(']BEAT_LIST_DELIMITER"', ']')\
.replace('"...",', '...')\
.replace('"BEAT_LIST_SIZE(', '(')\
.replace(')BEAT_LIST_SIZE"', ')')
logger.info(header + json_data)
return 0
......
This diff is collapsed.
......@@ -95,31 +95,31 @@ DEFAULTS = {
COLOR_THEMES = {
'none': {
'color_critical': '',
'color_error': '',
'color_warn': '',
'color_info': '',
'color_debug': '',
'none': {
'color_critical': '',
'color_error': '',
'color_warn': '',
'color_info': '',
'color_debug': '',
},
'dark': {
'color_critical': 'bold_red',
'color_error': 'fg_red',
'color_warn': 'bold_yellow',
'color_info': 'fg_green',
'color_debug': 'fg_white',
'color_critical': 'bold_red',
'color_error': 'fg_red',
'color_warn': 'bold_yellow',
'color_info': 'fg_green',
'color_debug': 'fg_white',
},
'light': {
'color_critical': 'bold_red',
'color_error': 'fg_red',
'color_warn': 'bold_blue',
'color_info': 'fg_green',
'color_debug': 'fg_grey',
'color_critical': 'bold_red',
'color_error': 'fg_red',
'color_warn': 'bold_blue',
'color_info': 'fg_green',
'color_debug': 'fg_grey',
},
}
}
DEFAULTS.update(COLOR_THEMES['none'])
......@@ -171,7 +171,7 @@ class Configuration(object):
if args.get('--color'):
if args['--color'] not in COLOR_THEMES:
print("ERROR: color theme must be one of `%s' - `%s' is invalid" % \
(','.join(COLOR_THEMES.keys()), args['--color']))
(','.join(COLOR_THEMES.keys()), args['--color']))
sys.exit(1)
self.__data.update(COLOR_THEMES[args['--color']])
......@@ -241,7 +241,7 @@ class Configuration(object):
elif value not in COLOR_THEMES:
print("ERROR: color theme must be one of `%s' - `%s' is invalid" % \
(','.join(COLOR_THEMES.keys()), value))
(','.join(COLOR_THEMES.keys()), value))
sys.exit(1)
self.__data.update(COLOR_THEMES[value])
......
This diff is collapsed.
......@@ -117,7 +117,7 @@ def pull(webapi, prefix, names, force, indentation, cache):
if not download: return 0
status, downloaded = common.pull(webapi, prefix, 'dataformat', download,
['declaration', 'description'], force, indentation)
['declaration', 'description'], force, indentation)
if status != 0: return status
......@@ -157,21 +157,21 @@ def process(args):
elif args['pull']:
with common.make_webapi(args['config']) as webapi:
args['<name>'] = common.make_up_remote_list(webapi, 'dataformat',
args['<name>'])
args['<name>'])
if args['<name>'] is None: return 1 #error
return pull(webapi, args['config'].path, args['<name>'],
args['--force'], 0, {})
args['--force'], 0, {})
elif args['push']:
with common.make_webapi(args['config']) as webapi:
return common.push(webapi, args['config'].path, 'dataformat',
args['<name>'], ['name', 'declaration', 'description'], {},
args['--force'], args['--dry-run'], 0)
args['<name>'], ['name', 'declaration', 'description'], {},
args['--force'], args['--dry-run'], 0)
elif args['diff']:
with common.make_webapi(args['config']) as webapi:
return common.diff(webapi, args['config'].path, 'dataformat',
args['<name>'][0], ['declaration', 'description'])
args['<name>'][0], ['declaration', 'description'])
elif args['status']:
with common.make_webapi(args['config']) as webapi:
......@@ -182,11 +182,11 @@ def process(args):
elif args['version']:
return common.new_version(args['config'].path, 'dataformat',
args['<name>'][0])
args['<name>'][0])
elif args['fork']:
return common.fork(args['config'].path, 'dataformat',
args['<src>'], args['<dst>'])
args['<src>'], args['<dst>'])
elif args['rm']:
if args['--remote']:
......@@ -194,7 +194,7 @@ def process(args):
return common.delete_remote(webapi, 'dataformat', args['<name>'])
else:
return common.delete_local(args['config'].path,
'dataformat', args['<name>'])
'dataformat', args['<name>'])
# Should not happen
logger.error("unrecognized `dataformats' subcommand")
......
......@@ -97,7 +97,7 @@ def run_experiment(configuration, name, force, use_docker, use_local):
f = CachedDataSource()
assert f.setup(os.path.join(executor.cache,
executor.data['result']['path'] + '.data'), executor.prefix)
executor.data['result']['path'] + '.data'), executor.prefix)
data, start, end = f.next()
return data
......@@ -150,7 +150,7 @@ def run_experiment(configuration, name, force, use_docker, use_local):
library_cache = {}
experiment = Experiment(configuration.path, name,
dataformat_cache, database_cache, algorithm_cache, library_cache)
dataformat_cache, database_cache, algorithm_cache, library_cache)
if not experiment.valid:
logger.error("Failed to load the experiment `%s':", name)
......@@ -179,18 +179,18 @@ def run_experiment(configuration, name, force, use_docker, use_local):
search_key = '%s (%s)' % (env['name'], env['version'])
if search_key not in host:
logger.error("Cannot execute block `%s' on environment `%s': " \
"environment was not found' - please install it",
key, search_key)
"environment was not found' - please install it",
key, search_key)
return 1
if use_docker:
executor = DockerExecutor(host, configuration.path, value['configuration'],
configuration.cache, dataformat_cache, database_cache,
algorithm_cache, library_cache)
configuration.cache, dataformat_cache, database_cache,
algorithm_cache, library_cache)
else:
executor = LocalExecutor(configuration.path, value['configuration'],
configuration.cache, dataformat_cache, database_cache,
algorithm_cache, library_cache, configuration.database_paths)
configuration.cache, dataformat_cache, database_cache,
algorithm_cache, library_cache, configuration.database_paths)
if not executor.valid:
logger.error("Failed to load the execution information for `%s':", key)
......@@ -199,7 +199,7 @@ def run_experiment(configuration, name, force, use_docker, use_local):
if executor.outputs_exist and not force:
logger.info("Skipping execution of `%s' for block `%s' " \
"- outputs exist", executor.algorithm.name, key)
"- outputs exist", executor.algorithm.name, key)
continue
logger.info("Running `%s' for block `%s'", executor.algorithm.name, key)
......@@ -216,37 +216,37 @@ def run_experiment(configuration, name, force, use_docker, use_local):
logger.error(" Standard output:\n%s", reindent(result['stdout'], 4))
logger.error(" Standard error:\n%s", reindent(result['stderr'], 4))
logger.error(" Captured user error:\n%s",
reindent(result['user_error'], 4))
reindent(result['user_error'], 4))
logger.error(" Captured system error:\n%s",
reindent(result['system_error'], 4))
reindent(result['system_error'], 4))
logger.extra(" Environment: %s" % 'default environment')
return 1
elif use_docker:
stats = result['statistics']
logger.extra(" CPU time (user, system, total, percent): %s, %s, %s, %d%%",
simplify_time(stats['cpu']['user']),
simplify_time(stats['cpu']['system']),
simplify_time(stats['cpu']['total']),
100. * (stats['cpu']['user'] + stats['cpu']['system']) / stats['cpu']['total'],
simplify_time(stats['cpu']['user']),
simplify_time(stats['cpu']['system']),
simplify_time(stats['cpu']['total']),
100. * (stats['cpu']['user'] + stats['cpu']['system']) / stats['cpu']['total'],
)
logger.extra(" Memory usage: %s",
simplify_size(stats['memory']['rss']))
simplify_size(stats['memory']['rss']))
logger.extra(" Cached input read: %s, %s",
simplify_time(stats['data']['time']['read']),
simplify_size(stats['data']['volume']['read']))
simplify_time(stats['data']['time']['read']),
simplify_size(stats['data']['volume']['read']))
logger.extra(" Cached output write: %s, %s",
simplify_time(stats['data']['time']['write']),
simplify_size(stats['data']['volume']['write']))
simplify_time(stats['data']['time']['write']),
simplify_size(stats['data']['volume']['write']))
logger.extra(" Communication time: %s (%d%%)",
simplify_time(stats['data']['network']['wait_time']),
100. * stats['data']['network']['wait_time'] / stats['cpu']['total'])
simplify_time(stats['data']['network']['wait_time']),
100. * stats['data']['network']['wait_time'] / stats['cpu']['total'])
else:
logger.extra(" Environment: %s" % 'local environment')
if executor.analysis:
data = load_result(executor)
r = reindent(simplejson.dumps(data.as_dict(), indent=2,
cls=NumpyJSONEncoder), 2)
cls=NumpyJSONEncoder), 2)
logger.info(" Results:\n%s", r)
logger.extra(" Outputs produced:")
......@@ -269,7 +269,7 @@ def caches(configuration, name, ls, delete, checksum):
library_cache = {}
experiment = Experiment(configuration.path, name,
dataformat_cache, database_cache, algorithm_cache, library_cache)
dataformat_cache, database_cache, algorithm_cache, library_cache)
if not experiment.valid:
logger.error("Failed to load the experiment `%s':", name)
......@@ -347,7 +347,7 @@ def pull(webapi, prefix, names, force, indentation, format_cache):
from .databases import pull as databases_pull
status, names = common.pull(webapi, prefix, 'experiment', names,
['declaration', 'description'], force, indentation)
['declaration', 'description'], force, indentation)
if status != 0:
logger.error("could not find any matching experiments - widen your search")
......@@ -373,11 +373,11 @@ def pull(webapi, prefix, names, force, indentation, format_cache):
format_cache = {}
library_cache = {}
tc_status, _ = common.pull(webapi, prefix, 'toolchain',
toolchains, ['declaration', 'description'], force, indentation + 2)
toolchains, ['declaration', 'description'], force, indentation + 2)
db_status = databases_pull(webapi, prefix, databases, force,
indentation + 2, format_cache)
indentation + 2, format_cache)
algo_status = algorithms_pull(webapi, prefix, algorithms, force,
indentation + 2, format_cache, library_cache)
indentation + 2, format_cache, library_cache)
return status + tc_status + db_status + algo_status
......@@ -389,7 +389,7 @@ def process(args):
if args['caches']:
return caches(args['config'], args['<name>'][0], args['--list'],
args['--delete'], args['--checksum'])
args['--delete'], args['--checksum'])
elif args['list']:
if args['--remote']:
......@@ -404,19 +404,19 @@ def process(args):
elif args['pull']:
with common.make_webapi(args['config']) as webapi:
return pull(webapi, args['config'].path, args['<name>'], args['--force'],
0, {})
0, {})
elif args['push']:
with common.make_webapi(args['config']) as webapi:
return common.push(webapi, args['config'].path, 'experiment',
args['<name>'],
['name', 'declaration', 'toolchain', 'description'],
{}, args['--force'], args['--dry-run'], 0)
args['<name>'],
['name', 'declaration', 'toolchain', 'description'],
{}, args['--force'], args['--dry-run'], 0)
elif args['diff']:
with common.make_webapi(args['config']) as webapi:
return common.diff(webapi, args['config'].path, 'experiment',
args['<name>'][0], ['declaration', 'description'])
args['<name>'][0], ['declaration', 'description'])
elif args['status']:
with common.make_webapi(args['config']) as webapi:
......@@ -424,7 +424,7 @@ def process(args):
elif args['fork']:
return common.fork(args['config'].path, 'experiment',
args['<src>'], args['<dst>'])
args['<src>'], args['<dst>'])
elif args['rm']:
if args['--remote']:
......@@ -432,11 +432,11 @@ def process(args):
return common.delete_remote(webapi, 'experiment', args['<name>'])
else:
return common.delete_local(args['config'].path, 'experiment',
args['<name>'])
args['<name>'])
elif args['draw']:
return common.dot_diagram(args['config'].path, 'experiment',
args['<name>'], args['--path'], [])
args['<name>'], args['--path'], [])
# Should not happen
logger.error("unrecognized `experiments' subcommand")
......
......@@ -112,7 +112,7 @@ def pull(webapi, prefix, names, force, indentation, cache):
if not download: return 0
status, downloaded = common.pull(webapi, prefix, 'library', download,
['declaration', 'code', 'description'], force, indentation)
['declaration', 'code', 'description'], force, indentation)
if status != 0: return status
......@@ -152,18 +152,18 @@ def process(args):
elif args['pull']:
with common.make_webapi(args['config']) as webapi:
return pull(webapi, args['config'].path, args['<name>'],
args['--force'], 0, {})
args['--force'], 0, {})
elif args['push']:
with common.make_webapi(args['config']) as webapi:
return common.push(webapi, args['config'].path, 'library',
args['<name>'], ['name', 'declaration', 'code', 'description'],
{}, args['--force'], args['--dry-run'], 0)
args['<name>'], ['name', 'declaration', 'code', 'description'],
{}, args['--force'], args['--dry-run'], 0)
elif args['diff']:
with common.make_webapi(args['config']) as webapi:
return common.diff(webapi, args['config'].path, 'library',
args['<name>'][0], ['declaration', 'code', 'description'])
args['<name>'][0], ['declaration', 'code', 'description'])
elif args['status']:
with common.make_webapi(args['config']) as webapi:
......@@ -174,11 +174,11 @@ def process(args):
elif args['version']:
return common.new_version(args['config'].path, 'library',
args['<name>'][0])
args['<name>'][0])
elif args['fork']:
return common.fork(args['config'].path, 'library',
args['<src>'], args['<dst>'])
args['<src>'], args['<dst>'])
elif args['rm']:
if args['--remote']:
......@@ -186,6 +186,6 @@ def process(args):
return common.delete_remote(webapi, 'library', args['<name>'])
else:
return common.delete_local(args['config'].path, 'library',
args['<name>'])
args['<name>'])
return 1
......@@ -71,11 +71,11 @@ def process(args):
elif args['version']:
return common.new_version(args['config'].path, 'plotter',
args['<name>'][0])
args['<name>'][0])
elif args['fork']:
return common.fork(args['config'].path, 'plotter', args['<src>'],
args['<dst>'])
args['<dst>'])
elif args['rm']:
return common.delete_local(args['config'].path, 'plotter', args['<name>'])
......
......@@ -97,15 +97,15 @@ def main(user_input=None):
prog = os.path.basename(sys.argv[0])
completions = dict(
prog=prog,
version=__version__,
)
prog=prog,
version=__version__,
)
args = docopt(
__doc__ % completions,
argv=arguments,
options_first=True,
version='BEAT command-line swiss army knife v%s' % __version__,
)
)
try:
......@@ -120,11 +120,11 @@ def main(user_input=None):
'plotters',
'toolchains',
'experiments',
]
]
if args['<command>'] not in commands_list:
cmd_attempts = difflib.get_close_matches(args['<command>'],
commands_list, cutoff=0.2)
commands_list, cutoff=0.2)
if len(cmd_attempts) > 0:
args['<command>'] = cmd_attempts[0]
......@@ -152,20 +152,20 @@ def main(user_input=None):
format_str = "[%(log_color)s%(levelname)-7s%(reset)s] %(message)s"
if args['--verbose'] >= 3:
format_str = "[%(log_color)s%(asctime)s:%(module)s:%(levelname)-6s" \
"%(reset)s] %(message)s"
"%(reset)s] %(message)s"
# Some coloring
formatter = colorlog.ColoredFormatter(format_str,
log_colors={
'DEBUG': config.color_debug,
'EXTRA': config.color_info,
'INFO': config.color_info,
'WARNING': config.color_warn,
'ERROR': config.color_error,
'CRITICAL': config.color_critical,
},
style='%'
)
log_colors={
'DEBUG': config.color_debug,
'EXTRA': config.color_info,
'INFO': config.color_info,
'WARNING': config.color_warn,
'ERROR': config.color_error,
'CRITICAL': config.color_critical,
},
style='%'
)
console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
......
......@@ -54,7 +54,7 @@ def call(*args, **kwargs):
'--cache=%s' % use_cache,
'--test-mode',
'algorithm',
) + args)
) + args)
@slow
......
......@@ -46,7 +46,7 @@ def call(*args, **kwargs):
'--prefix=%s' % use_prefix,
'--cache=%s' % tmp_prefix,
'--test-mode',
) + args)
) + args)
def setup_module():
......
......@@ -48,7 +48,7 @@ def call(*args, **kwargs):
return main((
'--prefix=%s' % use_prefix,
'--test-mode',
) + args)
) + args)
def test_config_list():
......
......@@ -49,7 +49,7 @@ def call(*args, **kwargs):
'--prefix=%s' % use_prefix,
'--test-mode',
'database',
) + args)
) + args)
@slow
......@@ -158,5 +158,5 @@ def test_index_all(): #bad and good, return != 0
expected_errors = 19
existing_errors = call('index')
assert existing_errors >= expected_errors, "There should be at least %d " \
"errors on installed databases, but I've found only %d" % \
(expected_errors, existing_errors)
"errors on installed databases, but I've found only %d" % \
(expected_errors, existing_errors)
......@@ -50,7 +50,7 @@ def call(*args, **kwargs):
'--prefix=%s' % use_prefix,
'--test-mode',
'dataformat',
) + args)
) + args)
@slow
......
......@@ -54,7 +54,7 @@ def call(*args, **kwargs):
'--cache=%s' % use_cache,
'--test-mode',
'experiment',
) + args)
) + args)
@slow
......
......@@ -44,7 +44,7 @@ def test_shortcuts():
'tc': 'toolchains',
'exp': 'experiments',
'xp': 'experiments',
}
}
for k, v in shortcuts.items():
cmd = difflib.get_close_matches(k, set(shortcuts.values()), cutoff=0.2)
......
......@@ -50,7 +50,7 @@ def call(*args, **kwargs):
'--platform=%s' % use_platform,
'--prefix=%s' % use_prefix,
'--test-mode',
) + args)
) + args)
@skipif(disconnected, "missing test platform (%s)" % platform)
def test_status():
......
......@@ -51,7 +51,7 @@ def call(*args, **kwargs):
'--prefix=%s' % use_prefix,
'--test-mode',
'toolchain',
) + args)
) + args)
@slow
......
......@@ -82,20 +82,20 @@ def process(args):
elif args['pull']:
with common.make_webapi(args['config']) as webapi:
status, downloaded = common.pull(webapi, args['config'].path,
'toolchain', args['<name>'], ['declaration', 'description'],
args['--force'], indentation=0)
'toolchain', args['<name>'], ['declaration', 'description'],
args['--force'], indentation=0)
return status
elif args['push']:
with common.make_webapi(args['config']) as webapi:
return common.push(webapi, args['config'].path, 'toolchain',
args['<name>'], ['name', 'declaration', 'description'], {},
args['--force'], args['--dry-run'], 0)
args['<name>'], ['name', 'declaration', 'description'], {},
args['--force'], args['--dry-run'], 0)
elif args['diff']:
with common.make_webapi(args['config']) as webapi:
return common.diff(webapi, args['config'].path, 'toolchain',
args['<name>'][0], ['declaration', 'description'])
args['<name>'][0], ['declaration', 'description'])
elif args['status']:
with common.make_webapi(args['config']) as webapi:
......@@ -106,11 +106,11 @@ def process(args):
elif args['version']:
return common.new_version(args['config'].path, 'toolchain',
args['<name>'][0])
args['<name>'][0])