Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Remove ATP v2 components
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredoconnell committed Oct 12, 2023
1 parent 4c4fe10 commit d953ad9
Showing 1 changed file with 8 additions and 35 deletions.
43 changes: 8 additions & 35 deletions arcaflow_plugin_wait/arcaflow_plugin_wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dataclasses import dataclass, field
from threading import Event

from arcaflow_plugin_sdk import plugin, validation, predefined_schemas
from arcaflow_plugin_sdk import plugin, validation


@dataclass
Expand Down Expand Up @@ -40,34 +40,15 @@ class ErrorOutput:


class WaitStep:
exit = Event()
finished_early = False

@plugin.signal_handler(
id=predefined_schemas.cancel_signal_schema.id,
name=predefined_schemas.cancel_signal_schema.display.name,
description=predefined_schemas.cancel_signal_schema.display.
description,
icon=predefined_schemas.cancel_signal_schema.display.icon,
)
def cancel_step(self, _input: predefined_schemas.cancelInput):
# First, let it know that this is the reason it's exiting.
self.finished_early = True
# Now signal to exit.
self.exit.set()

@plugin.step_with_signals(
@plugin.step(
id="wait",
name="Wait",
description="Waits for the given amount of time",
outputs={
"success": SuccessOutput,
"error": ErrorOutput,
"cancelled_early": ErrorOutput
},
signal_handler_method_names=["cancel_step"],
signal_emitters=[],
step_object_constructor=lambda: WaitStep(),
)
def wait(
self,
Expand All @@ -81,20 +62,12 @@ def wait(
"""
start_time = time.time()
self.exit.wait(params.seconds)
if self.finished_early:
actual_time = time.time() - start_time
return "cancelled_early", ErrorOutput(
"Aborted {:0.2f} seconds after being scheduled to wait for {}"
" seconds.".format(actual_time, params.seconds),
actual_time
)
else:
actual_time = time.time() - start_time
return "success", SuccessOutput(
"Waited {:0.2f} seconds after being scheduled to wait for {}"
" seconds.".format(actual_time, params.seconds),
actual_time
)
actual_time = time.time() - start_time
return "success", SuccessOutput(
"Waited {:0.2f} seconds after being scheduled to wait for {}"
" seconds.".format(actual_time, params.seconds),
actual_time
)


if __name__ == "__main__":
Expand Down

0 comments on commit d953ad9

Please sign in to comment.