Skip to content

Commit

Permalink
adding sync_last_modified_at operator
Browse files Browse the repository at this point in the history
  • Loading branch information
brimoor committed Sep 23, 2024
1 parent d403143 commit bd7042a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions fiftyone/operators/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,52 @@ def execute(self, ctx):
ctx.dataset.delete_workspace(name)


class SyncLastModifiedAt(foo.Operator):
@property
def config(self):
return foo.OperatorConfig(
name="sync_last_modified_at",
label="Sync last modified at",
dynamic=True,
)

def resolve_input(self, ctx):
inputs = types.Object()

instructions = """
This operation updates the `last_modified_at` property of the dataset if
necessary to incorporate any modification timestamps to its samples.
"""

inputs.str(
"instructions",
default=instructions.strip(),
view=types.MarkdownView(read_only=True),
)

if ctx.dataset._has_frame_fields():
inputs.bool(
"include_frames",
default=True,
required=False,
label="Include frames",
description=(
"Whether to sync the `last_modified_at` property of each "
"video sample first if necessary to incorporate any "
"modification timestamps to its frames"
),
)

return types.Property(
inputs, view=types.View(label="Sync last modified at")
)

def execute(self, ctx):
include_frames = ctx.params.get("include_frames", True)

ctx.dataset.sync_last_modified_at(include_frames=include_frames)


class ListFiles(foo.Operator):
@property
def config(self):
Expand Down Expand Up @@ -2258,5 +2304,6 @@ def _get_non_default_frame_fields(dataset):
SaveWorkspace(_builtin=True),
EditWorkspaceInfo(_builtin=True),
DeleteWorkspace(_builtin=True),
SyncLastModifiedAt(_builtin=True),
ListFiles(_builtin=True),
]

0 comments on commit bd7042a

Please sign in to comment.