@@ -475,6 +475,15 @@ class WorkerStep:
475
475
inp_messages : list = attrs .field (init = False , factory = list )
476
476
"""Messages related to input validation issues: unexpected changes and deleted inputs."""
477
477
478
+ inp_digest : bytes = attrs .field (init = False , default = b"" )
479
+ """The input digest, which can be useful for some actions.
480
+
481
+ They may use this to decide if cached results from a previously interrupted run
482
+ of the same stepo are still valid.
483
+ This can also be useful when action submit jobs to a scheduler,
484
+ to decide if a running job is still valid.
485
+ """
486
+
478
487
out_missing : list = attrs .field (init = False , factory = list )
479
488
"""List of expected output files that were not created."""
480
489
@@ -794,7 +803,11 @@ def compute_inp_step_hash(
794
803
label = self .step .action
795
804
if self .step .workdir != "./" :
796
805
label += f" # wd={ self .step .workdir } "
797
- return StepHash .from_inp (f"{ label } " , self .explain_rerun , all_inp_hashes , env_var_values ), []
806
+ result = StepHash .from_inp (f"{ label } " , self .explain_rerun , all_inp_hashes , env_var_values )
807
+
808
+ # Copy the inp_digest, because it can be useful for some actions.
809
+ self .step .inp_digest = result .inp_digest
810
+ return result , []
798
811
799
812
@allow_rpc
800
813
def compute_out_step_hash (
@@ -897,11 +910,14 @@ async def run(self):
897
910
await self .reporter ("START" , self .step .description )
898
911
await self .reporter .start_step (self .step .description , self .step .i )
899
912
900
- # For internal use only :
913
+ # For internal use in actions :
901
914
os .environ ["STEPUP_STEP_I" ] = str (self .step .i )
902
915
# Client code may use the following:
916
+ os .environ ["STEPUP_STEP_INP_DIGEST" ] = self .step .inp_digest .hex ()
903
917
os .environ ["ROOT" ] = str (Path .cwd ().relpath (self .step .workdir ))
904
918
os .environ ["HERE" ] = str (self .step .workdir .relpath ())
919
+ # Note: the variables defined here should be listed in stepup.core.api.getenv
920
+
905
921
# Create IO redirection for stdout and stderr
906
922
step_err = io .StringIO ()
907
923
step_out = io .StringIO ()
@@ -922,6 +938,12 @@ async def run(self):
922
938
self .step .stdout = step_out .getvalue ()
923
939
self .step .stderr = step_err .getvalue ()
924
940
941
+ # Clean up environment variables (to avoid potential confusion)
942
+ del os .environ ["STEPUP_STEP_I" ]
943
+ del os .environ ["STEPUP_STEP_INP_DIGEST" ]
944
+ del os .environ ["ROOT" ]
945
+ del os .environ ["HERE" ]
946
+
925
947
# Process results of the step.
926
948
if self .show_perf :
927
949
ru_final = resource .getrusage (resource .RUSAGE_CHILDREN )
0 commit comments