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
2 changes: 2 additions & 0 deletions .github/styles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Google
write-good
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ tokens:
- requirement
- reside
- residence
- retain
- satisfy
- shall
- should you wish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ extends: existence
message: "Don't use double spaces between words."
nonword: true
level: warning
scope: raw
tokens:
- '\w \w'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ extends: existence
message: "Don't use more than one empty line to structure content."
nonword: true
level: error
scope: raw
tokens:
- '\n\n\n'
File renamed without changes.
17 changes: 14 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ jobs:
- uses: actions/checkout@v4
with:
lfs: true
- uses: errata-ai/vale-action@reviewdog
- name: Install Vale
run: |
VALE_URL="https://github.com/errata-ai/vale/releases/download/v3.12.0/vale_3.12.0_Linux_64-bit.tar.gz"
curl -L "$VALE_URL" -o vale.tar.gz
tar -xzf vale.tar.gz
mv vale /usr/local/bin/
- name: Setup Node
uses: actions/setup-node@v4
with:
fail_on_error: true
node-version: 22
- name: Install MDX preprocessor
run: npm install -g mdx2vast
- name: Run vale
run: vale sync && vale .
docs-quality:
name: Check docs standards
runs-on: ubuntu-latest
Expand All @@ -22,7 +33,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- name: Install Mintlify CLI
run: npm install -g mintlify
- name: Run Mintlify broken-links
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
vale/styles/Google
.DS_Store
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/errata-ai/vale
rev: v3.9.6
rev: v3.12.0
hooks:
- id: vale
16 changes: 4 additions & 12 deletions .vale.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
StylesPath = "vale/styles"
StylesPath = ".github/styles"

Vocab = docs
Packages = Google
Packages = Google, write-good
IgnoredScopes = code, tt, img, url, a, text.frontmatter
SkippedScopes = script, style, pre, figure, code
MinAlertLevel = warning

# Treat MDX as Markdown
[formats]
mdx = md

[*.{md,mdx}]

# Ignore react components starting with export const
# Ignore code blocks in triple backticks
# Ignore inline code blocks in backticks
BlockIgnores = (export const (.|\n)*), (?s)<CodeGroup>.*?</CodeGroup>, (?s)```.*?```, `.*?`, \[.*\]\(http[^\)]*?\), \(\/.*\)
[*.mdx]
BasedOnStyles = Vale, Google, write-good, docs

write-good.TooWordy = NO # we have our own list of too wordy as docs.TooWordy
write-good.Passive = NO
Google.Headings = NO
Google.Will = NO
73 changes: 0 additions & 73 deletions api-reference/python/tilebox.datasets/Collection.load.mdx

This file was deleted.

73 changes: 73 additions & 0 deletions api-reference/python/tilebox.datasets/Collection.query.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: Collection.query
icon: layer-group
---

```python
def Collection.query(
temporal_extent: TimeIntervalLike,
skip_data: bool = False,
show_progress: bool = False
) -> xarray.Dataset
```

Query a range of data points in this collection in a specified temporal extent.
If no data exists for the requested time or interval, an empty `xarray.Dataset` is returned.

## Parameters

<ParamField path="temporal_extent" type="TimeIntervalLike">
The time or time interval for which to query data. This can be a single time scalar, a tuple of two time scalars, or an array of time scalars.

Valid time scalars are: `datetime.datetime` objects, strings in ISO 8601 format, or Unix timestamps in seconds.

Behavior for each input type:

- **TimeScalar**: If a single time scalar is provided, `query` returns all data points for that exact millisecond.

- **TimeInterval**: If a time interval is provided, `query` returns all data points in that interval. Intervals can be a tuple of two `TimeScalars` or a `TimeInterval` object. Tuples are interpreted as a half-open interval `[start, end)`. With a `TimeInterval` object, the `start_exclusive` and `end_inclusive` parameters control whether the start and end time are inclusive or exclusive.

- **Iterable[TimeScalar]**: If an array of time scalars is provided, `query` constructs a time interval from the first and last time scalar in the array. Here, both the `start` and `end` times are inclusive.

</ParamField>

<ParamField path="skip_data" type="bool">
If `True`, the response contains only the [required fields for the dataset type](/datasets/types/timeseries) without the actual dataset-specific fields. Defaults to `False`.
</ParamField>

<ParamField path="show_progress" type="bool">
If `True`, a progress bar is displayed when pagination is required. Defaults to `False`.
</ParamField>

## Returns

An [`xarray.Dataset`](/sdks/python/xarray) containing the requested data points.

<RequestExample>
```python Python
from datetime import datetime
from tilebox.clients.core.data import TimeInterval

# querying a specific time
time = "2023-05-01 12:45:33.423"
data = collection.query(temporal_extent=time)

# querying a time interval
interval = ("2023-05-01", "2023-08-01")
data = collection.query(temporal_extent=interval, show_progress=True)

# querying a time interval with TimeInterval
interval = TimeInterval(
start=datetime(2023, 5, 1),
end=datetime(2023, 8, 1),
start_exclusive=False,
end_inclusive=False,
)
data = collection.query(temporal_extent=interval, show_progress=True)

# querying with an iterable
meta_data = collection.query(temporal_extent=..., skip_data=True)
first_50 = collection.query(temporal_extent=meta_data.time[:50], skip_data=False)
```
</RequestExample>

2 changes: 1 addition & 1 deletion datasets/delete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ since you only need the datapoint IDs. See [fetching only metadata](/datasets/qu

<CodeGroup>
```python Python
to_delete = collection.load(("2023-05-01", "2023-06-01"), skip_data=True)
to_delete = collection.query(temporal_extent=("2023-05-01", "2023-06-01"), skip_data=True)

n_deleted = collection.delete(datapoints)
print(f"Deleted {n_deleted} data points.")
Expand Down
6 changes: 3 additions & 3 deletions datasets/ingest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Ingestion can be done either in Python or Go.

[`collection.ingest`](/api-reference/python/tilebox.datasets/Collection.ingest) supports a wide range of input types. Below is an example of using either a `pandas.DataFrame` or an `xarray.Dataset` as input.

#### pandas.DataFrame
#### pandas DataFrame

A [pandas.DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) is a representation of two-dimensional, potentially heterogeneous tabular data. It's a powerful tool for working with structured data, and Tilebox supports it as input for `ingest`.

Expand Down Expand Up @@ -145,7 +145,7 @@ Measurements: [2025-03-28T11:44:23.000 UTC, 2025-03-28T11:45:19.000 UTC] (2 data
You can now also head on over to the [Tilebox Console](/console) and view the newly ingested data points there.
</Tip>

#### xarray.Dataset
#### xarray Dataset

[`xarray.Dataset`](/sdks/python/xarray) is the default format in which Tilebox Datasets returns data when
[querying data](/datasets/query) from a collection.
Expand Down Expand Up @@ -260,7 +260,7 @@ Since `ingest` takes `query`'s output as input, you can easily copy or move data
<CodeGroup>
```python Python
src_collection = dataset.collection("Measurements")
data_to_copy = src_collection.load(("2025-03-28", "2025-03-29"))
data_to_copy = src_collection.query(temporal_extent=("2025-03-28", "2025-03-29"))

dest_collection = dataset.collection("OtherMeasurements")
dest_collection.ingest(data_to_copy) # copy the data to the other collection
Expand Down
30 changes: 15 additions & 15 deletions datasets/query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ func main() {
```
</CodeGroup>

To load data points from a dataset collection, use the [load](/api-reference/python/tilebox.datasets/Collection.load) method. It requires a `time_or_interval` parameter to specify the time or time interval for loading.
To query data points from a dataset collection, use the [query](/api-reference/python/tilebox.datasets/Collection.query) method. It requires a `temporal_extent` parameter to specify the time or time interval for querying.

## Filtering by time

### Time interval

To load data for a specific time interval, use a `tuple` in the form `(start, end)` as the `time_or_interval` parameter. Both `start` and `end` must be [TimeScalars](#time-scalars), which can be `datetime` objects or strings in ISO 8601 format.
To query data for a specific time interval, use a `tuple` in the form `(start, end)` as the `temporal_extent` parameter. Both `start` and `end` must be [TimeScalars](#time-scalars), which can be `datetime` objects or strings in ISO 8601 format.

<CodeGroup>
```python Python
interval = ("2017-01-01", "2023-01-01")
data = collection.load(interval, show_progress=True)
data = collection.query(temporal_extent=interval, show_progress=True)
```
```go Go
startDate := time.Date(2017, time.January, 1, 0, 0, 0, 0, time.UTC)
Expand Down Expand Up @@ -112,7 +112,7 @@ import xarray as xr
data = []
for year in [2017, 2018, 2019, 2020, 2021, 2022]:
interval = (f"{year}-01-01", f"{year + 1}-01-01")
data.append(collection.load(interval, show_progress=True))
data.append(collection.query(temporal_extent=interval, show_progress=True))

# Concatenate the data into a single dataset, which is equivalent
# to the result of the single request in the code example above.
Expand Down Expand Up @@ -170,7 +170,7 @@ print(f"They are equivalent: {interval1 == interval2}")
print(interval2.to_half_open())

# Query data for a time interval
data = collection.load(interval1, show_progress=True)
data = collection.query(temporal_extent=interval1, show_progress=True)
```
```go Go
interval1 := query.TimeInterval{
Expand Down Expand Up @@ -217,11 +217,11 @@ You can load all datapoints linked to a specific timestamp by specifying a `Time
A collection may contain multiple datapoints for one millisecond, so multiple data points could still be returned. If you want to fetch only a single data point, [query the collection by id](#loading-a-data-point-by-id) instead.
</Tip>

Here's how to load a data point at a specific millisecond from a [collection](/datasets/concepts/collections).
Here's how to query a data point at a specific millisecond from a [collection](/datasets/concepts/collections).

<CodeGroup>
```python Python
data = collection.load("2024-08-01 00:00:01.362")
data = collection.query(temporal_extent="2024-08-01 00:00:01.362")
print(data)
```
```go Go
Expand Down Expand Up @@ -265,18 +265,18 @@ First datapoint time: 2024-08-01 00:00:01.362 +0000 UTC
Tilebox uses millisecond precision for timestamps. To load all data points for a specific second, it's a [time interval](/datasets/query#time-interval) request. Refer to the examples below for details.
</Note>

The output of the `load` method is an `xarray.Dataset` object. To learn more about Xarray, visit the dedicated [Xarray page](/sdks/python/xarray).
The output of the `query` method is an `xarray.Dataset` object. To learn more about Xarray, visit the dedicated [Xarray page](/sdks/python/xarray).

### Time iterables (Python only)

You can specify a time interval by using an iterable of `TimeScalar`s as the `time_or_interval` parameter. This is especially useful when you want to use the output of a previous `load` call as input for another load. Here's how that works.
You can specify a time interval by using an iterable of `TimeScalar`s as the `temporal_extent` parameter. This is especially useful when you want to use the output of a previous `query` call as input for another query. Here's how that works.

<CodeGroup>
```python Python
interval = ("2017-01-01", "2023-01-01")
meta_data = collection.load(interval, skip_data=True)
meta_data = collection.query(temporal_extent=interval, skip_data=True)

first_50_data_points = collection.load(meta_data.time[:50], skip_data=False)
first_50_data_points = collection.query(temporal_extent=meta_data.time[:50], skip_data=False)
print(first_50_data_points)
```
</CodeGroup>
Expand Down Expand Up @@ -315,7 +315,7 @@ tokyo_time = pytz.timezone('Asia/Tokyo').localize(
datetime(2017, 1, 1, 11, 45, 25, 679000)
)
print(tokyo_time)
data = collection.load(tokyo_time)
data = collection.query(temporal_extent=tokyo_time)
print(data)
```
```go Go
Expand Down Expand Up @@ -431,7 +431,7 @@ If this flag is set, the response will only include the required fields for the

<CodeGroup>
```python Python
data = collection.load("2024-08-01 00:00:01.362", skip_data=True)
data = collection.query(temporal_extent="2024-08-01 00:00:01.362", skip_data=True)
print(data)
```
```go Go
Expand Down Expand Up @@ -473,12 +473,12 @@ First datapoint time: 2024-08-01 00:00:01.362 +0000 UTC

## Empty response

The `load` method always returns an `xarray.Dataset` object, even if there are no data points for the specified query. In such cases, the returned dataset will be empty, but no error will be raised.
The `query` method always returns an `xarray.Dataset` object, even if there are no data points for the specified query. In such cases, the returned dataset will be empty, but no error will be raised.

<CodeGroup>
```python Python
time_with_no_data_points = "1997-02-06 10:21:00"
data = collection.load(time_with_no_data_points)
data = collection.query(temporal_extent=time_with_no_data_points)
print(data)
```
```go Go
Expand Down
2 changes: 1 addition & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"api-reference/python/tilebox.datasets/Collection.find",
"api-reference/python/tilebox.datasets/Collection.info",
"api-reference/python/tilebox.datasets/Collection.ingest",
"api-reference/python/tilebox.datasets/Collection.load"
"api-reference/python/tilebox.datasets/Collection.query"
]
},
{
Expand Down
Loading