Skip to content

Commit b1261c2

Browse files
author
Matt Sokoloff
committed
wip
1 parent 456f2fe commit b1261c2

File tree

5 files changed

+26
-311
lines changed

5 files changed

+26
-311
lines changed

labelbox/data/annotation_types/metrics/scalar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ class ScalarMetric(BaseModel):
99
# For backwards compatibility, metric_name is optional. This will eventually be deprecated
1010
# The metric_name will be set to a default name in the editor if it is not set.
1111
12+
# aggregation will be ignored wihtout providing a metric name.
13+
# Not providing a metric name is deprecated.
1214
"""
1315
value: float
1416
metric_name: Optional[str] = None
1517
feature_name: Optional[str] = None
1618
subclass_name: Optional[str] = None
1719
aggregation: MetricAggregation = MetricAggregation.ARITHMETIC_MEAN
1820
extra: Dict[str, Any] = {}
21+
22+
def dict(self, *args, **kwargs):
23+
res = super().dict(*args, **kwargs)
24+
if res['metric_name'] is None:
25+
res.pop('aggregation')
26+
return {k: v for k, v in res.items() if v is not None}

labelbox/data/metrics/iou.py

Lines changed: 0 additions & 297 deletions
This file was deleted.

tests/data/annotation_types/test_metrics.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_legacy_scalar_metric():
2424
},
2525
'annotations': [{
2626
'value': 10.0,
27-
'extra': {}
27+
'extra': {},
2828
}],
2929
'extra': {},
3030
'uid': None
@@ -65,11 +65,17 @@ def test_custom_scalar_metric(feature_name, subclass_name, aggregation):
6565
'arr': None
6666
},
6767
'annotations': [{
68-
'value': value,
69-
'metric_name': 'iou',
70-
'feature_name': feature_name,
71-
'subclass_name': subclass_name,
72-
'aggregation': aggregation or MetricAggregation.ARITHMETIC_MEAN,
68+
'value':
69+
value,
70+
'metric_name':
71+
'iou',
72+
**({
73+
'feature_name': feature_name
74+
} if feature_name else {}),
75+
**({
76+
'subclass_name': subclass_name
77+
} if subclass_name else {}), 'aggregation':
78+
aggregation or MetricAggregation.ARITHMETIC_MEAN,
7379
'extra': {}
7480
}],
7581
'extra': {},

tests/integration/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def submit(project_id, data_row_id):
311311
})
312312
features = feature_result['project']['featuresForDataRow']
313313
feature_ids = [feature['id'] for feature in features]
314-
client.execute(
314+
res = client.execute(
315315
"""mutation createLabelPyApi ($project_id : ID!,$datarow_id: ID!,$feature_ids: [ID!]!,$time_seconds : Float!) {
316316
createLabelFromFeatures(data: {dataRow: { id: $datarow_id },project: { id: $project_id },
317317
featureIds: $feature_ids,secondsSpent: $time_seconds}) {id}}""",
@@ -321,6 +321,7 @@ def submit(project_id, data_row_id):
321321
"feature_ids": feature_ids,
322322
"time_seconds": 10
323323
})
324+
return res['createLabelFromFeatures']['id']
324325

325326
return submit
326327

tests/integration/mal_and_mea/conftest.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,11 @@ def model_run_annotation_groups(client, configured_project,
320320
client, configured_project.uid, f'mal-import-{uuid.uuid4()}',
321321
model_run_predictions)
322322
upload_task.wait_until_done()
323-
323+
label_ids = []
324324
for data_row_id in {x['dataRow']['id'] for x in model_run_predictions}:
325-
annotation_submit_fn(configured_project.uid, data_row_id)
326-
325+
label_ids.append(
326+
annotation_submit_fn(configured_project.uid, data_row_id))
327+
model_run.upsert_labels(label_ids)
327328
time.sleep(3)
328-
labels = configured_project.export_labels(download=True)
329-
model_run.upsert_labels([label['ID'] for label in labels])
330-
time.sleep(3)
331-
332329
yield model_run
333330
# TODO: Delete resources when that is possible ..

0 commit comments

Comments
 (0)