-
Notifications
You must be signed in to change notification settings - Fork 30
[r] Add functions for setting/getting global context #4364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4364 +/- ##
==========================================
- Coverage 86.62% 85.40% -1.23%
==========================================
Files 139 77 -62
Lines 20955 13809 -7146
Branches 15 15
==========================================
- Hits 18152 11793 -6359
+ Misses 2803 2016 -787
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
aaronwolen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Great documentation and user messaging.
There seems to be a lot of overlap between the getter/setter's functionality. It looks like both functions:
- Check if a context exists
- Create one if needed
- Store it in
.pkgenv[["somactx"]] - Return the context
So the only differences are:
set_default_context()acceptsconfigand always creates a new oneget_default_context()has no args and only creates one if missing
I'd expect get_default_context() to error if one wasn't set and suggest users call set_default_context(). That might make the use case for each function clearer.
And then for internal use within get_soma_context() maybe we add an internal helper .get_or_create_default_context() that matches the current behavior of get_default_context() so factory functions automatically handle lazy creation for users.
f7693c6 to
2c6a0a0
Compare
915bae4 to
090d452
Compare
Add a method for setting the global context and one for getting the global context. Use the one to get the global context in internal context helper function.