From 7ab10348ed226904e1d032454605465991723944 Mon Sep 17 00:00:00 2001 From: Jinjing Zhou Date: Mon, 28 Feb 2022 13:27:02 +0800 Subject: [PATCH] Sort recipe in DGL-Go (#3781) * add * remove * fix * rework the readme and some changes * add png * update png * add recipe get * sort recipe list and remove copy * fix Co-authored-by: Minjie Wang Co-authored-by: Quan (Andy) Gan --- dglgo/dglgo/cli/recipe_cli.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/dglgo/dglgo/cli/recipe_cli.py b/dglgo/dglgo/cli/recipe_cli.py index 0e20580f643d..4ad97088e73d 100644 --- a/dglgo/dglgo/cli/recipe_cli.py +++ b/dglgo/dglgo/cli/recipe_cli.py @@ -13,21 +13,20 @@ def list_recipes(): typer.echo("="*len(header)) typer.echo(header) typer.echo("="*len(header)) + output_list = [] for file in file_list: cfg = yaml.safe_load(Path(file).open("r")) - typer.echo("| {:<30} | {:<18} | {:<20} |".format(file.name, cfg["pipeline_name"], cfg["data"]["name"])) + output_list.append({ + "file_name": file.name, + "pipeline_name": cfg["pipeline_name"], + "dataset_name": cfg["data"]["name"] + }) + # sort by pipeline, if same sort by dataset, if same sort by file name + output_list.sort(key=lambda f: (f["pipeline_name"], f["dataset_name"], f["file_name"])) + for f in output_list: + typer.echo("| {:<30} | {:<18} | {:<20} |".format(f["file_name"], f["pipeline_name"], f["dataset_name"])) typer.echo("="*len(header)) -def copy_recipes(dir: str = typer.Option("dglgo_example_recipes", help="directory name for recipes")): - file_current_dir = Path(__file__).resolve().parent - recipe_dir = file_current_dir.parent.parent / "recipes" - current_dir = Path(os.getcwd()) - new_dir = current_dir / dir - new_dir.mkdir(parents=True, exist_ok=True) - for file in recipe_dir.glob("*.yaml"): - shutil.copy(file, new_dir) - print("Example recipes are copied to {}".format(new_dir.absolute())) - def get_recipe(recipe_name: Optional[str] = typer.Argument(None, help="The recipe filename to get, e.q. nodepred_citeseer_gcn.yaml")): if recipe_name is None: typer.echo("Usage: dgl recipe get [RECIPE_NAME] \n") @@ -47,7 +46,6 @@ def get_recipe(recipe_name: Optional[str] = typer.Argument(None, help="The recip recipe_app = typer.Typer(help="Get example recipes") recipe_app.command(name="list", help="List all available example recipes")(list_recipes) -recipe_app.command(name="copy", help="Copy all available example recipes to current directory")(copy_recipes) recipe_app.command(name="get", help="Copy the recipe to current directory")(get_recipe) if __name__ == "__main__":