Name | openjd-model JSON |
Version |
0.8.4
JSON |
| download |
home_page | None |
Summary | Provides a Python implementation of the data model for Open Job Description's template schemas. |
upload_time | 2025-09-12 20:34:38 |
maintainer | None |
docs_url | None |
author | Amazon Web Services |
requires_python | >=3.9 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Open Job Description - Models For Python
[](https://pypi.python.org/pypi/openjd-model)
[](https://pypi.python.org/pypi/openjd-model)
[](https://github.com/OpenJobDescription/openjd-model/blob/mainline/LICENSE)
Open Job Description is a flexible open specification for defining render jobs which are portable
between studios and render management solutions. This package provides a Python implementation of the
data model for Open Job Description's template schemas. It can parse, validate, create JSON/Yaml
documents for the Open Job Description specification, and more. A main use-case that this library
targets is interoperability by creating applications to translate a Job from Open Job Description
to the render management software of your choice.
For more information about Open Job Description and our goals with it, please see the
Open Job Description [Wiki on GitHub](https://github.com/OpenJobDescription/openjd-specifications/wiki).
## Compatibility
This library requires:
1. Python 3.9 or higher; and
2. Linux, MacOS, or Windows operating system.
## Versioning
This package's version follows [Semantic Versioning 2.0](https://semver.org/), but is still considered to be in its
initial development, thus backwards incompatible versions are denoted by minor version bumps. To help illustrate how
versions will increment during this initial development stage, they are described below:
1. The MAJOR version is currently 0, indicating initial development.
2. The MINOR version is currently incremented when backwards incompatible changes are introduced to the public API.
3. The PATCH version is currently incremented when bug fixes or backwards compatible changes are introduced to the public API.
## Contributing
We encourage all contributions to this package. Whether it's a bug report, new feature, correction, or additional
documentation, we greatly value feedback and contributions from our community.
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for our contributing guidelines.
## Example Usage
### Reading and Validating a Template File
```python
from openjd.model import (
DecodeValidationError,
DocumentType,
JobTemplate,
document_string_to_object,
decode_job_template
)
# String containing the json of the job template
template_string = "..."
try:
template_object = document_string_to_object(
document=template_string,
document_type=DocumentType.JSON
)
# Use 'decode_environment_template()' instead if decoding an
# Environment Template
job_template = decode_job_template(template=template_object)
except DecodeValidationError as e:
print(str(e))
```
### Creating a Template Model
```python
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!')"]
)
)
)
)
]
)
```
### Converting a Template Model to a Dictionary
```python
import json
from openjd.model import (
decode_job_template,
model_to_object,
)
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="echo",
args=["Hello world"]
)
)
)
)
]
)
obj = model_to_object(model=job_template)
print(json.dumps(obj))
```
### Creating a Job from a Job Template
```python
import os
from pathlib import Path
from openjd.model import (
DecodeValidationError,
create_job,
decode_job_template,
preprocess_job_parameters
)
job_template_path = Path("/absolute/path/to/job/template.json")
job_template = decode_job_template(
template={
"name": "DemoJob",
"specificationVersion": "jobtemplate-2023-09",
"parameterDefinitions": [
{ "name": "Foo", "type": "INT" }
],
"steps": [
{
"name": "DemoStep",
"script": {
"actions": {
"onRun": { "command": "python", "args": [ "-c", "print(r'Foo={{Param.Foo}}')" ] }
}
}
}
]
}
)
try:
parameters = preprocess_job_parameters(
job_template=job_template,
job_parameter_values={
"Foo": "12"
},
job_template_dir=job_template_path.parent,
current_working_dir=Path(os.getcwd())
)
job = create_job(
job_template=job_template,
job_parameter_values=parameters
)
except (DecodeValidationError, RuntimeError) as e:
print(str(e))
```
### Working with Step dependencies
```python
from openjd.model import (
StepDependencyGraph,
create_job,
decode_job_template
)
job_template = decode_job_template(
template={
"name": "DemoJob",
"specificationVersion": "jobtemplate-2023-09",
"steps": [
{
"name": "Step1",
"script": {
"actions": {
"onRun": { "command": "python", "args": [ "-c", "print('Step1')" ] }
}
}
},
{
"name": "Step2",
"dependencies": [ { "dependsOn": "Step1" }, { "dependsOn": "Step3" }],
"script": {
"actions": {
"onRun": { "command": "python", "args": [ "-c", "print('Step2')" ] }
}
}
},
{
"name": "Step3",
"script": {
"actions": {
"onRun": { "command": "echo", "args": [ "Step3" ] }
}
}
},
]
}
)
job = create_job(job_template=job_template, job_parameter_values={})
dependency_graph = StepDependencyGraph(job=job)
for step in job.steps:
step_node = dependency_graph.step_node(stepname=step.name)
if step_node.in_edges:
name_list = ', '.join(edge.origin.step.name for edge in step_node.in_edges)
print(f"Step '{step.name}' depends upon: {name_list}")
if step_node.out_edges:
name_list = ', '.join(edge.dependent.step.name for edge in step_node.out_edges)
print(f"The following Steps depend upon '{step.name}': {name_list}")
print(f"\nSteps in topological order: {[step.name for step in dependency_graph.topo_sorted()]}")
# The following Steps depend upon 'Step1': Step2
# Step 'Step2' depends upon: Step1, Step3
# The following Steps depend upon 'Step3': Step2
# Steps in topological order: ['Step1', 'Step3', 'Step2']
```
### Working with a Step's Tasks
```python
from openjd.model import (
StepParameterSpaceIterator,
create_job,
decode_job_template
)
job_template = decode_job_template(
template={
"name": "DemoJob",
"specificationVersion": "jobtemplate-2023-09",
"steps": [
{
"name": "DemoStep",
"parameterSpace": {
"taskParameterDefinitions": [
{ "name": "Foo", "type": "INT", "range": "1-5" },
{ "name": "Bar", "type": "INT", "range": "1-5" }
],
"combination": "(Foo, Bar)"
},
"script": {
"actions": {
"onRun": {
"command": "python",
"args": [ "-c", "print(f'Foo={{Task.Param.Foo}}, Bar={{Task.Param.Bar}}"]
}
}
}
},
]
}
)
job = create_job(job_template=job_template, job_parameter_values={})
for step in job.steps:
iterator = StepParameterSpaceIterator(space=step.parameterSpace)
print(f"Step '{step.name}' has {len(iterator)} Tasks")
for param_set in iterator:
print(param_set)
# Step 'DemoStep' has 5 Tasks
# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='1'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='1')}
# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='2'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='2')}
# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='3'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='3')}
# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='4'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='4')}
# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='5'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='5')}
```
## Downloading
You can download this package from:
- [PyPI](https://pypi.org/project/openjd-model/)
- [GitHub releases](https://github.com/OpenJobDescription/openjd-model-for-python/releases)
### Verifying GitHub Releases
See [Verifying GitHub Releases](https://github.com/OpenJobDescription/openjd-model-for-python?tab=security-ov-file#verifying-github-releases) for more information.
## Security
We take all security reports seriously. When we receive such reports, we will
investigate and subsequently address any potential vulnerabilities as quickly
as possible. If you discover a potential security issue in this project, please
notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/)
or directly via email to [AWS Security](aws-security@amazon.com). Please do not
create a public GitHub issue in this project.
## License
This project is licensed under the Apache-2.0 License.
Raw data
{
"_id": null,
"home_page": null,
"name": "openjd-model",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Amazon Web Services",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/f3/74/47be98ae509da7838d8f643e5fd26a9249eab2ecadf84055d348ad909e09/openjd_model-0.8.4.tar.gz",
"platform": null,
"description": "# Open Job Description - Models For Python\n\n[](https://pypi.python.org/pypi/openjd-model)\n[](https://pypi.python.org/pypi/openjd-model)\n[](https://github.com/OpenJobDescription/openjd-model/blob/mainline/LICENSE)\n\nOpen Job Description is a flexible open specification for defining render jobs which are portable\nbetween studios and render management solutions. This package provides a Python implementation of the\ndata model for Open Job Description's template schemas. It can parse, validate, create JSON/Yaml\ndocuments for the Open Job Description specification, and more. A main use-case that this library\ntargets is interoperability by creating applications to translate a Job from Open Job Description\nto the render management software of your choice.\n\nFor more information about Open Job Description and our goals with it, please see the\nOpen Job Description [Wiki on GitHub](https://github.com/OpenJobDescription/openjd-specifications/wiki).\n\n## Compatibility\n\nThis library requires:\n\n1. Python 3.9 or higher; and\n2. Linux, MacOS, or Windows operating system.\n\n## Versioning\n\nThis package's version follows [Semantic Versioning 2.0](https://semver.org/), but is still considered to be in its\ninitial development, thus backwards incompatible versions are denoted by minor version bumps. To help illustrate how\nversions will increment during this initial development stage, they are described below:\n\n1. The MAJOR version is currently 0, indicating initial development.\n2. The MINOR version is currently incremented when backwards incompatible changes are introduced to the public API.\n3. The PATCH version is currently incremented when bug fixes or backwards compatible changes are introduced to the public API.\n\n## Contributing\n\nWe encourage all contributions to this package. Whether it's a bug report, new feature, correction, or additional\ndocumentation, we greatly value feedback and contributions from our community.\n\nPlease see [CONTRIBUTING.md](./CONTRIBUTING.md) for our contributing guidelines.\n\n## Example Usage\n\n### Reading and Validating a Template File\n\n```python\nfrom openjd.model import (\n DecodeValidationError,\n DocumentType,\n JobTemplate,\n document_string_to_object,\n decode_job_template\n)\n\n# String containing the json of the job template\ntemplate_string = \"...\"\ntry:\n template_object = document_string_to_object(\n document=template_string,\n document_type=DocumentType.JSON\n )\n # Use 'decode_environment_template()' instead if decoding an\n # Environment Template\n job_template = decode_job_template(template=template_object)\nexcept DecodeValidationError as e:\n print(str(e))\n```\n\n### Creating a Template Model\n\n```python\nfrom openjd.model.v2023_09 import *\n\njob_template = JobTemplate(\n specificationVersion=\"jobtemplate-2023-09\",\n name=\"DemoJob\",\n steps=[\n StepTemplate(\n name=\"DemoStep\",\n script=StepScript(\n actions=StepActions(\n onRun=Action(\n command=\"python\",\n args=[\"-c\", \"print('Hello world!')\"]\n )\n )\n )\n )\n ]\n)\n```\n\n### Converting a Template Model to a Dictionary\n\n```python\nimport json\nfrom openjd.model import (\n decode_job_template,\n model_to_object,\n)\nfrom openjd.model.v2023_09 import *\n\njob_template = JobTemplate(\n specificationVersion=\"jobtemplate-2023-09\",\n name=\"DemoJob\",\n steps=[\n StepTemplate(\n name=\"DemoStep\",\n script=StepScript(\n actions=StepActions(\n onRun=Action(\n command=\"echo\",\n args=[\"Hello world\"]\n )\n )\n )\n )\n ]\n)\n\nobj = model_to_object(model=job_template)\nprint(json.dumps(obj))\n```\n\n### Creating a Job from a Job Template\n\n```python\nimport os\nfrom pathlib import Path\nfrom openjd.model import (\n DecodeValidationError,\n create_job,\n decode_job_template,\n preprocess_job_parameters\n)\n\njob_template_path = Path(\"/absolute/path/to/job/template.json\")\njob_template = decode_job_template(\n template={\n \"name\": \"DemoJob\",\n \"specificationVersion\": \"jobtemplate-2023-09\",\n \"parameterDefinitions\": [\n { \"name\": \"Foo\", \"type\": \"INT\" }\n ],\n \"steps\": [\n {\n \"name\": \"DemoStep\",\n \"script\": {\n \"actions\": {\n \"onRun\": { \"command\": \"python\", \"args\": [ \"-c\", \"print(r'Foo={{Param.Foo}}')\" ] }\n }\n }\n }\n ]\n }\n)\ntry:\n parameters = preprocess_job_parameters(\n job_template=job_template,\n job_parameter_values={\n \"Foo\": \"12\"\n },\n job_template_dir=job_template_path.parent,\n current_working_dir=Path(os.getcwd())\n )\n job = create_job(\n job_template=job_template,\n job_parameter_values=parameters\n )\nexcept (DecodeValidationError, RuntimeError) as e:\n print(str(e))\n```\n\n### Working with Step dependencies\n\n```python\nfrom openjd.model import (\n StepDependencyGraph,\n create_job,\n decode_job_template\n)\n\njob_template = decode_job_template(\n template={\n \"name\": \"DemoJob\",\n \"specificationVersion\": \"jobtemplate-2023-09\",\n \"steps\": [\n {\n \"name\": \"Step1\",\n \"script\": {\n \"actions\": {\n \"onRun\": { \"command\": \"python\", \"args\": [ \"-c\", \"print('Step1')\" ] }\n }\n }\n },\n {\n \"name\": \"Step2\",\n \"dependencies\": [ { \"dependsOn\": \"Step1\" }, { \"dependsOn\": \"Step3\" }],\n \"script\": {\n \"actions\": {\n \"onRun\": { \"command\": \"python\", \"args\": [ \"-c\", \"print('Step2')\" ] }\n }\n }\n },\n {\n \"name\": \"Step3\",\n \"script\": {\n \"actions\": {\n \"onRun\": { \"command\": \"echo\", \"args\": [ \"Step3\" ] }\n }\n }\n },\n ]\n }\n)\njob = create_job(job_template=job_template, job_parameter_values={})\ndependency_graph = StepDependencyGraph(job=job)\n\nfor step in job.steps:\n step_node = dependency_graph.step_node(stepname=step.name)\n if step_node.in_edges:\n name_list = ', '.join(edge.origin.step.name for edge in step_node.in_edges)\n print(f\"Step '{step.name}' depends upon: {name_list}\")\n if step_node.out_edges:\n name_list = ', '.join(edge.dependent.step.name for edge in step_node.out_edges)\n print(f\"The following Steps depend upon '{step.name}': {name_list}\")\n\nprint(f\"\\nSteps in topological order: {[step.name for step in dependency_graph.topo_sorted()]}\")\n# The following Steps depend upon 'Step1': Step2\n# Step 'Step2' depends upon: Step1, Step3\n# The following Steps depend upon 'Step3': Step2\n\n# Steps in topological order: ['Step1', 'Step3', 'Step2']\n```\n\n### Working with a Step's Tasks\n\n```python\nfrom openjd.model import (\n StepParameterSpaceIterator,\n create_job,\n decode_job_template\n)\n\njob_template = decode_job_template(\n template={\n \"name\": \"DemoJob\",\n \"specificationVersion\": \"jobtemplate-2023-09\",\n \"steps\": [\n {\n \"name\": \"DemoStep\",\n \"parameterSpace\": {\n \"taskParameterDefinitions\": [\n { \"name\": \"Foo\", \"type\": \"INT\", \"range\": \"1-5\" },\n { \"name\": \"Bar\", \"type\": \"INT\", \"range\": \"1-5\" }\n ],\n \"combination\": \"(Foo, Bar)\"\n },\n \"script\": {\n \"actions\": {\n \"onRun\": {\n \"command\": \"python\",\n \"args\": [ \"-c\", \"print(f'Foo={{Task.Param.Foo}}, Bar={{Task.Param.Bar}}\"]\n }\n }\n }\n },\n ]\n }\n)\njob = create_job(job_template=job_template, job_parameter_values={})\nfor step in job.steps:\n iterator = StepParameterSpaceIterator(space=step.parameterSpace)\n print(f\"Step '{step.name}' has {len(iterator)} Tasks\")\n for param_set in iterator:\n print(param_set)\n# Step 'DemoStep' has 5 Tasks\n# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='1'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='1')}\n# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='2'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='2')}\n# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='3'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='3')}\n# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='4'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='4')}\n# {'Foo': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='5'), 'Bar': ParameterValue(type=<ParameterValueType.INT: 'INT'>, value='5')}\n```\n\n## Downloading\n\nYou can download this package from:\n- [PyPI](https://pypi.org/project/openjd-model/)\n- [GitHub releases](https://github.com/OpenJobDescription/openjd-model-for-python/releases)\n\n### Verifying GitHub Releases\n\nSee [Verifying GitHub Releases](https://github.com/OpenJobDescription/openjd-model-for-python?tab=security-ov-file#verifying-github-releases) for more information.\n\n## Security\n\nWe take all security reports seriously. When we receive such reports, we will\ninvestigate and subsequently address any potential vulnerabilities as quickly\nas possible. If you discover a potential security issue in this project, please\nnotify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/)\nor directly via email to [AWS Security](aws-security@amazon.com). Please do not\ncreate a public GitHub issue in this project.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n",
"bugtrack_url": null,
"license": null,
"summary": "Provides a Python implementation of the data model for Open Job Description's template schemas.",
"version": "0.8.4",
"project_urls": {
"Homepage": "https://github.com/OpenJobDescription/openjd-model-for-python",
"Source": "https://github.com/OpenJobDescription/openjd-model-for-python"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "47ddf983f1a7560f30f6345dbfcab5da60e171aabe9a21fc44a65124f65ecb71",
"md5": "ce277ad46f495e1ffd0a16b71afb8905",
"sha256": "01f36a11bf84ca4271cfcc47a926120991ff65a750ec1d923a6774c37ab41424"
},
"downloads": -1,
"filename": "openjd_model-0.8.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ce277ad46f495e1ffd0a16b71afb8905",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 91242,
"upload_time": "2025-09-12T20:34:36",
"upload_time_iso_8601": "2025-09-12T20:34:36.434367Z",
"url": "https://files.pythonhosted.org/packages/47/dd/f983f1a7560f30f6345dbfcab5da60e171aabe9a21fc44a65124f65ecb71/openjd_model-0.8.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f37447be98ae509da7838d8f643e5fd26a9249eab2ecadf84055d348ad909e09",
"md5": "e04c1caa3f6f24834ea338603d042bc7",
"sha256": "417acbb56e622384117fb2837e5bbc110d5c42c84b4a3301a454ddfeba12066d"
},
"downloads": -1,
"filename": "openjd_model-0.8.4.tar.gz",
"has_sig": false,
"md5_digest": "e04c1caa3f6f24834ea338603d042bc7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 78385,
"upload_time": "2025-09-12T20:34:38",
"upload_time_iso_8601": "2025-09-12T20:34:38.177358Z",
"url": "https://files.pythonhosted.org/packages/f3/74/47be98ae509da7838d8f643e5fd26a9249eab2ecadf84055d348ad909e09/openjd_model-0.8.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-12 20:34:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "OpenJobDescription",
"github_project": "openjd-model-for-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "openjd-model"
}