Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

databricks.proto error when importing MLflow after tensorflow #33

Closed
jeanineharb opened this issue Jun 11, 2018 · 23 comments
Closed

databricks.proto error when importing MLflow after tensorflow #33

jeanineharb opened this issue Jun 11, 2018 · 23 comments

Comments

@jeanineharb
Copy link

When I try to import MLflow in my project, I get the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-1-d5dc4544d486> in <module>()
      9 from keras.optimizers import SGD
     10 from keras.preprocessing.image import ImageDataGenerator
---> 11 import mlflow
     12 
     13 import numpy as np

/usr/local/lib/python3.5/dist-packages/mlflow/__init__.py in <module>()
      6 
      7 # pylint: disable=wrong-import-position
----> 8 import mlflow.projects as projects # noqa
      9 import mlflow.tracking as tracking  # noqa
     10 

/usr/local/lib/python3.5/dist-packages/mlflow/projects.py in <module>()
     16 
     17 from mlflow.entities.source_type import SourceType
---> 18 from mlflow.entities.param import Param
     19 from mlflow import data
     20 import mlflow.tracking as tracking

/usr/local/lib/python3.5/dist-packages/mlflow/entities/param.py in <module>()
      1 from mlflow.entities._mlflow_object import _MLflowObject
----> 2 from mlflow.protos.service_pb2 import Param as ProtoParam
      3 
      4 
      5 class Param(_MLflowObject):

/usr/local/lib/python3.5/dist-packages/mlflow/protos/service_pb2.py in <module>()
     18 
     19 from mlflow.protos.scalapb import scalapb_pb2 as scalapb_dot_scalapb__pb2
---> 20 import mlflow.protos.databricks_pb2 as databricks__pb2
     21 
     22 

