Remove KaggleAPI authentication from __init__.py #658
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The kaggle-api module init.py creates an instance of the KaggleAPI and authenticates. If the user has not added a Kaggle API token in their local environment, this code causes a Kaggle.json not found exception to be thrown immediately on package import.
This assertion prevents the user from being able to use the kaggle python API for features that don't need authentication, like the downloading of public data sets. I verified we can download public data sets without authentication using the CLI commands and this feature was already publicly announced here: https://www.kaggle.com/discussions/product-feedback/485439
The existing code doesn't seem to add much value, it seems reasonable to give the developer (importer of the package), the responsibility to simply create an instance of KaggleAPI and authenticate as needed. By removing this code, both the CLI API and the python API can now download public data sets without authentication keeping the behavior consistent. I think it's pretty confusing to allow user's to call the CLI api without authenticating, but force them to authenticate when using the Python API directly. If anything the CLI API should be more restrictive. If this change is rejected, then I highly recommend removing this capability from the CLI API.