Skip to content

Commit d5a80f4

Browse files
chore: merge release/2.153.2 into main (#1679)
1 parent bbe436b commit d5a80f4

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
33

44
[project]
55
name = "kili"
6-
version = "2.153.1"
6+
version = "2.153.2"
77
description = "Python client for Kili Technology labeling tool"
88
readme = "README.md"
99
authors = [{ name = "Kili Technology", email = "[email protected]" }]

src/kili/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Kili Python SDK."""
22

3-
__version__ = "2.153.1"
3+
__version__ = "2.153.2"

src/kili/adapters/kili_api_gateway/asset/formatters.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@
99
def load_asset_json_fields(asset: Dict, fields: ListOrTuple[str]) -> Dict:
1010
"""Load json fields of an asset."""
1111
if "jsonMetadata" in fields:
12-
asset["jsonMetadata"] = json.loads(asset.get("jsonMetadata", "{}"))
12+
try:
13+
asset["jsonMetadata"] = json.loads(asset.get("jsonMetadata", "{}"))
14+
except json.JSONDecodeError:
15+
asset["jsonMetadata"] = {}
1316

1417
if "labels.jsonResponse" in fields:
1518
asset_labels = asset.get("labels", [])
1619
for label in asset_labels:
17-
label["jsonResponse"] = json.loads(label["jsonResponse"])
20+
try:
21+
label["jsonResponse"] = json.loads(label["jsonResponse"])
22+
except json.JSONDecodeError:
23+
label["jsonResponse"] = {}
1824

1925
if "latestLabel.jsonResponse" in fields and asset.get("latestLabel") is not None:
20-
asset["latestLabel"]["jsonResponse"] = json.loads(asset["latestLabel"]["jsonResponse"])
26+
try:
27+
asset["latestLabel"]["jsonResponse"] = json.loads(asset["latestLabel"]["jsonResponse"])
28+
except json.JSONDecodeError:
29+
asset["latestLabel"]["jsonResponse"] = {}
2130

2231
return asset

src/kili/adapters/kili_api_gateway/label/formatters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
def load_label_json_fields(label: Dict, fields: ListOrTuple[str]) -> Dict:
1010
"""Load json fields of a label."""
1111
if "jsonResponse" in fields:
12-
label["jsonResponse"] = json.loads(label.get("jsonResponse", "{}"))
12+
try:
13+
label["jsonResponse"] = json.loads(label.get("jsonResponse", "{}"))
14+
except json.JSONDecodeError:
15+
label["jsonResponse"] = {}
1316

1417
return label

src/kili/adapters/kili_api_gateway/project/formatters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
def load_project_json_fields(project: Dict, fields: ListOrTuple[str]) -> Dict:
1212
"""Load json fields of a project."""
1313
if "jsonInterface" in fields and isinstance(project.get("jsonInterface"), str):
14-
project["jsonInterface"] = json.loads(project["jsonInterface"])
14+
try:
15+
project["jsonInterface"] = json.loads(project["jsonInterface"])
16+
except json.JSONDecodeError:
17+
project["jsonInterface"] = {}
1518
return project

src/kili/services/copy_project/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ def _upload_assets(self, new_project_id: str, assets: List[Dict]) -> List[Dict]:
205205
# ocrMetadata field of assets need to be merged with jsonMetadata field
206206
for asset in assets:
207207
if isinstance(asset["jsonMetadata"], str):
208-
asset["jsonMetadata"] = json.loads(asset["jsonMetadata"])
208+
try:
209+
asset["jsonMetadata"] = json.loads(asset["jsonMetadata"])
210+
except json.JSONDecodeError:
211+
asset["jsonMetadata"] = {}
209212
if asset["ocrMetadata"]:
210213
asset["jsonMetadata"] = {**asset["jsonMetadata"], **asset["ocrMetadata"]}
211214

0 commit comments

Comments
 (0)