Skip to content

Commit

Permalink
pass input data directly to py workflow (#2055)
Browse files Browse the repository at this point in the history
  • Loading branch information
DatGuyJonathan authored Feb 21, 2025
1 parent 3973558 commit 5738bcc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/framework-cli/src/framework/python/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ block = Blocks(teardown=[DROP_MV_QUERY], setup=[MV_QUERY])
pub static PYTHON_BASE_SCRIPT_TEMPLATE: &str = r#"from moose_lib import task
@task()
def {{name}}(data: dict): # The name of your script
def {{name}}(input: dict): # The name of your script
"""
Description of what this script does
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ async def dynamic_activity(execution_input: ScriptExecutionInput) -> WorkflowSte
log.info(f"Task received input: {execution_input.input_data}")

# Pass the input data directly if it exists
input_data = execution_input.input_data if execution_input.input_data else {}
input_data = execution_input.input_data.get('data', execution_input.input_data) if execution_input.input_data else {}
log.info(f"Processed input_data for task: {input_data}")
if asyncio.iscoroutinefunction(task_func):
result = await task_func(data=input_data)
result = await task_func(input=input_data)
else:
result = task_func(data=input_data)
result = task_func(input=input_data)

# Validate and encode result
if not isinstance(result, dict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<C: ClickHouseClientTrait + 'static> Inserter<C> {

let mut queue = self.queue.lock().await;

if queue.is_empty() || queue.front().map_or(true, |batch| batch.records.is_empty()) {
if queue.is_empty() || queue.front().is_none_or(|batch| batch.records.is_empty()) {
continue;
}

Expand Down

0 comments on commit 5738bcc

Please sign in to comment.