Skip to content

🧹 Refactor DatabaseWriter to use Dependency Injection - #10

Closed
alfieprojectsdev wants to merge 1 commit into
mainfrom
refactor/vadase-db-writer-di-3487589831144081028
Closed

🧹 Refactor DatabaseWriter to use Dependency Injection#10
alfieprojectsdev wants to merge 1 commit into
mainfrom
refactor/vadase-db-writer-di-3487589831144081028

Conversation

@alfieprojectsdev

Copy link
Copy Markdown
Owner

🎯 What:
Refactored DatabaseWriter in services/vadase-rt-monitor to use dependency injection for configuration.

  • Created DatabaseConfig class in src/config.py using pydantic.
  • Updated DatabaseWriter to accept DatabaseConfig instance.
  • Updated scripts/run_ingestor.py and scripts/replay_events.py to instantiate and pass config.
  • Added tests/test_database_config.py to verify behavior.

💡 Why:
To improve testability and decouple the database writer from environment variables. This makes it easier to mock configuration during tests and supports different configurations (e.g. for testing vs production) without relying on global state.

Verification:

  • Ran new tests in tests/test_database_config.py.
  • Ran existing scripts in dry-run mode to ensure no regressions.
  • Ran ruff to ensure code style.

Result:
The DatabaseWriter is now more testable and follows the dependency injection pattern.


PR created automatically by Jules for task 3487589831144081028 started by @alfieprojectsdev

Co-authored-by: alfieprojectsdev <11991855+alfieprojectsdev@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.

@alfieprojectsdev

Copy link
Copy Markdown
Owner Author

Closing: Good pattern (DI) but wrong timing. The VADASE service is mid-refactor (PR #1 code review remediation, leaky integrator removal pending). DatabaseWriter DI should be addressed after core logic stabilizes. This also conflicts with PR #4's changes to writer.py.

@google-labs-jules

Copy link
Copy Markdown
Contributor

Closing: Good pattern (DI) but wrong timing. The VADASE service is mid-refactor (PR #1 code review remediation, leaky integrator removal pending). DatabaseWriter DI should be addressed after core logic stabilizes. This also conflicts with PR #4's changes to writer.py.

Understood. Acknowledging that this work is now obsolete due to ongoing refactoring and conflicts. Stopping work on this task.

alfieprojectsdev added a commit that referenced this pull request Jul 1, 2026
…(RH-002)

LinuxBPEBackend hardcoded PCF_FILE=RNX2SNX / CPU_FILE=PCF, so it could
only drive the stock demo PCF — never PAGENET, the real workflow proven
headless in the NAMRIA training week. Closes readiness gaps #3 and #10.

- Constructor: pcf_file (RNX2SNX), cpu_file (USER — the shipping USER.CPU,
  not the phantom PCF.CPU), driver_script, max_par. run() exports the
  parameterized PCF_FILE/CPU_FILE/BPE_CAMPAIGN and passes the PCF as
  argv[2] for pagenet_pcs.pl-style drivers; stock rnx2snx_pcs.pl ignores
  it. Defaults preserve the previous stock contract.
- compute_maxpar(n_sta) = max(1000, n_sta*4 + 500) + _count_crd_stations();
  run() auto-sizes MAXPAR from the campaign CRD (or max_par override) and
  exports it as a BPE variable. Left unset when uncomputable so the panel
  default stands. Panel-template wiring is RH-004 / readiness task B.
- test_backends.py +10 (maxpar bounds, CRD count, env-var flow, default
  preservation). 75 pass, ruff + mypy clean.
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