-
Notifications
You must be signed in to change notification settings - Fork 1
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
Adds new end-points and improves to existing ones #5
Conversation
name: R-CMD-check | ||
on: [push, pull_request] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check all the things sounds good to me!
R/extract_genotypic_data.R
Outdated
#' extract_genotypic_data(baseurl= "https://cloudos.lifebit.ai", | ||
#' auth = "Bearer ***token***", | ||
#' teamid = "***teamid***") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make everythang snakecase eg
baseurl
-> base_url
teamid
-> team_id
in all occurrences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
R/list_cohorts.R
Outdated
@@ -29,15 +29,15 @@ list_cohorts <- function(baseurl, | |||
query = list("teamId" = teamid, | |||
"pageNumber" = page_number, | |||
"pageSize" = page_size)) | |||
res <- httr::content(r) | |||
if(length(res) == 0){ | |||
if (!r$status_code == 200) { | |||
message("No cohorts found. Or not able to connect with server.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here why message
and not error
to exit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. There is stop()
for error message and exit. I'll include that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor request for snake_case 2 vars:
teamid
baseurl
@cgpu That's the point (strange thing) it didn't have Then I added this -
|
check/cloudos.Rcheck/cloudos-Ex.Rout
Outdated
@@ -0,0 +1,147 @@ | |||
|
|||
R version 4.0.2 (2020-06-22) -- "Taking Off Again" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this files under version control @sk-sahu ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgpu No we don't.
This check
directory created while local check and build. I need to delete this. Thank you for pointing out :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this to .gitignore
encode = "json" | ||
) | ||
if (!r$status_code == 200) { | ||
stop("Something went wrong. Not able to create a cohort") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, I see message
replaced for stop
R/create_cohort.R
Outdated
) | ||
if (!r$status_code == 200) { | ||
stop("Something went wrong. Not able to create a cohort") | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (r$status_code == 200)
on this, I generally think if
is more explicit and helps with matching assumptions with tests.
This is also Jenny Bryan approved, see here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a legit point 👍 This will make the code even more readable as well. Let me do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sk-sahu thanks for being on the Jenny Bryan side of life 😄 !
One note, after checking the code:
Lines 36 to 43 in c7d081e
) | |
if (!r$status_code == 200) { | |
stop("Something went wrong. Not able to create a cohort") | |
} | |
# parse the content | |
message("Cohort named ", cohort_name, " created successfully. Bellow are the details") | |
res <- httr::content(r) | |
# into a dataframe |
Once you remove else, the idea is to replace it with the explicit if statement
, not eliminate it altogether.
This is fine for now, I will open an issue and link it to your currently open PR to implement this in all functions.
So in principle as an example the following snippet, when if
-ified would lokk like this:
Lines 37 to 46 in 1e1ec00
if (!r$status_code == 200) { | |
stop("Something went wrong. Not able to create a cohort") | |
}else{ | |
message("Cohort named ", cohort_name, " created successfully. Bellow are the details") | |
res <- httr::content(r) | |
# into a dataframe | |
res_df <- do.call(rbind, res) | |
colnames(res_df) <- "details" | |
return(res_df) | |
} |
if (!r$status_code == 200) {
stop("Something went wrong. Not able to create a cohort")
}
if (r$status_code == 200){
message("Cohort named ", cohort_name, " created successfully. Bellow are the details")
res <- httr::content(r)
# into a dataframe
res_df <- do.call(rbind, res)
colnames(res_df) <- "details"
return(res_df)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! 👍
Only a minor note on (not) using else
, see here #r473191206, but approving.
* adds new end-points and impv to previous ones * adds pkgdown html links * linting correction * R-cmd-check in every push and PR * minor correction to title * updates doc * chnages to snakecase for team_id and base_url * error message() -> stop() which will exit with message. * minor corrections * local build and check * --no-build-vignettes added for R-CMD-Check as it require api-key to build * Attempt to fix tests (respect --no-build) * Attempt to address #5 (comment) * syntax fix in YAML * vignette oved to README * cleaning * no else based on @cgpu 's review Co-authored-by: cgpu <38183826+cgpu@users.noreply.github.com>
New API end-points
Also improvements to existing ones with status check
200
for API calls and error message.