@@ -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 {
@@ -182,7 +185,7 @@ async fn main() {
182185 ) ;
183186 let duration_us = start. elapsed ( ) . as_micros ( ) ;
184187 let finished_at = now_unix_micros ( ) ;
185- print_timing_debug (
188+ print_manual_execution_debug (
186189 started_at,
187190 finished_at,
188191 duration_us,
@@ -223,7 +226,7 @@ async fn main() {
223226 ) ;
224227 let duration_us = start. elapsed ( ) . as_micros ( ) ;
225228 let finished_at = now_unix_micros ( ) ;
226- print_timing_debug (
229+ print_manual_execution_debug (
227230 started_at,
228231 finished_at,
229232 duration_us,
@@ -301,6 +304,18 @@ async fn queue_execution(
301304 println ! ( "{}" , execution_id) ;
302305}
303306
307+ fn print_manual_execution_debug (
308+ started_at : i64 ,
309+ finished_at : i64 ,
310+ duration_us : u128 ,
311+ node_results : & [ NodeExecutionResult ] ,
312+ ) {
313+ let mut normalized_results = node_results. to_vec ( ) ;
314+ normalize_node_execution_results ( & mut normalized_results) ;
315+ print_timing_debug ( started_at, finished_at, duration_us, & normalized_results) ;
316+ print_execution_result_debug ( & normalized_results) ;
317+ }
318+
304319fn print_timing_debug (
305320 started_at : i64 ,
306321 finished_at : i64 ,
@@ -342,6 +357,69 @@ fn print_timing_debug(
342357 }
343358}
344359
360+ fn print_execution_result_debug ( node_results : & [ NodeExecutionResult ] ) {
361+ eprintln ! ( "[manual execution result] {:#?}" , node_results) ;
362+ }
363+
364+ fn normalize_node_execution_results ( node_results : & mut [ NodeExecutionResult ] ) {
365+ for result in node_results {
366+ normalize_node_execution_result ( result) ;
367+ }
368+ }
369+
370+ fn normalize_node_execution_result ( result : & mut NodeExecutionResult ) {
371+ for parameter_result in & mut result. parameter_results {
372+ match & mut parameter_result. value {
373+ Some ( value) => normalize_value ( value) ,
374+ None => {
375+ parameter_result. value = Some ( null_value ( ) ) ;
376+ }
377+ }
378+ }
379+
380+ match & mut result. result {
381+ Some ( NodeExecutionResultResult :: Success ( value) ) => normalize_value ( value) ,
382+ Some ( NodeExecutionResultResult :: Error ( error) ) => {
383+ if let Some ( details) = & mut error. details {
384+ for value in details. fields . values_mut ( ) {
385+ normalize_value ( value) ;
386+ }
387+ }
388+ }
389+ None => {
390+ result. result = Some ( NodeExecutionResultResult :: Success ( null_value ( ) ) ) ;
391+ }
392+ }
393+ }
394+
395+ fn normalize_value ( value : & mut Value ) {
396+ match & mut value. kind {
397+ Some ( Kind :: StructValue ( struct_value) ) => {
398+ for field in struct_value. fields . values_mut ( ) {
399+ normalize_value ( field) ;
400+ }
401+ }
402+ Some ( Kind :: ListValue ( list_value) ) => {
403+ for item in & mut list_value. values {
404+ normalize_value ( item) ;
405+ }
406+ }
407+ Some ( Kind :: NumberValue ( number) ) if number. number . is_none ( ) => {
408+ value. kind = Some ( Kind :: NullValue ( 0 ) ) ;
409+ }
410+ Some ( _) => { }
411+ None => {
412+ value. kind = Some ( Kind :: NullValue ( 0 ) ) ;
413+ }
414+ }
415+ }
416+
417+ fn null_value ( ) -> Value {
418+ Value {
419+ kind : Some ( Kind :: NullValue ( 0 ) ) ,
420+ }
421+ }
422+
345423fn execution_result_id_label ( result : & NodeExecutionResult ) -> String {
346424 match result. id {
347425 Some ( NodeExecutionResultId :: NodeId ( id) ) => format ! ( "node_id={}" , id) ,
0 commit comments