Skip to content

Bug: Template to YAML leaves unevaluated objects in the template #125

@lucaseck

Description

@lucaseck

Expected Behaviour

When trying to print a job template to YAML after calling model_to_object and then using yaml.dump the template is properly formatted and a valid template.

Current Behaviour

When trying to print a job template to YAML after calling model_to_object and then using yaml.dump the template contains what look like objects instead of the strings that those objects are supposed to contain.

Reproduction Steps

Ran the code snippet linked below.

Code Snippet

parameters: JobParameterDefinitionList = []
parameters.append(
    JobPathParameterDefinition(
        name="Parameter1",
        default="C:\\Users\\testing\\Desktop",
        type=JobParameterType.PATH,
    )
)

template = JobTemplate(
        name="bug template",
        specificationVersion="jobtemplate-2023-09",
        parameterDefinitions=parameters,
        steps=[
            StepTemplate(
                name="Main Step",
                script=StepScript(
                    actions=StepActions(onRun=Action(command="echo", args=["hello"]))
                ),
            )
        ],
    )
template_obj = model_to_object(model=template)
print(yaml.dump(template_obj))

Results in:

name: !!python/object/new:openjd.model.v2023_09._model.JobTemplateName
  args:
  - bug template
  state:
    _processed_list:
    - bug template
parameterDefinitions:
- default: C:\Users\testing\Desktop
  name: Parameter1
  type: !!python/object/apply:openjd.model.v2023_09._model.JobParameterType
  - PATH
specificationVersion: !!python/object/apply:openjd.model._types.TemplateSpecificationVersion
- jobtemplate-2023-09
steps:
- name: Main Step
  script:
    actions:
      onRun:
        args:
        - !!python/object/new:openjd.model.v2023_09._model.ArgString
          args:
          - hello
          state:
            _processed_list:
            - hello
        command: !!python/object/new:openjd.model.v2023_09._model.CommandString
          args:
          - echo
          state:
            _processed_list:
            - echo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions