Skip to content

Commit e9817fb

Browse files
committed
chore: Update to use openjd-model based on Pydantic V2 instead of Pydantic V1
Signed-off-by: Mark Wiebe <[email protected]>
1 parent 9ae21f8 commit e9817fb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

hatch.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ lint = [
2121
]
2222

2323
[[envs.all.matrix]]
24-
python = ["3.9", "3.10", "3.11"]
24+
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
2525

2626
[envs.codebuild.scripts]
2727
build = "hatch build"

src/openjd/cli/_schema/_schema_command.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ def do_get_schema(args: Namespace) -> OpenJDCliResult:
5959
schema_doc: dict = {}
6060

6161
try:
62-
# The `schema` attribute will have to be updated if/when Pydantic
63-
# is updated to v2.
64-
# (AFAIK it can be replaced with `model_json_schema()`.)
65-
schema_doc = Template.schema()
62+
schema_doc = Template.model_json_schema()
6663
_process_regex(schema_doc)
6764
except Exception as e:
6865
return OpenJDCliResult(status="error", message=f"ERROR generating schema: {str(e)}")

test/openjd/cli/test_common.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from openjd.cli._common._job_from_template import job_from_template
2727
from openjd.model import (
2828
DecodeValidationError,
29-
decode_template,
29+
decode_job_template,
3030
)
3131

3232

@@ -364,11 +364,13 @@ def test_job_from_template_success(
364364
Test that `job_from_template` creates a Job with the provided parameters.
365365
"""
366366
template_dir, current_working_dir = template_dir_and_cwd
367-
template = decode_template(template=template_dict)
367+
template = decode_job_template(template=template_dict)
368368

369369
result = job_from_template(template, mock_params, template_dir, current_working_dir)
370370
assert result.name == expected_job_name
371-
assert result.steps == template.steps
371+
assert [step.model_dump(exclude_none=True) for step in result.steps] == [
372+
step.model_dump(exclude_none=True) for step in template.steps
373+
]
372374
if result.parameters:
373375
assert len(result.parameters) == len(mock_params)
374376

@@ -410,7 +412,7 @@ def test_job_from_template_error(
410412
"""
411413
template_dir, current_working_dir = template_dir_and_cwd
412414

413-
template = decode_template(template=template_dict)
415+
template = decode_job_template(template=template_dict)
414416

415417
with pytest.raises(RuntimeError) as rte:
416418
job_from_template(template, mock_params, template_dir, current_working_dir)

test/openjd/cli/test_schema_command.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from openjd.cli._schema._schema_command import do_get_schema, _process_regex
44
from openjd.model import TemplateSpecificationVersion
5-
from pydantic.v1 import BaseModel
5+
import openjd.model.v2023_09
66

77
from argparse import Namespace
88
import json
@@ -129,9 +129,10 @@ def test_do_get_schema_error(capsys: pytest.CaptureFixture):
129129
"""
130130

131131
with (
132-
patch.object(BaseModel, "schema", side_effect=RuntimeError("Test error")),
132+
patch.object(openjd.model.v2023_09, "JobTemplate") as job_template_class,
133133
pytest.raises(SystemExit),
134134
):
135+
job_template_class.model_json_schema.side_effect = RuntimeError("Test error")
135136
do_get_schema(
136137
Namespace(
137138
version=TemplateSpecificationVersion.JOBTEMPLATE_v2023_09.value,

0 commit comments

Comments
 (0)