Skip to content

Commit db9d5f2

Browse files
authored
Allow creating empty slices (#434)
1 parent 2d7b350 commit db9d5f2

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.17.2](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.2) - 2024-02-28
9+
10+
### Modified
11+
- In `Dataset.create_slice`, the `reference_ids` parameter is now optional. If left unspecified, it will create an empty slice
12+
13+
14+
## [0.17.1](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.1) - 2024-02-22
15+
16+
### Added
17+
- Environment variable `NUCLEUS_SKIP_SSL_VERIFY` to skip SSL verification on requests
18+
19+
820
## [0.17.0](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.0) - 2024-02-06
921

1022
### Added

nucleus/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
KEYPOINTS_TYPE = "keypoints"
1414
CATEGORY_TYPE = "category"
1515
MULTICATEGORY_TYPE = "multicategory"
16+
ALLOW_EMPTY = "allow_empty"
1617
ANNOTATION_TYPES = (
1718
BOX_TYPE,
1819
LINE_TYPE,

nucleus/dataset.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
from .annotation import Annotation, check_all_mask_paths_remote
3838
from .constants import (
39+
ALLOW_EMPTY,
3940
ANNOTATIONS_KEY,
4041
AUTOTAG_SCORE_THRESHOLD,
4142
BACKFILL_JOB_KEY,
@@ -937,23 +938,27 @@ def ground_truth_loc(self, reference_id: str, annotation_id: str):
937938
return Annotation.from_json(response)
938939

939940
def create_slice(
940-
self,
941-
name: str,
942-
reference_ids: List[str],
941+
self, name: str, reference_ids: Optional[List[str]] = None
943942
) -> Slice:
944943
"""Creates a :class:`Slice` of dataset items within a dataset.
945944
946945
Parameters:
947946
name: A human-readable name for the slice.
948947
reference_ids: List of reference IDs of dataset items to add to the slice, cannot exceed 10,000 items.
948+
Can be left unspecified, and an empty slice will be created.
949949
950950
Returns:
951951
:class:`Slice`: The newly constructed slice item.
952952
953953
Raises:
954954
BadRequest: If length of reference_ids is too large (> 10,000 items)
955955
"""
956-
payload = {NAME_KEY: name, REFERENCE_IDS_KEY: reference_ids}
956+
payload = {NAME_KEY: name} # type: Dict[str, Any]
957+
if reference_ids:
958+
payload[REFERENCE_IDS_KEY] = reference_ids
959+
else:
960+
payload[ALLOW_EMPTY] = 1
961+
957962
response = self._client.make_request(
958963
payload, f"dataset/{self.id}/create_slice"
959964
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ignore = ["E501", "E741", "E731", "F401"] # Easy ignore for getting it running
2525

2626
[tool.poetry]
2727
name = "scale-nucleus"
28-
version = "0.17.1"
28+
version = "0.17.2"
2929
description = "The official Python client library for Nucleus, the Data Platform for AI"
3030
license = "MIT"
3131
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

0 commit comments

Comments
 (0)