feat: preserve Context subtype and enforce input==output context type - #1582
feat: preserve Context subtype and enforce input==output context type#1582AngeloDanducci wants to merge 3 commits into
Conversation
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
jakelorocco
left a comment
There was a problem hiding this comment.
looks good; I have a few concerns / thoughts that I think would be worth addressing in this PR so that we can get a better surface for the context typing.
| checked_ctx = _enforce_context_type( | ||
| context, new_ctx, allow_context_type_change=allow_context_type_change | ||
| ) | ||
| return result, checked_ctx |
There was a problem hiding this comment.
I know that SamplingResults don't currently keep track of their context type, but could we also check that the context types of the sampling results are accurate as well?
There was a problem hiding this comment.
This should be addressed in the new changeset.
There was a problem hiding this comment.
This is somewhat out of scope but I think it should be a part of this PR as well to ensure everything works smoothly. Can you please add some tests that check that the context functions that return self actually work when subclassing? ie do we need additional checks to make sure a context type always returns its own type for those functions?
There was a problem hiding this comment.
This looks good for the functional api. I wonder if there's a way we should allow changing context types for sessions? right now, sessions default to preventing context type changes. I guess we wouldn't be able to get correct static typing but maybe there should be a flag for overriding this at the session level as well?
There was a problem hiding this comment.
And on that same note, can we type the context (and backend I guess) of a given context at this point too? So that you can access the context type of a given session?
There was a problem hiding this comment.
This should be handled now - made MelleaSession context type generic.
…verride Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
Pull Request
Issue
Fixes #1522
Description
preserve Context subtype and enforce input==output context type
Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.