Uh oh!
There was an error while loading. Please reload this page.
Fix duplicate external model generation from directory files - #5897
Conversation
reachsrinivaschennupati-tech
commented
Jul 11, 2026
Hi maintainers, this PR is ready for review when you have a chance. I kept the change focused on preventing generated external model entries from duplicating models that are already explicitly defined under the external models directory. The PR includes regression coverage for the mixed case where a project has both a SQL model dependency and an existing external model YAML definition. Validation noted in the PR:
Happy to make any adjustments if you prefer a different boundary for the generated-vs-explicit external model handling. |
0a86936 to
8d55174CompareStuffbyYuki
commented
Jul 23, 2026
@reachsrinivaschennupati-tech Thanks for this PR! One consideration - it might be preferable to have |
reachsrinivaschennupati-tech
commented
Jul 25, 2026
@StuffbyYuki Thank you for your kind review and suggestion. I agree Please review. |
StuffbyYuki
commented
Jul 25, 2026
Can you add DCO checks? |
2fa140c to
e1ae3aeComparereachsrinivaschennupati-tech
commented
Jul 25, 2026
@StuffbyYuki Thanks for pointing that out. I added the DCO sign-off to the follow-up commit as well. |
e1ae3ae to
5257626CompareSigned-off-by: srinivas chennupati <reachsrinivaschennupati@gmail.com>
Signed-off-by: srinivas chennupati <reachsrinivaschennupati@gmail.com>
5257626 to
b6af103CompareStuffbyYuki
commented
Jul 29, 2026
@reachsrinivaschennupati-tech Hey some of the style related ci tests didn't pass. Could you check? |
Signed-off-by: reachsrinivaschennupati-tech <272427721+reachsrinivaschennupati-tech@users.noreply.github.com>
reachsrinivaschennupati-tech
commented
Aug 5, 2026
@StuffbyYuki I checked the failing style-and-cicd job and it was failing in the Jupyter create_external_models test. I updated the test expectation to match the new behavior where external models already registered under the external_models directory are skipped when rebuilding the root external_models.yaml file.\n\nLocal focused checks passed:\n\n- uv run pytest tests/integrations/jupyter/test_magics.py::test_create_external_models tests/core/test_schema_loader.py::test_create_external_models_skips_models_from_external_models_directory\n\nPlease review when you have a chance. |
Summary
Fixes duplicate external model generation when external models are already defined in the
external_modelsdirectory.Problem
create_external_models_fileconsidered every external model in the loaded model set, including models that originated from the configured external models directory. That could cause SQLMesh to regenerate an external model entry that was already explicitly defined by the project.Solution
external_modelsdirectory without writing duplicate generated entries.Validation
Fixes#5880