Skip to content

Commit

Permalink
fix save workspace built-in operator
Browse files Browse the repository at this point in the history
  • Loading branch information
imanjra committed Sep 30, 2024
1 parent 40593bd commit 7068e77
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions fiftyone/operators/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1940,8 +1940,9 @@ def resolve_input(self, ctx):
)

# @todo infer this automatically from current App spaces
spaces_prop = inputs.str(
spaces_prop = inputs.oneof(
"spaces",
[types.String(), types.Object()],
default=None,
required=True,
label="Spaces",
Expand All @@ -1955,7 +1956,7 @@ def resolve_input(self, ctx):
spaces = ctx.params.get("spaces", None)
if spaces is not None:
try:
fo.Space.from_json(spaces)
_parse_spaces(spaces)
except:
spaces_prop.invalid = True
spaces_prop.error_message = "Invalid workspace definition"
Expand All @@ -1978,10 +1979,7 @@ def execute(self, ctx):
color = ctx.params.get("color", None)
spaces = ctx.params.get("spaces", None)

if isinstance(spaces, dict):
spaces = fo.Space.from_dict(spaces)
else:
spaces = fo.Space.from_json(spaces)
spaces = _parse_spaces(spaces)

ctx.dataset.save_workspace(
name,
Expand Down Expand Up @@ -2294,6 +2292,12 @@ def _get_non_default_frame_fields(dataset):
return schema


def _parse_spaces(spaces):
if isinstance(spaces, dict):
return fo.Space.from_dict(spaces)
return fo.Space.from_json(spaces)


BUILTIN_OPERATORS = [
EditFieldInfo(_builtin=True),
CloneSelectedSamples(_builtin=True),
Expand Down

0 comments on commit 7068e77

Please sign in to comment.