Conversation
connorjward
left a comment
There was a problem hiding this comment.
I wonder if we should expose the autogenerated key to the user at all. Why not just deal in the string options?
I'd be fine with that. I can take out that part of the docstring so the only way we tell users to use the |
|
|
||
| with opts.inserted_options(): | ||
| default = MyCustomData(10) | ||
| data = appctx.get('solver_custompc_somedata', default) |
Co-authored-by: Connor Ward <c.ward20@imperial.ac.uk>
| xcheck = x.duplicate() | ||
| xcheck.pointwiseMult(b, diag) | ||
|
|
||
| with petsctools.inserted_options(ksp), petsctools.push_appctx(appctx): |
There was a problem hiding this comment.
Do we even have to do any appctx manipulation here? It could safely live in global scope.
|
|
||
|
|
||
| def get_appctx(): | ||
| return _global_appctx_stack[-1] |
There was a problem hiding this comment.
Instead of doing this could we maybe do a WeakKeyDictionary mapping between, say, ksp and AppContext? Or alternatively just do setattr(ksp, "appctx", AppContext)?
I don't recall the motivation behind having a stack.
Corresponding Firedrake PR: firedrakeproject/firedrake#4526