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

Use kagglehub inside Kaggle Notebook for tensorflow_hub #1342

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

rosbo
Copy link
Contributor

@rosbo rosbo commented Dec 14, 2023

Use kagglehub inside Kaggle Notebook for tensorflow_hub

Currently, if you try using tensorflow_hub with a kaggle.com URL inside
a Kaggle notebook but the model isn't attached you would get an error
message telling you to attach the model.

With this change, we are calling kagglehub instead and will attach the
model for the user if it is missing.

http://b/311184735

Currently, if you try using tensorflow_hub with a kaggle.com URL inside
a Kaggle notebook but the model isn't attached you would get an error
message telling you to attach the model.

With this change, we are calling `kagglehub` instead and will attach the
model for the user if it is missing.

http://b/311184735

def _is_on_kaggle_notebook():
return os.getenv("KAGGLE_CONTAINER_NAME") != None
return os.getenv("KAGGLE_KERNEL_RUN_TYPE") != None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rosbo rosbo changed the title Tensorflow hub kagglehub Use kagglehub inside Kaggle Notebook for tensorflow_hub Dec 14, 2023
tests/test_kaggle_module_resolver.py Dismissed Show dismissed Hide dismissed
tests/test_kaggle_module_resolver.py Dismissed Show dismissed Hide dismissed
"mountSlug": mount_slug,
},
}), "utf-8"))
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: start with this case to reduce tabs:

if not self.path.endswith(...):
  self.send_response(404)
  ...
content_length = int(self.headers["Content-Length"])
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to keep it this way because we may add new elif cases for other paths and we would want to fail only in the else at the bottom.

Copy link
Contributor Author

@rosbo rosbo left a comment

Choose a reason for hiding this comment

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

I tested the image in a Kaggle notebook and it works.

The test failure is unrelated. See b/316967430

@rosbo rosbo merged commit 83789d0 into main Dec 19, 2023
3 checks passed
@rosbo rosbo deleted the tensorflow_hub_kagglehub branch December 19, 2023 18:04
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.

2 participants