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

Simulation parameters and prettier show methods #639

Merged
merged 3 commits into from
Feb 24, 2020

Conversation

ali-ramadhan
Copy link
Member

This PR allows simulations to hold parameters, useful if you need to access stuff from the progress function (e.g. see ali-ramadhan/Atmosfoolery.jl#63) going with the idea that we'll probably get rid of model.parameters in favor of more local parameters.

It also cleans up show functions for models and simulations.

@ali-ramadhan ali-ramadhan added feature 🌟 Something new and shiny cleanup 🧹 Paying off technical debt labels Feb 24, 2020
@ali-ramadhan ali-ramadhan changed the title Ar/simulation fixes Simulation parameters and prettier show methods Feb 24, 2020
@codecov
Copy link

codecov bot commented Feb 24, 2020

Codecov Report

Merging #639 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #639   +/-   ##
=======================================
  Coverage   78.11%   78.11%           
=======================================
  Files         119      119           
  Lines        2326     2326           
=======================================
  Hits         1817     1817           
  Misses        509      509           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b5cc97...ff5ff0b. Read the comment docs.

Copy link
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

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

Yes. Let's get rid of model.parameters ASAP. BoundaryFunction also needs parameters.

@glwagner
Copy link
Member

BTW, the progress function does not have to run on the GPU, which means that flexible callable objects can be used which have embedded parameters. This is the way I envision progress function development moving forward. We may want eventually to have complex progress functions for fancy logging / in-terminal plotting, eg. A simulation.parameters field is probably not the right approach --- we want callable objects, I think.

@ali-ramadhan
Copy link
Member Author

Ah interesting yeah a callable object would have worked as well. We should change
https://github.com/climate-machine/Oceananigans.jl/blob/7b5cc97c18c8cd7dcc7a866312630df511735189/src/Simulations.jl#L158
to

iscallable(f) = !isempty(methods(f))
...
iscallable(sim.progress) && sim.progress(sim) 

See: https://discourse.julialang.org/t/how-to-determine-if-an-object-is-callable/2897

Although to have a callable object with parameters you'd have to define an new type right? (As in https://docs.julialang.org/en/v1/manual/methods/#Function-like-objects-1)

Either way, would be good to move the discussion to an issue on getting rid of model.parameters.

@ali-ramadhan ali-ramadhan merged commit 9f72d84 into master Feb 24, 2020
@ali-ramadhan ali-ramadhan deleted the ar/simulation-fixes branch February 24, 2020 02:38
@glwagner
Copy link
Member

Would a blacklisting strategy work better than whitelisting? What kind of progress object are we defending against? (Is it just nothing?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup 🧹 Paying off technical debt feature 🌟 Something new and shiny
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants