Skip to content

Commit 08991df

Browse files
committed
Merge remote-tracking branch 'origin' into feat/rowFiltering
2 parents 0607b6b + 64c80c2 commit 08991df

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

damnit/ctxsupport/ctxrunner.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,10 @@ def execute(self, run_data, run_number, proposal, input_vars) -> 'Results':
303303
if annotation.startswith("var#"):
304304
dep_name = annotation.removeprefix("var#")
305305
if dep_name in res:
306-
kwargs[arg_name] = res[dep_name].data
306+
dep_data = res[dep_name]
307+
if isinstance(dep_data, Cell):
308+
dep_data = dep_data.data
309+
kwargs[arg_name] = dep_data
307310
elif param.default is inspect.Parameter.empty:
308311
missing_deps.append(dep_name)
309312

@@ -343,11 +346,12 @@ def execute(self, run_data, run_number, proposal, input_vars) -> 'Results':
343346
if (data := func(run_data)) is None:
344347
continue
345348

346-
if not isinstance(data, Cell):
347-
data = Cell(data)
349+
if not var.transient:
350+
if not isinstance(data, Cell):
351+
data = Cell(data)
348352

349-
if data.summary is None:
350-
data.summary = var.summary
353+
if data.summary is None:
354+
data.summary = var.summary
351355
except Exception:
352356
log.error("Could not get data for %s", name, exc_info=True)
353357
else:

docs/backend.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ these arguments:
7272
- `cluster` (bool): whether or not to execute this variable in a Slurm job. This
7373
should always be used if the variable does any heavy processing.
7474
- `transient` (bool): do not save the variable's result to the database. This
75-
is useful for e.g. intermediate results to be reused by other Variables. By
75+
is useful for e.g. intermediate results to be reused by other Variables. Since
76+
their data isn't saved, `transient` variables can return any object. By
7677
default Variables do save their results (transient=False).
7778

7879
Variable functions can return any of:

tests/test_backend.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,12 @@ def var1(run):
10191019
10201020
@Variable(transient=True)
10211021
def var2(run, data: 'var#var1'):
1022-
return np.arange(data)
1022+
# transient vars can return any data type
1023+
return [np.arange(data), run]
10231024
10241025
@Variable(summary='max')
10251026
def var3(run, data: 'var#var2'):
1027+
data, run = data
10261028
return data.size * data
10271029
"""
10281030
ctx = mkcontext(ctx_code)

0 commit comments

Comments
 (0)