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 messages when YAML-writing agents/informants with a non-lazy tbl #597

Merged
merged 4 commits into from
Feb 16, 2025

Conversation

yjunechoe
Copy link
Collaborator

@yjunechoe yjunechoe commented Feb 15, 2025

Summary

write_yaml() now uses information in $tbl_name to construct more informative error messages when the tbl is not supplied lazily upon agent/informant's creation (requirement for yaml-writing).

Special error msg if tbl was supplied as a variable (hint to use ~):

create_agent(small_table) %>% 
  yaml_write()
#> Error:
#> ✖ The agent must have a `tbl` value that can be put into YAML.
#> ℹ Did you mean to pass the table lazily? Ex: `create_agent(tbl = ~ small_table)`

Generic error msg if tbl was supplied as a complex expression (points to yaml_write()):

create_agent(small_table %>% head(1)) %>% 
  yaml_write()
#> Error:
#> ✖ The agent must have a `tbl` value that can be put into YAML.
#> ℹ See `?yaml_write` for details.

This behavior has been united across agents and informants via a helper function check_lazy_tbl()

Related GitHub Issues and PRs

Checklist

@rich-iannone
Copy link
Member

Thank you so much for this PR and for handling the underlying issue so well! Will review this in short order :)

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

LGTM!

@rich-iannone
Copy link
Member

PR is awesome (as expected!). Merge anytime!

@yjunechoe yjunechoe merged commit a822d10 into rstudio:main Feb 16, 2025
12 checks passed
@yjunechoe yjunechoe deleted the yaml-write-tbl-name-error-msg branch February 16, 2025 19:20
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.

2 participants