Repository navigation
Allow multiple context managers - #2259
elebel-emerson wants to merge 5 commits into
Conversation
context_manager_name may now be a dict or a list of dicts, each with an optional method_name (default: initiate). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2259 +/- ##
==========================================
+ Coverage 88.12% 88.13% +0.01%
==========================================
Files 88 88
Lines 22830 22863 +33
==========================================
+ Hits 20118 20151 +33
Misses 2712 2712
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/azp run |
|
Commenter does not have sufficient privileges for PR 2259 in repo ni/nimi-python |
|
A better PR title is needed. |
Oops, forgot to change off of default name, should be better |
| def filter_context_managers(config): | ||
| '''Returns the 'context_manager_name' config entries as a list. | ||
|
|
||
| 'context_manager_name' may be a single dict or a list of dicts. A missing or empty value returns an empty list. | ||
| ''' | ||
| context_managers = config.get('context_manager_name') or [] | ||
| if not isinstance(context_managers, list): | ||
| context_managers = [context_managers] | ||
| return context_managers |
There was a problem hiding this comment.
This doesn't feel like a filter.
For filter_parameters functions, you take in the list of parameters for a function and only returns specific parameters.
For filter_*_functions and filter_*_attributes, we take in the full list of functions or attributes and return a filtered list.
Here, we're just returning the whole list.
There was a problem hiding this comment.
Maybe get_context_manager_configs or get_context_managers_md?
This contribution adheres to CONTRIBUTING.md.
I've updated CHANGELOG.md if applicable.Not a client-facing change: generated code for all shipping drivers is unchanged.
I've added tests applicable for this pull request
What does this Pull Request accomplish?
Allows a driver to define more than one session context manager (initiate/abort pair) in its metadata.
config['context_manager_name']may now be either a single dict (existing format, unchanged for all current drivers) or a list of dicts.method_namekey for the public method that returns the context manager. It defaults toinitiate, so existing behavior is preserved.helper.filter_context_managers(config), which normalizes the config to a list and drops empty entries (e.g. nitclk's{}).session.py.mako:session_context_managertocontext_managers, since the old name suggested the context manager returned bySession.__init__().initiate()blocks (_SessionBasevs.Session, chosen by the initiate function'srender_in_session_base) with loops.helper.initiate_function_def_for_doc()now takes a single context manager entry instead of the whole config, and uses itsmethod_name.class.rst.makoand nitclk'sclass.rst.makoadd one doc entry per context manager.acquisition(Initiate/Abort, methodinitiate(), rendered onSession).generation(InitiateGeneration/AbortGeneration, methodinitiate_generation(), rendered on_SessionBase). These two functions are not included in the proto.List issues fixed by this Pull Request below, if any.
None.
What testing has been done?
niFakehas been updated and passing changes