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

More helpful error message for invalid formats #67

Merged
merged 11 commits into from
Jan 10, 2023

Conversation

zdz2101
Copy link
Collaborator

@zdz2101 zdz2101 commented Dec 21, 2022

Per #60 and #64 , users seem to encounter this error with relative frequency:

"Error: Writing failure: A provided format string could not be understood."

I believe this is actually a haven error-message coming from line 55 in R/write.R :
write_xpt(data, path = path, version = 5, name = name)

To remedy this, I propose to add an additional format check inside xpt_validate() which is called at line 47 of R/write.R, but changes are contained inside R/utils-xportr.R

@codecov
Copy link

codecov bot commented Dec 23, 2022

Codecov Report

Merging #67 (9f4c146) into main (e598735) will increase coverage by 2.66%.
The diff coverage is 83.78%.

❗ Current head 9f4c146 differs from pull request most recent head ba4989f. Consider uploading reports for the commit ba4989f to get more accurate results

@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
+ Coverage   66.18%   68.85%   +2.66%     
==========================================
  Files          10       10              
  Lines         349      366      +17     
==========================================
+ Hits          231      252      +21     
+ Misses        118      114       -4     
Impacted Files Coverage Δ
R/utils-xportr.R 68.81% <83.78%> (+10.92%) ⬆️
R/write.R 83.33% <0.00%> (+5.55%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@zdz2101 zdz2101 requested review from elimillera and bms63 December 23, 2022 20:02
@zdz2101
Copy link
Collaborator Author

zdz2101 commented Dec 23, 2022

@elimillera @bms63 Not quite sure how to diagnose the R-CMD-checks, besides that what do you think of these proposed changes?

@bms63
Copy link
Collaborator

bms63 commented Jan 5, 2023

Hey @zdz2101 I think I fixed the actions for linux os. One is still running as I write

R/utils-xportr.R Outdated
Comment on lines 164 to 169
fmt_fmts <- function(x) {
fmts <- ntext(length(x), "Format", "Formats")
glue("{fmts} {encode_vals(x)}")
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

is this used somewhere? I see it is new but don't see it being used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Used up around line 114

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh lol i see can you move it so it comes before that call

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you scroll up a bit, you'll see a few other functions that are also mentioned after where they are called, do you want me to reorganize the entirety of the file such that functions are created before where they are called?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please just to increase readability for those who come afterwards.

Copy link
Collaborator

@bms63 bms63 left a comment

Choose a reason for hiding this comment

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

Can you roxygen this file and make it so it doesn't export. Sorry you have to clean up our mess!!

Copy link
Member

@elimillera elimillera left a comment

Choose a reason for hiding this comment

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

Thanks @zdz2101! I'll be pushing up a some changes to the news file and description but otherwise I think this looks great.

@zdz2101 zdz2101 requested a review from bms63 January 6, 2023 19:16
@bms63
Copy link
Collaborator

bms63 commented Jan 6, 2023

@zdz2101 Sorry. The newly roxygened functions shouldn't be exported unless you think they might be useful to users. I just wanted titles, explanations of function purpose (if you think it is not clear to a new developer) and arguments described properly. Like we do in admiral

NEWS.md Outdated
@@ -1,3 +1,6 @@
# xportr 0.1.0.9000 (development)
* Added a new validation test that errors when users pass invalid formats. Thanks to @zdz2101!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we link the issue here as well?

@zdz2101
Copy link
Collaborator Author

zdz2101 commented Jan 6, 2023

@zdz2101 Sorry. The newly roxygened functions shouldn't be exported unless you think they might be useful to users. I just wanted titles, explanations of function purpose (if you think it is not clear to a new developer) and arguments described properly. Like we do in admiral

Ah I see I thought you meant it just isn't exported in the NAMESPACE, which it currently isn't. Although, I think by using roxygen-style comments and a command like devtools::document() it expects to create .Rd files and request appropriate entries in the reference section under the pkgdown.yml . I can leave the roxygen comments and use something like "@"noRd ?

@bms63
Copy link
Collaborator

bms63 commented Jan 6, 2023

@zdz2101 Sorry. The newly roxygened functions shouldn't be exported unless you think they might be useful to users. I just wanted titles, explanations of function purpose (if you think it is not clear to a new developer) and arguments described properly. Like we do in admiral

Ah I see I thought you meant it just isn't exported in the NAMESPACE, which it currently isn't. Although, I think by using roxygen-style comments and a command like devtools::document() it expects to create .Rd files and request appropriate entries in the reference section under the pkgdown.yml . I can leave the roxygen comments and use something like "@"noRd ?

Apologies for creating confusion. Yes I meant noRd that is my bad.

@zdz2101 zdz2101 force-pushed the feature/error-message-for-invalid-formats branch from ba70a36 to db7e2d1 Compare January 6, 2023 20:06
@zdz2101 zdz2101 requested a review from bms63 January 6, 2023 20:13
Copy link
Collaborator

@bms63 bms63 left a comment

Choose a reason for hiding this comment

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

I think this is looking great. Thanks a lot @zdz2101!! Just the version comment needs to be addressed by @elimillera

@zdz2101 zdz2101 marked this pull request as ready for review January 10, 2023 16:49
@zdz2101 zdz2101 merged commit d1b33be into main Jan 10, 2023
@bms63 bms63 deleted the feature/error-message-for-invalid-formats branch April 23, 2023 14:38
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.

More informative error message for invalid formats xportr_format issue from Roche testing
3 participants