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

fix api_command_execute() #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
(cf. Antares v9 changelog)

NEW FEATURES (Antares v9.0) :

* `createStudy()` takes into account the new format of Antares studies (e.g. 9.0, 9.15 instead of 900, 915)

BUGFIXES :

* *[private function]* `api_command_execute()` manage snapshot generation of a variant study with a tempo to wait the end of current task (prevents the order from being ignored).



# antaresEditObject 0.7.1
Expand Down
33 changes: 31 additions & 2 deletions R/API-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,38 @@ api_command_execute <- function(command, opts, text_alert = "{msg_api}") {
msg_api=" " # HACK /!\
cli::cli_alert_success(paste0(text_alert, "success"))

# one more "PUT" "/generate" for variant only
# Snaphost /generate" for variant only
if (is_variant(opts)) {
api_put(opts, paste0(opts$study_id, "/generate"))
variant_res <- api_put(opts, paste0(opts$study_id, "/generate"))

# retrieve task information
result_task_id <- api_get(opts = opts,
endpoint = file.path("v1", "tasks", variant_res),
default_endpoint = NULL)

while(is.null(result_task_id$result)) {
message("...Generate Snapshot task in progress...")
if(is.null(opts$sleep))
Sys.sleep(0.5)
else
Sys.sleep(opts$sleep)
result_task_id <- api_get(opts = opts,
endpoint = file.path("v1", "tasks", variant_res),
default_endpoint = NULL)
}

# test if task is terminated with success
result_task_id_log <- result_task_id$result

status <- isTRUE(result_task_id_log$success)

details_command <- jsonlite::fromJSON(result_task_id_log$return_value,
simplifyVector = FALSE)

if(status)
message(paste0("Snapshot generated for : ", details_command$details[[1]]$name))
else
stop(paste0("Not success for task : ", details_command$details[[1]]$name))
return(invisible(TRUE))
}
}
Expand Down
Loading