operaton-contracts 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ .devenv/
3
+ dist/
4
+ build/
5
+ __pycache__/
6
+ .coverage*
7
+ htmlcov/
8
+ .mypy_cache/
9
+ .pytest_cache/
10
+ output.xml
11
+ log.html
12
+ report.html
13
+ .devenv*
14
+ site/
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ - Initial release: `TaskContract`, `template_hints`, the `OperatonContracts`
6
+ Robot library with `Validate Task Input`, element-template generation,
7
+ package consistency checks, and the `operaton-contracts` command.
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.5
2
+ Name: operaton-contracts
3
+ Version: 0.1.0
4
+ Summary: Pydantic task contracts, runtime validation, and generated element templates for Operaton external tasks, with optional Robot Framework support
5
+ Project-URL: Homepage, https://datakurre.github.io/operaton-contracts/
6
+ Project-URL: Documentation, https://datakurre.github.io/operaton-contracts/
7
+ Project-URL: Repository, https://github.com/datakurre/operaton-contracts
8
+ Project-URL: Issues, https://github.com/datakurre/operaton-contracts/issues
9
+ Project-URL: Changelog, https://github.com/datakurre/operaton-contracts/blob/main/CHANGELOG.md
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: bpmn,camunda,element-templates,operaton,purjo,robotframework
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Pydantic :: 2
15
+ Classifier: Framework :: Robot Framework
16
+ Classifier: Framework :: Robot Framework :: Library
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: pydantic>=2.7
23
+ Provides-Extra: robot
24
+ Requires-Dist: robotframework>=7.3; extra == 'robot'
25
+ Provides-Extra: templates
26
+ Requires-Dist: jsonschema>=4; extra == 'templates'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # operaton-contracts
30
+
31
+ Pydantic task contracts for Robot Framework packages served as
32
+ [Operaton](https://operaton.org/) (Camunda 7) external tasks, for example by
33
+ [purjo](https://github.com/datakurre/purjo).
34
+
35
+ Documentation: <https://datakurre.github.io/operaton-contracts/>
36
+
37
+ One model per external task topic is the source of truth for what the task
38
+ accepts and returns:
39
+
40
+ - **At runtime** each Robot task validates and normalizes its process
41
+ variables with `Validate Task Input`.
42
+ - **At build time** `operaton-contracts generate` renders one bpmn.io element
43
+ template per topic from the same models, and `operaton-contracts check`
44
+ verifies that the templates, `[tool.purjo.topics]`, and the Robot suites
45
+ agree.
46
+
47
+ ```console
48
+ uv add operaton-contracts # runtime: pydantic + robotframework
49
+ uv add --group dev "operaton-contracts[templates]" # adds jsonschema for validate
50
+ ```
51
+
52
+ ## Contracts
53
+
54
+ ```python
55
+ # OperatonTasks.py
56
+ from datetime import date
57
+ from typing import Any, Literal
58
+
59
+ from pydantic import Field
60
+ from OperatonContracts import TaskContract, template_hints
61
+
62
+
63
+ class RescindStudyRightsInput(TaskContract):
64
+ study_right_ids: list[str] = Field(
65
+ alias="studyRightIds",
66
+ title="Study right IDs",
67
+ min_length=1,
68
+ json_schema_extra=template_hints(value=["${studyRightId}"]),
69
+ )
70
+ cancellation_date: date = Field(
71
+ alias="cancellationDate", title="Cancellation date", strict=False
72
+ )
73
+ dry_run: bool = Field(alias="dryRun", title="Dry run", default=False)
74
+
75
+
76
+ class RescindStudyRightsOutput(TaskContract):
77
+ result: dict[str, Any] = Field(alias="result", title="Result variable")
78
+ ```
79
+
80
+ `TaskContract` is strict, forbids extra fields, and strips strings. Every
81
+ field needs an `alias` (the process variable name) and a `title` (the
82
+ template label). Use `Literal[...]` for choices; `Enum`, `Optional`, and nested
83
+ models are not supported in template inputs. `template_hints(value=...,
84
+ type=...)` sets template-only defaults and property types.
85
+
86
+ ## Robot tasks
87
+
88
+ ```robotframework
89
+ *** Settings ***
90
+ Library OperatonContracts OperatonTasks
91
+
92
+ *** Variables ***
93
+ ${BPMN:TASK} local
94
+ @{studyRightIds} @{EMPTY}
95
+ ${cancellationDate} ${EMPTY}
96
+ ${dryRun} ${False}
97
+
98
+ *** Tasks ***
99
+ Rescind Study Rights
100
+ ${input}= Validate Task Input RescindStudyRightsInput
101
+ Log ${input}[studyRightIds]
102
+ VAR ${result}= ${{{}}} scope=${BPMN:TASK}
103
+ ```
104
+
105
+ `Validate Task Input` reads `${alias}` for every field, validates, and returns
106
+ the values JSON-compatible (dates as `YYYY-MM-DD`), keyed by alias. Declare
107
+ typed suite defaults (`${False}`, `${0}`, `@{EMPTY}`): strict contracts reject
108
+ the string `"0"` or `"false"`. The library imports the contracts module from
109
+ `sys.path`, falling back to the running suite's directory.
110
+
111
+ ## Element templates
112
+
113
+ ```toml
114
+ # pyproject.toml of the robot package
115
+ [tool.operaton-contracts]
116
+ specs = "scripts.element_templates:TEMPLATES" # module:attribute
117
+ icon = "scripts/logo.svg" # optional SVG icon
118
+ reserved-topics = ["legacy.topic"] # optional
119
+ # schema-url = "…" # optional; pinned default
120
+ ```
121
+
122
+ ```python
123
+ # scripts/element_templates.py
124
+ from OperatonContracts.templates import TaskTemplate, TemplateGroup
125
+ from OperatonTasks import RescindStudyRightsInput, RescindStudyRightsOutput
126
+
127
+ TEMPLATES = (
128
+ TaskTemplate(
129
+ topic="study_rights.rescind",
130
+ template_id="org.example.study-rights-rescind",
131
+ name="Rescind Study Rights",
132
+ description="Rescind active study rights.",
133
+ filename="study-rights-rescind.json",
134
+ inputs=RescindStudyRightsInput,
135
+ outputs=RescindStudyRightsOutput,
136
+ groups=(TemplateGroup("main", "Rescission"),),
137
+ input_group="main",
138
+ output_group="main",
139
+ ),
140
+ )
141
+ ```
142
+
143
+ ```console
144
+ operaton-contracts generate # write .operaton/element-templates/*.json
145
+ operaton-contracts check # offline: drift and package consistency
146
+ operaton-contracts validate # against the pinned upstream schema (network)
147
+ ```
148
+
149
+ `check` fails when committed templates differ from the generated ones, when
150
+ specs and `[tool.purjo.topics]` differ, when a topic is reserved or lacks
151
+ `process-variables = false`, or when the suite defining a topic's task lacks a
152
+ typed default for an input, the `Validate Task Input` call, or a
153
+ `VAR … scope=${BPMN:TASK}` for an output. Names are matched the way Robot
154
+ matches them, suites are collected recursively (skipping hidden directories,
155
+ `tests/`, `lib/`, `examples/`, and `test_*.robot`), and a task name defined in
156
+ more than one suite is an error.
157
+
158
+ ## Development
159
+
160
+ ```console
161
+ uv run --group dev --group docs make test check docs # with uv
162
+ devenv shell -- make test check docs # or with devenv
163
+ make build
164
+ ```
165
+
166
+ `make docs-serve` previews the documentation site, which is published to
167
+ GitHub Pages from `main` by `.github/workflows/docs.yml`.
168
+
169
+ ## License
170
+
171
+ Apache License 2.0; see [LICENSE](LICENSE).
172
+
173
+ Releases are published to PyPI by `.github/workflows/release.yml` with
174
+ trusted publishing when a `v*` tag matching the project version is pushed.
@@ -0,0 +1,146 @@
1
+ # operaton-contracts
2
+
3
+ Pydantic task contracts for Robot Framework packages served as
4
+ [Operaton](https://operaton.org/) (Camunda 7) external tasks, for example by
5
+ [purjo](https://github.com/datakurre/purjo).
6
+
7
+ Documentation: <https://datakurre.github.io/operaton-contracts/>
8
+
9
+ One model per external task topic is the source of truth for what the task
10
+ accepts and returns:
11
+
12
+ - **At runtime** each Robot task validates and normalizes its process
13
+ variables with `Validate Task Input`.
14
+ - **At build time** `operaton-contracts generate` renders one bpmn.io element
15
+ template per topic from the same models, and `operaton-contracts check`
16
+ verifies that the templates, `[tool.purjo.topics]`, and the Robot suites
17
+ agree.
18
+
19
+ ```console
20
+ uv add operaton-contracts # runtime: pydantic + robotframework
21
+ uv add --group dev "operaton-contracts[templates]" # adds jsonschema for validate
22
+ ```
23
+
24
+ ## Contracts
25
+
26
+ ```python
27
+ # OperatonTasks.py
28
+ from datetime import date
29
+ from typing import Any, Literal
30
+
31
+ from pydantic import Field
32
+ from OperatonContracts import TaskContract, template_hints
33
+
34
+
35
+ class RescindStudyRightsInput(TaskContract):
36
+ study_right_ids: list[str] = Field(
37
+ alias="studyRightIds",
38
+ title="Study right IDs",
39
+ min_length=1,
40
+ json_schema_extra=template_hints(value=["${studyRightId}"]),
41
+ )
42
+ cancellation_date: date = Field(
43
+ alias="cancellationDate", title="Cancellation date", strict=False
44
+ )
45
+ dry_run: bool = Field(alias="dryRun", title="Dry run", default=False)
46
+
47
+
48
+ class RescindStudyRightsOutput(TaskContract):
49
+ result: dict[str, Any] = Field(alias="result", title="Result variable")
50
+ ```
51
+
52
+ `TaskContract` is strict, forbids extra fields, and strips strings. Every
53
+ field needs an `alias` (the process variable name) and a `title` (the
54
+ template label). Use `Literal[...]` for choices; `Enum`, `Optional`, and nested
55
+ models are not supported in template inputs. `template_hints(value=...,
56
+ type=...)` sets template-only defaults and property types.
57
+
58
+ ## Robot tasks
59
+
60
+ ```robotframework
61
+ *** Settings ***
62
+ Library OperatonContracts OperatonTasks
63
+
64
+ *** Variables ***
65
+ ${BPMN:TASK} local
66
+ @{studyRightIds} @{EMPTY}
67
+ ${cancellationDate} ${EMPTY}
68
+ ${dryRun} ${False}
69
+
70
+ *** Tasks ***
71
+ Rescind Study Rights
72
+ ${input}= Validate Task Input RescindStudyRightsInput
73
+ Log ${input}[studyRightIds]
74
+ VAR ${result}= ${{{}}} scope=${BPMN:TASK}
75
+ ```
76
+
77
+ `Validate Task Input` reads `${alias}` for every field, validates, and returns
78
+ the values JSON-compatible (dates as `YYYY-MM-DD`), keyed by alias. Declare
79
+ typed suite defaults (`${False}`, `${0}`, `@{EMPTY}`): strict contracts reject
80
+ the string `"0"` or `"false"`. The library imports the contracts module from
81
+ `sys.path`, falling back to the running suite's directory.
82
+
83
+ ## Element templates
84
+
85
+ ```toml
86
+ # pyproject.toml of the robot package
87
+ [tool.operaton-contracts]
88
+ specs = "scripts.element_templates:TEMPLATES" # module:attribute
89
+ icon = "scripts/logo.svg" # optional SVG icon
90
+ reserved-topics = ["legacy.topic"] # optional
91
+ # schema-url = "…" # optional; pinned default
92
+ ```
93
+
94
+ ```python
95
+ # scripts/element_templates.py
96
+ from OperatonContracts.templates import TaskTemplate, TemplateGroup
97
+ from OperatonTasks import RescindStudyRightsInput, RescindStudyRightsOutput
98
+
99
+ TEMPLATES = (
100
+ TaskTemplate(
101
+ topic="study_rights.rescind",
102
+ template_id="org.example.study-rights-rescind",
103
+ name="Rescind Study Rights",
104
+ description="Rescind active study rights.",
105
+ filename="study-rights-rescind.json",
106
+ inputs=RescindStudyRightsInput,
107
+ outputs=RescindStudyRightsOutput,
108
+ groups=(TemplateGroup("main", "Rescission"),),
109
+ input_group="main",
110
+ output_group="main",
111
+ ),
112
+ )
113
+ ```
114
+
115
+ ```console
116
+ operaton-contracts generate # write .operaton/element-templates/*.json
117
+ operaton-contracts check # offline: drift and package consistency
118
+ operaton-contracts validate # against the pinned upstream schema (network)
119
+ ```
120
+
121
+ `check` fails when committed templates differ from the generated ones, when
122
+ specs and `[tool.purjo.topics]` differ, when a topic is reserved or lacks
123
+ `process-variables = false`, or when the suite defining a topic's task lacks a
124
+ typed default for an input, the `Validate Task Input` call, or a
125
+ `VAR … scope=${BPMN:TASK}` for an output. Names are matched the way Robot
126
+ matches them, suites are collected recursively (skipping hidden directories,
127
+ `tests/`, `lib/`, `examples/`, and `test_*.robot`), and a task name defined in
128
+ more than one suite is an error.
129
+
130
+ ## Development
131
+
132
+ ```console
133
+ uv run --group dev --group docs make test check docs # with uv
134
+ devenv shell -- make test check docs # or with devenv
135
+ make build
136
+ ```
137
+
138
+ `make docs-serve` previews the documentation site, which is published to
139
+ GitHub Pages from `main` by `.github/workflows/docs.yml`.
140
+
141
+ ## License
142
+
143
+ Apache License 2.0; see [LICENSE](LICENSE).
144
+
145
+ Releases are published to PyPI by `.github/workflows/release.yml` with
146
+ trusted publishing when a `v*` tag matching the project version is pushed.
@@ -0,0 +1,72 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "operaton-contracts"
7
+ version = "0.1.0"
8
+ description = "Pydantic task contracts, runtime validation, and generated element templates for Operaton external tasks, with optional Robot Framework support"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.12"
13
+ dependencies = [
14
+ "pydantic>=2.7",
15
+ ]
16
+ keywords = ["operaton", "camunda", "bpmn", "robotframework", "purjo", "element-templates"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Framework :: Robot Framework",
20
+ "Framework :: Robot Framework :: Library",
21
+ "Framework :: Pydantic :: 2",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Typing :: Typed",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://datakurre.github.io/operaton-contracts/"
30
+ Documentation = "https://datakurre.github.io/operaton-contracts/"
31
+ Repository = "https://github.com/datakurre/operaton-contracts"
32
+ Issues = "https://github.com/datakurre/operaton-contracts/issues"
33
+ Changelog = "https://github.com/datakurre/operaton-contracts/blob/main/CHANGELOG.md"
34
+
35
+ [project.optional-dependencies]
36
+ robot = ["robotframework>=7.3"]
37
+ templates = ["jsonschema>=4"]
38
+
39
+ [project.scripts]
40
+ operaton-contracts = "OperatonContracts.cli:main"
41
+
42
+ [dependency-groups]
43
+ test = [
44
+ "pytest",
45
+ ]
46
+ dev = [
47
+ "black",
48
+ "jsonschema>=4",
49
+ "mypy",
50
+ "pytest",
51
+ "pytest-cov",
52
+ "robotframework>=7.3",
53
+ "types-jsonschema",
54
+ ]
55
+ docs = [
56
+ "mkdocs>=1.6,<2",
57
+ "mkdocs-material",
58
+ ]
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = ["src/OperatonContracts"]
62
+
63
+ [tool.pytest.ini_options]
64
+ testpaths = ["tests"]
65
+ addopts = "--cov=OperatonContracts --cov-branch --cov-report=term-missing --cov-fail-under=100"
66
+
67
+ [tool.mypy]
68
+ strict = true
69
+ mypy_path = "src"
70
+
71
+ [tool.hatch.build.targets.sdist]
72
+ include = ["src", "tests", "README.md", "CHANGELOG.md", "LICENSE"]
@@ -0,0 +1,61 @@
1
+ """Engine-facing Operaton external task contracts.
2
+
3
+ A worker declares one ``TaskContract`` input and output model per external
4
+ task topic. Element templates are generated from those models (see
5
+ ``OperatonContracts.templates`` and the ``operaton-contracts`` command), and
6
+ tasks validate their variables against them at runtime with
7
+ ``validate_input`` and ``validate_output``.
8
+
9
+ With the ``robot`` extra, the package is also a Robot Framework library:
10
+
11
+ *** Settings ***
12
+ Library OperatonContracts OperatonTasks
13
+
14
+ *** Tasks ***
15
+ Rescind Study Rights
16
+ ${input}= Validate Task Input RescindStudyRightsInput
17
+
18
+ The library class is imported lazily, so ``import OperatonContracts`` never
19
+ loads Robot Framework.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ from typing import TYPE_CHECKING
25
+ from typing import Any
26
+
27
+ from OperatonContracts.contracts import TEMPLATE_KEY
28
+ from OperatonContracts.contracts import TaskContract
29
+ from OperatonContracts.contracts import load_contract
30
+ from OperatonContracts.contracts import template_hints
31
+ from OperatonContracts.contracts import validate_input
32
+ from OperatonContracts.contracts import validate_output
33
+
34
+ if TYPE_CHECKING:
35
+ from OperatonContracts.robotframework import OperatonContracts
36
+
37
+ __all__ = [
38
+ "TEMPLATE_KEY",
39
+ "OperatonContracts",
40
+ "TaskContract",
41
+ "load_contract",
42
+ "template_hints",
43
+ "validate_input",
44
+ "validate_output",
45
+ ]
46
+
47
+
48
+ def __getattr__(name: str) -> Any:
49
+ # Robot Framework finds the library class with getattr(module, name).
50
+ if name == "OperatonContracts":
51
+ try:
52
+ from OperatonContracts.robotframework import OperatonContracts
53
+ except ModuleNotFoundError as error:
54
+ if error.name is None or not error.name.startswith("robot"):
55
+ raise
56
+ raise ImportError(
57
+ "The OperatonContracts Robot Framework library needs Robot "
58
+ "Framework: install operaton-contracts[robot]"
59
+ ) from error
60
+ return OperatonContracts
61
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,3 @@
1
+ from OperatonContracts.cli import main
2
+
3
+ raise SystemExit(main())