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
feat(#1130): Cleanup rb namespace by refactoring client API #1160
Conversation
d712000
to
a23f966
Compare
Ok, this should be ready to review. Apart from the stuff written above, this PR also includes following:
|
Codecov Report
@@ Coverage Diff @@
## master #1160 +/- ##
==========================================
- Coverage 95.28% 94.88% -0.41%
==========================================
Files 124 127 +3
Lines 5130 5391 +261
==========================================
+ Hits 4888 5115 +227
- Misses 242 276 +34
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Nice approach !! Just a question thinking about future monitoring workflows. Imagine the following use case that could be handled by client: "Logging record predictions in different Rubrix servers due to <place here the reason>". How could it be solved with the singleton module approach implemented in this PR ? Could we define local sessions by combining import rubrix as rb
rb.log(....) # Publish to default server
with rb.init(my-rubrix-server) as session:
session.log(....) # publish using contextualized session
# or
with rb.init(my-rubrix-server):
rb.log(...) |
yeah, simultaneously logging to different Rubrix servers with the singleton approach is difficult, not sure how to do this ... however, local (sequential) sessions like you described above are definitely possible, one basically would restore the prior client when exiting the context (with statement). Do you want me to include this feature in this PR? Or better a follow-up one? In a monitoring context, I would try to run the monitoring in different processes, but of course, this assumes that they do not depend on each other. |
Got it. The sequential approach can get complicated once we start using asynchronous logging. To sumarize, it is difficult to solve this type of situation if we are not able to create and isolate different communications with the server. Let's discuss in a call about the possibilities |
Ok, I moved the api module functions into an import rubrix as rb
from rubrix.client.api import Api
rb.log(...)
Api(...).log(...) |
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.
Great !
We should think about contextualized api operations for metrics and labeling modules
Yes, maybe move all the logic to the |
Closes #1130
This is a proposal for how to clean up the
rb
namespace when we doimport rubrix as rb
:RubrixClient
a module, I named itapi.py
since it's basically the API if you want to interact with the server, but naming suggestions are welcomerubrix.__init__.py
to this modulerubrix.__init__.py
just imports stuff that it wants to expose to the user, so it's the user-facing API