/usr/local/lib/python3.5/dist-packages/mlflow/protos/databricks_pb2.py in <module>()
     25   serialized_pb=_b('\n\x10\x64\x61tabricks.proto\x1a google/protobuf/descriptor.proto\x1a\x15scalapb/scalapb.proto\"\x9a\x01\n\x14\x44\x61tabricksRpcOptions\x12 \n\tendpoints\x18\x01 \x03(\x0b\x32\r.HttpEndpoint\x12\x1f\n\nvisibility\x18\x02 \x01(\x0e\x32\x0b.Visibility\x12\x1f\n\x0b\x65rror_codes\x18\x03 \x03(\x0e\x32\n.ErrorCode\x12\x1e\n\nrate_limit\x18\x04 \x01(\x0b\x32\n.RateLimit\"N\n\x0cHttpEndpoint\x12\x14\n\x06method\x18\x01 \x01(\t:\x04POST\x12\x0c\n\x04path\x18\x02 \x01(\t\x12\x1a\n\x05since\x18\x03 \x01(\x0b\x32\x0b.ApiVersion\"*\n\nApiVersion\x12\r\n\x05major\x18\x01 \x01(\x05\x12\r\n\x05minor\x18\x02 \x01(\x05\"@\n\tRateLimit\x12\x11\n\tmax_burst\x18\x01 \x01(\x03\x12 \n\x18max_sustained_per_second\x18\x02 \x01(\x03\"\x8c\x01\n\x15\x44ocumentationMetadata\x12\x11\n\tdocstring\x18\x01 \x01(\t\x12\x10\n\x08lead_doc\x18\x02 \x01(\t\x12\x1f\n\nvisibility\x18\x03 \x01(\x0e\x32\x0b.Visibility\x12\x1b\n\x13original_proto_path\x18\x04 \x03(\t\x12\x10\n\x08position\x18\x05 \x01(\x05\"g\n\x1f\x44\x61tabricksServiceExceptionProto\x12\x1e\n\nerror_code\x18\x01 \x01(\x0e\x32\n.ErrorCode\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x13\n\x0bstack_trace\x18\x03 \x01(\t*?\n\nVisibility\x12\n\n\x06PUBLIC\x10\x01\x12\x0c\n\x08INTERNAL\x10\x02\x12\x17\n\x13PUBLIC_UNDOCUMENTED\x10\x03*\xf6\x04\n\tErrorCode\x12\x12\n\x0eINTERNAL_ERROR\x10\x01\x12\x1b\n\x17TEMPORARILY_UNAVAILABLE\x10\x02\x12\x0c\n\x08IO_ERROR\x10\x03\x12\x0f\n\x0b\x42\x41\x44_REQUEST\x10\x04\x12\x1c\n\x17INVALID_PARAMETER_VALUE\x10\xe8\x07\x12\x17\n\x12\x45NDPOINT_NOT_FOUND\x10\xe9\x07\x12\x16\n\x11MALFORMED_REQUEST\x10\xea\x07\x12\x12\n\rINVALID_STATE\x10\xeb\x07\x12\x16\n\x11PERMISSION_DENIED\x10\xec\x07\x12\x15\n\x10\x46\x45\x41TURE_DISABLED\x10\xed\x07\x12\x1a\n\x15\x43USTOMER_UNAUTHORIZED\x10\xee\x07\x12\x1b\n\x16REQUEST_LIMIT_EXCEEDED\x10\xef\x07\x12\x1d\n\x18INVALID_STATE_TRANSITION\x10\xd1\x0f\x12\x1b\n\x16\x43OULD_NOT_ACQUIRE_LOCK\x10\xd2\x0f\x12\x1c\n\x17RESOURCE_ALREADY_EXISTS\x10\xb9\x17\x12\x1c\n\x17RESOURCE_DOES_NOT_EXIST\x10\xba\x17\x12\x13\n\x0eQUOTA_EXCEEDED\x10\xa1\x1f\x12\x1c\n\x17MAX_BLOCK_SIZE_EXCEEDED\x10\xa2\x1f\x12\x1b\n\x16MAX_READ_SIZE_EXCEEDED\x10\xa3\x1f\x12\x13\n\x0e\x44RY_RUN_FAILED\x10\x89\'\x12\x1c\n\x17RESOURCE_LIMIT_EXCEEDED\x10\x8a\'\x12\x18\n\x13\x44IRECTORY_NOT_EMPTY\x10\xf1.\x12\x18\n\x13\x44IRECTORY_PROTECTED\x10\xf2.\x12\x1f\n\x1aMAX_NOTEBOOK_SIZE_EXCEEDED\x10\xf3.:@\n\nvisibility\x12\x1d.google.protobuf.FieldOptions\x18\xd0\x86\x03 \x01(\x0e\x32\x0b.Visibility::\n\x11validate_required\x12\x1d.google.protobuf.FieldOptions\x18\xd1\x86\x03 \x01(\x08:4\n\x0bjson_inline\x12\x1d.google.protobuf.FieldOptions\x18\xd2\x86\x03 \x01(\x08:1\n\x08json_map\x12\x1d.google.protobuf.FieldOptions\x18\xd3\x86\x03 \x01(\x08:J\n\tfield_doc\x12\x1d.google.protobuf.FieldOptions\x18\xd4\x86\x03 \x03(\x0b\x32\x16.DocumentationMetadata:D\n\x03rpc\x12\x1e.google.protobuf.MethodOptions\x18\xd0\x86\x03 \x01(\x0b\x32\x15.DatabricksRpcOptions:L\n\nmethod_doc\x12\x1e.google.protobuf.MethodOptions\x18\xd4\x86\x03 \x03(\x0b\x32\x16.DocumentationMetadata:N\n\x0bmessage_doc\x12\x1f.google.protobuf.MessageOptions\x18\xd4\x86\x03 \x03(\x0b\x32\x16.DocumentationMetadata:N\n\x0bservice_doc\x12\x1f.google.protobuf.ServiceOptions\x18\xd4\x86\x03 \x03(\x0b\x32\x16.DocumentationMetadata:H\n\x08\x65num_doc\x12\x1c.google.protobuf.EnumOptions\x18\xd4\x86\x03 \x03(\x0b\x32\x16.DocumentationMetadata:O\n\x15\x65num_value_visibility\x12!.google.protobuf.EnumValueOptions\x18\xd0\x86\x03 \x01(\x0e\x32\x0b.Visibility:S\n\x0e\x65num_value_doc\x12!.google.protobuf.EnumValueOptions\x18\xd4\x86\x03 \x03(\x0b\x32\x16.DocumentationMetadataB*\n#com.databricks.api.proto.databricks\xe2?\x02\x10\x01')
     26   ,
---> 27   dependencies=[google_dot_protobuf_dot_descriptor__pb2.DESCRIPTOR,scalapb_dot_scalapb__pb2.DESCRIPTOR,])
     28 
     29 _VISIBILITY = _descriptor.EnumDescriptor(

/usr/local/lib/python3.5/dist-packages/google/protobuf/descriptor.py in __new__(cls, name, package, options, serialized_pb, dependencies, public_dependencies, syntax, pool)
    827         # TODO(amauryfa): use the pool passed as argument. This will work only
    828         # for C++-implemented DescriptorPools.
--> 829         return _message.default_pool.AddSerializedFile(serialized_pb)
    830       else:
    831         return super(FileDescriptor, cls).__new__(cls)

TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "databricks.proto":
  databricks.proto: Import "scalapb/scalapb.proto" has not been loaded.

Any idea where the issue may come from? Thank you!

@andrewmchen andrewmchen self-assigned this Jun 11, 2018
@andrewmchen
Copy link
Contributor

In theory, this line should have resolved your problem. https://github.com/databricks/mlflow/blob/master/mlflow/__init__.py#L5.

I noticed that you were able to run the mlflow tutorial from https://github.com/databricks/mlflow/issues/18. Were you running on a different installation there?

Could you let us know what the output of pip freeze? Thanks!

@jeanineharb
Copy link
Author

@andrewmchen Thank you for your answer. Indeed, I had tried to set this environment variable, but it did not resolve the error.

I am working on the same installation. The difference is that I am not using any of the example code provided by MLflow, but instead trying to import MLflow in my own project.

Here is the output of pip freeze:

absl-py==0.1.11
apturl==0.5.2
astor==0.6.2
awscli==1.15.33
beautifulsoup4==4.4.1
bleach==1.5.0
blinker==1.3
boto3==1.7.33
botocore==1.10.33
Brlapi==0.6.4
certifi==2018.4.16
chardet==3.0.4
checkbox-support==0.22
click==6.7
colorama==0.3.9
command-not-found==0.3
configparser==3.5.0
cryptography==1.2.3
cycler==0.10.0
daemonocle==1.0.1
databricks-cli==0.7.2
decorator==4.2.1
defer==1.0.6
docutils==0.14
entrypoints==0.2.3
feedparser==5.1.3
Flask==1.0.2
gast==0.2.0
gitdb2==2.0.3
GitPython==2.1.10
grpcio==1.10.0
guacamole==0.9.2
html5lib==0.9999999
httplib2==0.9.1
idna==2.6
imageio==2.2.0
ipykernel==4.8.2
ipython==6.2.1
ipython-genutils==0.2.0
ipywidgets==7.1.2
itsdangerous==0.24
jedi==0.11.1
Jinja2==2.10
jmespath==0.9.3
jsonschema==2.6.0
jupyter-client==5.2.3
jupyter-core==4.4.0
jupyterlab==0.31.12
jupyterlab-launcher==0.10.5
Keras==2.1.5
kiwisolver==1.0.1
language-selector==0.1
louis==2.6.4
lxml==3.5.0
Mako==1.0.3
Markdown==2.6.11
MarkupSafe==1.0
matplotlib==2.2.2
mistune==0.8.3
mlflow==0.1.0
nbconvert==5.3.1
nbformat==4.4.0
nbstripout==0.3.1
notebook==5.4.1
numpy==1.14.2
oauthlib==1.0.3
onboard==1.2.0
opencv-python==3.3.0.10
padme==1.1.1
pandas==0.22.0
pandocfilters==1.4.2
parso==0.1.1
pexpect==4.0.1
pickleshare==0.7.4
Pillow==3.1.2
plainbox==0.25
prompt-toolkit==1.0.15
protobuf==3.5.2.post1
psutil==5.4.5
ptyprocess==0.5
pyasn1==0.1.9
pycosat==0.6.3
pycups==1.9.73
pycurl==7.43.0
pygal==2.4.0
Pygments==2.2.0
pygobject==3.20.0
PyJWT==1.3.0
pyparsing==2.2.0
python-apt==1.1.0b1+ubuntu0.16.4.1
python-dateutil==2.7.0
python-debian==0.1.27
python-systemd==231
pytz==2018.3
pywinpty==0.5.1
pyxdg==0.25
PyYAML==3.12
pyzmq==17.0.0
querystring-parser==1.2.3
reportlab==3.3.0
requests==2.18.4
rsa==3.4.2
ruamel.yaml==0.15.37
s3transfer==0.1.13
scikit-learn==0.19.1
scipy==1.0.0
seaborn==0.8.1
Send2Trash==1.5.0
sessioninstaller==0.0.0
simplegeneric==0.8.1
six==1.11.0
sklearn==0.0
smmap2==2.0.3
ssh-import-id==5.5
system-service==0.3
tabulate==0.8.2
tensorboard==1.6.0
tensorflow==1.6.0
termcolor==1.1.0
terminado==0.8.1
testpath==0.3.1
tornado==5.0.1
tqdm==4.19.4
traitlets==4.3.2
ubuntu-drivers-common==0.0.0
ufw==0.35
unattended-upgrades==0.1
unity-scope-calculator==0.1
unity-scope-chromiumbookmarks==0.1
unity-scope-colourlovers==0.1
unity-scope-devhelp==0.1
unity-scope-firefoxbookmarks==0.1
unity-scope-gdrive==0.7
unity-scope-manpages==0.1
unity-scope-openclipart==0.1
unity-scope-texdoc==0.1
unity-scope-tomboy==0.1
unity-scope-virtualbox==0.1
unity-scope-yelp==0.1
unity-scope-zotero==0.1
urllib3==1.22
usb-creator==0.3.0
uuid==1.30
virtualenv==15.1.0
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.14.1
widgetsnbextension==3.1.4
xdiagnose==3.8.4.1
xkit==0.0.0
XlsxWriter==0.7.3
zipstream==1.1.4

@zegerhoogeboom
Copy link

I'm running into the same problem. @andrewmchen I believe the issue that fix is referring to is for fixing .proto having the same name, this issue is that there is no such file protos/scalapb/scalapb.proto as referenced here: https://github.com/databricks/mlflow/blob/9e7ec0093a72f4cbe3d55629c7e2cc5043068e12/mlflow/protos/service.proto#L5

Not sure if this is any help, just my two cents.

@zegerhoogeboom
Copy link

zegerhoogeboom commented Jun 12, 2018

Actually, if I manually set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python as an environment variable when running it works so @andrewmchen you're right and my previous comment is false. I'm not sure why this is occurring though.

@andrewmchen
Copy link
Contributor

@zegerhoogeboom, I'm surprised you need to manually set that environment variable. The intention is mlflow/__init__.py should do it for you. The purpose of that environment flag is documented here. protocolbuffers/protobuf#3002 (comment)

@jeanineharb
Copy link
Author

jeanineharb commented Jun 12, 2018

Setting the env variable before the import resolved the error for me as well:

import os
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"

import mlflow

@andrewmchen
Copy link
Contributor

andrewmchen commented Jun 12, 2018

@jeanineharb, @zegerhoogeboom thanks for the feedback. What's the output of print os.environ.get("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION") at this line https://github.com/databricks/mlflow/blob/master/mlflow/__init__.py#L5?

You can change the source of the installed mlflow by changing the file located at (exchanging the pyc extension for py).

import mlflow
mlflow.__file__

@zegerhoogeboom
Copy link

zegerhoogeboom commented Jun 13, 2018

Doing

os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
print(os.environ.get("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"))

at https://github.com/databricks/mlflow/blob/master/mlflow/__init__.py#L5 prints "python".

@zegerhoogeboom
Copy link

I'm not sure how helpful this is but a colleague just had the same problem. He didn't have import mlflow in his entry .py file and after adding import mlflow to the entry source file it worked. Obviously there is also import mlflow in the relevant source code that is using mlflow.

@mateiz
Copy link
Contributor

mateiz commented Jun 14, 2018

Did you import some submodule of mlflow before mlflow itself? Maybe that's the problem if that submodule does not cause the initialization code in mlflow/init.py to run.

@zegerhoogeboom
Copy link

That seems plausible but I can't seem to be able to replicate the issue by first importing a submodule before mlflow itself. If I can provide any more information, I'm happy to help.

@andrewmchen
Copy link
Contributor

@zegerhoogeboom would you be able to share a minimal code example to repro the problem? That'd help us a lot!

@andrewmchen
Copy link
Contributor

Also, perhaps this diff can fix your problem? https://github.com/databricks/mlflow/pull/74/files

Would be great if you can verify if it works.

@zegerhoogeboom
Copy link

@andrewmchen I can't seem to be able to reproduce the issue "on-demand". Manually setting the environment variable definitely worked for me but somehow it now also works if I remove it. Perhaps @jeanineharb is able to create a reproducible case?

If we can't reproduce the issue then perhaps the issue can be kept open for a while in the case someone else bumps into the problem. If not, close it?

@jeanineharb
Copy link
Author

@andrewmchen I have updated my installation to include the diff you proposed. However, it doesn't seem to fix the error.

On the other hand, while trying to create a reproducible case, I changed the import order, and putting import mlflow before all other imports (mainly Keras imports) resolved the error.

@andrewmchen
Copy link
Contributor

@jeanineharb Would you mind sharing the reproducible case? We'd like to fix the problem no matter what order you import mlfllow in.

@jeanineharb
Copy link
Author

@andrewmchen Finally managed to reproduce it:

from time import time
from keras.callbacks import TensorBoard
from keras.models import Sequential, model_from_json
from keras.layers import Conv2D, MaxPooling2D, Dropout, Flatten, Dense
from keras.constraints import maxnorm
from keras.applications import ResNet50, InceptionResNetV2, Xception, InceptionV3, DenseNet201
from keras import backend as K
from keras.optimizers import SGD
from keras.preprocessing.image import ImageDataGenerator

import mlflow


class HelloWorld:
    def __init__(self, arg):
        mlflow.start_run()
        mlflow.log_param("class", "HelloWorld")
        mlflow.log_metric("time", time())


def main():
    h = HelloWorld()


if __name__ == '__main__':
    main()

Running this code produces the following error:

Using TensorFlow backend.
Traceback (most recent call last):
  File "helloworld.py", line 11, in <module>
    import mlflow
  File "/usr/local/lib/python3.5/dist-packages/mlflow-0.1.0-py3.5.egg/mlflow/__init__.py", line 4, in <module>
    import mlflow.projects as projects  # noqa
  File "/usr/local/lib/python3.5/dist-packages/mlflow-0.1.0-py3.5.egg/mlflow/projects.py", line 18, in <module>
    from mlflow.entities.param import Param
  File "/usr/local/lib/python3.5/dist-packages/mlflow-0.1.0-py3.5.egg/mlflow/entities/param.py", line 2, in <module>
    from mlflow.protos.service_pb2 import Param as ProtoParam
  File "/usr/local/lib/python3.5/dist-packages/mlflow-0.1.0-py3.5.egg/mlflow/protos/service_pb2.py", line 20, in <module>
    import mlflow.protos.databricks_pb2 as databricks__pb2
  File "/usr/local/lib/python3.5/dist-packages/mlflow-0.1.0-py3.5.egg/mlflow/protos/databricks_pb2.py", line 27, in <module>
    dependencies=[google_dot_protobuf_dot_descriptor__pb2.DESCRIPTOR,scalapb_dot_scalapb__pb2.DESCRIPTOR,])
  File "/usr/local/lib/python3.5/dist-packages/google/protobuf/descriptor.py", line 829, in __new__
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "databricks.proto":
  databricks.proto: Import "scalapb/scalapb.proto" has not been loaded.

@andrewmchen
Copy link
Contributor

Great! I can repro now. Thanks @jeanineharb and @zegerhoogeboom.

@zegerhoogeboom
Copy link

Great! All props go to @jeanineharb!

@jeanineharb
Copy link
Author

My pleasure, thank you for open-sourcing this great project!

@andrewmchen andrewmchen changed the title databricks.proto error when importing MLflow databricks.proto error when importing MLflow after tensorflow Jun 27, 2018
@andrewmchen
Copy link
Contributor

Should be fixed by https://github.com/databricks/mlflow/pull/74.

@andrewmchen
Copy link
Contributor

The root cause here is that tensorflow is imported before mlflow. When this happens, the protobuf module is first initialized by tensorflow with the C implementation whereas mlflow expects protobuf to use the python implementation.

The fix is to make mlflow work with the C implementation by dropping in the original .proto files.

@andrewmchen
Copy link
Contributor

Fixed in master and in future 0.2.1 release.

javierluraschi pushed a commit to rstudio/mlflow that referenced this issue Aug 25, 2018
juntai-zheng pushed a commit that referenced this issue Dec 19, 2019
Add news item on SAIS talks and add Splice machine logo
jdlesage pushed a commit to jdlesage/mlflow that referenced this issue Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants