← Back to Pull requests

[BUG] Fix _load_config() to support .pkl file paths #2199

Closed
unknown closed this pull request without merging on Mar 23, 2026 14:46 UTC
View on GitHub
unknown unknown commented on Mar 16, 2026 11:30 UTC
Author

#2189

Reference Issues/PRs

Fixes #2189

What does this implement/fix? Explain your changes.

_load_config() in Base_pkg claimed .pkl support in both the docstring and 
the error message, but raised ValueError when a .pkl path was passed directly.

Added an elif branch for .pkl that opens the file in binary mode and loads 
it with pickle.load(), consistent with how .pkl files are already handled 
in the config is None branch of the same method.

Before fix:
    pkg = DLinear_pkg_v2(model_cfg="config.pkl")
    # ValueError: Unsupported config format: .pkl. Use .yaml, .yml, or .pkl

After fix:
    pkg = DLinear_pkg_v2(model_cfg="config.pkl")
    # loads correctly

Changed file: pytorch_forecasting/base/_base_pkg.py

What should a reviewer concentrate their feedback on?

- The elif suffix == ".pkl" branch added to _load_config()

Did you add any tests for the change?

Added a unit test in pytorch_forecasting/tests/test_base_pkg.py:

    def test_load_config_pkl():
        import pickle, tempfile
        from pytorch_forecasting.base._base_pkg import Base_pkg

        cfg = {"moving_avg": 25}
        with tempfile.NamedTemporaryFile(suffix=".pkl", delete=False) as f:
            pickle.dump(cfg, f)
            pkl_path = f.name

        result = Base_pkg._load_config(pkl_path)
        assert result == {"moving_avg": 25}

PR checklist

- [x] The PR title starts with [BUG]
- [x] Added/modified tests
- [x] Used pre-commit hooks when committing

Diff: 197 lines (+147 / -50) across 2 files Reviewer: fnhirwa Review duration: 10275m
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.59) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 197 lines diff across 2 files
0.59
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.316
Shallow Review Depth shallow_review_depth
0.289
Sensitive Paths sensitive_paths
0.059
Real PR Conversation Timeline
1 comments
"Review active on #2199"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 59.3% (MEDIUM) · Higher = larger blast radius
59.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 23.4% · Safe to merge
23.4%