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

Add support for utility scripts #207

Merged
merged 9 commits into from
Jan 9, 2025
Merged

Add support for utility scripts #207

merged 9 commits into from
Jan 9, 2025

Conversation

calderjo
Copy link
Contributor

@calderjo calderjo commented Jan 7, 2025

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

@calderjo calderjo changed the title rd1 Add support for utility scripts Jan 9, 2025
@calderjo calderjo requested review from jeward414 and dster2 January 9, 2025 19:16
Copy link
Contributor

@jeward414 jeward414 left a 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

Comment on lines 34 to 35
f"Notebook '{h.notebook}' by user '{h.notebook}is not an Utility Script"
"\n and will not be added to system path"
Copy link
Contributor

@jeward414 jeward414 Jan 9, 2025

Choose a reason for hiding this comment

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

Nit:

Suggested change
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"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch thanks!

Copy link
Contributor

@dster2 dster2 left a 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)
Copy link
Contributor

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?

Copy link
Contributor Author

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

@calderjo calderjo merged commit 3594c79 into main Jan 9, 2025
6 checks passed
@calderjo calderjo deleted the kernel-output-tests branch January 9, 2025 20:43
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.

3 participants