Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kaggle API
# Kaggle CLI

The official CLI to interact with [Kaggle](https://www.kaggle.com).

Expand Down Expand Up @@ -90,11 +90,9 @@ hatch run test:local

### Integration Tests

To run integration tests on your local machine, you need to set up your Kaggle API credentials. You can do this in one of these two ways described [this doc](docs/README.md). Refer to the sections:
- Using environment variables
- Using credentials file
To run integration tests on your local machine, you need to set up your Kaggle credentials. You can do this by following the [authentication instructions](docs/README.md).

After setting up your credentials by any of these methods, you can run the integration tests as follows:
After setting up your credentials, you can run the integration tests as follows:

```sh
hatch run test:integration
Expand All @@ -110,6 +108,6 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md).

## License

The Kaggle API is released under the [Apache 2.0 license](LICENSE.txt).
The Kaggle CLI is released under the [Apache 2.0 license](LICENSE.txt).


15 changes: 8 additions & 7 deletions docs/model_instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Commands for interacting with variations of Kaggle Models. A model variation typ
## `kaggle models variations init`

Initializes a metadata file (`model-instance-metadata.json`) for creating a new model variation.
Note that the name of the file reflects the old name for a variation, which was "instance".
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add support for either model-instance-metadata.json or model-variation-metadata.json. The latter always having priority over the former. And documentation should mention using model-variation-metadata.json with maybe a small note about the former name.

Can be addressed in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a bad idea. I'm planning to not change any more code for this release.

Copy link
Contributor

@rosbo rosbo Feb 4, 2026

Choose a reason for hiding this comment

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

On the flip-side, having a new metadata filename (even though would not be a breaking if implemented as described above) might be better to do at a major version bump.

Agree that we want to limit scope creep but can be likely addressed in a separate PR of <10 lines of code.


**Usage:**

Expand Down Expand Up @@ -52,7 +53,7 @@ Create a new model variation using the metadata and files in the `tmp` folder, q
# Example: Edit model-instance-metadata.json first
# sed -i 's/INSERT_OWNER_SLUG_HERE/your-username/' tmp/model-instance-metadata.json
# sed -i 's/INSERT_EXISTING_MODEL_SLUG_HERE/parent-model-slug/' tmp/model-instance-metadata.json
# sed -i 's/INSERT_INSTANCE_SLUG_HERE/my-instance-slug/' tmp/model-instance-metadata.json
# sed -i 's/INSERT_INSTANCE_SLUG_HERE/my-variation-slug/' tmp/model-instance-metadata.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be INSERT_VARIATION_SLUG? (may need to update the init command to set the proper value).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would require a change in the code.

# sed -i 's/INSERT_FRAMEWORK_HERE/jax/' tmp/model-instance-metadata.json
# echo "a,b,c,d" > tmp/data.csv # Example model file

Expand All @@ -70,12 +71,12 @@ Downloads the `model-instance-metadata.json` file for an existing model variatio
**Usage:**

```bash
kaggle models variations get <MODEL_INSTANCE> -p <FOLDER_PATH>
kaggle models variations get <MODEL_VARIATION> -p <FOLDER_PATH>
```

**Arguments:**

* `<MODEL_INSTANCE>`: Model variation URL suffix in the format `owner/model-slug/framework/instance-slug` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).
* `<MODEL_VARIATION>`: Model variation URL suffix in the format `owner/model-slug/framework/variation-slug` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).

**Options:**

Expand All @@ -100,12 +101,12 @@ Lists files for the current version of a model variation.
**Usage:**

```bash
kaggle models variations files <MODEL_INSTANCE> [options]
kaggle models variations files <MODEL_VARIATION> [options]
```

**Arguments:**

* `<MODEL_INSTANCE>`: Model variation URL suffix (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).
* `<MODEL_VARIATION>`: Model variation URL suffix (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).

**Options:**

Expand Down Expand Up @@ -158,12 +159,12 @@ Deletes a model variation from Kaggle.
**Usage:**

```bash
kaggle models variations delete <MODEL_INSTANCE> [options]
kaggle models variations delete <MODEL_VARIATION> [options]
```

**Arguments:**

* `<MODEL_INSTANCE>`: Model variation URL suffix in the format `owner/model-slug/framework/instance-slug` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).
* `<MODEL_VARIATION>`: Model variation URL suffix in the format `owner/model-slug/framework/variation-slug` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).

**Options:**

Expand Down
16 changes: 8 additions & 8 deletions docs/model_instances_versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Creates a new version of an existing model variation.
**Usage:**

```bash
kaggle models variations versions create <MODEL_INSTANCE> -p <FOLDER_PATH> [options]
kaggle models variations versions create <MODEL_VARIATION> -p <FOLDER_PATH> [options]
```

**Arguments:**

* `<MODEL_INSTANCE>`: The target model variation URL suffix for the new version (format: `owner/model-slug/framework/instance-slug`, e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).
* `<MODEL_VARIATION>`: The target model variation URL suffix for the new version (format: `owner/model-slug/framework/variation-slug`, e.g., `$KAGGLE_DEVELOPER/test-model/jax/main`).

**Options:**

Expand Down Expand Up @@ -45,12 +45,12 @@ Downloads files for a specific version of a model variation.
**Usage:**

```bash
kaggle models variations versions download <MODEL_INSTANCE_VERSION> [options]
kaggle models variations versions download <MODEL_VARIATION_VERSION> [options]
```

**Arguments:**

* `<MODEL_INSTANCE_VERSION>`: Model variation version URL suffix in the format `owner/model-slug/framework/instance-slug/version-number` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main/1`).
* `<MODEL_VARIATION_VERSION>`: Model variation version URL suffix in the format `owner/model-slug/framework/variation-slug/version-number` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main/1`).

**Options:**

Expand Down Expand Up @@ -79,12 +79,12 @@ Lists files for a specific version of a model variation.
**Usage:**

```bash
kaggle models variations versions files <MODEL_INSTANCE_VERSION> [options]
kaggle models variations versions files <MODEL_VARIATION_VERSION> [options]
```

**Arguments:**

* `<MODEL_INSTANCE_VERSION>`: Model variation version URL suffix (e.g., `google/gemma/pytorch/7b/2`).
* `<MODEL_VARIATION_VERSION>`: Model variation version URL suffix (e.g., `google/gemma/pytorch/7b/2`).

**Options:**

Expand All @@ -111,12 +111,12 @@ Deletes a specific version of a model variation from Kaggle.
**Usage:**

```bash
kaggle models variations versions delete <MODEL_INSTANCE_VERSION> [options]
kaggle models variations versions delete <MODEL_VARIATION_VERSION> [options]
```

**Arguments:**

* `<MODEL_INSTANCE_VERSION>`: Model variation version URL suffix in the format `owner/model-slug/framework/instance-slug/version-number` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main/1`).
* `<MODEL_VARIATION_VERSION>`: Model variation version URL suffix in the format `owner/model-slug/framework/variation-slug/version-number` (e.g., `$KAGGLE_DEVELOPER/test-model/jax/main/1`).

**Options:**

Expand Down
30 changes: 15 additions & 15 deletions docs/models_metadata.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
A full model is composed of 3 types of entities:

1. The model
2. The instances
3. The instance versions
2. The variations
3. The variation versions

Let's take the example of [efficientnet](https://www.kaggle.com/models/tensorflow/efficientnet) to explain these entities.

A model like `efficientnet` contains multiple instances.
A model like `efficientnet` contains multiple variations.

An instance is a specific variation of the model (e.g. B0, B1, ...) with a certain framework (e.g. TensorFlow2).
A variation is a specific variation of the model (e.g. B0, B1, ...) with a certain framework (e.g. TensorFlow2).

## Model

Expand Down Expand Up @@ -44,9 +44,9 @@ We currently support the following metadata fields for models.
* `publishTime`: the original publishing time of the model
* `provenanceSources`: the provenance of the model

## Model Instance
## Model Variation

To create a model instance, a special `model-instance-metadata.json` file must be specified.
To create a model variation, a special `model-instance-metadata.json` file must be specified.

Here's a basic example for `model-instance-metadata.json`:
```
Expand All @@ -66,22 +66,22 @@ Here's a basic example for `model-instance-metadata.json`:
}
```

You can also use the API command `kaggle models instances init -p /path/to/model-instance` to have the API create this file for you for a new model instance.
You can also use the API command `kaggle models variations init -p /path/to/model-variation` to have the API create this file for you for a new model variation.

### Contents

We currently support the following metadata fields for model instances.
We currently support the following metadata fields for model variations.

* `ownerSlug`: the slug of the user or organization of the model
* `modelSlug`: the existing model's slug
* `instanceSlug`: the slug of the instance
* `framework`: the instance's framework (possible options: `tensorFlow1`,`tensorFlow2`,`tfLite`,`tfJs`,`pyTorch`,`jax`,`coral`, ...)
* `overview`: a short overview of the instance
* `usage`: the instance's usage in markdown syntax (see the template below)
* `fineTunable`: whether the instance is fine tunable
* `instanceSlug`: the slug of the variation
* `framework`: the variation's framework (possible options: `tensorFlow1`,`tensorFlow2`,`tfLite`,`tfJs`,`pyTorch`,`jax`,`coral`, ...)
* `overview`: a short overview of the variation
* `usage`: the variation's usage in markdown syntax (see the template below)
* `fineTunable`: whether the variation is fine tunable
* `trainingData`: a list of training data in the form of strings, URLs, Kaggle Datasets, etc...
* `modelInstanceType`: whether the model instance is a base model, external variant, internal variant, or unspecified
* `baseModelInstance`: if this is an internal variant, the `{owner-slug}/{model-slug}/{framework}/{instance-slug}` of the base model instance
* `modelInstanceType`: whether the model variation is a base model, external variant, internal variant, or unspecified
* `baseModelInstance`: if this is an internal variant, the `{owner-slug}/{model-slug}/{framework}/{variation-slug}` of the base model variation
* `externalBaseModelUrl`: if this is an external variant, a URL to the base model

### Licenses
Expand Down
42 changes: 21 additions & 21 deletions src/kaggle/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def main() -> None:
"-v",
"--version",
action="version",
help="Print the Kaggle API version",
version="Kaggle API " + kaggle.__version__,
help="Print the Kaggle CLI version",
version="Kaggle CLI " + kaggle.__version__,
)
parser.add_argument(
"-W",
Expand Down Expand Up @@ -1087,9 +1087,9 @@ class Help(object):
+ ", ".join(kernels_choices)
+ "}\nmodels {"
+ ", ".join(models_choices)
+ "}\nmodels instances {"
+ "}\nmodels variations {"
+ ", ".join(model_instances_choices)
+ "}\nmodels instances versions {"
+ "}\nmodels variations versions {"
+ ", ".join(model_instance_versions_choices)
+ "}\nconfig {"
+ ", ".join(config_choices)
Expand All @@ -1102,8 +1102,8 @@ class Help(object):
group_datasets = "Commands related to Kaggle datasets"
group_kernels = "Commands related to Kaggle kernels"
group_models = "Commands related to Kaggle models"
group_model_instances = "Commands related to Kaggle model instances"
group_model_instance_versions = "Commands related to Kaggle model instance versions"
group_model_instances = "Commands related to Kaggle model variations"
group_model_instance_versions = "Commands related to Kaggle model variations versions"
group_files = "Commands related files"
group_config = "Configuration settings"
group_auth = "Commands related to authentication"
Expand Down Expand Up @@ -1320,12 +1320,12 @@ class Help(object):
)

# Model Instances params
param_model_instance = "Model Instance URL suffix in format <owner>/<model-name>/<framework>/<instance-slug>"
command_model_instances_get = "Get a model instance"
command_model_instances_init = "Initialize metadata file for model instance creation"
command_model_instances_files = "List files for the current version of a model instance"
command_model_instances_list = "List instances of a model"
command_model_instances_new = "Create a new model instance"
param_model_instance = "Model variation URL suffix in format <owner>/<model-name>/<framework>/<instance-slug>"
command_model_instances_get = "Get a model variation"
command_model_instances_init = "Initialize metadata file for model variation creation"
command_model_instances_files = "List files for the current version of a model variation"
command_model_instances_list = "List variations of a model"
command_model_instances_new = "Create a new model variation"
param_model_instance_downfile = (
"Folder for downloading the special model-instance-metadata.json file "
"(https://github.com/Kaggle/kaggle-cli/blob/main/docs/models_metadata.md#model-instance). "
Expand All @@ -1336,22 +1336,22 @@ class Help(object):
"(https://github.com/Kaggle/kaggle-cli/blob/main/docs/models_metadata.md#model-instance). "
"Defaults to current working directory"
)
command_model_instances_delete = "Delete a model instance"
command_model_instances_update = "Update a model instance"
command_model_instances_delete = "Delete a model variation"
command_model_instances_update = "Update a model variation"

# Model Instance Versions params
param_model_instance_version = (
"Model Instance Version URL suffix in format <owner>/<model-name>/<framework>/<instance-slug>/<version-number>"
"Model variation version URL suffix in format <owner>/<model-name>/<framework>/<variation-slug>/<version-number>"
)

# Model Instance Versions params
command_model_instance_versions_new = "Create a new model instance version"
command_model_instance_versions_new = "Create a new model variation version"
param_model_instance_version_upfile = "Folder for upload. Defaults to current working directory"
command_model_instance_versions_delete = "Delete a model instance version"
command_model_instance_versions_download = "Download model instance version files"
command_model_instance_versions_files = "List model instance version files"
command_model_instance_versions_list = "List model instance versions"
param_model_instance_version_notes = "Version notes to record for the new model instance version"
command_model_instance_versions_delete = "Delete a model variation version"
command_model_instance_versions_download = "Download model variation version files"
command_model_instance_versions_files = "List model variation version files"
command_model_instance_versions_list = "List model variation versions"
param_model_instance_version_notes = "Version notes to record for the new model variation version"

# Files params
param_files_upload_inbox_path = "Virtual path on the server where the uploaded files will be stored"
Expand Down
Loading