Closed preritdas closed 3 months ago
The recent changes introduce a global logging infrastructure, enhancing logging capabilities across various classes without requiring each class to manage logging individually. The BaseAnalyzer
, BaseOutputDeliverer
, and other classes have been updated to utilize this new logging system. Additionally, several methods have been renamed to indicate internal use, and abstract methods have been introduced for better encapsulation of core logic.
Files | Change Summary |
---|---|
bigdbm/analyze/base.py , bigdbm/analyze/insights/__init__.py , bigdbm/deliver/base.py , bigdbm/deliver/csv.py , bigdbm/deliver/followupboss/ai_fields.py , bigdbm/deliver/followupboss/vanilla.py , bigdbm/process/base.py , bigdbm/process/fill.py , bigdbm/process/simple.py , bigdbm/validate/base.py , bigdbm/validate/email.py , bigdbm/validate/home_attrs.py , bigdbm/validate/phone.py , bigdbm/validate/pii.py , bigdbm/validate/simple.py |
Enhanced logging functionality and method renaming to indicate internal use across multiple classes. New abstract methods introduced for core logic encapsulation. |
bigdbm/client.py |
Removed the logfire logging library and replaced it with an internal logging system. |
bigdbm/internal_logging.py |
Introduced a new global logging infrastructure that handles logging conditionally based on the presence of the logfire library. |
requirements.txt |
Updated the minimum version constraint for the logfire package from 0.50.1 to 0.51.0 . |
tests/test_analyze.py , tests/test_client.py |
Updated test method names to reflect changes in method visibility and modified instantiation of the BigDBMClient . |
sequenceDiagram
participant Logger
participant Client
participant Analyzer
participant Deliverer
participant Processor
Client->>Logger: Enable logging
Client->>Analyzer: Call analyze()
Analyzer->>Logger: Log start of analysis
Analyzer->>Deliverer: Call deliver()
Deliverer->>Logger: Log delivery process
Deliverer->>Processor: Call process()
Processor->>Logger: Log processing details
Logger->>Client: Log output
Objective | Addressed | Explanation |
---|---|---|
Global logging infrastructure (#57) | ✅ | |
Simplified logging management in classes | ✅ | |
Elimination of client dependency for logging | ✅ |
🐰 In the burrow where logs now flow,
A rabbit hops with joy, you know!
With each new change, our paths align,
No more tangled logs, all is fine.
So let us dance in the meadow bright,
For clean code brings us pure delight! 🌼
@coderabbitai full review
@preritdas Review all changed files again before merging.
@coderabbitai In the AI Follow Up Boss deliverer, if adding a person fails due to a custom lead having the wrong type for example, what happens? Does the entire delivery process for all leads fall back to the non-AI implementation? Does it fail for only that one person? Does it fail for only that custom field?
[!TIP] For best results, initiate chat on the files or code changes.
@preritdas The _deliver
method in the AI Follow Up Boss deliverer is designed to handle errors gracefully. If adding a person fails due to a custom lead having the wrong type (or any other error during the AI-based delivery process), the method falls back to the parent class's delivery method, which does not use AI fields. This fallback applies to the entire delivery process for all leads, meaning that if the AI-based delivery fails, the method will attempt to deliver all leads using the non-AI implementation.
Let me know if you need further clarification!
Tip
For best results, initiate chat on the files or code changes.
@preritdas The
_deliver
method in the AI Follow Up Boss deliverer is designed to handle errors gracefully. If adding a person fails due to a custom lead having the wrong type (or any other error during the AI-based delivery process), the method falls back to the parent class's delivery method, which does not use AI fields. This fallback applies to the entire delivery process for all leads, meaning that if the AI-based delivery fails, the method will attempt to deliver all leads using the non-AI implementation.Let me know if you need further clarification!
Analysis chain Scripts executed
Can you suggest a commitable change where we'd fallback only for one person if that person fails as opposed to the entire delivery of all people/leads?
Closes #57.
Why
This PR implements a global logging infrastructure to address the following issues:
BigDBMClient
class, making it difficult for other classes to log without a client instance.Processor
class (a non-client class) could log, usingself.client.logfire.log
.How
internal_logging.py
module with aLoggingManager
class and global logging functions.BaseAnalyzer
,BaseOutputDeliverer
,BaseProcessor
,BaseValidator
):analyze
,deliver
,process
,validate
) in base classes now include logging._analyze
,_deliver
,_process
,_validate
) to be implemented by subclasses.Impact
Observations
Client Code Changes
No changes are required in client code. However, users of the package now have more control over logging:
Enabling and disabling logging via this package as seen above is a convenience. It should be done with
logfire.configure(...)
in client code instead, as you can pass inFalse
to theconsole=
parameter or customConsoleOptions
at the global level.enable_logging()
anddisable_logging()
both do not calllogfire.configure(...)
, they simply access theGLOBAL_CONFIG
LogfireConfig
instance of thelogfire
package and adjust the.console: ConsoleOptions | Literal[False]
attribute.Interacting with internal_logging
The
internal_logging
module provides the following key functions:enable_logging()
: Enables logging if Logfire is available.disable_logging()
: Disables logging.log(level: str, message: str, **kwargs)
: Logs a message at the specified level.log_span(name: str, **kwargs)
: Creates a logging span for a specific operation.These functions can be used to control logging behavior and add custom logs when necessary.
Code Snippets
Before (in BigDBMClient):
After (using global logging):
New Base Class Structure (e.g., BaseAnalyzer):
This new structure ensures consistent logging across all implementations while allowing subclasses to focus on their specific logic.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation
logfire
package updated to ensure compatibility with newer features.