@@ -14,9 +14,12 @@ use taurus_provider::providers::remote::nats_remote_runtime::NATSRemoteRuntime;
1414use tucana:: shared:: ExecutionFlow ;
1515use tucana:: shared:: NodeExecutionResult ;
1616use tucana:: shared:: ValidationFlow ;
17+ use tucana:: shared:: Value ;
1718use tucana:: shared:: helper:: value:: from_json_value;
1819use tucana:: shared:: helper:: value:: to_json_value;
1920use tucana:: shared:: node_execution_result:: Id as NodeExecutionResultId ;
21+ use tucana:: shared:: node_execution_result:: Result as NodeExecutionResultResult ;
22+ use tucana:: shared:: value:: Kind ;
2023
2124#[ derive( Clone , Deserialize ) ]
2225pub struct Input {
@@ -161,10 +164,7 @@ async fn main() {
161164 }
162165
163166 let flow_input = match case. inputs . get ( index as usize ) {
164- Some ( inp) => match inp. input . clone ( ) {
165- Some ( json_input) => Some ( from_json_value ( json_input) ) ,
166- None => None ,
167- } ,
167+ Some ( inp) => inp. input . clone ( ) . map ( from_json_value) ,
168168 None => None ,
169169 } ;
170170
@@ -182,7 +182,7 @@ async fn main() {
182182 ) ;
183183 let duration_us = start. elapsed ( ) . as_micros ( ) ;
184184 let finished_at = now_unix_micros ( ) ;
185- print_timing_debug (
185+ print_manual_execution_debug (
186186 started_at,
187187 finished_at,
188188 duration_us,
@@ -223,7 +223,7 @@ async fn main() {
223223 ) ;
224224 let duration_us = start. elapsed ( ) . as_micros ( ) ;
225225 let finished_at = now_unix_micros ( ) ;
226- print_timing_debug (
226+ print_manual_execution_debug (
227227 started_at,
228228 finished_at,
229229 duration_us,
@@ -301,6 +301,18 @@ async fn queue_execution(
301301 println ! ( "{}" , execution_id) ;
302302}
303303
304+ fn print_manual_execution_debug (
305+ started_at : i64 ,
306+ finished_at : i64 ,
307+ duration_us : u128 ,
308+ node_results : & [ NodeExecutionResult ] ,
309+ ) {
310+ let mut normalized_results = node_results. to_vec ( ) ;
311+ normalize_node_execution_results ( & mut normalized_results) ;
312+ print_timing_debug ( started_at, finished_at, duration_us, & normalized_results) ;
313+ print_execution_result_debug ( & normalized_results) ;
314+ }
315+
304316fn print_timing_debug (
305317 started_at : i64 ,
306318 finished_at : i64 ,
@@ -342,6 +354,69 @@ fn print_timing_debug(
342354 }
343355}
344356
357+ fn print_execution_result_debug ( node_results : & [ NodeExecutionResult ] ) {
358+ eprintln ! ( "[manual execution result] {:#?}" , node_results) ;
359+ }
360+
361+ fn normalize_node_execution_results ( node_results : & mut [ NodeExecutionResult ] ) {
362+ for result in node_results {
363+ normalize_node_execution_result ( result) ;
364+ }
365+ }
366+
367+ fn normalize_node_execution_result ( result : & mut NodeExecutionResult ) {
368+ for parameter_result in & mut result. parameter_results {
369+ match & mut parameter_result. value {
370+ Some ( value) => normalize_value ( value) ,
371+ None => {
372+ parameter_result. value = Some ( null_value ( ) ) ;
373+ }
374+ }
375+ }
376+
377+ match & mut result. result {
378+ Some ( NodeExecutionResultResult :: Success ( value) ) => normalize_value ( value) ,
379+ Some ( NodeExecutionResultResult :: Error ( error) ) => {
380+ if let Some ( details) = & mut error. details {
381+ for value in details. fields . values_mut ( ) {
382+ normalize_value ( value) ;
383+ }
384+ }
385+ }
386+ None => {
387+ result. result = Some ( NodeExecutionResultResult :: Success ( null_value ( ) ) ) ;
388+ }
389+ }
390+ }
391+
392+ fn normalize_value ( value : & mut Value ) {
393+ match & mut value. kind {
394+ Some ( Kind :: StructValue ( struct_value) ) => {
395+ for field in struct_value. fields . values_mut ( ) {
396+ normalize_value ( field) ;
397+ }
398+ }
399+ Some ( Kind :: ListValue ( list_value) ) => {
400+ for item in & mut list_value. values {
401+ normalize_value ( item) ;
402+ }
403+ }
404+ Some ( Kind :: NumberValue ( number) ) if number. number . is_none ( ) => {
405+ value. kind = Some ( Kind :: NullValue ( 0 ) ) ;
406+ }
407+ Some ( _) => { }
408+ None => {
409+ value. kind = Some ( Kind :: NullValue ( 0 ) ) ;
410+ }
411+ }
412+ }
413+
414+ fn null_value ( ) -> Value {
415+ Value {
416+ kind : Some ( Kind :: NullValue ( 0 ) ) ,
417+ }
418+ }
419+
345420fn execution_result_id_label ( result : & NodeExecutionResult ) -> String {
346421 match result. id {
347422 Some ( NodeExecutionResultId :: NodeId ( id) ) => format ! ( "node_id={}" , id) ,
0 commit comments