-
Notifications
You must be signed in to change notification settings - Fork 5
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
Design vignette #69
Design vignette #69
Conversation
vignettes/design_principle.Rmd
Outdated
|
||
1. The `read_from_api()` function takes only two arguments to import data from an API: an object of class **credential** and an object of class **api**. | ||
|
||
The **credential** object is a list-like object that stores the information required to access the API. Its main attributes are: |
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.
Did you consider the benefits & downsides of list vs named vector?
Or should it be an actual class?
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.
Is there value of pulling the credential object outside of the read_from_()
call?
The workflow would be:
authenticate(name, credentials)
read()
read()
read()
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 opt for the class option. And yes, we can add more auxiliary functions for authentication--as you mentioned--, verification, and for checking the accessibility to API/database. Moreover, such steps are done internally when to you call the read_from_* functions, but we can modularize them as separate functions.
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.
The idea of what I'm proposing is that users would not have to repeat the same arguments over and over if they are trying to get different pieces of data from the same source with successive read_from_()
calls.
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.
We had this discussion internally here and we decided to make the 2 implementations and compare them.
My only reserves about this that, in read_from_*
, we will have a long list of arguments (including both username, password, url, database specific arguments and api-specific arguments).
The arguments were made in previous PRs that the list of arguments are to long and we need to act on this.
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.
Another option will consist in making the credential class such that it returns a connexion object as described below:
- It will have an
authenticate()
method that returns a connexion object. This method will be called internally by the class constructor. - It's print() method will display the user's credential details and a string to tell whether the connexion was successfully established or not.
That way, the credential object (can be called authentication object!!!) is created once and will be used in any call of the read_from_*
function, until the connection expires.
Co-authored-by: Hugo Gruson <Bisaloo@users.noreply.github.com>
add {xml2} as dependency
* add the examples to the functions documentations * build documentation for show_tables() and visualise_table() * Update CITATION.cff * update function's examples * fix linters * add new lines * remove unnecessary nolint * use explicit URL * update show_example_file documentation * align argument in function documentation * Automatic readme update * add examples and remove dontrun{} when not needed in DHIS2 related functions * add examples and remove dontrun{} when not needed in Fingertips related functions * add examples and remove dontrun{} when not needed in REDCap related functions * add examples and remove dontrun{} when not needed in server related functions * add examples and remove dontrun{} when not needed in readepi related functions * run devtools::document() * remove README.html * rearrange arguments in read_from_readcap example * complete test example for dhis2_get_attributes_from_user * Update _pkgdown.yml to account for read_from_fingertips * update on dhis2_get_attributes_from_user() * Update CITATION.cff * remove examples in internal functions documentation - for functions without dontrun{} * Update R/read_from_fingertips.R remove @nord in the function documentation Co-authored-by: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> --------- Co-authored-by: Karim-Mane <karimanee@outlook.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Karim MANE <84502011+Karim-Mane@users.noreply.github.com> Co-authored-by: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com>
* replace {httr} by {httr2} * Update CITATION.cff * fix linter and run devtools::document() * update test file for check_dhis2_attributes-helpers.R * use {httr2} to submit the query parameters * fix linters * allow for the query parameters to be specified as a list by the user * update the test files to account for the fact that the query parameters are provided as a list by the user * fix linters * use a different areaTypeId in the examples and tests * update the mock files * update test for readepi() * update test-readepi.R * fix issue with reading from DHIS2 * Automatic readme update * comment out the mock testing in Fingertips test files * use "%>%" instead of "|>" for harmonisation. * update the URL to the play DHIS2 instance --------- Co-authored-by: GitHub Action <action@github.com>
1619a6d
to
8a4b82d
Compare
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.
Different versions of the same figure are saved under different names. Please review and keep only the latest version.
The `read()` functions return a `list` object containing one or more `data frames`. Each `data frame` corresponds to the data from a specified source. | ||
The `get_metadata()` function returns a data dictionary containing information about the data structure. | ||
The `authenticate()` function returns a connection object that is used in the query 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.
Am I misunderstanding something or does this not match what the diagram is describing (read_from_api()
, read_from_server()
, authenticate()
)?
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.
There are few changes in the design diagram. We now want to split read_from_api()
into small functions that are specific to a given HIS. This, we think, will make it easy to perform targetted updates on the way data is imported from a HIS, when there is any changes from that API.
I have updated the design diagram in commit 41f41e8
.
@@ -34,8 +36,10 @@ Imports: | |||
odbc, | |||
pool, | |||
REDCapR, | |||
RMySQL | |||
RMySQL, | |||
xml2 |
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.
Was this dependency added by mistake?
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.
No - {RMySQL} is the {DBI} driver used when connecting to a MySQL database.
{xml2} is dependency for importing data from Fingertips or DHIS2. It was required for some examples to pass the check.
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.
Yes, but it's unrelated to this PR. Maybe a conflict fix that went wrong? Anyways, as long as you don't have conflicts, let's go with it.
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 is correct. There were some conflicts. I realised that some examples needed the {xml2} package when running devtools::check()
.
The {RMySQL} were (or should have been) there already as the example related to fetching data from RDBMS is using a MySQL database.
No description provided.