From 69cf3a3f62e60417495dfa7daba3c742ae525b64 Mon Sep 17 00:00:00 2001 From: Ondrej Platek Date: Wed, 13 Nov 2024 09:19:56 +0100 Subject: [PATCH] Add factgenie list downloadable --- factgenie/bin/run.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/factgenie/bin/run.py b/factgenie/bin/run.py index 620998b4..51f117ab 100644 --- a/factgenie/bin/run.py +++ b/factgenie/bin/run.py @@ -10,7 +10,7 @@ def list_datasets(app): - """List all available datasets.""" + """List locally available datasets.""" from factgenie.workflows import get_local_dataset_overview dataset_overview = get_local_dataset_overview(app) @@ -19,6 +19,22 @@ def list_datasets(app): print(dataset_id) +def list_downloadable(app): + from factgenie import workflows, utils + + datasets = workflows.get_local_dataset_overview(app) + + resources = utils.load_resources_config() + + # set as `downloaded` the datasets that are already downloaded + for dataset_id in resources.keys(): + resources[dataset_id]["downloaded"] = dataset_id in datasets + + for dataset_id, dataset_info in resources.items(): + print(f"{dataset_id} - downloaded: {dataset_info['downloaded']}") + + + def list_outputs(app): """List all available outputs.""" from factgenie.workflows import get_model_outputs_overview @@ -58,7 +74,7 @@ def list_campaigns(app): @app.cli.command("list") -@click.argument("output", type=click.Choice(["datasets", "outputs", "campaigns"])) +@click.argument("output", type=click.Choice(["datasets", "outputs", "campaigns", "downloadable"])) def list_data(output: str): """List available data.""" if output == "datasets": @@ -67,6 +83,10 @@ def list_data(output: str): list_outputs(app) elif output == "campaigns": list_campaigns(app) + elif output == "downloadable": + list_downloadable(app) + else: + click.echo(list_data.get_help(click.Context(list_data))) def show_dataset_info(app, dataset_id: str):