Skip to content

Commit 86f79ee

Browse files
committed
feat!: Implement FEATURE_BUNDLE_1 RFC 0004
I used the following prompt for LLM evaluation of this code change against RFC 0004 in openjd-specifications: > You are a helpful RFC conformance reviewer. Another agent has > implemented RFC 0004, along with tests, in the most recent commit. Your > job is to carefully inspect the RFC, the RFC-specific details in the > OpenJD spec, and look at all the code changes to evaluate compliance. > Produce a report on the quality of the implementation. How well does it > conform? Give each relevant section/subsection of the spec a score. Also > look at the unit tests and evaluate that it is covering all edge cases > of the spec. Write your report to the file CONFORMANCE_REPORT.md. All code also reviewed by hand. BREAKING CHANGE: The types of some model class fields are extended from Optional[int] to Optional[int | FormatString], so downstream code that relies on those types can fail type checking. Signed-off-by: Mark <399551+mwiebe@users.noreply.github.com>
1 parent d14a9ce commit 86f79ee

File tree

8 files changed

+1573
-38
lines changed

8 files changed

+1573
-38
lines changed

src/openjd/model/_internal/_create_job.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ def instantiate_model( # noqa: C901
9292
errors = list[InitErrorDetails]()
9393
instantiated_fields = dict[str, Any]()
9494

95+
# Apply pre-transform if defined
96+
if model._job_creation_metadata.transform is not None:
97+
model = model._job_creation_metadata.transform(model)
98+
9599
# Determine the target model to create as
96100
target_model = model.__class__
97101
if model._job_creation_metadata.create_as is not None:

src/openjd/model/_internal/_validator_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def validate_int_fmtstring_field(
1414
ge: Optional[int] = None,
1515
*,
1616
context: Optional[ModelParsingContextInterface],
17-
) -> Union[int, float, Decimal, FormatString]:
17+
) -> Union[int, FormatString]:
1818
"""Validates a field that is allowed to be either an integer, a string containing an integer,
1919
or a string containing expressions that resolve to an integer."""
2020
value_type_wrong_msg = "Value must be an integer or a string containing an integer."
@@ -57,7 +57,7 @@ def validate_float_fmtstring_field(
5757
ge: Optional[Decimal] = None,
5858
*,
5959
context: Optional[ModelParsingContextInterface],
60-
) -> Union[int, float, Decimal, FormatString]:
60+
) -> Union[Decimal, FormatString]:
6161
"""Validates a field that is allowed to be either an float, a string containing an float,
6262
or a string containing expressions that resolve to a float."""
6363
value_type_wrong_msg = "Value must be a float or a string containing a float."

src/openjd/model/_types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ class JobCreationMetadata:
268268
"""This instructs the instantiation code to rename the given fields.
269269
"""
270270

271+
transform: Optional[Callable[["OpenJDModel"], "OpenJDModel"]] = field(default=None)
272+
"""A callable that transforms the source model before field processing.
273+
arg0 - The model to transform.
274+
returns - The transformed model (can be the same instance or a new one).
275+
Use-case: Resolving syntax sugar on StepTemplate before creating Step.
276+
"""
277+
271278

272279
class OpenJDModel(BaseModel):
273280
model_config = ConfigDict(extra="forbid", frozen=True)

src/openjd/model/v2023_09/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
EmbeddedFiles,
3030
EmbeddedFileText,
3131
EmbeddedFileTypes,
32+
EndOfLine,
3233
Environment,
3334
EnvironmentActions,
3435
EnvironmentName,
@@ -64,6 +65,8 @@
6465
PathTaskParameterDefinition,
6566
RangeExpressionTaskParameterDefinition,
6667
RangeListTaskParameterDefinition,
68+
ScriptInterpreter,
69+
SimpleAction,
6770
Step,
6871
StepActions,
6972
StepEnvironmentList,
@@ -113,6 +116,7 @@
113116
"EmbeddedFiles",
114117
"EmbeddedFileText",
115118
"EmbeddedFileTypes",
119+
"EndOfLine",
116120
"Environment",
117121
"EnvironmentActions",
118122
"EnvironmentScript",
@@ -148,6 +152,8 @@
148152
"PathTaskParameterDefinition",
149153
"RangeExpressionTaskParameterDefinition",
150154
"RangeListTaskParameterDefinition",
155+
"ScriptInterpreter",
156+
"SimpleAction",
151157
"Step",
152158
"StepActions",
153159
"StepEnvironmentList",

0 commit comments

Comments
 (0)