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

Adds new end-points and improves to existing ones #5

Merged
merged 17 commits into from
Aug 19, 2020
Merged

Adds new end-points and improves to existing ones #5

merged 17 commits into from
Aug 19, 2020

Conversation

sk-sahu
Copy link
Contributor

@sk-sahu sk-sahu commented Aug 11, 2020

New API end-points

  • Create a Cohort
  • Extract Genotypic Data

Also improvements to existing ones with status check 200 for API calls and error message.

@sk-sahu sk-sahu requested a review from cgpu August 11, 2020 18:32
name: R-CMD-check
on: [push, pull_request]
Copy link
Contributor

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!

Comment on lines 17 to 19
#' extract_genotypic_data(baseurl= "https://cloudos.lifebit.ai",
#' auth = "Bearer ***token***",
#' teamid = "***teamid***")
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

R/extract_participants.R Outdated Show resolved Hide resolved
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.")
Copy link
Contributor

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?

Copy link
Contributor Author

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.

docs/404.html Show resolved Hide resolved
@github-pages github-pages bot temporarily deployed to github-pages August 13, 2020 10:13 Inactive
Copy link
Contributor

@cgpu cgpu left a 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

@github-pages github-pages bot temporarily deployed to github-pages August 13, 2020 11:55 Inactive
@github-pages github-pages bot temporarily deployed to github-pages August 13, 2020 12:04 Inactive
@sk-sahu
Copy link
Contributor Author

sk-sahu commented Aug 13, 2020

@cgpu I have tried to not build the vignettes --no-build-vignettes for R-CMD-Check as it require api-key. But this doesn't seems working. Any idea?

This is strange. Last time it worked in this - 168682f commit. Not sure how.

@cgpu
Copy link
Contributor

cgpu commented Aug 18, 2020

This is strange. Last time it worked in this - 168682f commit. Not sure how.

@sk-sahu i don't see the line with the --no-build-vignettes in 168682f.

Can you point the relevant line by checking in Browse files?

@sk-sahu
Copy link
Contributor Author

sk-sahu commented Aug 18, 2020

@sk-sahu i don't see the line with the --no-build-vignettes in 168682f.
Can you point the relevant line by checking in Browse files?

@cgpu That's the point (strange thing) it didn't have --no-build-vignettes in this 168682f commit. But somehow it didn't render. But from that point onward it started this error in next commit.

Then I added this -

run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--no-build-vignettes"), error_on = "warning", check_dir = "check")

@github-pages github-pages bot temporarily deployed to github-pages August 18, 2020 14:44 Inactive
@github-pages github-pages bot temporarily deployed to github-pages August 18, 2020 14:54 Inactive
@github-pages github-pages bot temporarily deployed to github-pages August 18, 2020 18:44 Inactive
@github-pages github-pages bot temporarily deployed to github-pages August 19, 2020 13:31 Inactive
@sk-sahu sk-sahu requested a review from cgpu August 19, 2020 13:35
@@ -0,0 +1,147 @@

R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copy link
Contributor

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 ?

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

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

@github-pages github-pages bot temporarily deployed to github-pages August 19, 2020 13:57 Inactive
@sk-sahu sk-sahu requested a review from cgpu August 19, 2020 14:14
encode = "json"
)
if (!r$status_code == 200) {
stop("Something went wrong. Not able to create a cohort")
Copy link
Contributor

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

)
if (!r$status_code == 200) {
stop("Something went wrong. Not able to create a cohort")
}else{
Copy link
Contributor

@cgpu cgpu Aug 19, 2020

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

Copy link
Contributor Author

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.

Copy link
Contributor

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:

)
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:

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) 
 } 

@cgpu cgpu self-requested a review August 19, 2020 17:12
Copy link
Contributor

@cgpu cgpu left a 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.

@sk-sahu sk-sahu merged commit c7d081e into devel Aug 19, 2020
@sk-sahu sk-sahu deleted the new-api branch August 19, 2020 18:34
sk-sahu added a commit that referenced this pull request Feb 19, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants