Переглянути джерело

fix/refactor: dont clobber ephemeral output types, add debug logging for outptus

Sam Jaffe 1 місяць тому
батько
коміт
38538c124a
2 змінених файлів з 26 додано та 8 видалено
  1. 1 1
      src/cipy/action.py
  2. 25 7
      src/cipy/runner.py

+ 1 - 1
src/cipy/action.py

@@ -164,7 +164,7 @@ class Composite(Action):
                     outctx.steps[step.id] = Results.Item(stat, step.outputs.validated())
                 else:
                     stat = Status.SKIPPED
-                    outctx.steps[step.id] = Results.Item(Status.SKIPPED)
+                    outctx.steps[step.id] = Results.Item(stat)
 
                 status |= stat
 

+ 25 - 7
src/cipy/runner.py

@@ -63,13 +63,16 @@ def ipc(func: Run[Action]) -> Run[Action]:
         ):
             rval = func(self, context)
 
+            annotation = self.__pydantic_fields__["outputs"].annotation
+            assert annotation is not None
+
             outdata = dotenv_values(output.name)
             if self.outputs is not None:
+                annotation = self.outputs.__class__
                 outdata = vars(self.outputs) | outdata
 
-            annotation = self.__pydantic_fields__["outputs"].annotation
-            assert annotation is not None
             self.outputs = annotation(**outdata)
+            _log_outputs(self)
 
         return rval
 
@@ -153,14 +156,29 @@ def preamble(func: Run[Action]):
     def wrapper(self: Action, context: Context) -> Status:
         with logging_group(self, "Run %s", self.name):
             _log_inputs(self)
-        return func(self, context)
+        try:
+            return func(self, context)
+        finally:
+            _log_outputs(self)
 
     return wrapper
 
 
 def _log_inputs(self: Action) -> None:
     inputs = [(k, v) for k, v in vars(self.inputs).items() if v is not None and v != ""]
-    if inputs:
-        self.logger.info("with:")
-        for key, value in inputs:
-            self.logger.info("  %s: %s", key, value)
+    if not inputs:
+        return
+
+    self.logger.info("with:")
+    for key, value in inputs:
+        self.logger.info("  %s: %s", key, value)
+
+
+def _log_outputs(self: Action) -> None:
+    outputs = [(k, v) for k, v in vars(self.outputs).items() if v is not None and v != ""]
+    if not outputs:
+        return
+
+    self.logger.debug("outputs:")
+    for key, value in outputs:
+        self.logger.debug("  %s: %s", key, value)