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

How to run a specific code at the start of each kernel ? #643

Open
12rambau opened this issue Oct 9, 2024 · 0 comments
Open

How to run a specific code at the start of each kernel ? #643

12rambau opened this issue Oct 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@12rambau
Copy link

12rambau commented Oct 9, 2024

Describe the bug

context
In the context of my documentation I need to connect to Google Earth Engine services. When doing so I need to authenticate to the API. I can do that in the test suit using dedicated environment variables. I would like to run these few lines of code when launching every kernel and avoid to write it down inside the notebooks everytime.
If possible can you show me how to run a "startup" script ?

expectation
I would like to run the following code in every kernel:

import ee, pytest_gee, os

if "EARTHENGINE_PROJECT" in os.environ:
    pytest_gee.init_ee_from_token()
elif "EARTHENGINE_SERVICE_ACCOUNT" in os.environ:
    pytest_gee.init_ee_from_service_account()
else:
    raise ValueError("Cannot authenticate with Earth Engine.")

PS: I'm not using MyST-NB in the context of jupyterbooks but a Sphinx documentation

Reproduce the bug

NA

List your environment

it is unrelated to jupyter-book

@12rambau 12rambau added the bug Something isn't working label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant