douban / pymesos

A pure python implementation of Mesos scheduler and executor
BSD 3-Clause "New" or "Revised" License
163 stars 88 forks source link

missing kazoo dependency #113

Closed dan-at-teza closed 5 years ago

dan-at-teza commented 5 years ago

In pymesos/detector.py:

from kazoo.client import KazooClient as ZKClient

gives me

ImportError: No module named kazoo.client

because kazoo is not listed as a dependency in requirements.txt and pip doesn't grab that dependency for me.

ariesdevil commented 5 years ago

This lib use zkpython as zookeeper client. See: https://github.com/douban/pymesos/blob/bf4ee5d8afbc048d863b5aa5cd5e302a95ae7ae3/pymesos/detector.py#L4

dan-at-teza commented 5 years ago

Hmm... then why isn't zkpython listed as a requirement according to pip? pip install doesn't pick up zpython (or kazoo for that matter).

$ pip show pymesos

Metadata-Version: 2.0 Name: pymesos Version: 0.3.9 Summary: A pure python implementation of Mesos scheduler and executor Home-page: https://github.com/douban/pymesos Author: Zhongbo Tian Author-email: tianzhongbo@douban.com Installer: pip License: UNKNOWN Location: /Users/dadkins/teza-conda/envs/mesos/lib/python2.7/site-packages Requires: addict, six, http-parser Classifiers: Intended Audience :: Developers License :: OSI Approved :: BSD License Operating System :: POSIX Programming Language :: Python

On Thu, Jan 24, 2019 at 7:25 PM ZHAO Yijun notifications@github.com wrote:

This lib use zkpython https://github.com/douban/pymesos/blob/bf4ee5d8afbc048d863b5aa5cd5e302a95ae7ae3/requirements.txt#L14 as zookeeper client. See: https://github.com/douban/pymesos/blob/bf4ee5d8afbc048d863b5aa5cd5e302a95ae7ae3/pymesos/detector.py#L4

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/douban/pymesos/issues/113#issuecomment-457442776, or mute the thread https://github.com/notifications/unsubscribe-auth/AgsndxN--oW1EuofX7gwKuwmnp7lqN64ks5vGnlEgaJpZM4aRY8E .

ariesdevil commented 5 years ago

https://github.com/douban/pymesos/releases/tag/0.3.10

dan-at-teza commented 5 years ago

I wanted to follow up, because I'm not sure what the intention of the following code is: https://github.com/douban/pymesos/blob/master/pymesos/detector.py

try:
    from zookeeper import ZooKeeperException as ZookeeperError
    from .zkpython import ZKClient, ChildrenWatch, DataWatch

    def adjust_zk_logging_level():
        pass
except ImportError:
    from kazoo.client import KazooClient as ZKClient
    from kazoo.recipe.watchers import ChildrenWatch, DataWatch
    from kazoo.exceptions import ZookeeperError

    def adjust_zk_logging_level():
        import logging
        import kazoo
        kazoo.client.log.setLevel(logging.WARNING)
        kazoo.protocol.connection.log.setLevel(logging.WARNING)

It looks to me like this code attempts to use the zkpython library, if available, and if not it falls back to kazoo.

kazoo is the pure python zookeeper client, which is preferable to me for the same reason that I'm attempting to use pymesos: it doesn't rely on native client libraries or installed headers.

I've been using kazoo, not zkpython, because I lack the zookeeper header files necessary to install zkpython. I would prefer to go the pure python route, since native libraries aren't available in my development environment (Mac OS X), or production (barebones Linux with no Internet access).

ariesdevil commented 5 years ago

@dan-at-teza zkpython used in our production and we have no reason to replace it. You could either make it configurable(PR is welcome) or use your fork version.