def set(ctx, name, values, append=False): config = ctx.obj['config'] benchmark_name = ctx.obj['benchmark_name'] if not config.exists(): config.parent.mkdir(exist_ok=True, parents=True) config.touch() if append: current_value = get_setting(name, config_file=config, benchmark_name=benchmark_name) if not isinstance(current_value, list): raise click.BadParameter( f"Cannot use option --append with setting '{name}' for which " "a string is expected.") current_value.extend(values) values = current_value if len(values) == 1: values = values[0] set_setting(name, values, config_file=config, benchmark_name=benchmark_name)
def get(ctx, name): config = ctx.obj['config'] benchmark_name = ctx.obj['benchmark_name'] value = get_setting(name, config_file=config, benchmark_name=benchmark_name) if not isinstance(value, str) and isinstance(value, Iterable): value = ' '.join(value) print(f"{name}: {value}")
def publish(benchmark, token=None, filename=None): if token is None: token = get_setting('github_token') if token is None: raise RuntimeError( "Could not find the token value to connect to GitHub.\n\n" "Please go to https://github.com/settings/tokens to generate a " "personal token $TOKEN.\nThen, either provide it with option `-t` " "or put it in a config file ./benchopt.ini\nunder section " "[benchopt] as `github_token = $TOKEN`.") # Get the result file benchmark = Benchmark(benchmark) result_filename = benchmark.get_result_file(filename) # Publish the result. publish_result_file(benchmark.name, result_filename, token)