Skip to content

Commit

Permalink
Merge branch 'master' into ANT1070/bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmek7 authored Feb 27, 2024
2 parents 93af90b + cee08fb commit a6bc136
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ BugReports: https://github.com/rte-antares-rpackage/antaresEditObject/issues
Encoding: UTF-8
RoxygenNote: 7.2.2
Roxygen: list(markdown = TRUE)
Depends: antaresRead (>= 2.4.2)
Depends:
antaresRead (>= 2.4.2)
Imports:
assertthat,
cli,
Expand All @@ -51,3 +52,4 @@ Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr

4 changes: 1 addition & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ BUGFIXES :
* Fix `getPlaylist()` works in API and local mode with weights.
* Fix `createDSR()` in API mode : daily binding constraint takes 366 rows.
* Fix `createCluster()` parameter `list_pollutants` stop for Antares Version < 860.



* `getJobs()` no longer returns duplicates and displays the two new columns `owner_id` and `owner_name`.

# antaresEditObject 0.6.1

Expand Down
35 changes: 28 additions & 7 deletions R/API.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,34 @@ getJobs <- function(job_id = NULL, opts = antaresRead::simOptions()) {
assertthat::assert_that(inherits(opts, "simOptions"))
if (!is_api_study(opts))
stop("getJobs can only be used with Antares API.", call. = FALSE)
if (is.null(job_id)) {
jobs <- api_get(opts = opts, "launcher/jobs", default_endpoint = "v1")
suppressWarnings(data.table::rbindlist(jobs, fill = TRUE))
} else {
jobs <- api_get(opts = opts, paste0("launcher/jobs/", job_id), default_endpoint = "v1")
data.table::as.data.table(jobs)
}
if (is.null(job_id))
.getjobs(opts = opts)
else
.getjobs(opts = opts,
id_job = job_id)
}

.getjobs <- function(opts, id_job=NULL){
# make endpoint with id or not
if(is.null(id_job))
custom_endpoint <- file.path("launcher", "jobs")
else
custom_endpoint <- file.path("launcher", "jobs", id_job)
# api call with text content
jobs <- api_get(opts = opts,
endpoint = custom_endpoint,
default_endpoint = "v1",
parse_result = "text")
# reformat
if(!is.null(id_job))
jobs <- paste0("[",jobs,"]")
# as DT to reformat names
jobs <- as.data.table(
jsonlite::fromJSON(jobs))
names(jobs) <- sub(pattern = "\\.",
replacement = "_",
x = names(jobs))
return(jobs)
}


Expand Down
2 changes: 1 addition & 1 deletion R/createClusterST.R
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ createClusterST <- function(area,
}
}

#' Output pollutants list for thermal clusters
#' Short Term Storage Property List
#'
#'
#' @return a named list
Expand Down
25 changes: 24 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,28 @@ update_opts <- function(opts) {
}
}


# reorder a list into a simple named list
# target a named list within the list, then move items up one step in the main list
rename_floor_list <- function(target_name, list_to_reforge){
assertthat::assert_that(inherits(target_name, "character"))
assertthat::assert_that(inherits(list_to_reforge, "list"))

if(target_name %in% names(list_to_reforge)){
if(class(list_to_reforge[[target_name]]) %in% "list"){
target_elements <- list_to_reforge[[target_name]]
names(target_elements) <- paste(target_name, names(target_elements), sep = "_")

# overwrite list
list_to_reforge[[target_name]] <- NULL
list_to_reforge <- append(list_to_reforge, target_elements)

return(list_to_reforge)
}else{
list_to_reforge[[target_name]] <- NULL
return(list_to_reforge)
}

}else
return(list_to_reforge)
}

4 changes: 2 additions & 2 deletions man/storage_values_default.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a6bc136

Please sign in to comment.