Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dotflow/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def workflow_id(self):

@workflow_id.setter
def workflow_id(self, value: UUID):
if isinstance(value, str):
Comment thread
FernandoCelmer marked this conversation as resolved.
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

Expand Down
2 changes: 1 addition & 1 deletion dotflow/core/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dotflow/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
14 changes: 10 additions & 4 deletions dotflow/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading