Skip to content

Commit

Permalink
resolve conflicts code, tests, doc
Browse files Browse the repository at this point in the history
up version package + news.md

# Conflicts:
#	NEWS.md
#	R/scenarioBuilder.R
#	man/scenario-builder.Rd
#	tests/testthat/helper_init.R
#	tests/testthat/test-scenarioBuilder.R
  • Loading branch information
BERTHET Clement (Externe) committed Oct 31, 2023
2 parents 1a60a94 + 28f0100 commit 5e1e19e
Show file tree
Hide file tree
Showing 187 changed files with 11,379 additions and 2,653 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: antaresEditObject
Type: Package
Title: Edit an 'Antares' Simulation
Version: 0.5.2
Version: 0.7.0
Authors@R: c(
person("Tatiana", "Vargas", email = "[email protected]", role = c("aut", "cre")),
person("Frederic", "Breant", role = "aut"),
Expand All @@ -13,6 +13,7 @@ Authors@R: c(
person("Etienne", "Sanchez", role = "ctb"),
person("Janus", "De Bondt", role = "ctb"),
person("Assil", "Mansouri", role = "ctb"),
person("Abdallah", "Mahoudi", role = "ctb"),
person("Clement", "Berthet", role = "ctb"),
person("RTE", role = "cph"))
Description: Edit an 'Antares' simulation before running it : create new areas, links, thermal
Expand Down
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ S3method(print,antares.api.command)
S3method(print,antares.api.commands)
S3method(print,antares.api.logs)
export(activateRES)
export(activateST)
export(adequacyOptions)
export(backupStudy)
export(checkRemovedArea)
Expand All @@ -21,20 +22,23 @@ export(createBindingConstraintBulk)
export(createCluster)
export(createClusterBulk)
export(createClusterRES)
export(createClusterST)
export(createDSR)
export(createDistrict)
export(createLink)
export(createPSP)
export(createStudy)
export(createStudyAPI)
export(createVariant)
export(deduplicateScenarioBuilder)
export(deleteStudy)
export(dicoGeneralSettings)
export(dicoOptimizationSettings)
export(editArea)
export(editBindingConstraint)
export(editCluster)
export(editClusterRES)
export(editClusterST)
export(editDSR)
export(editLink)
export(editPSP)
Expand All @@ -48,6 +52,7 @@ export(getVariantCommands)
export(group_values_check)
export(is_antares_v7)
export(is_antares_v820)
export(list_pollutants_values)
export(mockSimulationAPI)
export(nodalOptimizationOptions)
export(propertiesLinkOptions)
Expand All @@ -59,6 +64,7 @@ export(removeArea)
export(removeBindingConstraint)
export(removeCluster)
export(removeClusterRES)
export(removeClusterST)
export(removeLink)
export(runSimulation)
export(runTsGenerator)
Expand All @@ -67,6 +73,7 @@ export(searchStudy)
export(setAPImode)
export(setPlaylist)
export(setSolverPath)
export(storage_values_default)
export(updateAdequacySettings)
export(updateGeneralSettings)
export(updateInputSettings)
Expand All @@ -79,6 +86,7 @@ export(writeHydroValues)
export(writeIni)
export(writeIniAPI)
export(writeIniFile)
export(writeIniHydro)
export(writeInputTS)
export(writeMiscGen)
export(writeOutputValues)
Expand All @@ -101,6 +109,7 @@ importFrom(antaresRead,readClusterDesc)
importFrom(antaresRead,readIni)
importFrom(antaresRead,readIniAPI)
importFrom(antaresRead,readIniFile)
importFrom(antaresRead,readInputTS)
importFrom(antaresRead,readLayout)
importFrom(antaresRead,setSimulationPath)
importFrom(antaresRead,setSimulationPathAPI)
Expand Down
51 changes: 46 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
# antaresRead 0.7.0

# antaresEditObject 0.5.2

### Breaking changes (Antares v8.6) :
### Breaking changes (Antares v8.7, cf. Antares v8.7 changelog) :

* Existing function `createBindingConstraint()` / `createBindingConstraintBulk()` has new arguments `group`
* Existing function `editBindingConstraint()` has new arguments `group`
* Integration of the scenario of the coupling constraints of second member (cf. Antares v8.6 changelog)
* Integration of the scenario of the coupling constraints of second member


# antaresEditObject 0.6.0

### Breaking changes (Antares v8.6, cf. Antares v8.6 changelog) :

* `createStudy()` integrate "st-storage".
* `createArea()` integrate "st-storage".
* `removeArea()` integrate "st-storage".
* `writeInputTS()` integrate "mingen" data and dependency between "mod.txt" and "mingen.txt" data.
* `createCluster()` / `editCluster()` have new parameter `list_pollutants` for list of pollutants.


NEW FEATURES (Antares v8.6) :

* New function `activateST()` Activate "st-storage" in an Antares study.
* New functions `createClusterST()`, `editClusterST()`, `removeClusterST()` ("st-storage" family of functions for a study in "input" mode)
* Add control of data consistency between `mingen.txt` and `mod.txt` based on values in `hydro.ini` file
* Add control of data consistency between `mingen.txt` and `maxpower.txt` based on values in `hydro.ini` file
* Add and edit the property `enable-first-step` in `adequacy patch` section in `settings/generaldata.ini`

NEW FEATURES :


* Add `deduplicateScenarioBuilder()` function to keep the last value if a key is duplicated in `settings/scenariobuilder.dat`
* Add `writeIniHydro()` function to make easier the edition of the `input/hydro/hydro.ini` file
* Call `writeIniHydro()` in `createArea()` and `removeArea()`
* Enable edition of hydro levels in `settings/scenariobuilder.dat` by using `scenarioBuilder()` and `updateScenarioBuilder()`
* Add deduplicateScenarioBuilder() function to keep the last value if a key is duplicated in settings/scenariobuilder.dat
* Add writeIniHydro() function to make easier the edition of the input/hydro/hydro.ini file
* Call writeIniHydro() in createArea() and removeArea()
* removeArea() removes only expected files in links directory


### Breaking changes
* `deleteStudy()` no longer requires user confirmation

* `deleteStudy()` no longer requires user confirmation
* `api_command_execute()` displays an error message and causes the program to stop following an http error code. The error message is completed with the API error description
* `getPlaylist()` is compatible with the new format returned by `readIniAPI()`
* `removeClusterRES()` in API mode
* `removeLink()` delete properly data for an Antares version >= 820
* `rollback_to_previous_data()` enable to rollback if original value is NULL

BUGFIXES :

* `api_command_execute()` add timer to request api
* `writeInputTS()` works with argument `type = "tsLink"`
* `createLink()` and `editLink()` write the appropriate time series in _direct.txt and _indirect.txt files even if the areas `from` and `to` given as arguments are not sorted

### DOC :
* A new article presenting v8.6 features is available on the package's online documentation.

# antaresEditObject 0.5.1

Expand Down
14 changes: 13 additions & 1 deletion R/API-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ api_command_execute <- function(command, opts, text_alert = "{msg_api}") {
if (!is_quiet())
cli::cli_alert_danger(text_alert)
api_delete(opts, paste0(opts$study_id, "/commands/", result_log$id))
stop(paste0("\n", msg_api),
call. = FALSE)
if (!is_quiet())
cli::cli_alert_warning("Command has been deleted")
}
Expand Down Expand Up @@ -248,5 +250,15 @@ api_get_variants <- function(id, opts) {
)
}


