Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reverse order of prefixing & add changelog #792

Merged
merged 3 commits into from
Jan 30, 2025
Merged

Reverse order of prefixing & add changelog #792

merged 3 commits into from
Jan 30, 2025

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Jan 28, 2025

using DynamicPPL, Distributions

@model function subsubmodel()
  x ~ Normal()
end

@model function submodel()
  x ~ to_submodel(prefix(subsubmodel(), :c), false)
  return x
end

@model function parentmodel()
  x1 ~ to_submodel(prefix(submodel(), :a), false)
  x2 ~ to_submodel(prefix(submodel(), :b), false)
end

keys(VarInfo(parentmodel()))

Previously, the variable names would be c.a.x and c.b.x. This PR switches the order so that it's a.c.x and b.c.x, which is more intuitive.

This PR also adds a changelog. I copied the release notes which I wrote for the last few releases.

Targetting the 0.35 branch because this is a breaking change in behaviour.

Closes #786

@penelopeysm penelopeysm changed the title Reverse order of prefixing Reverse order of prefixing & add changelog Jan 28, 2025
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.17%. Comparing base (f5c5fda) to head (9ba4ad0).

Additional details and impacted files
@@               Coverage Diff                @@
##           release-0.35     #792      +/-   ##
================================================
- Coverage         86.17%   86.17%   -0.01%     
================================================
  Files                36       36              
  Lines              4305     4304       -1     
================================================
- Hits               3710     3709       -1     
  Misses              595      595              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Jan 28, 2025

Pull Request Test Coverage Report for Build 13012939391

Details

  • 4 of 6 (66.67%) changed or added relevant lines in 1 file are covered.
  • 29 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.003%) to 86.256%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/contexts.jl 4 6 66.67%
Files with Coverage Reduction New Missed Lines %
src/varinfo.jl 3 84.48%
src/model.jl 5 80.0%
src/threadsafe.jl 21 46.61%
Totals Coverage Status
Change from base Build 13010021727: -0.003%
Covered Lines: 3709
Relevant Lines: 4300

💛 - Coveralls

Copy link
Member

@mhauru mhauru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very happy with this. Note also that this restores the old behavior of @submodel:

       module MWE
       using DynamicPPL, Distributions

       @model function subsubmodel()
         x ~ Normal()
       end

       @model function submodel()
         @submodel prefix="c" x = subsubmodel()
         return x
       end

       @model function parentmodel()
         @submodel prefix="a" x1 = submodel()
         @submodel prefix="b" x2 = submodel()
       end

       @show keys(VarInfo(parentmodel()))
       end
keys(VarInfo(parentmodel())) = AbstractPPL.VarName{sym, typeof(identity)} where sym[a.c.x, b.c.x]

@penelopeysm
Copy link
Member Author

Hold on, I didn't realise that. 😅 In that case should it just be a patch release?

@mhauru
Copy link
Member

mhauru commented Jan 30, 2025

You could argue that. Depends on whether we consider the new behavior of to_submodel to have settled as the new standard maybe?

@mhauru
Copy link
Member

mhauru commented Jan 30, 2025

Which one is more likely? That someone hasn't adjusted to the new prefixing order of to_submodel yet, and will be saved the trouble of doing so, because they wouldn't have upgraded to the next minor version but will take the patch release into use and happily find that it restores the behaviour they expect. Or that someone has already adjusted to the new ordering, and will be frustrated when a patch release breaks their code.

Maybe the latter?

@penelopeysm
Copy link
Member Author

Aaah, yeah. I guess the other interpretation is that to_submodel's behaviour is defined to be the same as macro submodel, but anyway, let's stick to minor release then, since (a) it's less work; and (b) there's not much harm in releasing a patch as a minor (as opposed to the other way round).

@mhauru
Copy link
Member

mhauru commented Jan 30, 2025

Maybe add a mention in HISTORY.md though, that this is how @submodel worked?

@penelopeysm
Copy link
Member Author

Done!

@mhauru mhauru merged commit 161edf8 into release-0.35 Jan 30, 2025
1 of 14 checks passed
@mhauru mhauru deleted the py/prefix2 branch January 30, 2025 11:42
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants