man-group / arctic

High performance datastore for time series and tick data
https://arctic.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
3.06k stars 583 forks source link

NumPy 1.14.0 incompatibility #490

Closed dimosped closed 6 years ago

dimosped commented 6 years ago

Arctic Version

v1.56.0

Arctic Store

VersionStore, TickStore

Description of problem and/or code sample that reproduces the issue

We use astype() to convert to a a dtype which can be a superset of the existing numpy array: https://github.com/manahl/arctic/blob/master/arctic/store/_ndarray_store.py#L240

In this case, using Numpy==1.14.0 prohibits the conversion between dtypes of non equal sizes due to this change: https://github.com/numpy/numpy/commit/7412b85a1b4920e5b72ab694e51b11e4cb615866#diff-d3108a3599564ada8ce08fe45f539350R2674

An example test case to replicate the issue: https://github.com/manahl/arctic/blob/master/tests/integration/store/test_ndarray_store_append.py#L193

dimosped commented 6 years ago

    def append(self, arctic_lib, version, symbol, item, previous_version, dtype=None, dirty_append=True):
        collection = arctic_lib.get_top_level_collection()
        if previous_version.get('shape', [-1]) != [-1, ] + list(item.shape)[1:]:
            raise UnhandledDtypeException()

        if not dtype:
            dtype = item.dtype

        if previous_version['up_to'] == 0:
            dtype = dtype
        elif len(item) == 0:
            dtype = self._dtype(previous_version['dtype'])
        else:
            dtype = self._promote_types(dtype, previous_version['dtype'])
        item = item.astype(dtype)
        if str(dtype) != previous_version['dtype']:
            logger.debug('Converting %s from %s to %s' % (symbol, previous_version['dtype'], str(dtype)))
            if item.dtype.hasobject:
                raise UnhandledDtypeException()
            version['dtype'] = str(dtype)
            version['dtype_metadata'] = dict(dtype.metadata or {})
            version['type'] = self.TYPE

>           old_arr = self._do_read(collection, previous_version, symbol).astype(dtype)
E           ValueError: structures must have the same size

../../../arctic/store/_ndarray_store.py:240: ValueError
================= 1 failed, 1 pytest-warnings in 1.68 seconds ==================
Process finished with exit code 0
bmoscon commented 6 years ago

seems like we should just pin to <= 1.13 ?

dimosped commented 6 years ago

Sure, this will be merged shortly: https://github.com/manahl/arctic/pull/487/commits/f09b2fced394e4d3d777ec23253c7703ce0b44e3

The build now is green.

Frankkkkk commented 6 years ago

Doesn't seem to work for me:

requirements.txt:

git+https://github.com/manahl/arctic.git
flask
flask_restful

pip error:

---> Running in 39ebdbb2fb2e
Collecting git+https://github.com/manahl/arctic.git (from -r /requirements.txt (line 1))
  Cloning https://github.com/manahl/arctic.git to /tmp/pip-y_e8p2ey-build
Collecting flask (from -r /requirements.txt (line 2))
  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
Collecting flask_restful (from -r /requirements.txt (line 3))
  Downloading Flask_RESTful-0.3.6-py2.py3-none-any.whl
Collecting cython (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading Cython-0.27.3-cp35-cp35m-manylinux1_x86_64.whl (3.0MB)
Collecting decorator (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading decorator-4.1.2-py2.py3-none-any.whl
Collecting enum34 (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading enum34-1.1.6-py3-none-any.whl
Collecting mockextras (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading mockextras-1.0.2-py3-none-any.whl
Collecting pandas (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading pandas-0.22.0-cp35-cp35m-manylinux1_x86_64.whl (25.7MB)
Collecting pymongo (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading pymongo-3.6.0-cp35-cp35m-manylinux1_x86_64.whl (378kB)
Collecting python-dateutil (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
Collecting pytz (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
Collecting tzlocal (from arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading tzlocal-1.5.1.tar.gz
Collecting Werkzeug>=0.7 (from flask->-r /requirements.txt (line 2))
  Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
Collecting itsdangerous>=0.21 (from flask->-r /requirements.txt (line 2))
  Downloading itsdangerous-0.24.tar.gz (46kB)
Collecting click>=2.0 (from flask->-r /requirements.txt (line 2))
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting Jinja2>=2.4 (from flask->-r /requirements.txt (line 2))
  Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
Collecting six>=1.3.0 (from flask_restful->-r /requirements.txt (line 3))
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting aniso8601>=0.82 (from flask_restful->-r /requirements.txt (line 3))
  Downloading aniso8601-2.0.0.tar.gz (61kB)
Collecting numpy>=1.9.0 (from pandas->arctic===1.58.0->-r /requirements.txt (line 1))
  Downloading numpy-1.14.0-cp35-cp35m-manylinux1_x86_64.whl (17.1MB)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask->-r /requirements.txt (line 2))
  Downloading MarkupSafe-1.0.tar.gz
Building wheels for collected packages: tzlocal, itsdangerous, aniso8601, MarkupSafe
  Running setup.py bdist_wheel for tzlocal: started
  Running setup.py bdist_wheel for tzlocal: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/7c/a1/5d/0f37ce6eb6eea391bd185f5747429a93519be115d007263bcf
  Running setup.py bdist_wheel for itsdangerous: started
  Running setup.py bdist_wheel for itsdangerous: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a
  Running setup.py bdist_wheel for aniso8601: started
  Running setup.py bdist_wheel for aniso8601: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/d5/ae/d4/49eb253fbd4e2ee4e58c86c51efc65e8ce7b7ce8d845ae4a04
  Running setup.py bdist_wheel for MarkupSafe: started
  Running setup.py bdist_wheel for MarkupSafe: finished with status 'done'
  Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built tzlocal itsdangerous aniso8601 MarkupSafe
Installing collected packages: Werkzeug, itsdangerous, click, MarkupSafe, Jinja2, flask, pytz, six, aniso8601, flask-restful, cython, decorator, enum34, mockextras, python-dateutil, numpy, pandas, pymongo, tzlocal, arctic
  Running setup.py install for arctic: started
    Running setup.py install for arctic: finished with status 'error'
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-y_e8p2ey-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8ct1bo97-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-y_e8p2ey-build/setup.py", line 181, in <module>
        "Topic :: Software Development :: Libraries",
      File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 269, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 826, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1085, in best_match
        dist = working_set.find(req)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 695, in find
        raise VersionConflict(dist, req)
    pkg_resources.VersionConflict: (numpy 1.14.0 (/usr/local/lib/python3.5/dist-packages), Requirement.parse('numpy<=1.13.3'))

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-y_e8p2ey-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8ct1bo97-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-y_e8p2ey-build/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Frankkkkk commented 6 years ago

It works with this requirement.txt file though:

numpy<=1.13.3
git+https://github.com/manahl/arctic.git
flask
flask_restful
bmoscon commented 6 years ago

it looks like it already had numpy 1.14 installed and it errored out:

pkg_resources.VersionConflict: (numpy 1.14.0 (/usr/local/lib/python3.5/dist-packages), Requirement.parse('numpy<=1.13.3'))

dimosped commented 6 years ago

To resolve this issue, we need to take also care of #491

CrazyAlvaro commented 6 years ago

I had the same issue with pre-installed numpy 1.14.0, while uninstall numpy and try to install arctic works.