Skip to content

Commit 154e04c

Browse files
committed
Fix issue when we filter application
1 parent fa9886f commit 154e04c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

socon_embedded/executor/task_executor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def cleanup(self) -> None:
4747
executor.cleanup()
4848

4949
def _task_on_start(self, task: Task):
50-
if self._terminal._current_line not in ["", "\n", "\r"]:
50+
if self._terminal._current_line != "":
5151
self._terminal.line()
5252
self._terminal.line(f"TASK [{task.name}]")
5353
self._terminal.sep("*")

socon_embedded/schema/task.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import List, Literal, Optional, Type
3+
from typing import List, Literal, Optional, Type, Any
44

55
from socon.core.registry import projects
66

@@ -14,7 +14,7 @@
1414
class Task(Base, Nameable):
1515
"""Call a module (action) with specific arguments and other parameters"""
1616

17-
action: Type
17+
action: Any
1818
args: dict = {}
1919

2020
retries: Optional[int] = 0
@@ -31,6 +31,12 @@ def preprocess_action(cls, values):
3131
if "args" in values:
3232
args = values["args"]
3333

34+
# If the application registry filters some of the apps,
35+
# the validation will need to be retriggered and the action
36+
# will already be an instance. To avoid that, we check if we already have an action instance and return it as his.
37+
if isinstance(action, object) and action is not None:
38+
return values
39+
3440
# filter out task attributes so we're only querying unrecognized keys as actions/modules
3541
non_task_values = dict(
3642
(k, v) for k, v in values.items() if (k not in get_field_names(Task))
@@ -44,7 +50,6 @@ def preprocess_action(cls, values):
4450
is_action_candidate = True
4551

4652
if is_action_candidate:
47-
4853
# finding more than one module name is a problem
4954
if action is not None:
5055
raise ParserError(
@@ -82,7 +87,8 @@ def preprocess_action(cls, values):
8287
@model_validator(mode="after")
8388
def post_process_action(self):
8489
"""Validate the action schema"""
85-
self.action = self.action(self)
90+
if isinstance(self.action, type):
91+
self.action = self.action(self)
8692
return self
8793

8894

0 commit comments

Comments
 (0)