From 18e2e658f0cbf609974a97678ea61990f7fd059c Mon Sep 17 00:00:00 2001 From: Lukas Bindreiter Date: Mon, 12 Jan 2026 17:48:43 +0100 Subject: [PATCH] Document create_or_update dataset --- .../{Create.mdx => CreateOrUpdate.mdx} | 19 +++++++------------ ...dx => Client.create_or_update_dataset.mdx} | 9 +++------ datasets/concepts/datasets.mdx | 14 ++++++++------ 3 files changed, 18 insertions(+), 24 deletions(-) rename api-reference/go/datasets/{Create.mdx => CreateOrUpdate.mdx} (91%) rename api-reference/python/tilebox.datasets/{Client.create_dataset.mdx => Client.create_or_update_dataset.mdx} (93%) diff --git a/api-reference/go/datasets/Create.mdx b/api-reference/go/datasets/CreateOrUpdate.mdx similarity index 91% rename from api-reference/go/datasets/Create.mdx rename to api-reference/go/datasets/CreateOrUpdate.mdx index ae35fe7..9d161db 100644 --- a/api-reference/go/datasets/Create.mdx +++ b/api-reference/go/datasets/CreateOrUpdate.mdx @@ -5,31 +5,27 @@ icon: laptop-code --- ```go -func (datasetClient) Create( +func (datasetClient) CreateOrUpdate( ctx context.Context, - name string, kind datasets.DatasetKind, codeName string, - description string, + name string, fields []Field, ) (*datasets.Dataset, error) ``` -Create a dataset. +Create a dataset or update an existing one, if a dataset with the given `codeName` already exists. ## Parameters - - The name of the dataset - The kind of the dataset The code name of the dataset - - The description of the dataset + + The name of the dataset The fields of the dataset @@ -95,11 +91,10 @@ The created dataset object. ```go Go -dataset, err := client.Datasets.Create(ctx, - "My personal catalog", +dataset, err := client.Datasets.CreateOrUpdate(ctx, datasets.KindSpatiotemporal, "my_catalog", - "A description of my catalog", + "My personal catalog", []Field{ field.String("field1"), field.Int64("field2").Repeated(), diff --git a/api-reference/python/tilebox.datasets/Client.create_dataset.mdx b/api-reference/python/tilebox.datasets/Client.create_or_update_dataset.mdx similarity index 93% rename from api-reference/python/tilebox.datasets/Client.create_dataset.mdx rename to api-reference/python/tilebox.datasets/Client.create_or_update_dataset.mdx index 94f7b2d..598c038 100644 --- a/api-reference/python/tilebox.datasets/Client.create_dataset.mdx +++ b/api-reference/python/tilebox.datasets/Client.create_or_update_dataset.mdx @@ -1,16 +1,16 @@ --- -title: Client.create_dataset +title: Client.create_or_update_dataset +sidebarTitle: Client.create_or_update... icon: laptop-code --- ```python -def Client.create_dataset( +def Client.create_or_update_dataset( kind: DatasetKind, code_name: str, fields: list[FieldDict], *, name: str | None = None, - description: str | None = None ) -> Dataset ``` @@ -30,9 +30,6 @@ Create a dataset. The name of the dataset - - A short description of the dataset - ## Dataset kinds diff --git a/datasets/concepts/datasets.mdx b/datasets/concepts/datasets.mdx index cbd9b0f..4c3ed22 100644 --- a/datasets/concepts/datasets.mdx +++ b/datasets/concepts/datasets.mdx @@ -149,9 +149,9 @@ Once you have your dataset object, you can use it to [list the available collect In python, if you're using an IDE or an interactive environment with auto-complete, you can use it on your client instance to discover the datasets available to you. Type `client.` and trigger auto-complete after the dot to do so. -## Creating a dataset +## Creating / Updating a dataset -You can create a dataset in code or using the Console (cf [Creating a dataset using the Console](/guides/datasets/create)). +You can create a dataset using the [Tilebox Console](/guides/datasets/create) or by using one of the available [client SDKs](/sdks/introduction). ```python Python @@ -161,7 +161,7 @@ from tilebox.datasets.data.datasets import DatasetKind client = Client() -dataset = client.create_dataset( +dataset = client.create_or_update_dataset( DatasetKind.SPATIOTEMPORAL, "my_landsat8_oli_tirs", [ @@ -185,15 +185,13 @@ dataset = client.create_dataset( }, ], name="Personal Landsat-8 catalog", - description="This catalog contains metadata for Landsat-8 OLI-TIRS data.", ) ``` ```go Go dataset, err := client.Datasets.Create(ctx, - "Personal Landsat-8 catalog", datasets.KindSpatiotemporal, "my_landsat8_oli_tirs", - "This catalog contains metadata for Landsat-8 OLI-TIRS data.", + "Personal Landsat-8 catalog", []datasets.Field{ field.String("granule_name").Description("The name of the Earth View Granule").ExampleValue("20220830_185202_SN18_10N_552149_5297327"), field.Float64("cloud_cover").Description("Cloud cover percentage").ExampleValue("91"), @@ -206,6 +204,10 @@ dataset, err := client.Datasets.Create(ctx, This code will create a new catalog with 7 fields in total. 4 of those fields are auto-generated by choosing the spatio-temporal dataset type, and 3 (`granule_name`, `cloud_cover`, `proj_shape`) are custom fields that are defined. + + If a dataset with the same `code_name` already exists, it will be updated instead. + + ## Accessing a dataset Each dataset has an automatically generated *slug* that can be used to access it. The *slug* is the name of the group, followed by a dot, followed by the dataset *code name*.