Base.open
— Methodopen(MC::PlutoConfig))
Open notebook in web-browser via Pluto.
Important note: this assumes that the Pluto server is already running, e.g. from Pluto.run()
, at URL pluto_url
(by default, "http://localhost:1234/", should work on a laptop or desktop).
notebooks.open(PlutoConfig(model="examples/defaults.jl"))
ClimateModels.notebooks.download
— Methodnotebooks.download(path,nbs)
Download notebooks/files listed in nbs
to path
.
- If
nbs.file[i]
is found atnbs.url[i]
then download it topath
/nbs.folder[i]
. - If a second file is found at
nbs.url[i][1:end-3]*"_module.jl"
then we download it too.
nbs=notebooks.list()
notebooks.download(tempdir(),nbs)
ClimateModels.notebooks.list
— Methodnotebooks.list()
List downloadable notebooks based on the JuliaClimate/Notebooks
webpage.
Returns a DataFrame
with columns folder, file, and url.
ClimateModels.notebooks.reroll
— Methodreroll(p,f; PlutoFile="notebook.jl")
The reroll
function can be used to reassemble as a Pluto notebook that was previously unroll
'ed.
See unroll
documentation for a use case example.
ClimateModels.notebooks.unroll
— Methodunroll(PlutoFile::String; EnvPath="", ModuleFile="")
Split up Pluto notebook file (PlutoFile
) into main program (main.jl), Project.toml, Manifest.toml, and CellOrder.txt.
- these files are saved to folder
p
(EnvPath
or a temporary folder by default) unroll
returns output pathp
and main program file nameunroll
optionally copies companion filemf
top
(if filemf
exists)- default
mf
isPlutoFile[1:end-3]*"_module.jl"
unlessModuleFile
is specified - the
reroll
function can be used to reassemble as a Pluto notebook
Use case example: updating notebook dependencies
using Pkg
p,f=notebooks.unroll("CMIP6.jl")
Pkg.activate(p)
Pkg.update()
n=notebooks.reroll(p,f)
ClimateModels.notebooks.update
— Methodupdate(MC::PlutoConfig)
Update notebook dependencies (via unroll
& reroll
) and replace initial notebook file.
update(PlutoConfig(model="examples/defaults.jl"))
run(PlutoConfig(model="examples/defaults.jl"))
ClimateModels.setup
— Methodsetup(MC::PlutoConfig)
- call
default_ClimateModelSetup
- call
unroll
- add
notebook_launch
to tasks
MC1=PlutoConfig(model="examples/defaults.jl")
setup(MC1)
build(MC1)
launch(MC1)
ClimateModels.ModelConfig
— Typestruct ModelConfig <: AbstractModelConfig
Generic data structure for a model configuration. This serves as :
- default concrete type for
AbstractModelConfig
- keyword constructor for
AbstractModelConfig
model :: Union{Function,String,Pkg.Types.PackageSpec} = "anonymous"
configuration :: Union{Function,String} = "anonymous"
inputs :: OrderedDict{Any,Any} = OrderedDict{Any,Any}()
outputs :: OrderedDict{Any,Any} = OrderedDict{Any,Any}()
channel :: Channel{Any} = Channel{Any}(10)
folder :: String = tempdir()
ID :: UUID = UUIDs.uuid4()
ClimateModels.ModelConfig
— MethodModelConfig(func::Function,inputs::NamedTuple)
Simplified constructor for case when model is a Function.
ClimateModels.PlutoConfig
— Typestruct PlutoConfig <: AbstractModelConfig
Generic data structure for a model configuration based on a Pluto notebook.
ClimateModels.PlutoConfig
— MethodPlutoConfig(func::Function,inputs::NamedTuple)
Simplified constructor for case when model is a Pluto notebook.
If a folder path is passed in inputs.data
then it will get linked to the run folder.
Base.Filesystem.cd
— Methodcd(x::AbstractModelConfig)
Temporarily change the current working directory to x.folder
.
Base.Filesystem.joinpath
— Methodjoinpath(x::AbstractModelConfig,y...)
Same as joinpath(pathof(x),y...)
Base.Filesystem.readdir
— Methodreaddir(x::AbstractModelConfig,subfolder::String)
Same as readdir(joinpath(pathof(x),subfolder)).
Base.Filesystem.readdir
— Methodreaddir(x::AbstractModelConfig)
Same as readdir(pathof(x)).
Base.log
— Methodlog( x :: AbstractModelConfig, y :: String; fil="", msg="", prm=false)
Show or add a git
commit to the log
folder (i.e., joinpath(x,"log")
).
If no keyword is provided then
y
should be a commit ID fromlog(x)
Keyword arguments are mutually exclusive (i.e., use only one at a time) and work like this:
msg
is a non emptyString
: commitmsg
tolog/README.md
with messagey
.fil
is a non emptyString
: commit changes to filelog/$(fil)
with messagey
. Iflog/$(fil)
is unknown to git (i.e. commit errors out) then try addinglog/$(fil)
first.prm
istrue
: add files found ininput
ortracked_parameters/
(if any) to git log.
Example:
MC=run(ModelConfig(ClimateModels.RandomWalker,(NS=100,)))
MC.inputs[:NS]=200
msg="update tracked_parameters.toml (or skip if up to date)"
log(MC,msg,prm=true)
log(MC)
Base.log
— Methodlog(x :: AbstractModelConfig)
Show the record of git
commits that have taken place in the log
folder.
Base.pathof
— Methodpathof(x::AbstractModelConfig,subfolder::String)
Same as pathof(joinpath(x,subfolder))
or joinpath(pathof(x),subfolder)
Base.pathof
— Methodpathof(x::AbstractModelConfig)
Returns the run directory path for x ; i.e. joinpath(x.folder,string(x.ID))
Base.put!
— Methodput!(x :: AbstractModelConfig,v)
Adds v
to x.channel (i.e. put!(x.channel,v)
)
using ClimateModels, Suppressor
tmp=ModelConfig()
setup(tmp)
put!(tmp,ClimateModels.RandomWalker)
ClimateModels.pause(tmp)
@suppress ClimateModels.monitor(tmp)
@suppress ClimateModels.help(tmp)
launch(tmp)
isa(tmp,AbstractModelConfig)
Base.show
— Methodshow(io::IO, z::AbstractModelConfig)
tmp=ModelConfig(model=ClimateModels.RandomWalker)
setup(tmp)
show(tmp)
Base.take!
— Methodtake!(x :: AbstractModelConfig)
Takes command v
from x.channel (i.e. take!(x.channel)
) and execute v(x)
(if a Function) or return v
(if not a Function, e.g. a String).
tmp=ModelConfig()
put!(tmp,ClimateModels.RandomWalker)
take!(tmp)
ClimateModels.ModelRun
— MethodModelRun(x :: AbstractModelConfig)
Shorthand for x |> setup |> build |> launch
Returns AbstractModelConfig
as output.
ClimateModels.PkgDevConfig
— MethodPkgDevConfig(url::String,func::Function,inputs::NamedTuple)
Simplified constructor for case when model is a url (PackageSpec).
ClimateModels.RandomWalker
— MethodRandomWalker(x::AbstractModelConfig)
Random Walk in 2D over NS
steps (100 by default). Result is provided as an array and a text file.
By default, RandomWalker.csv
will be created in pathof(x)
. That folder itself is created by setup
, possibly via run
as below.
MC=ModelConfig(ClimateModels.RandomWalker)
run(MC)
ClimateModels.build
— Methodbuild(x)
Defaults to default_ClimateModelBuild(x)
. Can be expected to be specialized for most concrete types of AbstractModelConfig
using ClimateModels
tmp=ModelConfig(model=ClimateModels.RandomWalker)
setup(tmp)
build(tmp)
isa(tmp,AbstractModelConfig) # hide
ClimateModels.build_the_pkg
— Methodbuildthepkg(x)
Default for building/compiling model when it is a cloned julia package
ClimateModels.clean
— Methodclean(x :: AbstractModelConfig)
Cancel any remaining task (x.channel) and rm the run directory (pathof(x))
tmp=ModelConfig(model=ClimateModels.RandomWalker)
setup(tmp)
clean(tmp)
ClimateModels.compile
— Methodcompile(x)
Defaults to default_ClimateModelBuild(x)
. Can be expected to be specialized for most concrete types of AbstractModelConfig
using ClimateModels, Pkg
tmp0=PackageSpec(url="https://github.com/JuliaOcean/AirSeaFluxes.jl")
tmp=ModelConfig(model=tmp0)
setup(tmp)
compile(tmp)
isa(tmp,AbstractModelConfig)
ClimateModels.git_log_fil
— Methodgit_log_fil(x :: AbstractModelConfig,fil,commit_msg)
Commit changes to file log/fil
with message commit_msg
. If log/fil
is unknown to git (i.e. commit errors out) then try adding log/fil
first.
ClimateModels.git_log_init
— Methodgit_log_init(x :: AbstractModelConfig)
Create log
subfolder, initialize git, and commit initial README.md
ClimateModels.git_log_msg
— Methodgit_log_msg(x :: AbstractModelConfig,msg,commit_msg)
Add message msg
to the log/README.md
file and git commit.
ClimateModels.git_log_prm
— Methodgit_log_prm(x :: AbstractModelConfig)
Add files found in tracked_parameters/
(if any) to git log.
ClimateModels.git_log_show
— Methodgit_log_show(x :: AbstractModelConfig,y:: String)
Show the record of git commit y
from the log
folder.
ClimateModels.git_log_show
— Methodgit_log_show(x :: AbstractModelConfig)
Show the record of git commits that have taken place in the log
folder.
using ClimateModels
f=ClimateModels.RandomWalker
i=ClimateModels.OrderedDict(); i["NS"]=100
tmp=ModelConfig(model=f,inputs=i)
setup(tmp)
build(tmp)
launch(tmp)
ClimateModels.@suppress log(tmp)
isa(tmp,AbstractModelConfig)
ClimateModels.launch
— Methodlaunch(x)
Defaults to default_ClimateModelLaunch(x)
which consists in take!(x)
for AbstractModelConfig
. Can be expected to be specialized for most concrete types of AbstractModelConfig
f=ClimateModels.RandomWalker
tmp=ModelConfig(model=f)
setup(tmp)
build(tmp)
launch(tmp)
ClimateModels.monitor
— Methodmonitor(x)
Show x.status[end]
by default.
tmp=ModelConfig(model=ClimateModels.RandomWalker)
setup(tmp)
monitor(tmp)
ClimateModels.run_the_tests
— Methodrun_the_tests(x)
Default for launching model when it is a cloned julia package
using ClimateModels, Pkg
tmp0=PackageSpec(url="https://github.com/JuliaOcean/AirSeaFluxes.jl")
tmp1=ModelConfig(model=tmp0)
setup(tmp1)
build(tmp1)
launch(tmp1)
clean(tmp1)=="no task left in pipeline"
ClimateModels.setup
— Methodsetup(x::AbstractModelConfig)
Defaults to default_ClimateModelSetup(x)
. Can be expected to be specialized for most concrete types of AbstractModelConfig
f=ClimateModels.RandomWalker
tmp=ModelConfig(model=f)
setup(tmp)
ClimateModels.@ModelRun
— Macro@ModelRun(func)
Macro equivalent for run(ModelConfig(model=func))
.