Skip to content

Conversation

@mwiebe
Copy link
Contributor

@mwiebe mwiebe commented Feb 11, 2025

What was the problem/requirement? (What/Why)

https://github.com/OpenJobDescription/openjd-specifications/blob/mainline/rfcs/0001-task-chunking.md

What was the solution? (How)

Implement the task chunking additions as the TASK_CHUNKING extensions, using the context-sensitive parsing introduced by the Pydantic V2 conversion and extensions RFC implementation.

What is the impact of this change?

Job templates that use the task chunking feature can be parsed successfully.

How was this change tested?

Added tests for the new functionality.

  • Have you run the unit tests?

Yes

Was this change documented?

  • Are relevant docstrings in the code base updated?

Yes

Is this a breaking change?

Not a breaking change, it adds support for the TASK_CHUNKING extension.

Does this change impact security?

This does not impact the threat model, and the new extensions field and parameter follow the same level of input validation relevant for existing threats.


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

@mwiebe mwiebe requested a review from a team as a code owner February 11, 2025 21:29
@mwiebe mwiebe force-pushed the rfc-0001-task-chunking branch 2 times, most recently from fffedf4 to a2b335c Compare February 11, 2025 21:39
@mwiebe mwiebe force-pushed the rfc-0001-task-chunking branch from a2b335c to edfc0e3 Compare February 12, 2025 19:31
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
9.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@jusiskin jusiskin left a comment

Choose a reason for hiding this comment

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

Great job. Just a few nitpicks, but I don't consider them blocking. Feel free to address them or merge as-is.

Comment on lines +584 to +585
# If the string value has no expressions, can validate the value now.
# Otherwise will validate when
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this comment is unfinished

Comment on lines +147 to +159
pytest.param(
{
"name": "foo",
"type": "CHUNK[INT]",
"range": "1-100",
"chunks": {
"defaultTaskCount": 10,
"targetRuntimeSeconds": "{{Param.TargetChunkRuntime}}",
"rangeConstraint": "NONCONTIGUOUS",
},
},
id="targetRuntimeSeconds is str expression",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should we also have a case where defaultTaskCount is a format string? I see it is already covered in test/openjd/model/v2023_09/test_create.py, but maybe for completeness it would be good to have here as well.

},
"Value must be an integer or integer string.",
1,
id="disallow floats",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should this mention "range"? same applies to test cases below this

Comment on lines +945 to +961
# Reject the string if it contains any expressions.
if len(item.expressions) == 0:
try:
int(item)
except ValueError:
errors.append(
InitErrorDetails(
type="value_error",
loc=(i,),
ctx={
"error": ValueError(
"String literal must contain an integer."
)
},
input=item,
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this code comment doesn't match the implementation. It seems we are only rejecting strings if they have no expressions and the string cannot be parsed as an integer.

@mwiebe
Copy link
Contributor Author

mwiebe commented Feb 13, 2025

Great job. Just a few nitpicks, but I don't consider them blocking. Feel free to address them or merge as-is.

Thanks! I'll merge this and then open a smaller PR to fix up what you found.

@mwiebe mwiebe merged commit c51683e into OpenJobDescription:mainline Feb 13, 2025
18 of 19 checks passed
@mwiebe mwiebe deleted the rfc-0001-task-chunking branch February 13, 2025 22:27
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.

4 participants