Skip to content

Commit 66da8bb

Browse files
Merge pull request #154 from avarga1/fix/bugs-135-136-137-138
fix: resolve four bugs in execution, module, context, and workflow
2 parents 177369f + a9c5e28 commit 66da8bb

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

dotflow/core/context.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def workflow_id(self):
7777

7878
@workflow_id.setter
7979
def workflow_id(self, value: UUID):
80+
if isinstance(value, str):
81+
try:
82+
value = UUID(value)
83+
except ValueError as err:
84+
raise ValueError(
85+
f"Invalid workflow_id: '{value}' is not a valid UUID format."
86+
) from err
8087
if isinstance(value, UUID):
8188
self._workflow_id = value
8289

dotflow/core/execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _is_action(self, class_instance: Callable, func: Callable):
5959
return (
6060
callable(getattr(class_instance, func))
6161
and getattr(class_instance, func).__module__
62-
is Action.__module__
62+
== Action.__module__
6363
and not func.startswith("__")
6464
)
6565
except AttributeError:

dotflow/core/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def import_module(cls, value: str):
1919
spec = file_location(value, cls._get_path(value))
2020
module = module_from_spec(spec)
2121

22-
sys.modules[module] = module
22+
sys.modules[module.__name__] = module
2323
spec.loader.exec_module(module)
2424

2525
if hasattr(module, cls._get_name(value)):

dotflow/core/workflow.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,16 @@ def __init__(
107107
execution = None
108108
groups = grouper(tasks=tasks)
109109

110-
try:
111-
execution = getattr(self, mode)
112-
except AttributeError as err:
113-
raise ExecutionModeNotExist() from err
110+
VALID_MODES = {
111+
"sequential",
112+
"sequential_group",
113+
"background",
114+
"parallel",
115+
}
116+
if mode not in VALID_MODES:
117+
raise ExecutionModeNotExist()
118+
119+
execution = getattr(self, mode)
114120

115121
self.tasks = execution(
116122
tasks=tasks,

0 commit comments

Comments
 (0)