glenn-jocher pre-commit-ci[bot] commited on
Commit
676e10c
1 Parent(s): 5783de2

Simplify callbacks.py return (#7333)

Browse files

* Simplify callbacks.py return

* Indent args (pytorch convention)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Files changed (1) hide show
  1. utils/callbacks.py +8 -11
utils/callbacks.py CHANGED
@@ -38,9 +38,9 @@ class Callbacks:
38
  Register a new action to a callback hook
39
 
40
  Args:
41
- hook The callback hook name to register the action to
42
- name The name of the action for later reference
43
- callback The callback to fire
44
  """
45
  assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"
46
  assert callable(callback), f"callback '{callback}' is not callable"
@@ -51,21 +51,18 @@ class Callbacks:
51
  Returns all the registered actions by callback hook
52
 
53
  Args:
54
- hook The name of the hook to check, defaults to all
55
  """
56
- if hook:
57
- return self._callbacks[hook]
58
- else:
59
- return self._callbacks
60
 
61
  def run(self, hook, *args, **kwargs):
62
  """
63
  Loop through the registered actions and fire all callbacks
64
 
65
  Args:
66
- hook The name of the hook to check, defaults to all
67
- args Arguments to receive from YOLOv5
68
- kwargs Keyword Arguments to receive from YOLOv5
69
  """
70
 
71
  assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"
 
38
  Register a new action to a callback hook
39
 
40
  Args:
41
+ hook: The callback hook name to register the action to
42
+ name: The name of the action for later reference
43
+ callback: The callback to fire
44
  """
45
  assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"
46
  assert callable(callback), f"callback '{callback}' is not callable"
 
51
  Returns all the registered actions by callback hook
52
 
53
  Args:
54
+ hook: The name of the hook to check, defaults to all
55
  """
56
+ return self._callbacks[hook] if hook else self._callbacks
 
 
 
57
 
58
  def run(self, hook, *args, **kwargs):
59
  """
60
  Loop through the registered actions and fire all callbacks
61
 
62
  Args:
63
+ hook: The name of the hook to check, defaults to all
64
+ args: Arguments to receive from YOLOv5
65
+ kwargs: Keyword Arguments to receive from YOLOv5
66
  """
67
 
68
  assert hook in self._callbacks, f"hook '{hook}' not found in callbacks {self._callbacks}"