-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add Config class with static fields #99
Conversation
Also ran check(), but still a few issues there for sure. For some reason it thinks no changes were made to NEWS.md even though a new line was clearly added?
for more information, see https://pre-commit.ci
This is not intended as the final version, only for rough testing. The next step is to create a function for reading a JSON file into a Config class
for more information, see https://pre-commit.ci
Thank you for your contribution @natemcintosh 🚀! Your pkgdown-site is ready for download 👉 here 👈! |
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files📢 Thoughts on this report? Let us know! |
Was a little worried about future proofing this as parameters change. It should do everything automatically, EXCEPT for the case where we add another nested class to Config. In that case, we'll have to add it to str2class in read_json_into_config(). If we forget, we should at least get a warning about an usued parameter
This took a little more finessing than expected. Particularly around using lists for the sampler opts and the priors, I went back to lists from S7 objects, and added a default list that shows the desired keys and the expected types.
for more information, see https://pre-commit.ci
Looks like lintr is failing because the class names start with a capital. I had thought classes should start with a capital letter? Am willing to change this if they should be lower case. |
Nah this is just a |
The S7 docs seem to use |
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.
This is super cool. A few inline questions as I try to get my head around S7.
Can you add tests to bring patch coverage up to 100%?
😅 my brain conveniently forgot to write tests. Will add tests. |
Also fix placement of as_of_date in the Config object itself
…fa-epinow2-pipeline into nam-static-config-class
…fa-epinow2-pipeline into nam-static-config-class
for more information, see https://pre-commit.ci
…fa-epinow2-pipeline into nam-static-config-class
for more information, see https://pre-commit.ci
Ok, things are looking pretty good. I am left confused by the warning from R CMD check however. There's some formatting difference between docstrings and the .Rd files? Searching for this online leads me down rabbit holes, and no direct answers. |
Ok, it looks like running |
I think you need to run |
It looks like that line is already in the repo. Running |
Ok noting that I can reproduce the R CMD check warning. Looking into it a bit. |
Looks like it just be that Roxygen2 does not yet support S7. Thanks @damonbayer for noticing this. If this is the issue, then I think our choices are:
At this point, I think I would go for 3. |
@natemcintosh you could manually modify the |
As in manually change whitespace differences? |
I thought the problem was all of this bonus stuff in the cfa-epinow2-pipeline/man/Config.Rd Lines 25 to 160 in 0c12e82
My suggestion was to remove that by hand (or automate its removal). I could be misunderstanding the issue, though. |
After a little more playing around, I discovered that removing the default values for two lists inside But I will also update the list of possible actions we can take above. |
This was a merry goose chase! Until S7 is better supported in Roxygen, I think we should rely on the documentation to see what fields are required for these lists
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 asked one question but otherwise LGTM. Please have Zack look too before merge!
😎
Goal
As stated in #98, the goal is to create a
Config
class with static fields for all the required input parameters for the model.You can see all of the fields for the class by creating an empty instance of it:
Hopefully this should make syncing changes to the fields easier.
Gotchas
To read a JSON file into the
Config
class, I ran into an issue created by the nested classes (e.g.Data
class inside theConfig
class), so this uses a hard-coded solution which maps the name of the field in theConfig
class to the nested class, e.g.list(data = Data)
. If we ever add more sub-classes, they will have to be added to this hard coded list. If any knows an easier way, I'd love to use that.Defaults
Note that S7 adds the "empty value" of the type as the default, hence the many
chr(0)
andint(0)
. In a few places, I told S7 that a field could be a union of string and NULL, to deal with reading in NULL values from the JSON. I also added defaults of actual values for"EpiNow2"
c(0.5 0.95)
Feel free to change / add / remove these as necessary.
Use of lists for
sampler_opts
andpriors
For these two, I had originally created an S7 class each, but ran into issues that required changing the pipeline code more than desired. Instead, I went back to lists, but created default values that show all of the required keys, and set the values to be the expected types. As you can see above, it should make it easy to see what is required. Because the values are classes (e.g.
S7::class_integer
), and not actual values like10
, it should fail loudly if the default values are used.