diff --git a/notebooks/integrations/integration-prefect-workflows.ipynb b/notebooks/integrations/integration-prefect-workflows.ipynb index 4c7d029a..92ef2159 100644 --- a/notebooks/integrations/integration-prefect-workflows.ipynb +++ b/notebooks/integrations/integration-prefect-workflows.ipynb @@ -29,8 +29,7 @@ "\n", "### Setting up a simple flow\n", "\n", - "Now we can get started! Creating Prefect **tasks** is easy enough on its own, but we've added\n", - "some simple ones to the ``rubicon_ml`` library." + "Now we can get started! Let's create some simple Prefect **tasks** for the core ``rubcion_ml`` loggers." ] }, { @@ -39,15 +38,56 @@ "metadata": {}, "outputs": [], "source": [ - "from rubicon_ml.workflow.prefect import (\n", - " get_or_create_project_task,\n", - " create_experiment_task,\n", - " log_artifact_task,\n", - " log_dataframe_task,\n", - " log_feature_task,\n", - " log_metric_task,\n", - " log_parameter_task,\n", - ")" + "\n", + "from prefect import task\n", + "\n", + "\n", + "@task\n", + "def get_or_create_project_task(\n", + " persistence, root_dir, project_name, auto_git_enabled=False, storage_options={}, **kwargs\n", + "):\n", + " from rubicon_ml import Rubicon\n", + "\n", + "\n", + " rubicon = Rubicon(\n", + " persistence=persistence,\n", + " root_dir=root_dir,\n", + " auto_git_enabled=auto_git_enabled,\n", + " **storage_options,\n", + " )\n", + " project = rubicon.get_or_create_project(project_name, **kwargs)\n", + "\n", + " return project\n", + "\n", + "\n", + "@task\n", + "def create_experiment_task(project, **kwargs):\n", + " return project.log_experiment(**kwargs)\n", + "\n", + "\n", + "@task\n", + "def log_artifact_task(parent, **kwargs):\n", + " return parent.log_artifact(**kwargs)\n", + "\n", + "\n", + "@task\n", + "def log_dataframe_task(parent, df, **kwargs):\n", + " return parent.log_dataframe(df, **kwargs)\n", + "\n", + "\n", + "@task\n", + "def log_feature_task(experiment, feature_name, **kwargs):\n", + " return experiment.log_feature(feature_name, **kwargs)\n", + "\n", + "\n", + "@task\n", + "def log_metric_task(experiment, metric_name, metric_value, **kwargs):\n", + " return experiment.log_metric(metric_name, metric_value, **kwargs)\n", + "\n", + "\n", + "@task\n", + "def log_parameter_task(experiment, parameter_name, parameter_value, **kwargs):\n", + " return experiment.log_parameter(parameter_name, parameter_value, **kwargs)" ] }, { @@ -65,9 +105,6 @@ "metadata": {}, "outputs": [], "source": [ - "from prefect import task\n", - "\n", - "\n", "@task\n", "def load_data():\n", " from sklearn.datasets import load_wine\n", diff --git a/rubicon_ml/workflow/__init__.py b/rubicon_ml/workflow/__init__.py index e69de29b..24588bfb 100644 --- a/rubicon_ml/workflow/__init__.py +++ b/rubicon_ml/workflow/__init__.py @@ -0,0 +1,8 @@ +import warnings + +warnings.warn( + "The `rubicon_ml.workflow` module is deprecated and will be removed in an upcoming release. " + "`rubicon_ml` can still be leveraged within custom tasks " + "(see https://capitalone.github.io/rubicon-ml/integrations/integration-prefect-workflows.html).", + DeprecationWarning, +) diff --git a/rubicon_ml/workflow/prefect/__init__.py b/rubicon_ml/workflow/prefect/__init__.py index 9e131fcb..7dc8d919 100644 --- a/rubicon_ml/workflow/prefect/__init__.py +++ b/rubicon_ml/workflow/prefect/__init__.py @@ -1,3 +1,6 @@ +import warnings + + def _check_for_prefect_extras(): try: import prefect # noqa F401 @@ -8,6 +11,13 @@ def _check_for_prefect_extras(): raise ImportError(message) +warnings.warn( + "The `rubicon_ml.workflow.prefect` module is deprecated and will be removed in an upcoming release." + "`rubicon_ml` can still be leveraged within custom tasks. " + "(see https://capitalone.github.io/rubicon-ml/integrations/integration-prefect-workflows.html).", + DeprecationWarning, +) + _check_for_prefect_extras() from rubicon_ml.workflow.prefect.tasks import ( # noqa E402 diff --git a/rubicon_ml/workflow/prefect/tasks.py b/rubicon_ml/workflow/prefect/tasks.py index d7bb6b99..14f5805f 100644 --- a/rubicon_ml/workflow/prefect/tasks.py +++ b/rubicon_ml/workflow/prefect/tasks.py @@ -1,7 +1,16 @@ +import warnings + from prefect import task from rubicon_ml import Rubicon +warnings.warn( + "The `rubicon_ml.workflow.prefect.tasks` module is deprecated and will be removed in an upcoming release." + "`rubicon_ml` can still be leveraged within custom tasks. " + "(see https://capitalone.github.io/rubicon-ml/integrations/integration-prefect-workflows.html).", + DeprecationWarning, +) + @task def get_or_create_project_task( diff --git a/tests/unit/workflow/prefect/test_prefect.py b/tests/unit/workflow/prefect/test_prefect.py index e64e9fc5..d624f33c 100644 --- a/tests/unit/workflow/prefect/test_prefect.py +++ b/tests/unit/workflow/prefect/test_prefect.py @@ -1,9 +1,23 @@ +import importlib import sys from unittest.mock import patch import pytest -from rubicon_ml.workflow.prefect import _check_for_prefect_extras +from rubicon_ml import workflow +from rubicon_ml.workflow import prefect +from rubicon_ml.workflow.prefect import _check_for_prefect_extras, tasks + + +def test_deprecations(): + with pytest.deprecated_call(): + importlib.reload(workflow) + + with pytest.deprecated_call(): + importlib.reload(prefect) + + with pytest.deprecated_call(): + importlib.reload(tasks) def test_missing_prefect_extra_raises_error():