From 5f271ca9e0b6d8fcea1c9a594d645aac82240d50 Mon Sep 17 00:00:00 2001 From: Sashank Aryal <66688606+sashankaryal@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:00:25 -0500 Subject: [PATCH] use fos utility function for parsing scene json (#4237) * use fos.read_json instead * use fos.write_json too --- fiftyone/core/threed/scene_3d.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fiftyone/core/threed/scene_3d.py b/fiftyone/core/threed/scene_3d.py index f9c7a5fb7c..b17ed9ce20 100644 --- a/fiftyone/core/threed/scene_3d.py +++ b/fiftyone/core/threed/scene_3d.py @@ -12,6 +12,8 @@ from pydantic.dataclasses import dataclass +import fiftyone.core.storage as fos + from .camera import PerspectiveCamera from .lights import Light from .mesh import FbxMesh, GltfMesh, ObjMesh, PlyMesh, StlMesh @@ -200,8 +202,7 @@ def write(self, fo3d_path: str, resolve_relative_paths=False): fo3d_path_dir, node.ply_path ) - with open(fo3d_path, "w") as f: - json.dump(validated_scene.as_dict(), f, indent=4) + fos.write_json(validated_scene.as_dict(), fo3d_path, pretty_print=True) def traverse(self, include_self=False): """Traverse the scene graph. @@ -334,7 +335,6 @@ def from_fo3d(path: str): if not path.endswith(".fo3d"): raise ValueError("Scene must be loaded from a .fo3d file") - with open(path, "r") as f: - dict_data = json.load(f) + dict_data = fos.read_json(path) return Scene._from_fo3d_dict(dict_data)