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

Adds default reads/writes to burr actions #269

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elijahbenizzy
Copy link
Contributor

This allows you to specify defaults if your action does not write. In the majority of cases they will be none, but this allows simple (static) arbitrary values. This specifically helps with the branching case -- e.g. where you have two options, and want to null out anything it doesn't write. For instance, an error and a result -- you'll only ever produce one or the other.

This works both in the function and class-based approaches -- in the function-based it is part of the two decorators
(@action/@streaming_action). In the class-based it is part of the class, overriding the default_reads and default_writes property function

[Short description explaining the high-level reason for the pull request]

Changes

How I tested this

Notes

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

@elijahbenizzy elijahbenizzy marked this pull request as draft July 16, 2024 18:40
Copy link
Contributor Author

@elijahbenizzy elijahbenizzy left a comment

Choose a reason for hiding this comment

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

Add some tests

burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
burr/core/application.py Outdated Show resolved Hide resolved
This allows you to specify defaults if your action does not write. In
the majority of cases they will be none, but this allows simple (static)
arbitrary values. This specifically helps with the branching case --
e.g. where you have two options, and want to null out anything it
doesn't write. For instance, an error and a result -- you'll only ever
produce one or the other.

This works both in the function and class-based approaches -- in the
function-based it is part of the two decorators
(@action/@streaming_action). In the class-based it is part of the class,
overriding the default_reads and default_writes property function

We add a bunch of new tests for default (as the code to handle multiple
action types is fairly dispersed, for now), and also make the naming of
the other tests/content more consistent.

Note that this does not currently work with settings defaults to
append/increment operations -- it will produce strange behavior.
This is documented in all appropriate signatures.

This also does not work (or even make sense) in the case that the
function writes a default that it also reads. In that case, it will
clobber the current value with the write value. To avoid this,
we just error out if that is the case beforehand.
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.

1 participant