-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add dlt commands as Jupyter Notebook magic commands #793
Conversation
…n vs jupyter notebook. It is now more specific
✅ Deploy Preview for dlt-hub-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this PR. it looks good! adding magics is really like writing cli with click library. maybe we'll switch from argparse to click.
what is most important in review:
- please investigate if we really cannot take user input. I was able to take it when launching dlt cli via !dlt ...
maybe regular Pythoninput
works. ie like in here. just placinginput
in a cell definitely works
from IPython.core.magic import register_line_magic
@register_line_magic
def confirm_magic(line):
# Splitting the arguments if you have any
args = line.split()
# Your custom operation logic
print("Starting the operation...")
# Interactive part
confirmation = input("Do you want to continue? [y/n]: ")
if confirmation.lower() == 'y':
print("Operation confirmed.")
# Place the rest of your operation here
else:
print("Operation cancelled.")
# Use the line magic with '%confirm_magic'
- if that does not work - I have an idea how to use non interactive mode and some slight
echo.confirm
modifications instead of all ifs you added. please see my review - please see my remarks in
pyproject.toml
what else we need
- docs are started but not yet finished
- we need to figure out if there's any decent way to write a test for a magic. this may be complicated. I can surely help with that
# Import get_ipython from IPython | ||
from IPython import get_ipython | ||
# Get the class name of the current IPython instance | ||
shell = get_ipython().__class__.__name__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you have a false positive? so notebook detected while not being in the environment? what was wrong with previous function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you can have get_ipython()
returning true without actually being a notebook?
…nk and renamed it, added docstrings
# Conflicts: # poetry.lock
# Conflicts: # poetry.lock
This reverts commit d5bf33f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my quick manual testing:
- detecting notebook presence was changed and now colab is not detected as notebook
- so the
_dlt
alias is not created - documentation to magics does not mention that you need import dlt first
- magics are decorated in a way that positional arguments are optional that should not be the case
- would be cool to tell people how to get help ie
%init?
gives you argument for init
@sh-rp @AstrakhantsevaAA still it would be good to merge it somehow... on a notebook it will be really helpful
2ee3eab
to
e48f641
Compare
Description
Non-interactive ipython magics that work in the notebooks or in the Ipython shell
[ x] add magics for init, pipeline and other commands
[ x] there's a known limitation on Colab - their file editor cannot show files starting with . the result is that users do not see the .dlt folder with secrets and configs. we should solve this somehow. ie. by dlt init that detects running on colab (there's a helper) and then creates a link ie. _dlt that is visible
add a demo colab notebook and documentation to reference section of the docs -> Note, documentation was added, but there is a question of the colab notebook.
run a notebook in Databrics
Implements #502