opendrift icon indicating copy to clipboard operation
opendrift copied to clipboard

Missing requirements v1.5.5

Open AndreLobato opened this issue 4 years ago • 18 comments

These requirements are missing, it was necessary to install before installing OpenDrift:

  • xarray
  • nc_time_axis
  • coloredlogs

AndreLobato avatar Feb 04 '21 04:02 AndreLobato

Also, to install OilLibrary, I had to install:

  • futures

And fix this library version:

  • zope.sqlalchemy<1.2

AndreLobato avatar Feb 04 '21 04:02 AndreLobato

Hi, how did you install opendrift? These should be included both in environment.yml and in the conda package.

gauteh avatar Feb 04 '21 08:02 gauteh

I've cloned the repo, set the tag 1.5.5 and used pip install -r requirements.txt && pip install .

AndreLobato avatar Feb 04 '21 20:02 AndreLobato

Hi,

No that won't work. You should follow this recipe: https://opendrift.github.io/install.html

knutfrode avatar Feb 04 '21 20:02 knutfrode

Well, by only supporting Conda installs, you're basic vendor-locking the package installation as not all Python developers are Conda users. With some small changes to requirements.txt could be installed with pip or python setup.py install without issues. Would have to keep requirements.txt and propagate to install_requires from setup.py file and everything should work.

The OilLibrary and opendrift_landmask_data would have to follow the same idea, for the opendrift_landmask_data I only had to install affine that wasn't declared.

AndreLobato avatar Feb 04 '21 21:02 AndreLobato

Ok, good that you managed.

We had pip-instructions earlier, but left it out in favor of conda, as it was much more straightforward and identical on all platforms. But we should probably re-introduce the pip-instructions anyway. Are there any details you could share about the changes you needed to do - apart from what you already mentioned?

knutfrode avatar Feb 04 '21 21:02 knutfrode

Ok, I think I've managed to do a (near) stable build with pip, out of a Python official Docker image.

FROM python:3.8-buster

RUN apt update && \
    apt install -y libeccodes-dev libeccodes0 libproj-dev proj-bin libgeos-dev && \
    apt -y upgrade && \
    apt clean

RUN pip install -U pip Cython &&\
    pip install \
        # OilLibrary requires
        zope.sqlalchemy\<1.2\
        # opendrift-landmask-data requires
        future\
        # opendrift requires
        cfgrib \
        coloredlogs \
        dask \
        eccodes \
        ffmpeg \
        geojson \
        motuclient \
        nc_time_axis \
        pytest-benchmark\
        toolz\
        xarray \
        xhistogram \
        shapely --no-binary shapely &&\
    # We do this because we don't trust setup.py install_requires
    pip install -r https://raw.githubusercontent.com/OpenDrift/OilLibrary/master/requirements.txt &&\
    pip install -r https://raw.githubusercontent.com/OpenDrift/opendrift-landmask-data/master/requirements.txt

RUN git clone --depth 1 --branch v1.5.5 https://github.com/OpenDrift/opendrift.git /source/opendrift &&\
    cd /source/opendrift &&\
    pip install -r requirements.txt &&\
    pip install .

Fixed (see Edit): I've only had to skip 2 tests that gave segmentation fault, something between Cartopy, Matplotlib and multiprocessing, but I am not sure what, but all other tests from testall passed, although many warnings were raised:

  • tests/integration/test_run.py:TestRun.test_plot_animation
  • tests/unit/test_readers.py:TestReaders.test_map_background

For propagating the requirements to install_required I usually just .read().splitlines() the requirements file, but is a bit limited approach since you could have comments and some version notations that might not work.

Edit: Figured the issue with the 2 failed tests, turnsout that Shapely needs to be installed not from Pypi wheel, but built from source at install time using the current system GEOS library, that's why need to install Cython first then Shapely with --no-binary shapely option.

Note on GEOS installation: Debian stable (buster) only has GEOS v2.4 but Cartopy requres >v.3.3, which will be only avalable on apt on next Debian release, so it's possible to find some issue there, but at least all tests seems to pass as far OpenDrift is concerned.

I hope it helps

AndreLobato avatar Feb 05 '21 04:02 AndreLobato

@gauteh you saved my day. I cannot stand Conda on Ubuntu, thanks!

Boorhin avatar Feb 25 '21 12:02 Boorhin

You probably meant @AndreLobato :) ?

gauteh avatar Feb 25 '21 12:02 gauteh

You probably meant @AndreLobato :) ?

hahahahha yes, sorry :) just to say it worked

Boorhin avatar Feb 25 '21 12:02 Boorhin

Did you manage to install it with the recipe of Andre, or did you have to make further tweaks?

We wish that installation with pip would be even smoother and same for all platforms, but will look out for updates towards this end in the future.

knutfrode avatar Feb 25 '21 12:02 knutfrode

I followed the recipe, had to downgrade zope.sqlalchemy which was a bit annoying and didn't install shapely as I had done it already No tweak really on Ubuntu 20.04

Boorhin avatar Feb 25 '21 13:02 Boorhin

There will have to be some major changes to the oil-drift module in the future (but probably not near future), we will then hopefully get rid of several of the problematic dependencies, and maybe even make it easier to create a PIP package.

gauteh avatar Apr 12 '21 07:04 gauteh

I come back to this as I am trying to deploy Opendrift in a cloud environment. The main annoyance is this SQLAlchemy module. One version working is 1.1.18. Then the Oil library work. pip install SQLAlchemy==1.1.18 The error is

ImportError: cannot import name 'SessionExtension' from 'sqlalchemy.orm.session' (/home/moreau_juli1/.local/lib/python3.8/site-packages/sqlalchemy/orm/session.py)

It would be good to change generation of SQLAlchemy as the 1.3 is fully python3 https://docs.sqlalchemy.org/en/13/intro.html#installation

It seems that it could just be this import command that needs to be changed. Then you can probably install everything with pip which would be a great convenience

Boorhin avatar Jan 13 '22 16:01 Boorhin

In OpenDrift v 1.8.0 we have switched to the new version of NOAA OilLibrary (ADIOS), and therefore do not anymore need SQLAlchemy and several other troublesome packages:

https://github.com/OpenDrift/opendrift/blob/master/environment.yml

knutfrode avatar Jan 13 '22 16:01 knutfrode

ok I am running 1.8 but oildrift and landmask requirements.txt are still SQLAlchemy I think, let me check

Boorhin avatar Jan 13 '22 16:01 Boorhin

ok, yes requirements.txt has not yet been updated. I believe you can simply remove the OilLibrary from there, and possible need to insert pynucos>=2.12

knutfrode avatar Jan 13 '22 16:01 knutfrode

made a pull request then

Boorhin avatar Jan 13 '22 16:01 Boorhin