-
Notifications
You must be signed in to change notification settings - Fork 36
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 support for utility scripts #207
Conversation
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.
LGTM! Thanks for the integration tests! When we get the notebook versioning tests working and merged, we should add tests for this as well in the tests folder
src/kagglehub/utility_scripts.py
Outdated
f"Notebook '{h.notebook}' by user '{h.notebook}is not an Utility Script" | ||
"\n and will not be added to system path" |
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.
Nit:
f"Notebook '{h.notebook}' by user '{h.notebook}is not an Utility Script" | |
"\n and will not be added to system path" | |
f"Notebook '{h.notebook}' by user '{h.owner}' is not a Utility Script" | |
"\n and will not be added to system path" |
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.
nice catch thanks!
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.
LGTM, thanks!
I think there should be no specific Kaggle Cache work needed for this, we already have notebook Kaggle Cache support (though without versioning for now) which I think your logic here will utilize automatically?
def _is_notebook_utility_script(h: UtilityScriptHandle) -> bool: | ||
try: | ||
api_client = KaggleApiV1Client() | ||
json_response = api_client.get(f"kernels/pull/{h.owner}/{h.notebook}", h) |
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.
How does versioning work with utility scripts? Is it possible for earlier versions of a Notebook to be Utility Scripts but then later versions aren't, or vice versa?
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.
utility scripts is determined at a kernel level by checking if the tag exists (set by users),
and not at a session level like packages.
so if the tag is removed, then all versions are treated like normal notebooks. vice versa
This is introducing a new method that allows users to download and install an utility script from kaggle.
method leverages existing "notebook_output_download" to obtain notebook file,
a call is made to GetKernel to check if notebook is a utility script,
if so, the file path is added to sys path.
in a follow up pr, we will include the cache resolver (if needed) to support this method within kaggle.
https://b.corp.google.com/issues/377510971
DEMO:
https://screencast.googleplex.com/cast/NTk2NTkxOTA0OTIyMDA5Nnw0ODlmOTBhYS0zYw