Skip to content

Commit

Permalink
Add prophet flavor (mlflow#4773)
Browse files Browse the repository at this point in the history
* WIP build

Signed-off-by: benwilson <benjamin.wilson@databricks.com>

* Finish unit tests and address prophet build dependencies for serving

Signed-off-by: benwilson <benjamin.wilson@databricks.com>

* refactor example for prophet and add tracking validation test

Signed-off-by: benwilson <benjamin.wilson@databricks.com>

* adjusting build env

Signed-off-by: benwilson <benjamin.wilson@databricks.com>

* linting

Signed-off-by: benwilson <benjamin.wilson@databricks.com>

* Increase HTTP timeout to 90s. Disabled cloud storage HTTP timeout. (mlflow#4764)

* Increase HTTP timeout to 120s. Disabled cloud storage HTTP timeout.

* Enable auto dependency inference in spark flavor (mlflow#4759)

* use infer_pip_requirements to spark.py

Signed-off-by: harupy <hkawamura0130@gmail.com>

* fix tests

Signed-off-by: harupy <hkawamura0130@gmail.com>

* fix tests

Signed-off-by: harupy <hkawamura0130@gmail.com>

* rename test

Signed-off-by: harupy <hkawamura0130@gmail.com>

* workaround for databricks

Signed-off-by: harupy <hkawamura0130@gmail.com>

* workaround for pyspark in databricks

Signed-off-by: harupy <hkawamura0130@gmail.com>

* rename test

Signed-off-by: harupy <hkawamura0130@gmail.com>

* address comments

Signed-off-by: harupy <hkawamura0130@gmail.com>

* better error message

Signed-off-by: harupy <hkawamura0130@gmail.com>

* fix error message

Signed-off-by: harupy <hkawamura0130@gmail.com>

* Fix `test_autolog_emits_warning_message_when_model_prediction_fails` (mlflow#4768)

* Use AttributeError

Signed-off-by: harupy <hkawamura0130@gmail.com>

* comment

Signed-off-by: harupy <hkawamura0130@gmail.com>

* fix

Signed-off-by: harupy <hkawamura0130@gmail.com>

* use sanity_checking (mlflow#4767)

Signed-off-by: harupy <hkawamura0130@gmail.com>

* refactor: Extract the docker image building _build_image_from_context function (mlflow#4769)

* refactor: Extract the docker image building _build_image_from_context function

Signed-off-by: Alexey Volkov <alexey.volkov@ark-kun.com>

* blacken

Signed-off-by: harupy <hkawamura0130@gmail.com>

Co-authored-by: harupy <hkawamura0130@gmail.com>

* Fix autologging compatibility with Keras >= 2.6.0 (mlflow#4766)

* Increase HTTP timeout to 90s. Disabled cloud storage HTTP timeout. (mlflow#4764)

* Increase HTTP timeout to 120s. Disabled cloud storage HTTP timeout.

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Include keras conditionally

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Fixes

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Fix root cause

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* docstring

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Some test cases

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Some test cases

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Tests

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Format

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Test fixes

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Test fix 2

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Remove keras change

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Use is

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Remove unused modules

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Use fixtures

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Docstring

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Fix fixtures

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Lint fixes

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Format

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Try preserve find module

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>

* fix2

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>

* Simplify fluent test cases

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Format

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Tweaks, add a warning

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Test excludee

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Reverts

Signed-off-by: dbczumar <corey.zumar@databricks.com>

Co-authored-by: jinzhang21 <78067366+jinzhang21@users.noreply.github.com>
Co-authored-by: Weichen Xu <weichen.xu@databricks.com>

* Update spark support version to be 3.2 (mlflow#4770)

* init

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>

* Fix set matrix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Format

Signed-off-by: dbczumar <corey.zumar@databricks.com>

Co-authored-by: dbczumar <corey.zumar@databricks.com>

* merge

* merge

* fix build errors

* Changelog message tweak (mlflow#4777)

* Tweak

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Lang

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Update CHANGELOG.rst

* [ALL TESTS] Update  (mlflow#4778)

* Update MLflow version to 1.20.3

Signed-off-by: Jenkins <jenkins@databricks.com>

* Update

Signed-off-by: dbczumar <corey.zumar@databricks.com>

Co-authored-by: Jenkins <jenkins@databricks.com>
Co-authored-by: dbczumar <corey.zumar@databricks.com>

* Fix small typo (mlflow#4772)

Before:
```
2021/09/03 18:53:45 WARNING mlflow.sklearn.utils: precision_score failed. The metric test_gold_precision_scorewill not be recorded. Metric error: '<' not supported between instances of 'float' and 'str'
2021/09/03 18:53:45 WARNING mlflow.sklearn.utils: recall_score failed. The metric test_gold_recall_scorewill not be recorded. Metric error: '<' not supported between instances of 'float' and 'str'
2021/09/03 18:53:45 WARNING mlflow.sklearn.utils: f1_score failed. The metric test_gold_f1_scorewill not be recorded. Metric error: '<' not supported between instances of 'float' and 'str'
2021/09/03 18:53:45 WARNING mlflow.sklearn.utils: accuracy_score failed. The metric test_gold_accuracy_scorewill not be recorded. Metric error: '<' not supported between instances of 'float' and 'str'
```

Signed-off-by: Louis Guitton <louisguitton93@gmail.com>

* Push MLflow model to Sagemaker model registry (mlflow#4669)

* Added push_sagemaker_model() api to enable push model from MLflow to Sagemaker model registry

Signed-off-by: Jinni Gu <jinnigu@uw.edu>

* Fixed the python doc for _find_transform_job()

Signed-off-by: Jinni Gu <jinnigu@uw.edu>

* Replace https protocol with s3:// protocol for the URL where Sagemaker model artifacts are stored in S3.

Signed-off-by: Yiqing Wang <yiqing@wangemail.com>

* rename push_sagemaker_model function
add CLI function for push_model_to_sagemaker

Signed-off-by: qtz123 <qiutingzhi1995@gmail.com>

* reformat CLI for push_model_to_sagemaker

Signed-off-by: qtz123 <qiutingzhi1995@gmail.com>

* Used describe_model instead of list_models to check if the model exists.

Signed-off-by: Yiqing Wang <yiqing@wangemail.com>

* Renamed the _find_model method to _does_model_exist and limit the scope

Signed-off-by: Yiqing Wang <yiqing@wangemail.com>

* Fixed lint error and changed command to push model

Signed-off-by: Yiqing Wang <yiqing@wangemail.com>

Co-authored-by: Yiqing Wang <yiqing@wangemail.com>
Co-authored-by: qtz123 <qiutingzhi1995@gmail.com>

* Fix tensorflow dev cross test (mlflow#4780)

* init

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>

* dummy tf update

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>

* Adding requirements for prophet examples

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* update conda versions for prophet

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* Fixing the prophet tests

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* PR fixes

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* Add notes on sub-dependencies

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* Updating docs for Prophet flavor

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* Resolve dependencies and add flavor tests

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

* update conda.yaml in examples for prophet

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>

Co-authored-by: jinzhang21 <78067366+jinzhang21@users.noreply.github.com>
Co-authored-by: Harutaka Kawamura <hkawamura0130@gmail.com>
Co-authored-by: Alexey Volkov <alexey.volkov@ark-kun.com>
Co-authored-by: dbczumar <39497902+dbczumar@users.noreply.github.com>
Co-authored-by: Weichen Xu <weichen.xu@databricks.com>
Co-authored-by: dbczumar <corey.zumar@databricks.com>
Co-authored-by: mlflow-automation <61449322+mlflow-automation@users.noreply.github.com>
Co-authored-by: Jenkins <jenkins@databricks.com>
Co-authored-by: Louis Guitton <louisguitton@users.noreply.github.com>
Co-authored-by: Jinni Gu <jinnigu@uw.edu>
Co-authored-by: Yiqing Wang <yiqing@wangemail.com>
Co-authored-by: qtz123 <qiutingzhi1995@gmail.com>
Signed-off-by: Anjali Samad <samad.anjali.14@gmail.com>
  • Loading branch information
13 people authored and anjsam1402 committed Sep 14, 2021
1 parent cb54575 commit e5b486b
Show file tree
Hide file tree
Showing 15 changed files with 779 additions and 276 deletions.
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def pytest_ignore_collect(path, config):
"tests/models",
"tests/shap",
"tests/paddle",
"tests/prophet",
"tests/utils/test_model_utils.py",
# this test is included here because it imports many big libraries like tf, keras, etc
"tests/tracking/fluent/test_fluent_autolog.py",
Expand Down
6 changes: 6 additions & 0 deletions dev/extra-ml-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ pyspark
shap
# Required by mlflow.paddle
paddlepaddle
# Required by mlflow.prophet
# NOTE: Prophet's whl build process will fail with dependencies not being present.
# Installation will default to setup.py in order to install correctly.
# To install in dev environment, ensure that gcc>=8 is installed to allow pystan
# to compile the model binaries. See: https://gcc.gnu.org/install/
prophet
3 changes: 2 additions & 1 deletion dev/run-python-flavor-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ pytest tests/pyfunc --large
pytest tests/azureml --large
pytest tests/utils/test_model_utils.py --large

# TODO: Run tests for h2o, shap, and paddle in the cross-version-tests workflow
# TODO: Run tests for h2o, shap, prophet, and paddle in the cross-version-tests workflow
pytest tests/h2o --large
pytest tests/shap --large
pytest tests/paddle --large
pytest tests/prophet --large

pytest tests/tracking/fluent/test_fluent_autolog.py --large
pytest tests/autologging --large
Expand Down
13 changes: 13 additions & 0 deletions docs/source/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,19 @@ on a ``statsmodels`` model.

For more information, see :py:mod:`mlflow.statsmodels`.

Prophet (``prophet``)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``prophet`` model flavor enables logging of `Prophet models
<https://facebook.github.io/prophet/>`_ in MLflow format via the :py:func:`mlflow.prophet.save_model()`
and :py:func:`mlflow.prophet.log_model()` methods.
These methods also add the ``python_function`` flavor to the MLflow Models that they produce, allowing the
models to be interpreted as generic Python functions for inference via
:py:func:`mlflow.pyfunc.load_model()`. This loaded PyFunc model can only be scored with DataFrame input.
You can also use the :py:func:`mlflow.prophet.load_model()`
method to load MLflow Models with the ``prophet`` model flavor in native prophet format.

For more information, see :py:mod:`mlflow.prophet`.

Model Customization
-------------------

Expand Down
7 changes: 7 additions & 0 deletions docs/source/python_api/mlflow.prophet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mlflow.prophet
==================

.. automodule:: mlflow.prophet
:members:
:undoc-members:
:show-inheritance:
2 changes: 2 additions & 0 deletions docs/source/tutorials-and-examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Below, you can find a number of tutorials and examples for various MLflow use ca

- `SHAP <https://github.com/mlflow/mlflow/tree/master/examples/shap>`_

- `Prophet <https://github.com/mlflow/mlflow/tree/master/examples/prophet>`_

- scikit-learn

+ `Diabetes example <https://github.com/mlflow/mlflow/tree/master/examples/sklearn_elasticnet_diabetes>`_
Expand Down
11 changes: 2 additions & 9 deletions examples/prophet/MLproject
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
name: tutorial
name: prophet_example

conda_env: conda.yaml

entry_points:
main:
parameters:
csv_url: {type: uri, default: 'https://raw.githubusercontent.com/facebook/prophet/e21a05f4f9290649255a2a306855e8b4620816d7/examples/example_wp_log_peyton_manning.csv'}
rolling_window: {type: float, default: 0.1}
command: "python train.py {csv_url} {rolling_window}"
predict:
parameters:
model_uri: {type: uri}
command: "python predict.py {model_uri}"
command: "python train.py"
6 changes: 3 additions & 3 deletions examples/prophet/conda.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: tutorial
name: prophet-example
channels:
- conda-forge
dependencies:
- python=3.6
- pip
- pip:
- mlflow>=1.0
- fbprophet<=0.7
- prophet>=1.0.1

16 changes: 0 additions & 16 deletions examples/prophet/predict.py

This file was deleted.

167 changes: 0 additions & 167 deletions examples/prophet/train.ipynb

This file was deleted.

0 comments on commit e5b486b

Please sign in to comment.