sacred icon indicating copy to clipboard operation
sacred copied to clipboard

Suggestions for the capture decorator

Open timmeinhardt opened this issue 8 years ago • 1 comments

I have two suggestions for the capture decorator.

  1. The sacred tool could provide a fail-safe post-definition helper function for decorating. This function could improve could such as this:

    from xxx import x, y, z
    ex = sacred.Experiment('foo')
    x = ex.capture(x)
    y = ex.capture(y)
    z = ex.capture(z)
    

    The helper function could handle the assignments and even take an array of input functions and
    look something like ex.post_capture([x, y, z]).

  2. Decorating an entire class with capture should not only decorate the __init__ constructor but all class methods. If one only wants to decorate the constructor this could still be done by explicitly decorating it.

timmeinhardt avatar Nov 13 '17 00:11 timmeinhardt

  1. But unless you want to modify the global scope in some hacky way, you would have to do x, y, z = ex.post_capture([x, y, z]) no? And that you can almost do currently with x, y, z = map(ex.capture, [x, y, z]). So would post_capture really improve anything?
  2. That usecase makes sense to me. I honestly have never tried capturing a class, but if it would work, I would also expect that behavior. So I'll mark this as a feature request.

Qwlouse avatar Nov 21 '17 13:11 Qwlouse