Skip to content

Commit 2009cec

Browse files
Merge pull request #701 from Labelbox/rsun/QQC-558
[QQC-558] Remove test code updating queue_mode for a Project
2 parents bfffb80 + ad9af19 commit 2009cec

File tree

7 files changed

+55
-44
lines changed

7 files changed

+55
-44
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
# Version 0.0.0 (YYYY-MM-DD) - In Progress
4+
5+
### Added
6+
### Changed
7+
* Updated docs for deprecated methods `_update_queue_mode` and `get_queue_mode` in `Project`
8+
* Use the `queue_mode` attribute in `Project` to get and set the queue mode instead
9+
* For more information, visit https://docs.labelbox.com/reference/migrating-to-workflows#upcoming-changes
10+
### Fixed
11+
312
# Version 3.27.1 (2022-09-16)
413
### Changed
514
* Removed `client.get_data_rows_for_global_keys` until further notice
@@ -17,7 +26,7 @@
1726
### Changed
1827
* Increase scalar metric value limit to 100m
1928
* Added deprecation warnings when updating project `queue_mode`
20-
## Fixed
29+
### Fixed
2130
* Fix bug in `feature_confusion_matrix` and `confusion_matrix` causing FPs and FNs to be capped at 1 when there were no matching annotations
2231

2332
# Version 3.26.2 (2022-09-06)

labelbox/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def create_project(self, **kwargs) -> Project:
611611
612612
Attribute values are passed as keyword arguments.
613613
614-
>>> project = client.create_project(name="<project_name>", description="<project_description>")
614+
>>> project = client.create_project(name="<project_name>", description="<project_description>", queue_mode=QueueMode.Batch)
615615
616616
Args:
617617
**kwargs: Keyword arguments with Project attribute values.

labelbox/schema/project.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def update(self, **kwargs):
9595
Args:
9696
kwargs: a dictionary containing attributes to be upserted
9797
98-
Note that the quality setting cannot be changed after a project has been created. The quality mode
98+
Note that the queue_mode cannot be changed after a project has been created.
99+
100+
Additionally, the quality setting cannot be changed after a project has been created. The quality mode
99101
for a project is inferred through the following attributes:
100102
Benchmark:
101103
auto_audit_number_of_labels = 1
@@ -106,9 +108,6 @@ def update(self, **kwargs):
106108
Attempting to switch between benchmark and consensus modes is an invalid operation and will result
107109
in an error.
108110
"""
109-
mode: Optional[QueueMode] = kwargs.pop("queue_mode", None)
110-
if mode:
111-
self._update_queue_mode(mode)
112111

113112
media_type = kwargs.get("media_type")
114113
if media_type:
@@ -623,6 +622,8 @@ def _update_queue_mode(self, mode: "QueueMode") -> "QueueMode":
623622
go through a migration to have the queue mode changed. Users should specify the
624623
queue mode for a project during creation if a non-default mode is desired.
625624
625+
For more information, visit https://docs.labelbox.com/reference/migrating-to-workflows#upcoming-changes
626+
626627
Args:
627628
mode: the specified queue mode
628629
@@ -669,6 +670,8 @@ def get_queue_mode(self) -> "QueueMode":
669670
a future version. To obtain the queue mode of a project, simply refer
670671
to the queue_mode attribute of a Project.
671672
673+
For more information, visit https://docs.labelbox.com/reference/migrating-to-workflows#upcoming-changes
674+
672675
Returns: the QueueMode for this project
673676
674677
"""

tests/integration/annotation_import/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,20 @@ def configured_project_pdf(client, ontology, rand_gen, pdf_url):
160160

161161
@pytest.fixture
162162
def configured_project_without_data_rows(client, configured_project, rand_gen):
163-
project = client.create_project(name=rand_gen(str))
163+
project = client.create_project(name=rand_gen(str),
164+
description=rand_gen(str),
165+
queue_mode=QueueMode.Batch)
164166
editor = list(
165167
client.get_labeling_frontends(
166168
where=LabelingFrontend.name == "editor"))[0]
167169
project.setup_editor(configured_project.ontology())
168-
project.update(queue_mode=QueueMode.Batch)
169170
yield project
170171
project.delete()
171172

172173

173174
@pytest.fixture
174175
def prediction_id_mapping(configured_project):
175-
#Maps tool types to feature schema ids
176+
# Maps tool types to feature schema ids
176177
ontology = configured_project.ontology().normalized
177178
result = {}
178179

tests/integration/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from labelbox.pagination import PaginatedCollection
1717
from labelbox.schema.annotation_import import LabelImport
1818
from labelbox.schema.invite import Invite
19+
from labelbox.schema.queue_mode import QueueMode
1920
from labelbox.schema.user import User
2021

2122
IMG_URL = "https://picsum.photos/200/300.jpg"
@@ -164,6 +165,14 @@ def project(client, rand_gen):
164165
project.delete()
165166

166167

168+
@pytest.fixture
169+
def batch_project(client, rand_gen):
170+
project = client.create_project(name=rand_gen(str),
171+
queue_mode=QueueMode.Batch)
172+
yield project
173+
project.delete()
174+
175+
167176
@pytest.fixture
168177
def consensus_project(client, rand_gen):
169178
project = client.create_project(name=rand_gen(str), auto_audit_percentage=0)

tests/integration/test_batch.py

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,46 +32,41 @@ def small_dataset(dataset: Dataset):
3232
yield dataset
3333

3434

