-
Notifications
You must be signed in to change notification settings - Fork 195
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
Output writer "diagnostic dependencies" #886
Conversation
I couldn't get tests to work for the Oceananigans.jl/test/test_simulations.jl Lines 67 to 75 in ede8021
|
Codecov Report
@@ Coverage Diff @@
## master #886 +/- ##
==========================================
+ Coverage 70.99% 71.67% +0.67%
==========================================
Files 188 188
Lines 5230 5433 +203
==========================================
+ Hits 3713 3894 +181
- Misses 1517 1539 +22
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the NetCDFOutputWriter
test for dependencies_added_correctly!
so it passes now. I think since it goes through a C library, NetCDFOutputWriter
needs strings as keys, while it was using symbols. Annoying, but probably a NetCDF limitation.
Also, simulations are tested before output writers so I'm slightly concerned that we are relying on output writers before they are tested so there's no guarantee they even work. I.e. the dependencies_added_correctly!
tests should go into test_output_writers.jl
.
src/Simulations/run.jl
Outdated
@@ -44,6 +46,12 @@ function wall_time_limit_exceeded(sim) | |||
return false | |||
end | |||
|
|||
add_dependency!(diagnostics, output) = nothing # fallback | |||
add_dependency!(diags, wta::WindowedTimeAverage) = !(wta ∈ values(diags)) && push!(diags, wta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably write this as
wta ∈ values(diags) || push!(diags, wta)
but maybe it's a bit more obfuscated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's nice.
@ali-ramadhan I'll move the tests to |
@ali-ramadhan can you restart gitlab? |
This PR introduces the concept of an output writer "diagnostic dependency": a diagnostic which must be added to
simulation.diagnostics
in order for output to be correct.If a type of output has a "diagnostic dependency", it must define the function
add_dependency!(diagnostics, output)
, which will add any appropriate diagnostics to the ordered dictionarydiagnostics
.Currently we only have one type of output that requires a diagnostic, which is the
WindowedTimeAverage
. ForWindowedTimeAverage
,add_dependency!
is(As a side note, we could require that all values of
diagnostics
are unique, which would obviate the check above.)