Skip to content

Commit da19eff

Browse files
committed
Improve validation on workflow crons (no arg schema allowed) or tasks in workflows (no args allowed without defaults)
1 parent 1e10bf0 commit da19eff

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

hyrex/hyrex_registry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ def decorator(func):
223223
config_phase=ConfigPhase.decorator, queue=queue, priority=priority
224224
)
225225

226+
# Validate that cron workflows don't require arguments
227+
if cron and workflow_arg_schema:
228+
raise ValueError(
229+
f"Workflow '{workflow_name}' has cron scheduling but requires arguments. "
230+
f"Cron-scheduled workflows must not have any required arguments."
231+
)
232+
226233
# Create and return a HyrexWorkflow instance
227234
workflow = HyrexWorkflow(
228235
name=workflow_name,

hyrex/workflow/workflow_builder.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ def __exit__(self, exc_type, exc_value, traceback) -> None:
9191

9292
def get_or_create_node(self, task_wrapper: TaskWrapper) -> DagNode:
9393
if task_wrapper not in self.nodes:
94+
# Validate that the task doesn't have required arguments
95+
required_params = [
96+
name for name, info in task_wrapper.param_info.items()
97+
if not info.has_default
98+
]
99+
if required_params:
100+
raise ValueError(
101+
f"Task '{task_wrapper.task_identifier}' cannot be used in a workflow because it requires arguments: {required_params}. "
102+
f"Tasks used in workflows must have no arguments or all arguments must have default values."
103+
)
104+
94105
self.nodes[task_wrapper] = DagNode(
95106
task_wrapper=task_wrapper, workflow_builder=self
96107
)

0 commit comments

Comments
 (0)