Repository navigation
fix(compiler): read a family a declared composite sums as one measure - #198
Merged
Merged
Conversation
A plan card ranking France's DAC2a aid to recipients could not switch to "net bilateral plus imputed multilateral as published, by convention": the compiler read the composite's two StatVars as two measures and refused the ranking with `input_shape_unsupported`. dfo-apis adds a stacked composite's components by declaration and now says so in `resolved.stat_vars.sums_components`. `source_from_spec_block` carries the flag onto `SelectedSource.sums_components`, and `default_reading` reads such a family summed unless an open axis cannot be summed. A block without the flag reads as before. A refused plan revision now logs its code and the compiler's raw detail before the reason is reworded for the user, so a refused switch can be diagnosed from the logs.
…reason only The detail dict can hold several issues naming the user's entities. The log keeps what diagnosis needs: the refusal code, the compile issue code and the compiler's reason, cut to 500 characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Studio card ranking France's DAC2a aid to recipients could not switch its provider to "net bilateral plus imputed multilateral as published, by convention". In prod the switch failed with "a calculation was asked of data in a shape it cannot read". That option binds DAC2a's stacked composite, whose two StatVars (aid type 206 and the gross imputed line 106) dfo-apis adds by declaration. Every slot is bound, so the compiler saw two StatVars and no axis to sum over, read them separately, and
planner.shapes._rejects_rankrefused a ranking over two measures. A fresh plan on that option failed the same way unless it statedstat_vars: "sum". DevelopmentFinanceObservatory/apis#304 serves the fact the mint acts on; this PR reads it.Changes
SelectedSource.sums_components(new, hashed only when set) comes fromresolved.stat_vars.sums_componentsincompiler.sources.source_from_spec_block. Only a JSONtruesets it.compiler.sources.default_readingreads a family summed when it has no open axis that cannot be summed and either has open axes or carriessums_components._check_summableis unchanged, so an open unsummable axis, such as an expanded aid type, still reads separately. The plan card's reading clause now says the family is "summed over whichever of its 2 indicators hold data by default".PlannerAdapter._revision_refusedlogsplan revision refusedwith the refusal code, the compile issue code (constraint) and the compiler's own reason cut to 500 characters, before the reason is reworded for the user. User-facing text is unchanged.Notes for reviewers
The fix takes effect once apis#304 deploys. Until then the flag is absent and every family reads as today. The fixtures are the blocks apis serves for the DAC2a and CRS inclusive answers, captured from apis#304's tests. The ranking tests open the recipient on a copy, and that edit is stated in each docstring.
Testing:
test_family_reading.pycovers the DAC2a block summed by rule and a rank over recipients compiling with SUM. It also pins the unchanged cases: no flag still refusesinput_shape_unsupported, an expanded aid type stays separate, and CRS inclusive reads summed either way.test_graph.pyrunsswitch._switched_planfrom a bilateral DAC2a ranking card toprovider:inclusivethrough the real revise, translate and compile; before the change it reproduces the prod error.test_planner_adapter.pyasserts the new log record's code and detail. Targeted harness suites pass (1,526 passed, 1 xfailed), with ruff and ty.