35-
def test_create_batch(configured_project: Project, big_dataset: Dataset):
36-
configured_project.update(queue_mode=QueueMode.Batch)
37-
35+
def test_create_batch(batch_project: Project, big_dataset: Dataset):
3836
data_rows = [dr.uid for dr in list(big_dataset.export_data_rows())]
39-
batch = configured_project.create_batch("test-batch", data_rows, 3)
37+
batch = batch_project.create_batch("test-batch", data_rows, 3)
4038
assert batch.name == "test-batch"
4139
assert batch.size == len(data_rows)
4240

4341

44-
def test_archive_batch(configured_project: Project, small_dataset: Dataset):
42+
def test_archive_batch(batch_project: Project, small_dataset: Dataset):
4543
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
46-
configured_project.update(queue_mode=QueueMode.Batch)
47-
batch = configured_project.create_batch("batch to archive", data_rows)
44+
batch = batch_project.create_batch("batch to archive", data_rows)
4845
batch.remove_queued_data_rows()
4946
exported_data_rows = list(batch.export_data_rows())
5047

5148
assert len(exported_data_rows) == 0
5249

5350

54-
def test_delete(configured_project: Project, small_dataset: Dataset):
51+
def test_delete(batch_project: Project, small_dataset: Dataset):
5552
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
56-
configured_project.update(queue_mode=QueueMode.Batch)
57-
batch = configured_project.create_batch("batch to delete", data_rows)
53+
batch = batch_project.create_batch("batch to delete", data_rows)
5854
batch.delete()
5955

60-
assert len(list(configured_project.batches())) == 0
56+
assert len(list(batch_project.batches())) == 0
6157

6258

63-
def test_batch_project(configured_project: Project, small_dataset: Dataset):
59+
def test_batch_project(batch_project: Project, small_dataset: Dataset):
6460
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
65-
configured_project.update(queue_mode=QueueMode.Batch)
66-
batch = configured_project.create_batch(
67-
"batch to test project relationship", data_rows)
61+
batch = batch_project.create_batch("batch to test project relationship",
62+
data_rows)
6863
project_from_batch = batch.project()
6964

70-
assert project_from_batch.uid == configured_project.uid
71-
assert project_from_batch.name == configured_project.name
65+
assert project_from_batch.uid == batch_project.uid
66+
assert project_from_batch.name == batch_project.name
7267

7368

74-
def test_export_data_rows(configured_project: Project, dataset: Dataset):
69+
def test_export_data_rows(batch_project: Project, dataset: Dataset):
7570
n_data_rows = 5
7671
task = dataset.create_data_rows([
7772
{
@@ -82,8 +77,7 @@ def test_export_data_rows(configured_project: Project, dataset: Dataset):
8277
task.wait_till_done()
8378

8479
data_rows = [dr.uid for dr in list(dataset.export_data_rows())]
85-
configured_project.update(queue_mode=QueueMode.Batch)
86-
batch = configured_project.create_batch("batch test", data_rows)
80+
batch = batch_project.create_batch("batch test", data_rows)
8781

8882
result = list(batch.export_data_rows())
8983
exported_data_rows = [dr.uid for dr in result]
@@ -95,23 +89,19 @@ def test_export_data_rows(configured_project: Project, dataset: Dataset):
9589
@pytest.mark.skip(
9690
reason="Test cannot be used effectively with MAL/LabelImport. \
9791
Fix/Unskip after resolving deletion with MAL/LabelImport")
98-
def test_delete_labels(configured_project_with_label):
99-
project, dataset, _, _ = configured_project_with_label
100-
101-
data_rows = [dr.uid for dr in list(dataset.export_data_rows())]
102-
project.update(queue_mode=QueueMode.Batch)
103-
batch = project.create_batch("batch to delete labels", data_rows)
92+
def test_delete_labels(batch_project, small_dataset):
93+
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
94+
batch = batch_project.create_batch("batch to delete labels", data_rows)
10495

10596

10697
@pytest.mark.skip(
10798
reason="Test cannot be used effectively with MAL/LabelImport. \
10899
Fix/Unskip after resolving deletion with MAL/LabelImport")
109-
def test_delete_labels_with_templates(configured_project: Project,
100+
def test_delete_labels_with_templates(batch_project: Project,
110101
small_dataset: Dataset):
111102
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
112-
configured_project.update(queue_mode=QueueMode.Batch)
113-
batch = configured_project.create_batch(
114-
"batch to delete labels w templates", data_rows)
103+
batch = batch_project.create_batch("batch to delete labels w templates",
104+
data_rows)
115105
exported_data_rows = list(batch.export_data_rows())
116106
res = batch.delete_labels(labels_as_template=True)
117107
exported_data_rows = list(batch.export_data_rows())

tests/integration/test_project.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,21 @@ def test_queue_mode(configured_project: Project):
207207
assert configured_project.queue_mode == QueueMode.Dataset
208208

209209

210-
def test_batches(configured_project: Project, dataset: Dataset, image_url):
210+
def test_batches(batch_project: Project, dataset: Dataset, image_url):
211211
task = dataset.create_data_rows([
212212
{
213213
"row_data": image_url,
214214
"external_id": "my-image"
215215
},
216216
] * 2)
217217
task.wait_till_done()
218-
configured_project.update(queue_mode=QueueMode.Batch)
219218
data_rows = [dr.uid for dr in list(dataset.export_data_rows())]
220219
batch_one = 'batch one'
221220
batch_two = 'batch two'
222-
configured_project.create_batch(batch_one, [data_rows[0]])
223-
configured_project.create_batch(batch_two, [data_rows[1]])
221+
batch_project.create_batch(batch_one, [data_rows[0]])
222+
batch_project.create_batch(batch_two, [data_rows[1]])
224223

225-
names = set([batch.name for batch in list(configured_project.batches())])
224+
names = set([batch.name for batch in list(batch_project.batches())])
226225
assert names == {batch_one, batch_two}
227226

228227

0 commit comments

Comments
 (0)