### Introduction
The repository adds simple class for adding a wrapper on top of kaggle cli tools for ease of downloading competition datasets, listing competitions, downloading and un-zipping datasets.
It aims to make it easy to use kaggle datasets directly from python scripts.
It's main usecase is to be used as a submodule in other repos/ or used as a standalone package.
If the library is used as a standalone package - the data is downloaded and stored in data folder.
In case of using the package as a submodule - the data is downloaded in a data folder created in the base folder of the calling script.
### Installation
The repo relies on setuptools and kaggle library packages. To install the repo please use one of the following options:
```bash
pip install -U kaggle setuptools
python setup.py install
```
It also assumes that presence of Kaggle User ID and public API credentials at
```
On Windows: C:\Users\<Windows-username>\.kaggle\kaggle.json
Others: ~/. kaggle/kaggle.json
```
After the above steps: the repo can be installed from git using:
```
pip install git+https://github.com/sunny1401/kaggle_utils.git#egg=kaggle-cli-wrapper
```
The project can also be installed using pip:
```
pip install kaggle-cli-wrapper
```
## Code details
### DataAPI class
#### To list all available datasets
```python
from kaggle_cli_wrapper import KaggleDataApi
kda = KaggleDataApi(call_path=__file__)
kda.list_all_kaggle_datasets(search_term="cityscapes")
```
The call_path argument is required to decide the folder where downloaded files are stored.
The function would return all available datasets with cityscape. This would also be saved as a .txt file.
Currently the list is sorted by "votes".
To change this sorting please use the argument ```sort_by```. Allowed values of sort by are:
```python
'hottest', 'votes', 'updated', 'active', 'published'
```
#### To list all available competition datasets
```python
from kaggle_cli_wrapper import KaggleDataApi
kda = KaggleDataApi(call_path=__file__)
kda.list_all_kaggle_competitions(search_term="cityscapes")
```
Currently the list is sorted by "earliestDeadline".
To change this sorting please use the argument ```sort_by```. Allowed values of sort by are:
```python
'grouped', 'prize', 'earliestDeadline','latestDeadline', 'numberOfTeams', 'recentlyCreated'
```
#### To download datasets
```python
from kaggle_cli_wrapper import KaggleDataApi
kda = KaggleDataApi(call_path=__file__)
kda.download_kaggle_dataset(dataset_name="cityscapes_train_val_test", is_competition_dataset=False)
```
To download a competition dataset, is_competition_dataset needs to be set to True
### ScoringAPI
The code currently supports minimum functionality for submission of files to a competition and getting scores for the competition
#### To submit to a competition
```python
from kaggle_utils.kaggle_cli_wrapper import KaggleScoringsApi
kaggle_scoring_api = KaggleScoringsApi(competition_name="facial-keypoints-detection")
kaggle_scoring_api.submit_solution(submissions_file=submission_path, description="facial_keypoint_vanilla_cnn")
kaggle_scoring_api.get_top_scores()
```
## Remaining Issues
- improve error handling
- allow for saving of stdout
Raw data
{
"_id": null,
"home_page": "https://github.com/sunny1401/kaggle_utils",
"name": "kaggle-cli-wrapper",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "Kaggle,API,Wrapper,Python",
"author": "Sunny Joshi",
"author_email": "Sunny Joshi <sunnyjoshi1401@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8a/9a/c57ff02d0c852b3fe117599e72ffd349acbcb0217e99479b895842d4a32c/kaggle_cli_wrapper-0.2.tar.gz",
"platform": null,
"description": "### Introduction\nThe repository adds simple class for adding a wrapper on top of kaggle cli tools for ease of downloading competition datasets, listing competitions, downloading and un-zipping datasets.\n\nIt aims to make it easy to use kaggle datasets directly from python scripts. \n It's main usecase is to be used as a submodule in other repos/ or used as a standalone package.\n If the library is used as a standalone package - the data is downloaded and stored in data folder.\n In case of using the package as a submodule - the data is downloaded in a data folder created in the base folder of the calling script. \n\n### Installation\nThe repo relies on setuptools and kaggle library packages. To install the repo please use one of the following options:\n\n\n```bash\npip install -U kaggle setuptools\npython setup.py install\n```\n\n\nIt also assumes that presence of Kaggle User ID and public API credentials at \n\n```\nOn Windows: C:\\Users\\<Windows-username>\\.kaggle\\kaggle.json\n\nOthers: ~/. kaggle/kaggle.json\n```\n\nAfter the above steps: the repo can be installed from git using:\n\n```\npip install git+https://github.com/sunny1401/kaggle_utils.git#egg=kaggle-cli-wrapper\n```\n\nThe project can also be installed using pip:\n\n```\npip install kaggle-cli-wrapper\n```\n\n## Code details\n\n### DataAPI class\n\n#### To list all available datasets\n\n```python\nfrom kaggle_cli_wrapper import KaggleDataApi\n\nkda = KaggleDataApi(call_path=__file__)\nkda.list_all_kaggle_datasets(search_term=\"cityscapes\")\n```\nThe call_path argument is required to decide the folder where downloaded files are stored.\n\nThe function would return all available datasets with cityscape. This would also be saved as a .txt file. \n\nCurrently the list is sorted by \"votes\".\nTo change this sorting please use the argument ```sort_by```. Allowed values of sort by are: \n\n```python\n'hottest', 'votes', 'updated', 'active', 'published'\n```\n\n\n#### To list all available competition datasets\n\n```python\nfrom kaggle_cli_wrapper import KaggleDataApi\n\nkda = KaggleDataApi(call_path=__file__)\nkda.list_all_kaggle_competitions(search_term=\"cityscapes\")\n```\n\nCurrently the list is sorted by \"earliestDeadline\".\nTo change this sorting please use the argument ```sort_by```. Allowed values of sort by are: \n\n```python\n'grouped', 'prize', 'earliestDeadline','latestDeadline', 'numberOfTeams', 'recentlyCreated'\n\n```\n\n#### To download datasets\n```python\nfrom kaggle_cli_wrapper import KaggleDataApi\n\nkda = KaggleDataApi(call_path=__file__)\nkda.download_kaggle_dataset(dataset_name=\"cityscapes_train_val_test\", is_competition_dataset=False)\n```\n\nTo download a competition dataset, is_competition_dataset needs to be set to True\n\n\n### ScoringAPI\n\nThe code currently supports minimum functionality for submission of files to a competition and getting scores for the competition\n\n#### To submit to a competition\n\n```python\nfrom kaggle_utils.kaggle_cli_wrapper import KaggleScoringsApi\n\nkaggle_scoring_api = KaggleScoringsApi(competition_name=\"facial-keypoints-detection\")\n\nkaggle_scoring_api.submit_solution(submissions_file=submission_path, description=\"facial_keypoint_vanilla_cnn\")\nkaggle_scoring_api.get_top_scores()\n```\n\n## Remaining Issues\n\n- improve error handling \n- allow for saving of stdout\n\n\n\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Kaggle CLI based python wrapper",
"version": "0.2",
"split_keywords": [
"kaggle",
"api",
"wrapper",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b2e840065cad1e71a3c53c5b3ce0e456d61497fdec7936fde44f3adc52396457",
"md5": "e1678c97d8b9007ffd4c046c86df6e3a",
"sha256": "4e7b1b74db28801b87400c7ccf8f02157543d23c27b2850c4d95102c9a73feef"
},
"downloads": -1,
"filename": "kaggle_cli_wrapper-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e1678c97d8b9007ffd4c046c86df6e3a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7239,
"upload_time": "2023-03-11T16:39:39",
"upload_time_iso_8601": "2023-03-11T16:39:39.515142Z",
"url": "https://files.pythonhosted.org/packages/b2/e8/40065cad1e71a3c53c5b3ce0e456d61497fdec7936fde44f3adc52396457/kaggle_cli_wrapper-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8a9ac57ff02d0c852b3fe117599e72ffd349acbcb0217e99479b895842d4a32c",
"md5": "ccc20fbac00d3219178c207f61104618",
"sha256": "7164e4a502430a6063f0cad1aa00d612c45cb7a7c1cf7afa48c2b81357305fa1"
},
"downloads": -1,
"filename": "kaggle_cli_wrapper-0.2.tar.gz",
"has_sig": false,
"md5_digest": "ccc20fbac00d3219178c207f61104618",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6688,
"upload_time": "2023-03-11T16:39:41",
"upload_time_iso_8601": "2023-03-11T16:39:41.141625Z",
"url": "https://files.pythonhosted.org/packages/8a/9a/c57ff02d0c852b3fe117599e72ffd349acbcb0217e99479b895842d4a32c/kaggle_cli_wrapper-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-11 16:39:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "sunny1401",
"github_project": "kaggle_utils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "kaggle-cli-wrapper"
}