def launch_options(): blueprint_types = get_valid_blueprint_types() architect_types = get_valid_architect_types() provider_types = get_valid_provider_types() return jsonify( { "success": True, "architect_types": architect_types, "provider_types": provider_types, "blueprint_types": [ {"name": bp, "rank": idx + 1} for (idx, bp) in enumerate(blueprint_types) ], } )
def get_available_architects(): architect_types = get_valid_architect_types() return jsonify({"success": True, "architect_types": architect_types})
def get_help_arguments(args): if len(args) == 0: click.echo( "Usage: mephisto wut <abstraction>[=<type>] [...specific args to check]" ) return from mephisto.operations.registry import ( get_blueprint_from_type, get_crowd_provider_from_type, get_architect_from_type, get_valid_blueprint_types, get_valid_provider_types, get_valid_architect_types, ) from mephisto.operations.utils import get_extra_argument_dicts VALID_ABSTRACTIONS = [ "blueprint", "architect", "requester", "provider", "task" ] abstraction_equal_split = args[0].split("=", 1) abstraction = abstraction_equal_split[0] if abstraction not in VALID_ABSTRACTIONS: click.echo( f"Given abstraction {abstraction} not in valid abstractions {VALID_ABSTRACTIONS}" ) return if abstraction == "task": from mephisto.data_model.task_config import TaskConfig target_class = TaskConfig else: if len(abstraction_equal_split) == 1: # querying about the general abstraction if abstraction == "blueprint": click.echo( f"The blueprint determines the task content. Valid blueprints are {get_valid_blueprint_types()}" ) return elif abstraction == "architect": click.echo( f"The architect determines the server where a task is hosted. Valid architects are {get_valid_architect_types()}" ) return elif abstraction == "requester": click.echo( f"The requester is an account for a crowd provider. Valid requester types are {get_valid_provider_types()}. \n" "Use `mephisto requesters` to see registered requesters, and `mephisto register <requester type>` to register." ) return elif abstraction == "provider": click.echo( f"The crowd provider determines the source of the crowd workers. Valid provider are {get_valid_provider_types()}" ) return # There's a specific abstraction to check abstract_value = abstraction_equal_split[1] target_class = None valid = None if abstraction == "blueprint": try: target_class = get_blueprint_from_type(abstract_value) except: valid = get_valid_blueprint_types() elif abstraction == "architect": try: target_class = get_architect_from_type(abstract_value) except: valid = get_valid_architect_types() elif abstraction == "provider": try: target_class = get_crowd_provider_from_type(abstract_value) except: valid = get_valid_provider_types() elif abstraction == "requester": try: target_class = get_crowd_provider_from_type( abstract_value).RequesterClass except: valid = get_valid_provider_types() if valid is not None: click.echo( f"The valid types for {abstraction} are {valid}. '{abstract_value}' not found." ) return from tabulate import tabulate arg_dict = get_extra_argument_dicts(target_class)[0] click.echo(arg_dict["desc"]) checking_args = arg_dict["args"] if len(args) > 1: checking_args = { k: v for k, v in checking_args.items() if k in args[1:] } click.echo(tabulate(checking_args.values(), headers="keys"))