From 68019c80db432e1a15e81e8b86492b7bc7fc1b6e Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 26 Apr 2021 10:38:48 +0100 Subject: [PATCH] core/influx: reuse _locate_functions_or_prompt to choose the data provider --- my/core/influxdb.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/my/core/influxdb.py b/my/core/influxdb.py index a5e950f..3800dae 100644 --- a/my/core/influxdb.py +++ b/my/core/influxdb.py @@ -132,16 +132,12 @@ def main() -> None: @main.command(name='populate', short_help='populate influxdb') @click.option('--reset', is_flag=True, help='Reset Influx measurements before inserting', show_default=True) -@click.argument('MODULE', type=str, required=True) -def populate(module: str, reset: bool) -> None: - from .stats import guess_data_providers - providers = guess_data_providers(module) - # meh.. encapsulate in guess_data_providers? - if 'inputs' in providers: - del providers['inputs'] - # todo could do interactive thing? same way as in hpi query - [(k, f)] = providers.items() - magic_fill(f, reset=reset) +@click.argument('FUNCTION_NAME', type=str, required=True) +def populate(function_name: str, reset: bool) -> None: + from .__main__ import _locate_functions_or_prompt + [provider] = list(_locate_functions_or_prompt([function_name])) + # todo could have a non-interactive version which populates from all data sources for the provider? + magic_fill(provider, reset=reset) # todo later just add to hpi main?