Skip to content
Snippets Groups Projects
Commit 3a702e24 authored by xo30xoqa's avatar xo30xoqa
Browse files

Added "core.overwrite" parameter

parent 0874ec32
No related branches found
No related tags found
No related merge requests found
...@@ -25,12 +25,9 @@ using ...@@ -25,12 +25,9 @@ using
## define exported functions and variables ## define exported functions and variables
export export
#types #types
LandCover,
EventType,
Pixel, Pixel,
FarmEvent, FarmEvent,
FarmPlot, FarmPlot,
Sex,
Animal, Animal,
Farmer, Farmer,
#functions #functions
......
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
##XXX Does it make sense to move the settings dict into the model object itself? ##XXX Does it make sense to move the settings dict into the model object itself?
## (It could be integrated into the properties dict.) Advantage: we have less ## (It could be integrated into the properties dict.) Advantage: we have less
## global state lying around, and serialising becomes easier (if we want to do ## global state lying around, and serialising becomes easier (if we want to do
## that). Disadvantage: only functions that have access to the model object can ## that). Also, during testing we often need to change individual parameters,
## access the settings - this may give problems during initialisation. ## which is currently impossible. Disadvantage: immutability of parameters at
## runtime is intended, and some start-up functions may have problems if they need
## access to parameters before the model object has been created.
##TODO -> yes, changing this is probably sensible
let settings::Dict{String, Dict{String, Any}} let settings::Dict{String, Dict{String, Any}}
""" """
initsettings(configfile) initsettings(configfile)
......
...@@ -16,14 +16,21 @@ Creates the output directory and copies relevant files into it. ...@@ -16,14 +16,21 @@ Creates the output directory and copies relevant files into it.
function setupdatadir() function setupdatadir()
# Check whether the output directory already exists and handle conflicts # Check whether the output directory already exists and handle conflicts
if isdir(param("core.outdir")) if isdir(param("core.outdir"))
@warn "The chosen output directory $(param("core.outdir")) already exists." overwrite = param("core.overwrite")
println("Type 'yes' to overwrite this directory. Otherwise, the simulation will abort.") if param("core.overwrite") == "ask"
print("Overwrite? ") println("The chosen output directory $(param("core.outdir")) already exists.")
answer = readline() println("Type 'yes' to overwrite this directory. Otherwise, the simulation will abort.")
(answer != "yes") && Base.error("Output directory exists, will not overwrite. Aborting.") print("Overwrite? ")
else answer = readline()
mkpath(param("core.outdir")) (answer == "yes") && (overwrite = true)
end
if !overwrite
Base.error("Output directory exists, will not overwrite. Aborting.")
else
@warn "Overwriting existing output directory $(param("core.outdir"))."
end
end end
mkpath(param("core.outdir"))
# Setup the logging system and logfile # Setup the logging system and logfile
loglevel = Logging.Info loglevel = Logging.Info
if param("core.loglevel") == "debug" if param("core.loglevel") == "debug"
......
...@@ -11,6 +11,7 @@ configfile = "src/parameters.toml" # location of the configuration file ...@@ -11,6 +11,7 @@ configfile = "src/parameters.toml" # location of the configuration file
landcovermap = "data/landcover_jena.tif" # location of the landcover map landcovermap = "data/landcover_jena.tif" # location of the landcover map
farmfieldsmap = "data/fields_jena.tif" # location of the field geometry map farmfieldsmap = "data/fields_jena.tif" # location of the field geometry map
outdir = "results" # location and name of the output folder outdir = "results" # location and name of the output folder
overwrite = "ask" # overwrite the output directory? (true/false/"ask")
loglevel = "debug" # verbosity level: "debug", "info", "quiet" loglevel = "debug" # verbosity level: "debug", "info", "quiet"
seed = 0 # seed value for the RNG (0 -> random value) seed = 0 # seed value for the RNG (0 -> random value)
# dates to start and end the simulation # dates to start and end the simulation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment