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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.46.0] - 2025-12-04

### Added

- `tilebox-datasets`: Added `create_dataset` method to `Client` to create a new dataset.
Expand Down Expand Up @@ -293,8 +295,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Released under the [MIT](https://opensource.org/license/mit) license.
- Released packages: `tilebox-datasets`, `tilebox-workflows`, `tilebox-storage`, `tilebox-grpc`

[Unreleased]: https://github.com/tilebox/tilebox-python/compare/v0.45.0...HEAD
[0.45.0]: https://github.com/tilebox/tilebox-python/compare/v0.45.0...v0.45.0
[Unreleased]: https://github.com/tilebox/tilebox-python/compare/v0.46.0...HEAD
[0.46.0]: https://github.com/tilebox/tilebox-python/compare/v0.45.0...v0.46.0
[0.45.0]: https://github.com/tilebox/tilebox-python/compare/v0.44.0...v0.45.0
[0.44.0]: https://github.com/tilebox/tilebox-python/compare/v0.43.0...v0.44.0
[0.43.0]: https://github.com/tilebox/tilebox-python/compare/v0.42.0...v0.43.0
[0.42.0]: https://github.com/tilebox/tilebox-python/compare/v0.41.0...v0.42.0
Expand Down
43 changes: 43 additions & 0 deletions tilebox-datasets/tests/data/datasets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import string
from dataclasses import replace
from datetime import datetime, timedelta
from functools import lru_cache
from uuid import UUID

import numpy as np
from google.protobuf.descriptor_pb2 import FieldDescriptorProto, FileDescriptorProto, FileDescriptorSet
from hypothesis.strategies import (
DrawFn,
Expand All @@ -16,6 +19,7 @@
text,
uuids,
)
from shapely import Geometry

from tests.example_dataset.example_dataset_pb2 import DESCRIPTOR_PROTO
from tilebox.datasets.data.datasets import (
Expand All @@ -26,6 +30,7 @@
DatasetType,
Field,
FieldAnnotation,
FieldDict,
ListDatasetsResponse,
)
from tilebox.datasets.message_pool import register_once
Expand All @@ -39,6 +44,44 @@ def field_annotations(draw: DrawFn) -> FieldAnnotation:
return FieldAnnotation(description, example_value)


@composite
def field_dicts(draw: DrawFn) -> FieldDict:
"""A hypothesis strategy for generating random field dicts"""
name = draw(text(alphabet=string.ascii_lowercase + "_", min_size=3, max_size=25))
field_type = draw(
one_of(
just(str),
just(list[str]),
just(bytes),
just(list[bytes]),
just(bool),
just(list[bool]),
just(int),
just(list[int]),
just(np.uint64),
just(list[np.uint64]),
just(float),
just(list[float]),
just(timedelta),
just(list[timedelta]),
just(datetime),
just(list[datetime]),
just(UUID),
just(list[UUID]),
just(Geometry),
just(list[Geometry]),
)
)
annotation = draw(field_annotations())

return {
"name": name,
"type": field_type,
"description": annotation.description,
"example_value": annotation.example_value,
}


@composite
def fields(draw: DrawFn) -> Field:
"""A hypothesis strategy for generating random fields"""
Expand Down
11 changes: 11 additions & 0 deletions tilebox-datasets/tests/data/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
dataset_types,
datasets,
field_annotations,
field_dicts,
fields,
list_datasets_responses,
)
Expand All @@ -16,6 +17,7 @@
DatasetType,
Field,
FieldAnnotation,
FieldDict,
ListDatasetsResponse,
)

Expand All @@ -25,6 +27,15 @@ def test_field_annotations_to_message_and_back(annotation: FieldAnnotation) -> N
assert FieldAnnotation.from_message(annotation.to_message()) == annotation


@given(field_dicts())
def test_field_from_dict(field_dict: FieldDict) -> None:
field = Field.from_dict(field_dict)
assert field.descriptor.name == field_dict["name"]
assert field.descriptor.type is not None
assert field.annotation.description == field_dict.get("description", "")
assert field.annotation.example_value == field_dict.get("example_value", "")


@given(fields())
def test_fields_to_message_and_back(field: Field) -> None:
assert Field.from_message(field.to_message()) == field
Expand Down
Loading