fiftyone
fiftyone copied to clipboard
Reset stage states in cloned saved views
What changes are proposed in this pull request?
There's a problem with saved_views of cloned datasets, specifically ones with stages involving generated/temp datasets. The name of the generated view in the saved view of the cloned dataset is the same as the original dataset. However, after a dataset is cloned, it can be modified independently. This means that the generated temp dataset also must be different. Otherwise changes on the generated view will be persisted to both the clone and the original, which may lead to errors and undesirable effects.
When viewing the saved view of the clone, 4 temporary datasets are created per interaction with the view and expanding the sidebar throws an error
Example:
# Load dataset with saved views that have stages with _state:
dataset=fo.load_dataset('quickstart-sim-sort-tests')
cloned = dataset.clone()
orig_views= dataset._doc.saved_views
cloned_views = cloned._doc.saved_views
for (o,c) in zip(orig_views, cloned_views):
print("original:{}\ncloned:{}\n".format(o.view_stages, c.view_stages))
original:['{"_cls": "fiftyone.core.stages.ToPatches", "kwargs": [["field", "predictions"], ["config", null], ["_state", {"dataset": "quickstart", "stages": [], "field": "predictions", "config": null, "name": "2023.09.29.14.22.14"}]]}']
cloned:['{"_cls": "fiftyone.core.stages.ToPatches", "kwargs": [["field", "predictions"], ["config", null], ["_state", {"dataset": "quickstart", "stages": [], "field": "predictions", "config": null, "name": "2023.09.29.14.22.14"}]]}']