Skip to content

🧪 Fix missing initialization in Logger.add_config#28

Open
mysticBliss wants to merge 3 commits into
mainfrom
fix-logger-init-config-8179432794639914049
Open

🧪 Fix missing initialization in Logger.add_config#28
mysticBliss wants to merge 3 commits into
mainfrom
fix-logger-init-config-8179432794639914049

Conversation

@mysticBliss

Copy link
Copy Markdown
Owner

This PR addresses a bug where Logger.add_config would raise an AttributeError if self.config was not initialized (e.g., if __init__ was bypassed via __new__ or failed).

Changes:

  • datamov/core/logger/Logger.py:

    • Added a check in add_config: if not hasattr(self, 'config'): self.config = {}.
    • Added a check in __init__: if not hasattr(self, 'config'): self.config = {} (instead of unconditional assignment).
  • tests/test_logger_fix.py:

    • Added a test case test_add_config_handles_missing_initialization to verify add_config works without __init__.
    • Added a test case test_init_preserves_existing_config to verify __init__ does not overwrite existing config.

This ensures robust configuration handling for the Singleton Logger class.


PR created automatically by Jules for task 8179432794639914049 started by @mysticBliss

- Modify `Logger.add_config` to lazily initialize `self.config` if it is missing, preventing `AttributeError` in scenarios where `__init__` is bypassed or fails.
- Update `Logger.__init__` to preserve existing configuration if `self.config` is already set, ensuring that pre-configured settings (via `add_config`) are not overwritten during initialization.
- Add `tests/test_logger_fix.py` to verify the fix and ensure `add_config` works on uninitialized instances and `__init__` respects existing config.

Co-authored-by: mysticBliss <11345806+mysticBliss@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits February 21, 2026 11:22
- Fixed `AttributeError` in `DataMovements.py` by using `self._environments` internally instead of `self.environments`.
- Updated `tests/test_data_movements.py` to use the public property `environment_configs`.
- Added fallback logic in `DataFlow.py` to attempt `strftime` formatting if `eval` fails, fixing path generation for simple format strings like `%Y%m%d`.
- Updated `tests/test_data_flow_paths.py` to expect correct evaluation results for python expressions (since `eval` is enabled) and verify `strftime` fallback works.
- Fixed `tests/test_integration.py` assertions to check the correct mock object (`mock_transformed_df`) when `DataProcessor` is mocked.
- Updated `tests/conftest.py` to robustly detect broken `pyspark` installations (common in some CI environments) and enforce mocking if submodules cannot be imported.

Co-authored-by: mysticBliss <11345806+mysticBliss@users.noreply.github.com>
- Updated `tests/conftest.py` to attempt importing `pyspark.testing` during the dependency check.
- If `pyspark.testing` is missing (as observed in the CI environment with PySpark 4.1.1?), the test suite now correctly falls back to using `MagicMock` for `pyspark`, avoiding `ModuleNotFoundError`.
- This ensures tests run reliably in environments with broken or partial PySpark installations.

Co-authored-by: mysticBliss <11345806+mysticBliss@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant