From 5e6a809efdffb9d56aa7a3db7c05027dc8a002a2 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 28 Oct 2019 21:53:34 +0200 Subject: [PATCH] Remove deprecated command --- trains_agent/__main__.py | 22 ++---------------- trains_agent/commands/check_config.py | 5 +++++ trains_agent/commands/worker.py | 32 +++++++++------------------ trains_agent/helper/process.py | 2 -- trains_agent/interface/base.py | 5 ----- 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/trains_agent/__main__.py b/trains_agent/__main__.py index 1f68a3e..5ca6f43 100644 --- a/trains_agent/__main__.py +++ b/trains_agent/__main__.py @@ -20,7 +20,7 @@ from .interface import get_parser def run_command(parser, args, command_name): debug = args.debug - if command_name and command_name.lower() == 'config': + if command_name and command_name.lower() in ('config', 'init'): command_class = commands.Config elif len(command_name.split('.')) < 2: command_class = commands.Worker @@ -76,25 +76,7 @@ def main(): except AttributeError: parser.error(argparse._('too few arguments')) - if not args.trace: - return run_command(parser, args, command_name) - - with named_temporary_file( - mode='w', - buffering=FileBuffering.LINE_BUFFERING, - prefix='.trains_agent_trace_', - suffix='.txt', - delete=False, - ) as output: - print( - 'Saving trace for command ' - '"{definitions.PROGRAM_NAME} {command_name} {args.func}" to "{output.name}"'.format( - **chain_map(locals(), globals()))) - tracer = PackageTrace( - package=trains_agent, - out_file=output, - ignore_submodules=(__name__, interface, definitions, session)) - return tracer.runfunc(run_command, parser, args, command_name) + return run_command(parser, args, command_name) if __name__ == "__main__": diff --git a/trains_agent/commands/check_config.py b/trains_agent/commands/check_config.py index 2657577..d646ab7 100644 --- a/trains_agent/commands/check_config.py +++ b/trains_agent/commands/check_config.py @@ -9,6 +9,11 @@ class Config(ServiceCommandSection): def config(self, **_): return self._session.print_configuration() + def init(self, **_): + # alias config init + from .config import main + return main() + @property def service(self): """ The name of the REST service used by this command """ diff --git a/trains_agent/commands/worker.py b/trains_agent/commands/worker.py index ba1f2ed..04cc583 100644 --- a/trains_agent/commands/worker.py +++ b/trains_agent/commands/worker.py @@ -557,15 +557,6 @@ class Worker(ServiceCommandSection): ) self.dump_config() - def init(self, **_): - # alias config init - from .config import main - return main() - - def config(self, **_): - # alias for check - return self.check() - def check(self, **_): try: check_directory_path(str(Path(".").resolve())) @@ -609,18 +600,17 @@ class Worker(ServiceCommandSection): if not queues: default_queue = self._session.send_api(queues_api.GetDefaultRequest()) queues = [default_queue.id] - print('Listening to default queue "{0.name}" ({0.id})'.format(default_queue)) - else: - queues = return_list(queues) - queues_info = [ - self._session.send_api( - queues_api.GetByIdRequest(queue) - ).queue.to_dict() - for queue in queues - ] - columns = ("id", "name", "tags") - print("Listening to queues:") - print_table(queues_info, columns=columns, titles=columns) + + queues = return_list(queues) + queues_info = [ + self._session.send_api( + queues_api.GetByIdRequest(queue) + ).queue.to_dict() + for queue in queues + ] + columns = ("id", "name", "tags") + print("Listening to queues:") + print_table(queues_info, columns=columns, titles=columns) # register worker self._register(queues) diff --git a/trains_agent/helper/process.py b/trains_agent/helper/process.py index 3c075d2..b723926 100644 --- a/trains_agent/helper/process.py +++ b/trains_agent/helper/process.py @@ -295,8 +295,6 @@ class WorkerParams(object): global_args = ("--config-file", str(self.config_file)) if self.debug: global_args += ("--debug",) - if self.trace: - global_args += ("--trace",) worker_args = tuple() if self.optimization: worker_args += self.get_optimization_flag() diff --git a/trains_agent/interface/base.py b/trains_agent/interface/base.py index d46dc70..a49db34 100644 --- a/trains_agent/interface/base.py +++ b/trains_agent/interface/base.py @@ -374,11 +374,6 @@ def base_arguments(top_parser): '--config-file', help='Use a different configuration file (default: "{}")'.format(definitions.CONFIG_FILE)) top_parser.add_argument('--debug', '-d', action='store_true', help='print debug information') - top_parser.add_argument( - '--trace', '-t', - action='store_true', - help='Trace execution to a temporary file.', - ) def bound_number_type(minimum=None, maximum=None):