# standardization of character strings for the API
# (e.g. cluster names, links, etc.)
transform_name_to_id <- function(name, lower = TRUE, id_dash = FALSE) {
valid_id <- gsub("[^a-zA-Z0-9_(),& -]+", " ", name)
valid_id <- trimws(valid_id)
if(lower)
valid_id <- tolower(valid_id)
if(id_dash)
valid_id <- gsub("-", "_", valid_id)
return(valid_id)
}

76 changes: 76 additions & 0 deletions R/ST.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@


# st-storage utilities functions -------------------------------------------------

#' @title Activate st-storage in an Antares study
#'
#' @param quietly Display or not a message to the user if success.
#'
#' @param opts
#' List of simulation parameters returned by the function
#' \code{antaresRead::setSimulationPath}
#'
#' @return An updated list containing various information about the simulation.
#' @export
#'
#' @examples
#' \dontrun{
#'
#' library(antaresEditObject)
#' tmp <- tempfile()
#' createStudy(path = tmp)
#' opts <- antaresRead::setSimulationPath(tmp)
#' activateST()
#'
#' # then you can use createClusterST()...
#'
#' }
activateST <- function(opts = antaresRead::simOptions(), quietly = !interactive()) {
assertthat::assert_that(inherits(opts, "simOptions"))
initialize_ST(opts)
if (!isTRUE(quietly))
cat("\u2713", "Short Term Storages Sources activated\n")
invisible(opts)
}


# If the study does not have an st-storage repository, it creates it. Useful for existant study with version < 8.6.0

initialize_ST <- function(opts) {
if (is_api_study(opts)) {
# no need in API mode
return(invisible(TRUE))
}
inputPath <- opts$inputPath
st_dir <- file.path(inputPath, "st-storage")
dir.create(st_dir, showWarnings = FALSE)
dir.create(file.path(st_dir, "clusters"), showWarnings = FALSE)
areas <- antaresRead::getAreas(opts = opts)
for (area in areas) {
dir.create(file.path(inputPath, "st-storage", "clusters", tolower(area)), showWarnings = FALSE)
path_ini <- file.path(inputPath, "st-storage", "clusters", tolower(area), "list.ini")
if (!file.exists(path_ini))
writeLines(character(0), con = path_ini)
}
dir.create(file.path(st_dir, "series"), showWarnings = FALSE)
return(invisible(TRUE))
}


check_active_ST <- function(opts, check_dir = FALSE) {
if (opts$antaresVersion < 860)
stop("Short Term Storage Sources is only available if using Antares >= 8.6.0", call. = FALSE)
if (is_api_study(opts))
check_dir <- FALSE
if (isTRUE(check_dir)) {
inputPath <- opts$inputPath
st_dir <- file.path(inputPath, "st-storage")
if (!dir.exists(st_dir)) {
stop(
"There is no 'st-storage' directory in the study.",
call. = FALSE
)
}
}
return(invisible(TRUE))
}
Loading

0 comments on commit 5e1e19e

Please sign in to comment.