From 829450c017b6f0748ef329cb32de03756097e3b3 Mon Sep 17 00:00:00 2001 From: Serhii Koropets <33310880+koropets@users.noreply.github.com> Date: Fri, 29 Jul 2022 14:20:50 +0300 Subject: [PATCH] DEFAULT_BACK_COMPATIBLES environment variable (#1264) * DEFAULT_BACK_COMPATIBLES * test_default_data_provider * Black reformatting * Additonal logger.info() call on server start * Black reformating --- gordo/cli/workflow_generator.py | 8 ++++++++ gordo/server/server.py | 1 + requirements/full_requirements.txt | 2 +- requirements/requirements.in | 2 +- .../data/config-empty-default-data-provider.yml | 17 +++++++++++++++++ .../test_workflow_generator.py | 8 ++++++++ 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/gordo/workflow/test_workflow_generator/data/config-empty-default-data-provider.yml diff --git a/gordo/cli/workflow_generator.py b/gordo/cli/workflow_generator.py index a83b6f008..14e358419 100644 --- a/gordo/cli/workflow_generator.py +++ b/gordo/cli/workflow_generator.py @@ -20,6 +20,7 @@ ) from gordo.cli.exceptions_reporter import ReportLevel from gordo.util.version import parse_version +from gordo_dataset.back_compatibles import DEFAULT_BACK_COMPATIBLES logger = logging.getLogger(__name__) @@ -393,6 +394,11 @@ def workflow_cli(gordo_ctx): help="ModelBuilder class", envvar="MODEL_BUILDER_CLASS", ) +@click.option( + "--default-data-provider", + help="Default data_provider.type for dataset", + envvar=f"{PREFIX}_DEFAULT_DATA_PROVIDER", +) @click.pass_context def workflow_generator_cli(gordo_ctx, **ctx): """ @@ -435,6 +441,8 @@ def workflow_generator_cli(gordo_ctx, **ctx): yaml_content, project_name=context["project_name"], model_builder_env=model_builder_env, + back_compatibles=DEFAULT_BACK_COMPATIBLES, + default_data_provider=context["default_data_provider"], ) version = parse_version(context["gordo_version"]) diff --git a/gordo/server/server.py b/gordo/server/server.py index dcd3a7358..13d97e3de 100644 --- a/gordo/server/server.py +++ b/gordo/server/server.py @@ -143,6 +143,7 @@ def build_app( """ Build app and any associated routes """ + logger.info("Starting Flask('%s') server", __name__) app = Flask(__name__) app.config.from_object(Config()) if config is not None: diff --git a/requirements/full_requirements.txt b/requirements/full_requirements.txt index e4bda8188..7f4d975ab 100644 --- a/requirements/full_requirements.txt +++ b/requirements/full_requirements.txt @@ -152,7 +152,7 @@ google-pasta==0.2.0 # via tensorflow gordo-client==5.2.0rc2 # via -r requirements.in -gordo-dataset==5.0.0rc6 +gordo-dataset==5.0.0rc7 # via # -r requirements.in # gordo-client diff --git a/requirements/requirements.in b/requirements/requirements.in index 3e6a2a055..5c67bce59 100644 --- a/requirements/requirements.in +++ b/requirements/requirements.in @@ -14,7 +14,7 @@ catboost~=0.26.1 prometheus_client~=0.7.1 jeepney>=0.6 packaging~=20.7 -gordo-dataset~=5.0.0rc6 +gordo-dataset~=5.0.0rc7 gordo-client~=5.2.0rc2 # At the bottom are optional dependencies scipy~=1.5.4 diff --git a/tests/gordo/workflow/test_workflow_generator/data/config-empty-default-data-provider.yml b/tests/gordo/workflow/test_workflow_generator/data/config-empty-default-data-provider.yml new file mode 100644 index 000000000..ada41e400 --- /dev/null +++ b/tests/gordo/workflow/test_workflow_generator/data/config-empty-default-data-provider.yml @@ -0,0 +1,17 @@ +machines: + - name: machine + dataset: + tags: + - Tag 1 + - Tag 2 + - Tag 3 + train_start_date: 2016-11-07T08:10:30+00:00 + train_end_date: 2017-11-07T10:10:01+00:00 + +globals: + model: + sklearn.pipeline.Pipeline: + steps: + - sklearn.preprocessing.MinMaxScaler + - gordo.machine.model.models.KerasAutoEncoder: + kind: feedforward_hourglass diff --git a/tests/gordo/workflow/test_workflow_generator/test_workflow_generator.py b/tests/gordo/workflow/test_workflow_generator/test_workflow_generator.py index 2251213a9..5b97c2201 100644 --- a/tests/gordo/workflow/test_workflow_generator/test_workflow_generator.py +++ b/tests/gordo/workflow/test_workflow_generator/test_workflow_generator.py @@ -748,3 +748,11 @@ def test_with_resources_labels(path_to_config_files: str): assert workflow_str.find( expected_str ), 'Unable to find label "some_custom_label" in the generated argo-workflow' + + +def test_default_data_provider(path_to_config_files: str): + args = ["--default-data-provider", "RandomDataProvider"] + workflow_str = _generate_test_workflow_str( + path_to_config_files, "config-empty-default-data-provider.yml", args=args + ) + assert "gordo_dataset.data_providers.providers.RandomDataProvider" in workflow_str