generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 18
feat!: Implement 'in' operator and chunksize overide for StepParamerSpaceIterator #177
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
Merged
mwiebe
merged 1 commit into
OpenJobDescription:mainline
from
mwiebe:param-space-contains
Mar 3, 2025
Merged
feat!: Implement 'in' operator and chunksize overide for StepParamerSpaceIterator #177
mwiebe
merged 1 commit into
OpenJobDescription:mainline
from
mwiebe:param-space-contains
Mar 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
epmog
reviewed
Feb 28, 2025
Contributor
epmog
left a comment
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.
Looks good! Just the few comments about errors and the changing type
840f2c1 to
df7fc05
Compare
epmog
previously approved these changes
Mar 1, 2025
df7fc05 to
58a6894
Compare
epmog
previously approved these changes
Mar 1, 2025
crowecawcaw
reviewed
Mar 3, 2025
…rSpaceIterator
* The in operator and validate_containment function of the StepParameterSpaceIterator
will allow the openjd-cli to validate that input task parameters
are within the parameter space of steps that it is running. The latter
* The purpose of this change is to support chunked iteration. This
validation helps ensure the `openjd run` command only accepts
correct chunk, in addition to adding validation that was marked as
a TODO in the openjd-cli codebase. Having validate_containment
raise an exception with a message about why the task parameters are
not in the parameter space results in better error messages.
* The chunksize override lets a caller iterate over every task of a
parameter space regardless of the space's chunk size or adaptivity.
This is useful for callers to evaluate the whole task space so that
they can perform their own chunking logic later.
* Add a property chunks_parameter_name to the StepParameterSpaceIterator
so that code using it can easily access the chunked parameter and its
properties without having to perform its own loop over all of them.
* Use an IntRangeExpr instead of a string to hold the range expression
of a RangeExpressionTaskParameterDefinition, the class used to
instantiate a parameter definition template into a job.
* Found that negative steps in IntRange have bugs in corner cases. Code
that is processing the list of IntRanges includes assumptions that the
step is positive. To fix this, chose to normalize the step to be
positive instead of adjusting the code to handle persistence of
negative steps, as that is much simpler to get right.
* Note that the IntRangeExpr was already not preserving the input
order of a range expression, because it sorted all the components.
* Removed _BaseMessageError and used ValueError instead as a base class
for the exceptions. This reduces custom code and interoperates with
Pydantic better.
BREAKING CHANGE: The IntRangeExpr class now normalizes the steps of
individual range components like "3-1:-2" to be positive like "1-3:2",
so anything depending on the prior behavior needs to be updated.
Signed-off-by: Mark Wiebe <[email protected]>
58a6894 to
ad39f77
Compare
|
crowecawcaw
approved these changes
Mar 3, 2025
epmog
approved these changes
Mar 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



What was the problem/requirement? (What/Why)
The OpenJD CLI lacks a way to validate whether a provided set of parameters are in the parameter space of the step they're for. When using chunks, adding this validation would make it easier to catch errors about whether the chunked parameter is contiguous and needs an interval like "3-3" vs a single value like "3".
With chunking, the step parameter space iterator doesn't have a mechanism, other than editing the input space object, to iterate over each individual task instead of over chunks of tasks. A mechanism like this is useful for scheduler integrations that reason at the task level and do their own chunking.
What was the solution? (How)
openjd runcommand only accepts correct chunk, in addition to adding validation that was marked as a TODO in the openjd-cli codebase. Having validate_containment raise an exception with a message about why the task parameters are not in the parameter space results in better error messages.What is the impact of this change?
With a follow-up OpenJD CLI change, more pleasant CLI usage.
How was this change tested?
Added unit tests for the new functions and operator.
Was this change documented?
Updated docstrings
Is this a breaking change?
BREAKING CHANGE: The IntRangeExpr class now normalizes the steps of
individual range components like "3-1:-2" to be positive like "1-3:2",
so anything depending on the prior behavior needs to be updated.
Does this change impact security?
No
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.