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

setup jupyter notebook root folder #2044

Closed
1 task done
prudhomm opened this issue Feb 18, 2023 · 1 comment · Fixed by #2051
Closed
1 task done

setup jupyter notebook root folder #2044

prudhomm opened this issue Feb 18, 2023 · 1 comment · Fixed by #2051
Assignees

Comments

@prudhomm
Copy link
Member

prudhomm commented Feb 18, 2023

I'm not sure this line should stay here : if the preset selected is not python there is no reason this path should be correct.
The advantage of this setting it that when we run a notebook in vscode, it automatically find the development packages installed in build directory, so there is no need to set by hand $PYTHONPATH.
The drawback is that when we launch a kernel, the working directory is no longer the directory where the ipynb file is saved, it is the one set in this line. So it is messy to load the config file (for example in python/pyfeelpp-mor/feelpp/mor/nirb/test_nirb_offline.ipynb, the path is hard coded to a local path "/home/saigre/Documents/code/feelpp/python/pyfeelpp-mor/feelpp/mor/nirb/model/square/square.cfg" which should have not been pushed, my bad !)

see eg:

"jupyter.notebookFileRoot": "${workspaceFolder}/build/python/install/lib/python3/dist-packages",

I don't know what would be the best way to set the environment easily : automatically set PYTHONPATH to the install directory, while the working directory still being the one where the notebook file is saved...

Originally posted by @thomas-saigre in #1944 (comment)

@prudhomm prudhomm changed the title setup jupyter notebook root folter setup jupyter notebook root folder Feb 28, 2023
@prudhomm
Copy link
Member Author

prudhomm commented Mar 1, 2023

I have a solution to propose that does not directly involve vscode but rather cmake and the presets.
I propose to start our notebooks like this:

import sys,os
dev_mode=True
preset='python'
if dev_mode and os.path.exists(f'../../build/{preset}/install/lib/python3/dist-packages'):
    sys.path.insert(0,os.path.abspath(f'../../build/{preset}/install/lib/python3/dist-packages'))
    print(sys.path)

it is the choice of the user to select the dev_node or the preset.
it works nicely.
I am adding notebooks to python and some automated pytests for them.

@prudhomm prudhomm linked a pull request Mar 1, 2023 that will close this issue
5 tasks
prudhomm referenced this issue Mar 12, 2023
skip feelpp skip tests skip mor skip toolboxes
prudhomm referenced this issue Mar 12, 2023
skip feelpp skip toolboxes skip mor skip tests
prudhomm added a commit that referenced this issue Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants