Repository: mlflow/mlflow
Pull request: Fix #849: updated mlflow api set used in the tensorflow example
Fix #849: train_predict.py present in mlflow/examples/tensorflow is corresponding to the old branch (0.7) and the code in master is not working with it.

Run log from test after api update: [tensorflow_example_run_log.txt](https://github.com/mlflow/mlflow/files/2834738/tensorflow_example_run_log.txt)


Problem statement:
Tensorflow example is corresponding to old version
### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: No
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Linux Ubuntu 16.04
- **MLflow installed from (source or binary)**: binary
- **MLflow version (run ``mlflow --version``)**:Tried master and 0.7
- **Python version**:  3.7.1 
- **npm version (if running the dev UI):
- **Exact command to reproduce**: Run the example for tensorflow

### Describe the problem
train_predict.py present in mlflow/examples/tensorflow is corresponding to the old branch (0.7) and the code in master is not working with it. Kindly update the example. The method 'log_saved_model' is not present on the file master/mlflow/tensorflow.py instead it is replaced with log_model. The new method has additional parameter which is missing in example. 

### Source code / logs
Already part of source

Hints from issue discussion:

Commit message: updated mlflow api set used

Patch to review:
diff --git a/examples/tensorflow/train_predict.py b/examples/tensorflow/train_predict.py
index 34c0224932529..1bfa06feb8a2e 100644
--- a/examples/tensorflow/train_predict.py
+++ b/examples/tensorflow/train_predict.py
@@ -3,12 +3,15 @@
 from __future__ import print_function
 
 import mlflow
-from mlflow import tensorflow, tracking, pyfunc
+from mlflow import tracking, pyfunc
 import numpy as np
 import pandas as pd
+import os.path
 import shutil
 import tempfile
 import tensorflow as tf
+from tensorflow.python.saved_model import tag_constants
+import mlflow.tensorflow
 
 
 def main(argv):
@@ -36,9 +39,12 @@ def main(argv):
         try:
             saved_estimator_path = regressor.export_savedmodel(temp, receiver_fn).decode("utf-8")
             # Logging the saved model
-            tensorflow.log_saved_model(saved_model_dir=saved_estimator_path, signature_def_key="predict", artifact_path="model")
+            mlflow.tensorflow.log_model(tf_saved_model_dir=saved_estimator_path,
+                                        tf_meta_graph_tags = [tag_constants.SERVING],
+                                        tf_signature_def_key="predict",
+                                        artifact_path="model")
             # Reloading the model
-            pyfunc_model = pyfunc.load_pyfunc(saved_estimator_path)
+            pyfunc_model = pyfunc.load_pyfunc(os.path.join(mlflow.get_artifact_uri(),'model'))
             df = pd.DataFrame(data=x_test, columns=["features"] * x_train.shape[1])
             # Predicting on the loaded Python Function
             predict_df = pyfunc_model.predict(df)


Code review comments:
diff_hunk: @@ -36,9 +39,12 @@ def main(argv):
         try:
             saved_estimator_path = regressor.export_savedmodel(temp, receiver_fn).decode("utf-8")
             # Logging the saved model
-            tensorflow.log_saved_model(saved_model_dir=saved_estimator_path, signature_def_key="predict", artifact_path="model")
+            mlflow.tensorflow.log_model(tf_saved_model_dir=saved_estimator_path,
+                                        tf_meta_graph_tags = [tag_constants.SERVING],
+                                        tf_signature_def_key="predict",
+                                        artifact_path="model")
             # Reloading the model
-            pyfunc_model = pyfunc.load_pyfunc(saved_estimator_path)
+            pyfunc_model = pyfunc.load_pyfunc(os.path.join(mlflow.get_artifact_uri(),'model'))
path: examples/tensorflow/train_predict.py
text: @user1:
LGTM - could we change this to `mlflow.get_artifact_uri("model"))`

@author:
@user1   I implemented the recommended change