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

Add transaction method for multi-stage updates #123

Merged
merged 4 commits into from
Jan 25, 2021
Merged

Add transaction method for multi-stage updates #123

merged 4 commits into from
Jan 25, 2021

Conversation

hdoupe
Copy link
Collaborator

@hdoupe hdoupe commented Jan 12, 2021

  • Rollback to previous state after errors/exceptions
  • Optionally defer schema-level validation until the update is complete
  • Change is_deserialized arg to deserialized
import paramtools

class Params(paramtools.Parameters):
    defaults = {
        "min_param": {
            "title": "Min param",
            "description": "Must be less than 'max_param'",
            "type": "int",
            "value": 2,
            "validators": {
                "range": {"max": "max_param"}
            }
        },
        "max_param": {
            "title": "Max param",
            "type": "int",
            "value": 3
        }
    }

params = Params()
with params.transaction():
    params.adjust({"min_param": 4})
    params.adjust({"max_param": 5})

params.sel["min_param"]

# Values([
#   {'value': 4},
# ])

params.sel["max_param"]

# Values([
#   {'value': 5},
# ])

- Rollback to previous state after errors/exceptions
- Optionally defer schema-level validation until the update is complete
- Change `is_deserialized` arg to `deserialized`
@hdoupe hdoupe changed the title Add transaction function for multi-stage updates Add transaction method for multi-stage updates Jan 13, 2021
@hdoupe
Copy link
Collaborator Author

hdoupe commented Jan 25, 2021

Merging #123. There may be some things that ParamTools can do down the road to optimize which values are validated after a transaction, but for now, the lack of optimization here doesn't appear to have a significant performance impact.

@hdoupe hdoupe merged commit 45c0467 into master Jan 25, 2021
@hdoupe hdoupe deleted the transactions branch January 25, 2021 22:35
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