diff --git a/dotflow/core/context.py b/dotflow/core/context.py index 087a1d04..66541047 100644 --- a/dotflow/core/context.py +++ b/dotflow/core/context.py @@ -80,6 +80,13 @@ def workflow_id(self): @workflow_id.setter def workflow_id(self, value: UUID): + if isinstance(value, str): + try: + value = UUID(value) + except ValueError as err: + raise ValueError( + f"Invalid workflow_id: '{value}' is not a valid UUID format." + ) from err if isinstance(value, UUID): self._workflow_id = value diff --git a/dotflow/core/execution.py b/dotflow/core/execution.py index 3eadaf00..98b46859 100644 --- a/dotflow/core/execution.py +++ b/dotflow/core/execution.py @@ -59,7 +59,7 @@ def _is_action(self, class_instance: Callable, func: Callable): return ( callable(getattr(class_instance, func)) and getattr(class_instance, func).__module__ - is Action.__module__ + == Action.__module__ and not func.startswith("__") ) except AttributeError: diff --git a/dotflow/core/module.py b/dotflow/core/module.py index 0866c16c..2297bf97 100644 --- a/dotflow/core/module.py +++ b/dotflow/core/module.py @@ -19,7 +19,7 @@ def import_module(cls, value: str): spec = file_location(value, cls._get_path(value)) module = module_from_spec(spec) - sys.modules[module] = module + sys.modules[module.__name__] = module spec.loader.exec_module(module) if hasattr(module, cls._get_name(value)): diff --git a/dotflow/core/workflow.py b/dotflow/core/workflow.py index 5e7b9bab..312275ce 100644 --- a/dotflow/core/workflow.py +++ b/dotflow/core/workflow.py @@ -107,10 +107,16 @@ def __init__( execution = None groups = grouper(tasks=tasks) - try: - execution = getattr(self, mode) - except AttributeError as err: - raise ExecutionModeNotExist() from err + VALID_MODES = { + "sequential", + "sequential_group", + "background", + "parallel", + } + if mode not in VALID_MODES: + raise ExecutionModeNotExist() + + execution = getattr(self, mode) self.tasks = execution( tasks=tasks,