Skip to content

feat: add utility methods for primitive clients#424

Open
nborges-aws wants to merge 1 commit intomainfrom
feat/PrimitiveClientUtilities
Open

feat: add utility methods for primitive clients#424
nborges-aws wants to merge 1 commit intomainfrom
feat/PrimitiveClientUtilities

Conversation

@nborges-aws
Copy link
Copy Markdown

Description of changes:
Adding utility methods used in new primitive clients. Releasing utilities first so the PRs adding primitive clients can be done in parallel, as they all take dependency on these methods. The changes in this PR include:

  • Config.py -> adds WaitConfig dataclass
  • Polling.py -> adds wait_until and wait_until_deleted utility methods used in *_and_wait methods across primitives
  • snake_case.py -> adds additional snake case conversion helper used across primitives
  • test_utils.py -> Unit tests for added utilities

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link
Copy Markdown
Contributor

✅ No Breaking Changes Detected

No public API breaking changes found in this PR.

target: str,
failed: Set[str],
wait_config: Optional[WaitConfig] = None,
error_field: str = "statusReasons",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why was this default chosen?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The majority of CP resources use statusReasons as the error detail field, which is why I set it as the default. The few primitives whose CP resources use failureReason are set as such at the method level

poll_interval: Seconds between status checks. Default: 10. Must be >= 1.
"""

max_wait: int = 300
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if one function requires different max_waits than another? For example, if create_memories takes longer than 5 minutes usually, then create_memories_and_wait would usually fail with these defaults.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If a *_and_wait method requires a larger window than the standard, the default max_wait can be set at the method level. Right now all the _and_wait methods pass None if the caller does not provide a WaitConfig. But if necessary for a specific case we could instead pass in a WaitConfig we define.

"""

max_wait: int = 300
poll_interval: int = 10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same answer as above. As for the exponential backoff, I think it would be good to have. Should we include that as an optional parameter or a default behavior?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lets keep that as a p1

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