Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Acquire ownership of data returned by compute! #88

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Acquire ownership of data returned by compute! #88

merged 1 commit into from
Oct 8, 2024

Conversation

Sbozzolo
Copy link
Member

@Sbozzolo Sbozzolo commented Oct 7, 2024

Prior to this version, ClimaDiagnostics would directly store use the output returned by compute! functions the first time they are called. This leads to problems when the output is a reference to an existing object since multiple diagnostics would modify the same object. Now, ClimaDiagnostics makes a copy of the return object so that it is no longer necessary to do so in the compute! function.

Fixes problem found by @szy21 with radiation

Prior to this version, `ClimaDiagnostics` would directly store use the
output returned by `compute!` functions the first time they are called.
This leads to problems when the output is a reference to an existing
object since multiple diagnostics would modify the same object. Now,
`ClimaDiagnostics` makes a copy of the return object so that it is no
longer necessary to do so in the `compute!` function.
Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

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

LGTM. I think that this is more along the lines of how the functional version will look, too, if/when we change over to using LazyBroadcast.jl.

@Sbozzolo
Copy link
Member Author

Sbozzolo commented Oct 7, 2024

LGTM. I think that this is more along the lines of how the functional version will look, too, if/when we change over to using LazyBroadcast.jl.

Yes, I agree, and I don't know why I didn't think about this earlier

Sbozzolo added a commit to CliMA/ClimaAtmos.jl that referenced this pull request Oct 7, 2024
The radiation diagnostics were returning references to objects, leading
to conflicts when multiple diagnostics were added at the same time.

This commit ensures that all the radiation diagnostics return a new
object.

CliMA/ClimaDiagnostics.jl#88 fixes the problem
direclty in ClimaDiagnostics, but I think it is still worth fixing in
atmos, too, so that we can be compatible with previous versions of
ClimaDiagnostics and more uniform with what we are doing with all the
other diagnostics
Sbozzolo added a commit to CliMA/ClimaAtmos.jl that referenced this pull request Oct 7, 2024
The radiation diagnostics were returning references to objects, leading
to conflicts when multiple diagnostics were added at the same time.

This commit ensures that all the radiation diagnostics return a new
object.

CliMA/ClimaDiagnostics.jl#88 fixes the problem
direclty in ClimaDiagnostics, but I think it is still worth fixing in
atmos, too, so that we can be compatible with previous versions of
ClimaDiagnostics and more uniform with what we are doing with all the
other diagnostics
@charleskawczynski
Copy link
Member

Yes, I agree, and I don't know why I didn't think about this earlier

This was kind of my related concern with the deepcopy (I forget which repo/PR it was from).

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.19%. Comparing base (57d2261) to head (19437cd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #88   +/-   ##
=======================================
  Coverage   85.19%   85.19%           
=======================================
  Files          13       13           
  Lines         520      520           
=======================================
  Hits          443      443           
  Misses         77       77           

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

@Sbozzolo Sbozzolo merged commit 48488e1 into main Oct 8, 2024
12 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.

2 participants