Skip to content

Fix backward compatibility for InferenceConfig schema - #14

Merged
EiffL merged 2 commits into
mainfrom
claude/issue-13-20260210-1607
Feb 10, 2026
Merged

Fix backward compatibility for InferenceConfig schema#14
EiffL merged 2 commits into
mainfrom
claude/issue-13-20260210-1607

Conversation

@EiffL

@EiffL EiffL commented Feb 10, 2026

Copy link
Copy Markdown
Member

Summary

Resolves #13 by adding backward compatibility to the InferenceConfig class. The example script examples/shear_inference.py now works with both the old flat config structure and the new hierarchical structure.

Changes

  • Added optional legacy fields to InferenceConfig (warmup, samples, chains, dense_mass, map_init)
  • Implemented migrate_legacy_config validator that automatically migrates old configs to new hierarchical structure
  • Added comprehensive tests for backward compatibility
  • Ensured mixing both formats raises a clear error

Testing

Added tests covering:

  • Full legacy config migration
  • Legacy config with MAP initialization
  • Partial legacy fields with defaults
  • Error when mixing both formats
  • Loading legacy YAML config

Generated with Claude Code

Resolves #13: Add support for legacy flat config structure to fix
AttributeError when running pedagogical example with dev version.

The InferenceConfig class now accepts both:
1. Legacy flat structure (warmup, samples, chains at inference level)
2. New hierarchical structure (method, nuts_config, map_config, vi_config)

Changes:
- Add optional legacy fields to InferenceConfig
- Implement migrate_legacy_config validator that auto-migrates old configs
- Add comprehensive tests for backward compatibility
- Ensure mixing both formats raises a clear error

This fixes the issue where examples work with PyPI but fail with GitHub
dev version, and vice versa for shine.main.

Co-authored-by: Ezequiel Centofanti <CentofantiEze@users.noreply.github.com>
@EiffL

EiffL commented Feb 10, 2026

Copy link
Copy Markdown
Member Author

ok, @claude can you update this PR to actually discard all legacy code, we don't care about maintaining backward compatibility, just make sure the documentation, example codes and pedagofical examples and notebooks are up to date with the main branch.

@claude

claude Bot commented Feb 10, 2026

Copy link
Copy Markdown

Claude finished @EiffL's task in 2m 37s —— View job


Removed backward compatibility code ✅

  • Analyze current changes and understand what needs to be removed
  • Remove legacy compatibility code from shine/config.py
  • Remove backward compatibility tests from tests/test_config.py
  • Update examples/shear_inference.py to use new config structure
  • Update configs/test_run.yaml to use new config structure
  • Update configs/validation/level0_base.yaml to use new config structure (already uses new structure ✅)
  • Check notebook for legacy config usage (already uses new structure ✅)
  • Commit and push changes

Summary

I've successfully removed all backward compatibility code from this PR and updated all documentation, examples, and config files to use the new hierarchical inference config structure.

Changes made:

  1. shine/config.py: Removed all legacy fields and the migration validator

    • Removed optional legacy fields: warmup, samples, chains, dense_mass, map_init
    • Removed migrate_legacy_config validator method
    • Updated docstring to remove deprecation notices
  2. tests/test_config.py: Removed backward compatibility tests

    • Removed test_inference_config_legacy_flat_structure
    • Removed test_inference_config_legacy_with_map_init
    • Removed test_inference_config_legacy_partial_fields
    • Removed test_inference_config_legacy_and_new_conflict
    • Removed test_load_config_with_legacy_inference
  3. examples/shear_inference.py: Updated to use new hierarchical structure

    • Changed config dict to use nuts_config with nested parameters
    • Updated print statement to reference config.inference.nuts_config.* fields
  4. configs/test_run.yaml: Updated to use new hierarchical structure

    • Reorganized inference config to use nuts_config block

Already using new structure:

  • configs/validation/level0_base.yaml
  • examples/level0_batched_inference.ipynb

The PR now contains only the new hierarchical config structure with no backward compatibility code.
| Branch

This commit removes all legacy backward compatibility code and updates
all documentation, examples, and config files to use the new hierarchical
inference config structure.

Changes:
- Removed legacy fields (warmup, samples, chains, dense_mass, map_init)
  from InferenceConfig class
- Removed migrate_legacy_config validator
- Removed all backward compatibility tests
- Updated examples/shear_inference.py to use nuts_config structure
- Updated configs/test_run.yaml to use hierarchical structure
- configs/validation/level0_base.yaml already used new structure
- examples/level0_batched_inference.ipynb already used new structure

Co-authored-by: Francois Lanusse <EiffL@users.noreply.github.com>
@EiffL
EiffL marked this pull request as ready for review February 10, 2026 16:21
@EiffL

EiffL commented Feb 10, 2026

Copy link
Copy Markdown
Member Author

I think this should fix the problem, but let me know (at least when installing from the main branch)

@EiffL
EiffL merged commit fac519e into main Feb 10, 2026
4 of 5 checks passed
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.

Bug when running the pedagogical example

1 participant