Skip to content

Commit 58cdcde

Browse files
authored
Merge pull request #75 from scaleapi/jihan/validation-fix
Nucleus - prediction pdf optional
2 parents c89989f + bd66a8d commit 58cdcde

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

nucleus/prediction.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def to_payload(self) -> dict:
7575
payload = super().to_payload()
7676
if self.confidence is not None:
7777
payload[CONFIDENCE_KEY] = self.confidence
78+
if self.class_pdf is not None:
7879
payload[CLASS_PDF_KEY] = self.class_pdf
7980

8081
return payload
@@ -93,7 +94,7 @@ def from_json(cls, payload: dict):
9394
confidence=payload.get(CONFIDENCE_KEY, None),
9495
annotation_id=payload.get(ANNOTATION_ID_KEY, None),
9596
metadata=payload.get(METADATA_KEY, {}),
96-
class_pdf=payload.get(CLASS_PDF_KEY, {}),
97+
class_pdf=payload.get(CLASS_PDF_KEY, None),
9798
)
9899

99100

@@ -124,6 +125,7 @@ def to_payload(self) -> dict:
124125
payload = super().to_payload()
125126
if self.confidence is not None:
126127
payload[CONFIDENCE_KEY] = self.confidence
128+
if self.class_pdf is not None:
127129
payload[CLASS_PDF_KEY] = self.class_pdf
128130

129131
return payload
@@ -139,5 +141,5 @@ def from_json(cls, payload: dict):
139141
confidence=payload.get(CONFIDENCE_KEY, None),
140142
annotation_id=payload.get(ANNOTATION_ID_KEY, None),
141143
metadata=payload.get(METADATA_KEY, {}),
142-
class_pdf=payload.get(CLASS_PDF_KEY, {}),
144+
class_pdf=payload.get(CLASS_PDF_KEY, None),
143145
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = '''
2121

2222
[tool.poetry]
2323
name = "scale-nucleus"
24-
version = "0.1.8"
24+
version = "0.1.9"
2525
description = "The official Python client library for Nucleus, the Data Platform for AI"
2626
license = "MIT"
2727
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

tests/helpers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ def reference_id_from_url(url):
103103
"confidence": 0.10 * i,
104104
"class_pdf": TEST_BOX_MODEL_PDF,
105105
}
106+
if i != 0
107+
else {
108+
**TEST_BOX_ANNOTATIONS[i],
109+
"confidence": 0.10 * i,
110+
}
106111
for i in range(len(TEST_BOX_ANNOTATIONS))
107112
]
108113

@@ -112,6 +117,11 @@ def reference_id_from_url(url):
112117
"confidence": 0.10 * i,
113118
"class_pdf": TEST_POLYGON_MODEL_PDF,
114119
}
120+
if i != 0
121+
else {
122+
**TEST_POLYGON_ANNOTATIONS[i],
123+
"confidence": 0.10 * i,
124+
}
115125
for i in range(len(TEST_POLYGON_ANNOTATIONS))
116126
]
117127

0 commit comments

Comments
 (0)