pixiedust / pixiedust_node

Jupyter magic to allow Node.js code to run in a notebook
https://medium.com/ibm-watson-data-lab/running-node-js-notebooks-in-watson-studio-a8f6545d8299
Apache License 2.0
213 stars 24 forks source link

Working Directory should match Jupyter Python environment #41

Open kav opened 5 years ago

kav commented 5 years ago

It seems like the working directory for the node process should match the python working directory in jupyter. I think, related to #38, this would also default the npm location to this same working directory which makes sense and mirrors the behavior of the %%script node jupyter cell magic.

I'm happy to put together a PR here if needed. My expertise is definitely more on the node side and less on the jupyter and python side so feel free to correct any misunderstandings I may have here.

mptnt1988 commented 5 years ago

Just do this BEFORE importing the package:

import os
os.environ.setdefault('PIXIEDUST_HOME', os.getcwd())
kav commented 5 years ago

Thanks for the workaround. I just set the working for in the node side myself but this is a bit better. That said I’d still propose fixing it more generally. It makes file imports and exports cleaner.