Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to locate OSRM module. #52

Closed
josiekre opened this issue May 21, 2019 · 3 comments
Closed

unable to locate OSRM module. #52

josiekre opened this issue May 21, 2019 · 3 comments

Comments

@josiekre
Copy link

Using the following Dockerfile with the fix from #50, points are matching from the tests but lines are not. There's a problem finding the OSRM module.

FROM node:10

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER node
RUN npm install -g sharedstreets@0.12.3
$ docker build -t shst .
$ docker run -it --rm -v ~/Downloads/:/usr/node/ shst:latest shst match /usr/node/line_2.in.geojson --out=/usr/node/out.geojson

  🌏  Loading geojson data...
       Matching using car routing rules on all streets
  ✨  Matching 1 lines...
     writing to cache: /home/node/.shst/cache/tiles/osm/planet-181224/12-1171-1566.geometry.8.pbf
     writing to cache: /home/node/.shst/cache/tiles/osm/planet-181224/12-1171-1566.reference.8.pbf
unable to locate OSRM module.
Unable to build graph: unable to locate OSRM module.
Try deleting existing cached graph: /home/node/.shst/cache/graphs/33d9f459-1a49-3aba-a144-bd7b8338c420

I looked into src/graph.ts. getOSRMDirectory() should be finding the path correctly given where I can find it inside the Docker.

function getOSRMDirectory() {
if(fs.existsSync('node_modules/osrm/')) {
return 'node_modules/osrm/';
}

Inside the Docker, OSRM gets installed at /home/node/.npm-global/lib/node_modules/sharedstreets/node_modules/osrm/.

$ head /home/node/.npm-global/lib/node_modules/sharedstreets/node_modules/osrm/package.json

{
  "_from": "osrm@^5.22.0",
  "_id": "osrm@5.22.0",
  "_inBundle": false,
  "_integrity": "sha512-+OTFX2XsvtBNY47hgkZfxqPhjdXB/wyz1iNqFpVrtNC16VHDvh7twrmOshMzHnRh/KCljJ5ogmRYix8d5
  "_location": "/sharedstreets/osrm",
  "_phantomChildren": {},
  "_requested": {
    "type": "range",
    "registry": true,
@kpwebb
Copy link
Member

kpwebb commented May 22, 2019

@josiekre I just pushed a fix for this, adding additional search steps to find the location of OSRM in node user directories. I tested this on docker and was able to get it to work:

Dockerfile:

FROM node:11

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

USER node
RUN git clone https://github.com/sharedstreets/sharedstreets-js.git /tmp/
RUN npm install -g sharedstreets

Docker image build:
docker build --tag shst-image .

Run match on test data:
docker run -it --rm shst-image shst match /tmp/test/geojson/line_2.in.geojson --out=/tmp/out.geojso

Thanks for investigating the docker steps -- I think that this will be useful of other users, especially those on Windows. The tricky part is making it easy to access data stored on the host computer from inside the docker container. I'm going to investigate if there are standardized approaches for dockerized CLI workflows and will push up this image once we can document the steps.

@kpwebb
Copy link
Member

kpwebb commented May 22, 2019

feature: #53 adding manual override for OSRM path

@josiekre
Copy link
Author

Worked! Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants