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

Choose kernel #2

Open
Eloitor opened this issue Oct 29, 2023 · 4 comments
Open

Choose kernel #2

Eloitor opened this issue Oct 29, 2023 · 4 comments

Comments

@Eloitor
Copy link

Eloitor commented Oct 29, 2023

In a jupyter notebook it is possible to choose other kernels (like SageMath).

Is it possible to choose the kernel in saturn?

@mrzv
Copy link
Owner

mrzv commented Oct 29, 2023

There is no concept of kernels in Saturn. The idea is not to take over the environment, but to be just another Python module, inside whatever (possibly virtual) environment you like, that plays nice with everything else. So it's possible to install saturn as a package inside sage. The following works:

sage --pip install saturn_notebook
sage --python -m saturn_notebook

>>> from sage.all import *
>>> u = var('u')

Unfortunately, I don't know enough about sage to know if this will create problems or work as intended.

@Eloitor
Copy link
Author

Eloitor commented Oct 29, 2023

Thanks for the answer.

SageMath has slightly different syntax to python's: https://doc.sagemath.org/html/en/tutorial/afterword.html
The equivalent of eval in sage is from sage.misc.sage_eval import sage_eval.

I think it should be possible to replace the python's eval of the notebook with sage_eval, but I'm not sure how

@mrzv
Copy link
Owner

mrzv commented Oct 29, 2023

All the code evaluation logic happens in evaluate.py. Perhaps, there is a way to tweak that. If you find a clean way, please submit a pull request.

@Eloitor
Copy link
Author

Eloitor commented Oct 29, 2023

Maybe https://pypi.org/project/jupyter-client/ could be used...

Here's an example of a jupyter notebook app using it: https://github.com/cvfosammmm/Porto/blob/master/notebook/backend/backend_code.py#L209

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