You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, electron have call_after hooks, which means electron can do something after electron completed successfully. However, there isn't some hooks to let electron do something when status of electron is Failed or Cancelled. Maybe there should have some callback hooks for electron when it is failure or cancelled.
Describe alternatives you've considered.
There is a suggested UX to use callback hooks.
UX
defcall_before_hook(value):
Path("data.txt").write_text(value)
returnvaluedefcall_after_hook():
Path("data.txt").unlink()
# Remove `data.txt` when `get_my_value_completed` is completed. It has been archieved by `Covalent`. # ref: https://covalent.readthedocs.io/en/latest/how_to/coding/add_callable_dependencies_to_electron.html@ct.electron(call_before=ct.DepsCall(call_before_hook, args=(1, )),call_after=ct.DepsCall(call_after_hook),)defget_my_value_completed():
value=Path("data.txt").read_text()
returnint(value)
# Remove `data.txt`, regardless of the status of `get_my_value`. It uses new `call_finally` hook.@ct.electron(call_before=ct.DepsCall(call_before_hook, args=(1, )),call_finally=ct.DepsCall(call_after_hook),)defget_my_value_finally():
value=Path("data.txt").read_text()
returnint(value)
# Remove `data.txt` when `get_my_value` is cancelled. It uses new `call_after_cancelled` hook@ct.electron(call_before=ct.DepsCall(call_before_hook, args=(1, )),call_after_cancelled=ct.DepsCall(call_after_hook),)defget_my_value_cancelled():
value=Path("data.txt").read_text()
returnint(value)
This example will create a file named data.txt, and when function get_my_value* goes to a certain status, data.txt will be removed.
The text was updated successfully, but these errors were encountered:
What should we add?
Now,
electron
havecall_after
hooks, which meanselectron
can do something afterelectron
completed successfully. However, there isn't some hooks to letelectron
do something when status ofelectron
is Failed or Cancelled. Maybe there should have some callback hooks forelectron
when it is failure or cancelled.Describe alternatives you've considered.
There is a suggested UX to use callback hooks.
UX
This example will create a file named
data.txt
, and when functionget_my_value*
goes to a certain status,data.txt
will be removed.The text was updated successfully, but these errors were encountered: