ODM2 / WOFpy

A server-side implementation of CUAHSI's Water One Flow service stack in Python.
http://odm2.github.io/WOFpy/
9 stars 9 forks source link

yaml dependency problem #237

Open emiliom opened 5 years ago

emiliom commented 5 years ago

I'm running into a strange problem with the yaml package, when creating a conda environment for wofpy. Hopefully this problem will be familiar to you (I'm guessing it's not specific to wofpy).

I've created a wofpy conda env the usual way: conda create -n wofpy -c conda-forge python=2.7 wofpy

yaml is installed:

(wofpy) $ conda list | grep yaml
yaml                      0.1.7             h14c3975_1001    conda-forge

But import yaml produces the error "ImportError: No module named yaml".

I tried explicitly installing yaml after creating the env, but the response was that it was already installed:

(wofpy) $ conda install -c conda-forge yaml
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.

I ran into this yesterday on two independent Ubuntu machines (my laptop and a server), with conda environments created within a two-hour period.

emiliom commented 5 years ago

From @ocefpaf:

The yaml package is not a python package and we need to fix the wofpy dependency declaration. That is the C yaml, see https://github.com/conda-forge/yaml-feedstock/blob/master/recipe/meta.yaml

What you want is pyyaml. I'll send a PR to fix the package.

emiliom commented 5 years ago

I was seeing references to pyyaml in the discussions I found. But I was assuming the wofpy dependency declaration was fine, b/c we used it a lot when developing (or installing) wofpy.

From @ocefpaf: On second thought yaml/pyyaml does not depend on yaml at all. Only one example uses it but that is not core code.

emiliom commented 5 years ago

@ocefpaf, since it turned out to be a problem with wofpy directly, I've opened this issue and copied over our exchanges so far. Thanks again!

ocefpaf commented 5 years ago

yaml, via pyyaml, is only imported in https://github.com/ODM2/WOFpy/blob/8427e345e0853a9ea429f53a4fff115f5f90730c/wof/examples/flask/odm2/timeseries/odm2_timeseries_dao.py#L7, and that is an example, not core code. If yaml is really needed to run WOFpy it is an indirect dependency then, is that correct?

emiliom commented 5 years ago

It's correct that odm2/timeseries/odm2_timeseries_dao.py is not part of the core WOFpy, strictly speaking. But it's more than an example. It's the template "Data Access Object" (DAO) for reading an ODM2 timeseries database, where ODM2 is our primary target for WOFpy. Also, that same code should eventually be added to https://github.com/ODM2/WOFpy/blob/8427e345e0853a9ea429f53a4fff115f5f90730c/wof/examples/flask/odm2/measurement/odm2_measurement_dao.py#L24 But that DAO hasn't been as fully developed and tested as odm2/timeseries (there's actually a PR from Miguel with improvements to it, but I haven't merged it yet because it needs to be broken up).

Anyway, let's add pyyaml to the build. It's lightweight anyways, and we already have odm2api in the build, which is much dependency-heavier and is also not required by the core WOFpy.

Is https://github.com/ODM2/WOFpy/blob/master/setup.py#L54 used directly in the conda build? If so, pyyaml could be added there, right?

ocefpaf commented 5 years ago

Is https://github.com/ODM2/WOFpy/blob/master/setup.py#L54 used directly in the conda build? If so, pyyaml could be added there, right?

Not directly but that should be update first, then a new release, than a conda package update to keep things consistent.

emiliom commented 5 years ago

Ok. For now I'm able to get past this problem by simply installing pyyaml. There are other changes to WOFpy that I already have on my local clone, and a few more coming. I'll plan on sending a PR to update setup.py in the next few days, but I'll wait a while (couple of weeks) before issuing a new release.