diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eba8c65..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -cache: packages diff --git a/DESCRIPTION b/DESCRIPTION index 24f525e..e1b31b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,7 +25,7 @@ Imports: stats, utils, XML -RoxygenNote: 7.1.2 +RoxygenNote: 7.3.1 Suggests: testthat (>= 2.1.0), covr, diff --git a/R/ApproveAssignment.R b/R/ApproveAssignment.R index bab591b..21c00fb 100644 --- a/R/ApproveAssignment.R +++ b/R/ApproveAssignment.R @@ -118,7 +118,7 @@ function (assignments, ) # Check if failure - if (class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { valid <- TRUE if (verbose) { message(i, ": Assignment (", assignments[i], ") Approved") diff --git a/R/AssignQualification.R b/R/AssignQualification.R index b32bb31..689f3b2 100644 --- a/R/AssignQualification.R +++ b/R/AssignQualification.R @@ -142,7 +142,7 @@ AssignQualification <- ), silent = !verbose) # Validity check - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { return(data.frame(valid = FALSE)) } else response$valid = TRUE diff --git a/R/BlockWorker.R b/R/BlockWorker.R index db78408..3451a32 100644 --- a/R/BlockWorker.R +++ b/R/BlockWorker.R @@ -88,7 +88,7 @@ BlockWorker <- ), silent = !verbose) # Validity check - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { valid = FALSE } else { diff --git a/R/ChangeHITType.R b/R/ChangeHITType.R index a20c944..db2ff70 100644 --- a/R/ChangeHITType.R +++ b/R/ChangeHITType.R @@ -162,7 +162,7 @@ ChangeHITType <- auto.approval.delay = auto.approval.delay, qual.req = qual.req), silent = !verbose) - if (class(register) == "try-error") { + if (inherits(register, "try-error")) { stop("Could not RegisterHITType(), check parameters") } else { new.hit.type <- register$HITTypeId @@ -204,10 +204,10 @@ ChangeHITType <- HITTypeId = new.hit.type ), silent = !verbose) - if (class(response) != "try-error") { # Valid - valid <- TRUE - } else { + if (inherits(response, "try-error")) { valid <- FALSE + } else { + valid <- TRUE } if (is.null(old.hit.type)) { diff --git a/R/ContactWorker.R b/R/ContactWorker.R index d0fe21f..83e87b9 100644 --- a/R/ContactWorker.R +++ b/R/ContactWorker.R @@ -146,7 +146,7 @@ ContactWorker <- WorkerIds = as.list(workerbatch[[i]]), MessageText = msgs ), silent = !verbose) - if (class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { Notifications$Valid[Notifications$WorkerId %in% workerbatch[[i]]] <- TRUE if (verbose) { message(i, ": Workers ", workerbatch[[i]][1], " to ", utils::tail(workerbatch[[i]],1), " Notified") @@ -226,7 +226,7 @@ ContactWorker <- response$NotifyWorkersFailureStatuses[[1]]$NotifyWorkersFailureMessage) } } - if (class(response) != "try-error" & valid == TRUE) { + if ((!(inherits(response, "try-error"))) & valid == TRUE) { if (verbose) { message(i, ": Worker (", workers[i], ") Notified") } diff --git a/R/CreateHIT.R b/R/CreateHIT.R index 4d49917..19e2902 100644 --- a/R/CreateHIT.R +++ b/R/CreateHIT.R @@ -300,7 +300,7 @@ CreateHIT <- ) # Validity check - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { warning("Invalid Request") warning(response) } else { diff --git a/R/CreateQualificationType.R b/R/CreateQualificationType.R index 8fb9a25..68199d3 100644 --- a/R/CreateQualificationType.R +++ b/R/CreateQualificationType.R @@ -169,7 +169,7 @@ CreateQualificationType <- # Update Qualification with any other parameters, # but only if we've just created it - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Unable to create qualification") } else { diff --git a/R/DisableHIT.R b/R/DisableHIT.R index 12f110a..5743c3b 100644 --- a/R/DisableHIT.R +++ b/R/DisableHIT.R @@ -162,7 +162,7 @@ DisableHIT <- ), silent = !verbose) operation <- "Disable/Expire" - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { warning(i, ": Invalid Request for HIT ", hit) valid <- FALSE } else { @@ -184,7 +184,7 @@ DisableHIT <- if(hitdetail$HITs$HITStatus %in% c("Reviewing", "Reviewable")){ response <- try(pyMTurkR$Client$delete_hit(HITId = hit), silent = !verbose) - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { warning(i, ": Unable to Delete HIT ", hit) valid <- FALSE } else { diff --git a/R/DisposeQualificationType.R b/R/DisposeQualificationType.R index 5b60d23..d832cd7 100644 --- a/R/DisposeQualificationType.R +++ b/R/DisposeQualificationType.R @@ -60,7 +60,7 @@ DisposeQualificationType <- QualificationTypeId = qual ), silent = !verbose) - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { warning("Invalid request\n Does this qualification exist?") return(emptydf(0, 2, c("QualificationTypeId", "Valid"))) } else { diff --git a/R/ExtendHIT.R b/R/ExtendHIT.R index 8cc694a..542d90b 100644 --- a/R/ExtendHIT.R +++ b/R/ExtendHIT.R @@ -160,7 +160,7 @@ ExtendHIT <- do.call('fun', args) ) - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { valid <- FALSE warning("Invalid Request") } else { @@ -176,7 +176,7 @@ ExtendHIT <- HITId = hit, ExpireAt = as.character(as.integer(expirations[i]) + as.integer(add.seconds)) ), silent = !verbose) - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { warning("Invalid Request") valid <- FALSE } else { diff --git a/R/GetAssignment.R b/R/GetAssignment.R index 0d3b233..00bc24d 100644 --- a/R/GetAssignment.R +++ b/R/GetAssignment.R @@ -110,7 +110,7 @@ GetAssignment <- for (i in 1:length(assignment)) { response <- try(pyMTurkR$Client$get_assignment(AssignmentId = assignment[i]), silent = !verbose) QualificationRequirements <- list() - if (class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { tmp <- ToDataFrameAssignment(response$Assignment) a <- tmp$assignments ans <- tmp$answers @@ -185,7 +185,7 @@ GetAssignment <- } # Validity check response - if(class(response) == "try-error" & persist.on.error) { + if ((inherits(response, "try-error")) & persist.on.error) { # If the response was an error, then we should try again # but stop after 5 attempts diff --git a/R/GetBlockedWorkers.R b/R/GetBlockedWorkers.R index f2f9da8..fa4d0b7 100644 --- a/R/GetBlockedWorkers.R +++ b/R/GetBlockedWorkers.R @@ -19,7 +19,7 @@ GetBlockedWorkers <- } # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GetBonuses.R b/R/GetBonuses.R index 0de702c..e5f0365 100644 --- a/R/GetBonuses.R +++ b/R/GetBonuses.R @@ -95,7 +95,7 @@ GetBonuses <- } # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GetHIT.R b/R/GetHIT.R index a8720fd..29f042a 100644 --- a/R/GetHIT.R +++ b/R/GetHIT.R @@ -63,7 +63,7 @@ GetHIT <- GetClient() # Boto3 client response <- try(pyMTurkR$Client$get_hit(HITId = hit), silent = !verbose) - if (class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { hitdetails <- list(response$HIT) # Hack for 1 result return.list <- list(HITs = ToDataFrameHITs(hitdetails), QualificationRequirements = ToDataFrameQualificationRequirements(hitdetails)) diff --git a/R/GetHITsForQualificationType.R b/R/GetHITsForQualificationType.R index a5f5787..d0ac51b 100644 --- a/R/GetHITsForQualificationType.R +++ b/R/GetHITsForQualificationType.R @@ -55,7 +55,7 @@ GetHITsForQualificationType <- } # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GetQualificationRequests.R b/R/GetQualificationRequests.R index da641cd..bcf8a83 100644 --- a/R/GetQualificationRequests.R +++ b/R/GetQualificationRequests.R @@ -87,7 +87,7 @@ GetQualificationRequests <- } # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GetQualificationScore.R b/R/GetQualificationScore.R index d16142a..9fb90b7 100644 --- a/R/GetQualificationScore.R +++ b/R/GetQualificationScore.R @@ -81,7 +81,7 @@ GetQualificationScore <- WorkerId = workers[i]), silent = !verbose) # Validity check response - if(class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { Qualifications[i,] <- ToDataFrameQualifications(response$Qualification) Qualifications[i,]$Valid <- TRUE if (verbose) { diff --git a/R/GetQualificationType.R b/R/GetQualificationType.R index 55bbdd6..c61636f 100644 --- a/R/GetQualificationType.R +++ b/R/GetQualificationType.R @@ -48,7 +48,7 @@ GetQualificationType <- response <- try(pyMTurkR$Client$get_qualification_type(QualificationTypeId = qual), silent = !verbose) # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { Qualifications <- emptydf(nrow=0, ncol=13, c("QualificationTypeId", "CreationTime", "Name", "Description", "Keywords", "QualificationTypeStatus", "AutoGranted", "AutoGrantedValue", "IsRequestable", "RetryDelayInSeconds", "TestDurationInSeconds", diff --git a/R/GetQualifications.R b/R/GetQualifications.R index b01087f..2f5eb5a 100644 --- a/R/GetQualifications.R +++ b/R/GetQualifications.R @@ -87,7 +87,7 @@ GetQualifications <- ) # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GetReviewResultsForHIT.R b/R/GetReviewResultsForHIT.R index 970e2fc..99b23ad 100644 --- a/R/GetReviewResultsForHIT.R +++ b/R/GetReviewResultsForHIT.R @@ -84,7 +84,7 @@ GetReviewResultsForHIT <- ) # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GetReviewableHITs.R b/R/GetReviewableHITs.R index 0b31aaf..4d3b174 100644 --- a/R/GetReviewableHITs.R +++ b/R/GetReviewableHITs.R @@ -74,7 +74,7 @@ GetReviewableHITs <- ) # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed") } diff --git a/R/GrantBonus.R b/R/GrantBonus.R index 57d7840..f2eadf7 100644 --- a/R/GrantBonus.R +++ b/R/GrantBonus.R @@ -152,10 +152,10 @@ GrantBonus <- ) # Check if failure - if (class(response) != "try-error") { - valid <- TRUE - } else { + if (inherits(response, "try-error")) { valid <- FALSE + } else { + valid <- TRUE } Bonuses[i, ] <- c(workers[i], assignments[i], amounts[i], reasons[i], valid) @@ -167,7 +167,7 @@ GrantBonus <- response[1]) } } - if (class(response) != "try-error" & valid == TRUE) { + if ((!(inherits(response, "try-error"))) & valid == TRUE) { if (verbose) { message(i, ": Worker (", workers[i], ") Granted Bonus of ", amounts[i], " for Assignment ", assignments[i]) } diff --git a/R/GrantQualification.R b/R/GrantQualification.R index 7f0af60..6a7f381 100644 --- a/R/GrantQualification.R +++ b/R/GrantQualification.R @@ -101,16 +101,16 @@ GrantQualification <- # Check if failure - if (class(response) != "try-error") { - valid <- TRUE - } else { + if (inherits(response, "try-error")) { valid <- FALSE + } else { + valid <- TRUE } QualificationRequests[i, ] <- c(qual.requests[i], values[i], valid) # Message with results - if (class(response) != "try-error" & valid == TRUE) { + if ((!(inherits(response, "try-error"))) & valid == TRUE) { if (verbose) { message(i, ": Qualification (", qual.requests[i],") Granted") } diff --git a/R/RegisterHITType.R b/R/RegisterHITType.R index 05659de..55450c7 100644 --- a/R/RegisterHITType.R +++ b/R/RegisterHITType.R @@ -136,7 +136,7 @@ RegisterHITType <- do.call('fun', args), silent = !verbose ) - if (class(response) != "try-error") { # Valid + if (!(inherits(response, "try-error"))) { # Valid HITType[1, ] <- c(response$HITTypeId, TRUE) if (verbose) { message("HITType Registered: ", HITType$HITTypeId) diff --git a/R/RejectAssignment.R b/R/RejectAssignment.R index a9edfac..695ed32 100644 --- a/R/RejectAssignment.R +++ b/R/RejectAssignment.R @@ -73,7 +73,7 @@ RejectAssignment <- ), silent = !verbose) # Check if failure - if (class(response) == "try-error") { + if (inherits(response, "try-error")) { valid <- FALSE if (verbose) { warning(i, ": Invalid request for assignment ",assignments[i]) diff --git a/R/RejectQualification.R b/R/RejectQualification.R index 4c3b862..ac04731 100644 --- a/R/RejectQualification.R +++ b/R/RejectQualification.R @@ -34,7 +34,7 @@ RejectQualification <- } # Check if failure - if (class(response) == "try-error") { + if (inherits(response, "try-error")) { valid <- FALSE if (verbose) { warning(i, ": Invalid Request for QualificationRequestId ", qual.requests[i]) diff --git a/R/RevokeQualification.R b/R/RevokeQualification.R index 2a44ede..baf1c93 100644 --- a/R/RevokeQualification.R +++ b/R/RevokeQualification.R @@ -98,7 +98,7 @@ RevokeQualification <- ) # Check if failure - if (class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { message(i, ": Qualification (", qual, ") for worker ", workers[i], " Revoked") valid <- TRUE } else { diff --git a/R/SearchHITs.R b/R/SearchHITs.R index 56ab79e..b9739a1 100644 --- a/R/SearchHITs.R +++ b/R/SearchHITs.R @@ -54,7 +54,7 @@ function (return.pages = NULL, } # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("SearchHITs request failed!") } diff --git a/R/SearchQualificationTypes.R b/R/SearchQualificationTypes.R index 712e3d5..44c21a8 100644 --- a/R/SearchQualificationTypes.R +++ b/R/SearchQualificationTypes.R @@ -89,7 +89,7 @@ SearchQualificationTypes <- ) # Validity check response - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Request failed!") } diff --git a/R/SendTestEventNotification.R b/R/SendTestEventNotification.R index c0bd1ba..651f771 100644 --- a/R/SendTestEventNotification.R +++ b/R/SendTestEventNotification.R @@ -83,7 +83,7 @@ SendTestEventNotification <- ) # Check if failure - if (class(response) != "try-error") { + if (!(inherits(response, "try-error"))) { valid <- TRUE if (verbose) { message("TestEventNotification ", test.event.type," Sent") diff --git a/R/SetHITAsReviewing.R b/R/SetHITAsReviewing.R index 7082c9c..6dda6f3 100644 --- a/R/SetHITAsReviewing.R +++ b/R/SetHITAsReviewing.R @@ -114,7 +114,7 @@ SetHITAsReviewing <- status <- "Reviewable" } - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { warning(i, ": Invalid Request for HIT ", hit) valid = FALSE } else { diff --git a/R/SetHITTypeNotification.R b/R/SetHITTypeNotification.R index ac1a797..0153852 100644 --- a/R/SetHITTypeNotification.R +++ b/R/SetHITTypeNotification.R @@ -106,7 +106,7 @@ SetHITTypeNotification <- # Call the function with the arguments response <- try(do.call('fun', args), silent = !verbose) - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { valid = FALSE if (verbose) { warning("Invalid Request") diff --git a/R/UnblockWorker.R b/R/UnblockWorker.R index 5e4f83c..5bea43e 100644 --- a/R/UnblockWorker.R +++ b/R/UnblockWorker.R @@ -44,7 +44,7 @@ UnblockWorker <- ) # Validity check - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { valid = FALSE if(verbose){ message(i, ": Worker ", workers[i], " Unblocked") diff --git a/R/UpdateQualificationType.R b/R/UpdateQualificationType.R index 0e411c2..d909a7e 100644 --- a/R/UpdateQualificationType.R +++ b/R/UpdateQualificationType.R @@ -130,7 +130,7 @@ function (qual, # Update Qualification with any other parameters, # but only if we've just created it - if(class(response) == "try-error") { + if (inherits(response, "try-error")) { stop("Unable to update qualification") } else { diff --git a/README.md b/README.md index a997f21..d0843e9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # pyMTurkR: A Client for the MTurk Requester API -[![travis-ci](https://travis-ci.org/cloudyr/pyMTurkR.svg?branch=master)](https://travis-ci.org/cloudyr/pyMTurkR?branch=master) +[![CI](https://github.com/cloudyr/pyMTurkR/actions/workflows/main.yml/badge.svg)](https://github.com/cloudyr/pyMTurkR/actions/workflows/main.yml) [![codecov test coverage](https://codecov.io/gh/cloudyr/pyMTurkR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/cloudyr/pyMTurkR?branch=master) [![CRAN version](https://img.shields.io/cran/v/pyMTurkR)](https://cran.r-project.org/package=pyMTurkR) ![dev version](https://img.shields.io/badge/dev-1.14-blue) diff --git a/tests/testthat/test-CreateHIT.R b/tests/testthat/test-CreateHIT.R index ab1e8c8..1a5e4d8 100644 --- a/tests/testthat/test-CreateHIT.R +++ b/tests/testthat/test-CreateHIT.R @@ -77,16 +77,16 @@ test_that("CreateHIT", { Sys.sleep(15) # Delete HIT - ExpireHIT(hit$HITId, + ExpireHIT(hit["HITId"], verbose = FALSE) - DeleteHIT(hit$HITId, + DeleteHIT(hit["HITId"], skip.delete.prompt = TRUE, verbose = FALSE) # Delete HIT - ExpireHIT(hit2$HITId, + ExpireHIT(hit2["HITId"], verbose = FALSE) - DeleteHIT(hit2$HITId, + DeleteHIT(hit2["HITId"], skip.delete.prompt = TRUE, verbose = FALSE) })