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

[DOC] dynamic session loading in non jupyter environments (marimo, python scripts, streamlit) #4497

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lucharo
Copy link

@lucharo lucharo commented Feb 18, 2025

Description

As discussed in #4440 currently kedro users that decide to not use jupyter for exploration cannot dynamically load their kedro config (catalog, credentials, etc) as those non jupyter environments lack the % magic commands that kedro currently relies on for its ipython/jupyter integration

This PR simply documents how to go ahead with such integration with today's codebase, making use of the private kedro.utils._find_kedro_project

Development notes

nothing changed in development, just a doc PR

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

Signed-off-by: lucharo <luis@merqato.eu>
@lucharo lucharo changed the title [DOC] dynamic session loading wih non jupyter environments [DOC] dynamic session loading in non jupyter environments (marimo, python scripts, streamlit) Feb 18, 2025
Signed-off-by: lucharo <luis@merqato.eu>
Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this contribution @lucharo !

A thought: would it be useful to modify https://docs.kedro.org/en/stable/kedro_project_setup/session.html too? Asking because yesterday I copy-pasted that block on a notebooks/main.ipynb and failed because of similar reasons. So perhaps this is not just a marimo problem.

It does make use of private API though, so I brought this PR to the attention of the team in #4473

Having said all this, I don't want to block this PR on these discussions, which might take long 🙏🏼 So I'll leave some comments just on the changes you made.

Comment on lines 1 to 9
# How to use Kedro from Marimo and non-Jupyter environments

This guide explains how to set up Kedro programmatically without relying on IPython magics, making it compatible with non-Jupyter environments (python scripts or streamlit apps) and modern notebook interfaces like Marimo.

## Overview

Kedro Jupyter notebook users rely on the magic command `%load_ext kedro.ipython` to source their catalog, context, pipelines and session objects, see [Kedro and Notebooks](../notebooks_and_ipython/kedro_and_notebooks.md) for more. This magic command automatically finds the location of the root kedro project, avoiding having users hardcode paths to their configuration files.

Such magic commands are not available in modern notebook interfaces such as marimo or in simple python scripts. Yet, using Kedro for sharing configuration, credentials or the data catalog across a project is still desired when developing data science projects.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While factually correct, I think I'd focus this page on describing how to run Kedro on marimo, so trim down this introduction a bit. Some other possible additions:

  • Do not assume that the reader knows marimo, hence include a sentence linking to its official website and explaining briefly what it is
  • Add the necessary marimo edit or marimo run commands
  • Add a screenshot that demonstrates how this looks like

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you want to focus solely on marimo? I think it could be relevant to talk about non jupyter environments as well: streamlit, python scripts or even cli scripts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also, what is the screenshot meant to show? I think what I might do is create a start that uses marimo, I'd need a screenshot of a starter project that's not my work projects anyway

@astrojuanlu
Copy link
Member

Signed-off-by: lucharo <luis@merqato.eu>
@lucharo
Copy link
Author

lucharo commented Feb 27, 2025

@astrojuanlu I've changed the block in https://docs.kedro.org/en/stable/kedro_project_setup/session.html

I will have a look at kedro starters and hopefully get more content for a doc page, feel free to re-write anything of what I've written. I thought it made sense to treat it as a non jupyter doc page rather than just marimo but it's you guys call the shots!

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

Successfully merging this pull request may close these issues.

kedro marimo + better programmatic setup for non jupyter/ipython envs
2 participants