Skip to content

Docs: broken examples for creating job templates programmatically #238

@jusiskin

Description

@jusiskin

Documentation Issue

Background

The README.md file contains code examples that create job template objects programmatically in Python without parsing from YAML or JSON.

Problem

The code examples are not functioning correctly. For example, when trying to run the job template creation example:

from openjd.model.v2023_09 import *

job_template = JobTemplate(
    specificationVersion="jobtemplate-2023-09",
    name="DemoJob",
    steps=[
        StepTemplate(
            name="DemoStep",
            script=StepScript(
                actions=StepActions(
                    onRun=Action(
                        command="python",
                        args=["-c", "print('Hello world!')"]
                    )
                )
            )
        )
    ]
)

you get the following error:

Traceback (most recent call last):
  File "/Users/usiskin/temp/step_paramspace_job_param/openjd_template_to_dict.py", line 11, in <module>
    onRun=Action(
        command="python",
        args=["-c", "print('Hello world!')"]
    )
  File "/Users/usiskin/temp/step_paramspace_job_param/.venv/lib/python3.13/site-packages/pydantic/main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 3 validation errors for Action
command
  Value error, Internal parsing error: No parsing context was provided during model validation for the DynamicConstrainedStr subclass CommandString. [type=value_error, input_value='python', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error
args.0
  Value error, Internal parsing error: No parsing context was provided during model validation for the DynamicConstrainedStr subclass ArgString. [type=value_error, input_value='-c', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error
args.1
  Value error, Internal parsing error: No parsing context was provided during model validation for the DynamicConstrainedStr subclass ArgString. [type=value_error, input_value="print('Hello world!')", input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions