Remove kedro.line_magic entrypoint #3748
Replies: 10 comments
-
Thanks for this very clear write up! I'm wondering how this would fit into current ideas around improving the jupyter/ipython workflow (as per 0.17.5 release notes, we have removed
This is an excellent idea I think. As far as I can see the
Just to understand, this would effectively give users the ability to add their own custom code that would be executed upon running |
Beta Was this translation helpful? Give feedback.
-
Yes, I've seen how you refactored the ipython part for the next release and it seems much simpler like this. Regarding the documentation, I agree that apart from the
Yes. The current workflow for a user is:
%reload_kedro
%reload_kedro_mlflow I wish it were:
It is honestly not a big deal and the first workflow is quite satisfying, I just think that it may be more user friendly to hide the "kedro-mlflow" part from the user. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
Somehow it's nearly a year now since this was posted, but I have some fresh thoughts on it now! For context, we've been working on the kedro-viz tl;dr: let's go for the proposal under Possible Alternatives above and remove the Background
So let's remove the entrypoint!If we can agree a good plan with @Galileo-Galilei then I would even be happy to do this as a non-breaking release, after doing a user survey to double check that no one else is using it. What would replace it?Here's the requirements:
Essential (requirement 1)As far as I can tell, satisfying requirement 1 is trivial because this is exactly what's already provided by IPython extensions! If you write an IPython extension then it can then do whatever you like - no need to be constrained like you currently are to just writing line magics with The user flow in a managed jupyter instance would then be:
This is basically the Possible Alternatives proposal from @Galileo-Galilei above. The crucial thing is that I believe this statement is not correct:
So long as Nice to have (requirement 2)If we wanted to, this could be achieved by introducing a new, more general IPython entrypoint that runs when However, introducing this hook feels like a big addition for what would be a small increase in convenience for a small and infrequently used feature (basically just @Galileo-Galilei + kedro-viz). Given that all it does it remove the need for a user to type one extra line of code ( Please comment!From the kedro side, I think the only possible objection would be that the flow for doing We should also check that this doesn't break everything. i.e. if someone upgraded to a version of kedro without this entrypoint but still had things registered to it, would everything crash horribly? What happens if you @Galileo-Galilei what do you think of this all? As above, if it's a plan you are happy with then I think we should just do it after checking that no one else cares in a user survey. |
Beta Was this translation helpful? Give feedback.
-
I should also clarify that the above
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the very detailed answer!
Completely happy with it, and not considering it as a breaking change:
Glad to go with this option!
I figured this out muuuuuuuuch longer after I wrote the original post 😅, but thank you for the indication!
Completly agree on this. The feature seems too little used to be worth the engineering effort, especially since your "Requirement 1" would already be a very convenient setup.
Indeed, it would be a pity to have a lot of users complaining because you removed something unused !
Let's go! 🚀 |
Beta Was this translation helpful? Give feedback.
-
Awesome, thanks for the confirmation @Galileo-Galilei. Looking at the code again actually there's no way this can break anything since Kedro actually doesn't expose particular entrypoint that are available for use; it just tries to load things up using The actions here are: Initial checks
Implement it!
|
Beta Was this translation helpful? Give feedback.
-
Notes from technical design session on 31 August:
|
Beta Was this translation helpful? Give feedback.
-
I am slightly in favor of loading Existing workflows
I would expect 1 is a more common case, so I think most people would only interact with Overall I agree the existing implementation is incorrect (arguably it's a bug, just that no one is using it), but I would go for a lower effort option which may just be fixing the |
Beta Was this translation helpful? Give feedback.
-
@noklam I definitely see the argument for
Compare to possible kedro-viz IPython workflow:
I don't feel strongly about What I think is more important is the existence of the
None of these are hard things to do but I think the effort is comparable to just removing it. Adding the One advantage of an explicit Let me try and paint the picture in a different way: if this It's such a minor thing though that I'm also happy just to leave it as it is rather than removing or fixing it... 😀 |
Beta Was this translation helpful? Give feedback.
-
This issue has changed quite a bit since it was originally written. Look at the final post here to see what we now need to do.
Original issue here for posterity.
Description
I am the author of several kedro plugins either open souce (kedro-mlflow) or at work. It turns out that most plugins either perform one (or several) of the following tasks:
Since Kedro is a data science framework, and since Jupyter is a standard for the exploration phase of a data science project, it seems natural to make Kedro compatible with Jupyter. For now, Kedro offers the following functionnality:
This works well for the core library, but it would be a more pleasant user experience to improve plugin compatibilities with notebooks with the following actions:
Context
It is a common pattern to "setup" your plugin, e.g. instantiate a connection to an external service (kedro-mlflow creates a connection to the mlflow server, I do have a sas plugin which creates a connection to the database...), especially in ther "before pipeline_run" hook.
If I create a custom
line_magic
(say%reload_kedro_mlflow
), it is discovered by kedro and it is accessible inside the notebook or the ipython session. However, I'd like to run it automatically when the notebook is opened via the Kedro CLI instead of forcing the user to make it manually.Possible Implementation
(Optional) Suggest an idea for implementing the addition or change.
IpythonHook()
with aon_ipython_start
@hook_spec
to enable plugins to setup their own configuration when activating the session.line_magic
are discovered (https://github.com/quantumblacklabs/kedro/blob/fc9d1c5d35981c51a651af467e79e93df065d354/kedro/extras/extensions/ipython.py#L104-L106), callhook_manager.on_ipython_start(path, metadata, session, context, catalog)
, so that plugins can setup some configuration automatically.Possible Alternatives
It is currently possible to bypass Kedro configuration by creating a
load_ipython_extension
function to execute code when opening the notebook (like here: https://github.com/quantumblacklabs/kedro/blob/fc9d1c5d35981c51a651af467e79e93df065d354/kedro/extras/extensions/ipython.py#L121). However, we cannot access the objects created byreload_kedro
(especially the session or the catalog if we want to modify /use them). We need to duplicate almost all the code to make it works, and it prevents combining several plugins.Beta Was this translation helpful? Give feedback.
All reactions