eldang / elevation_lookups

Takes an input file of paths described as series of points, outputs a file of data about the elevation changes along those paths.
Apache License 2.0
3 stars 2 forks source link

Start a Dockerfile for building the project, with all dependencies. #6

Closed dabreegster closed 3 years ago

dabreegster commented 3 years ago

This makes it through all of the dependency building, but there's an error at runtime:

Traceback (most recent call last):
  File "main.py", line 10, in <module>
    from data import DataSource
  File "/elevation/data.py", line 11, in <module>
    import geopandas as gp  # type: ignore
  File "/usr/local/lib/python3.6/dist-packages/geopandas/__init__.py", line 1, in <module>
    from geopandas._config import options  # noqa
  File "/usr/local/lib/python3.6/dist-packages/geopandas/_config.py", line 126, in <module>
    default_value=_default_use_pygeos(),
  File "/usr/local/lib/python3.6/dist-packages/geopandas/_config.py", line 112, in _default_use_pygeos
    import geopandas._compat as compat
  File "/usr/local/lib/python3.6/dist-packages/geopandas/_compat.py", line 202, in <module>
    import rtree  # noqa
  File "/usr/local/lib/python3.6/dist-packages/rtree/__init__.py", line 9, in <module>
    from .index import Rtree, Index  # noqa
  File "/usr/local/lib/python3.6/dist-packages/rtree/index.py", line 6, in <module>
    from . import core
  File "/usr/local/lib/python3.6/dist-packages/rtree/core.py", line 77, in <module>
    rt.Error_GetLastErrorNum.restype = ctypes.c_int
  File "/usr/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python3: undefined symbol: Error_GetLastErrorNum

The stack trace and https://github.com/Toblerity/rtree/issues/135 suggest the issue is with the rtree dependency. I'm still working on figuring it out.

eldang commented 3 years ago

This is definitely a good idea, given that the dependencies can (a) be such a pain to install and (b) have version conflicts with other tools any given user might need, which aren't resolvable in a convenient way like Python virtual environments. I think it makes sense to get it basically working before merging this.

For how to run this, we should be able to pass the command directly instead of having to invoke bash. Something like:

docker run [IMAGE] bash -c "python3 main.py elevation_montlake"

Adding -v or --mount to mount the data and file directories would also help. I can definitely figure that out, but suspect you might already know how to do it in which case it'll be quicker left to you.

dabreegster commented 3 years ago

I fixed the Error_GetLastErrorNum issue by installing a missing dep. Now everything runs! I'll keep playing around with Docker to figure out the best way to plumb input/output files around, so that ultimately the readme can just have a single command to run.

dabreegster commented 3 years ago

PTAL -- I was able to run on the montlake input data and get some output successfully!

I'm new to Docker, so there may be a simpler way to do this.

dabreegster commented 3 years ago

Thanks for the review! I'll integrate this in the A/B Street importing pipeline tomorrow and likely find other small issues, but this is a start.