Skip to content

Commit

Permalink
rm state from saved views when cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
kaixi-wang committed Nov 2, 2023
1 parent 07eb4df commit 4e6b181
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions fiftyone/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7378,12 +7378,6 @@ def _clone_extras(src_dataset, dst_dataset):
dst_doc.save()


def _clone_view_doc(view_doc):
_view_doc = view_doc.copy()
_view_doc.id = ObjectId()
return _view_doc


def _clone_run(run_doc):
_run_doc = run_doc.copy()
_run_doc.id = ObjectId()
Expand All @@ -7399,6 +7393,24 @@ def _clone_run(run_doc):
return _run_doc


def _clone_view_doc(view_doc):
_view_doc = view_doc.copy()
_view_doc.id = ObjectId()
_reset_stage_states(view_doc)

return _view_doc


def _reset_stage_states(view_doc):
stages = [json_util.loads(stage) for stage in view_doc.view_stages]
for stage in stages:
for i, kwarg in enumerate(stage.get("kwargs", [])):
if kwarg[0] == "_state":
stage["kwargs"][i][1] = None

view_doc.view_stages = [json_util.dumps(stages) for s in stages]


def _ensure_index(dataset, db_field, unique=False):
# For some reason the ID index is not reported by `index_information()` as
# being unique like other manually created indexes, but it is
Expand Down

0 comments on commit 4e6b181

Please sign in to comment.