Skip to content

Commit

Permalink
fix bug: in batch mode, only test on batch input node for single file…
Browse files Browse the repository at this point in the history
…, to allow single file as input in batch mode and not go converting other files
  • Loading branch information
tengfei committed Dec 5, 2016
1 parent 4ba64e1 commit b6a91f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
16 changes: 9 additions & 7 deletions R/class-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ App <- setRefClass("App", contains = "Item",
message("done")
},

input_check = function(input, batch = FALSE) {
input_check = function(input, batch = NULL) {

message("check id match")
in_type = input_type()
Expand All @@ -164,20 +164,22 @@ App <- setRefClass("App", contains = "Item",
for (i in id.fl) {
# input should be File
if(is(input[[i]], "Files")){
if(batch){
message("Converting single Files as a list for batch mode: ", names(input[[i]]))

if(!is.null(batch) && cus_id[i] == batch$batch_input){
## only operate on the batch input node, otherwise will cause error
message("Converting single Files as a list for batch mode: ", cus_id[i])
input[[i]] = list(input[[i]])
}
}
if (is(input[[i]], "FilesList")) {
if (length(input[[i]]) == 1) {
if(!batch){
if(is.null(batch)){
message("Converting to single Files type: ", names(input[[i]]))
input[[i]] = input[[i]][[1]]
}

} else {
if(!batch){
if(is.null(batch)){
stop(in_id[i], " only accept single File")
}

Expand All @@ -186,13 +188,13 @@ App <- setRefClass("App", contains = "Item",

if (is.list(input[[i]])) {
if (length(input[[i]]) == 1 && is(input[[i]][[1]], "Files")) {
if(!batch){
if(is.null(batch)){
message("Converting to single Files type: ", names(input[[i]]))
input[[i]] = input[[i]][[1]]
}
}
if (length(input[[i]]) > 1) {
if(!batch){
if(is.null(batch)){
stop(in_id[i], " only accept single File")
}
}
Expand Down
7 changes: 1 addition & 6 deletions R/class-project.R
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,7 @@ Project <- setRefClass("Project", contains = "Item",
message("API: getting app input information ...")
apps = auth$app(id = app)
message("checking ...")
if(is.null(batch)){
inputs = apps$input_check(inputs)
}else{
inputs = apps$input_check(inputs, TRUE)
}

inputs = apps$input_check(inputs, batch)
}
message("Task drafting ...")

Expand Down

0 comments on commit b6a91f2

Please sign in to comment.