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

Proposal: get rid of assertthat and replace with unified argument checking/adapting framework w/rlang #262

Closed
jmobrien opened this issue Jun 8, 2022 · 4 comments

Comments

@jmobrien
Copy link
Collaborator

jmobrien commented Jun 8, 2022

So, I'm trying to finish adding a couple of the really essential features like filtering (#223), time/date control (#158), and survey activation/deactivation (#215, since that's not much extra work once we have date/times going).

It's all pretty straightforward overall, but I keep running into how complicated our current handling of argument checking is making this. Right now:

  • Argument checks are all done by separate functions made using assertthat, (in assertions.R).
  • Generally, each argument (and even each thing to check for each argument), has its own custom-built assert_* function.
  • (Most) arguments are actually checked in a separate function (in utils.R) that goes through a list populated with arguments.
  • Those checks work okay, but they're still limited, because some (often optional) arguments can be specified in ways that still need further processing in order to match, say, the API protocol.
  • Any further processing of argument content, if needed, happens somewhere else entirely--for instance inside construct_raw_payload.R

asserthat is dead--it's not been updated in 5 years. There are other good options like checkmate, but really as some of the recent updates have shown, rlang::abort() does quite well. Also it seems evident that any further development of this kind of thing from the hadley/tidyverse is coming from there (e.g., r-lib/rlang#1111).

So, maybe continuing with rlang might make sense. But more generally while I'm trying to finish all this I was wondering if people wouldn't mind me reworking things more generally into streamlined approach that handles both cleaning and checking arguments in a unified way. It's probably more efficient for what I'm doing right now and would make everyone's efforts easier going forward. Thoughts? If people don't hate the idea I'll send a draft in shortly, and can adjust the strategy from there.

@juliasilge
Copy link
Collaborator

Oh, I think it would be GREAT if you reworked all that asserting and checking! I think it would be a huge improvement.

@jmobrien
Copy link
Collaborator Author

jmobrien commented Jun 8, 2022

Okay, I'm working on it. BTW, how do you feel about using the new native pipes (|>)? It's a lot faster to write with them, but I wanted to run it by you first.

@juliasilge
Copy link
Collaborator

Unfortunately not in a package yet, I think, since there are lots of people still using pre-4.1.0 R in their workplaces, servers, etc. It is a lot easier to update packages than R for many people.

juliasilge added a commit that referenced this issue Jun 20, 2022
…223, & #262 (#263)

* Refactoring of argument checking

* functions use new arg checking, include_* + date/times in fetch_survey, extend fetch_id()

* update tests

* mark new arg checks as internal functions

* updated fetch_survey roxygen

* Further modularizing export-resposes (to support fetch_in_progress())

* documentation of new functions & fix inappropriate globals

* documentation of new functions & fix inappropriate globals

* remove extra param from qualtrics_response_codes

* Use rlang::arg_match for more safety

* No more assertthat

* Use sort of glue-ish pseudocode

* Fix order to generate protocol message, plus attempt some more consistency in messages

* Redocument

* Update tests

* One more test

* Update NEWS

Co-authored-by: Julia Silge <julia.silge@gmail.com>
@jmobrien
Copy link
Collaborator Author

Glad that it helped. Closing this, but feel free to reopen if there's more to do.

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

No branches or pull requests

2 participants