def list_model_commands(args): """ List the commands supported by this model.""" model = args.model # Correct model name if possible. matched_model = utils.get_misspelled_pkg(model) if matched_model is not None: model = matched_model logger = logging.getLogger(__name__) logger.info("List available commands of '{}'".format(model)) # Check that the model is installed. utils.check_model_installed(model) entry = utils.load_description(model) commands = entry['commands'] if args.name_only: print('\n'.join(list(commands))) return msg = "The '{}' model " meta = entry['meta'] if 'title' not in meta: title = None else: title = utils.lower_first_letter(utils.dropdot(meta['title'])) msg += "({}) " msg += "supports the following commands:" msg = msg.format(model, title) msg = textwrap.fill(msg, width=75) print(msg) for cmd in commands: utils.print_model_cmd_help(entry, cmd) # Update bash completion list. utils.update_command_completion(set(commands)) # Suggest next step. if not args.quiet: utils.print_next_step('commands', description=entry, model=model)
def list_model_commands(args): """ List the commands supported by this model.""" # Setup. model = args.model # Check that the model is installed. utils.check_model_installed(model) info = utils.load_description(model) if args.name_only: print('\n'.join(list(info['commands']))) return msg = "The model '{}' " if 'title' not in info['meta']: title = None else: title = utils.lower_first_letter(utils.dropdot(info['meta']['title'])) msg += "({}) " msg += "supports the following commands:" msg = msg.format(model, title) msg = textwrap.fill(msg, width=75) print(msg) for c in info['commands']: print("\n $ {} {} {}".format(CMD, c, model)) c_meta = info['commands'][c] if type(c_meta) is str: print(" " + c_meta) else: # Handle malformed DESCRIPTION.yaml like # -- # commands: # print: # description: print a textual summary of the model # score: # equired: the name of a CSV file containing a header and 6 columns # description: apply the model to a supplied dataset desc = c_meta.get('description', None) if desc is not None: print(" " + desc) c_meta = {k:c_meta[k] for k in c_meta if k != 'description'} if len(c_meta) > 0: msg = yaml.dump(c_meta, default_flow_style=False) msg = msg.split('\n') msg = [" " + ele for ele in msg] print('\n'.join(msg), end='') # Update available commands for the model for fast bash tab completion. utils.update_completion_list(COMPLETION_COMMANDS, set(info['commands'])) # Suggest next step. if not args.quiet: utils.print_next_step('commands', description=info, model=model)