oleander-kedro 0.0.1__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.
- oleander_kedro-0.0.1/.gitignore +7 -0
- oleander_kedro-0.0.1/.python-version +1 -0
- oleander_kedro-0.0.1/PKG-INFO +150 -0
- oleander_kedro-0.0.1/README.md +139 -0
- oleander_kedro-0.0.1/pyproject.toml +32 -0
- oleander_kedro-0.0.1/src/oleander_kedro/__init__.py +13 -0
- oleander_kedro-0.0.1/src/oleander_kedro/decorators.py +157 -0
- oleander_kedro-0.0.1/src/oleander_kedro/errors.py +5 -0
- oleander_kedro-0.0.1/src/oleander_kedro/py.typed +0 -0
- oleander_kedro-0.0.1/tests/fixtures/cron.json +51 -0
- oleander_kedro-0.0.1/tests/test_declarations.py +185 -0
- oleander_kedro-0.0.1/tests/test_public_package.py +85 -0
- oleander_kedro-0.0.1/uv.lock +1077 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: oleander-kedro
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Declare Oleander metadata on ordinary Kedro pipelines
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: croniter<7,>=6
|
|
7
|
+
Requires-Dist: email-validator<3,>=2.3
|
|
8
|
+
Requires-Dist: kedro<1.8,>=1.7
|
|
9
|
+
Requires-Dist: tzdata>=2025.2
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# oleander-kedro
|
|
13
|
+
|
|
14
|
+
Public Python package for declaring Oleander metadata on standard Kedro pipelines.
|
|
15
|
+
Requires **Python >=3.10** and **Kedro >=1.7,<1.8**. Intended for distribution on
|
|
16
|
+
PyPI; it has no Oleander SDK or cloud dependencies.
|
|
17
|
+
|
|
18
|
+
## Author pipelines
|
|
19
|
+
|
|
20
|
+
Add this package to your Kedro project's dependencies, then decorate pipeline
|
|
21
|
+
factories:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from kedro.pipeline import node, pipeline
|
|
25
|
+
from oleander_kedro import run_as, schedule
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@run_as("sales-pipeline@iam.application.oleander.dev")
|
|
29
|
+
@schedule(cron="0 * * * *", timezone="UTC")
|
|
30
|
+
def create_pipeline(**kwargs):
|
|
31
|
+
return pipeline([node(print, "params:message", None, name="print_message")])
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Register pipelines using the usual `register_pipelines()` function, optionally
|
|
35
|
+
calling `find_pipelines(raise_errors=True)`. Authors use conventional Kedro:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
uv run kedro run --pipelines orders
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This package installs **no command or Kedro hooks**. Normal `kedro run` executes
|
|
42
|
+
ordinary Kedro pipelines without applying schedules, selecting identities, or
|
|
43
|
+
injecting intervals. Kedro's catalog and parameter behavior remains unchanged.
|
|
44
|
+
Decorators still validate their arguments and factory return types; invalid
|
|
45
|
+
declarations fail early.
|
|
46
|
+
|
|
47
|
+
## Declarations
|
|
48
|
+
|
|
49
|
+
- `@schedule(cron=..., timezone=...)` requires basic five-field cron syntax:
|
|
50
|
+
numeric fields with `*`, `,`, `-`, and `/`, plus an explicit IANA timezone.
|
|
51
|
+
For example, `0 9 * * 1-5` runs on weekdays at 09:00. Named months/weekdays
|
|
52
|
+
and extensions such as `L5`, `L`, `W`, `#`, `H`, `R`, and `?` are rejected
|
|
53
|
+
at declaration time, as are macros, seconds, and year expressions. Whitespace
|
|
54
|
+
is normalized. Croniter validates field values and expression structure;
|
|
55
|
+
its day-of-month/day-of-week convention is OR. Oleander's scheduler must
|
|
56
|
+
use the same interpretation.
|
|
57
|
+
Ranges must be ascending: use `22-23,0-2` instead of `22-2` for hours that
|
|
58
|
+
cross midnight. List entries must not repeat or overlap values, including
|
|
59
|
+
overlaps introduced by steps. Sunday may be `0` or `7`, but `0,7` is a
|
|
60
|
+
duplicate. A single full-week range such as `0-7` remains valid.
|
|
61
|
+
- `@run_as(email)` requires one email address. UUIDs, principal names, display
|
|
62
|
+
names, and address lists are rejected. Surrounding whitespace is stripped and
|
|
63
|
+
the address is lowercased and normalized to match Oleander's email convention.
|
|
64
|
+
Validation checks syntax locally, without DNS queries or delivery checks.
|
|
65
|
+
It declares the desired principal for **scheduled** execution only. It grants
|
|
66
|
+
no permissions and never changes the identity of a manual run. The example
|
|
67
|
+
application-principal email is a placeholder; it need not exist for local tests.
|
|
68
|
+
- Either decorator order works. Duplicate declarations are errors. Factories
|
|
69
|
+
preserve their signatures, names, and docstrings and return ordinary Kedro
|
|
70
|
+
`Pipeline` objects.
|
|
71
|
+
- Metadata belongs to the exact returned object. Copying, composing, filtering,
|
|
72
|
+
or namespacing a pipeline does not carry declarations forward. Decorate the
|
|
73
|
+
factory returning the final scheduled pipeline.
|
|
74
|
+
|
|
75
|
+
Oleander's private discovery/runtime validates the complete registry: pipelines
|
|
76
|
+
must declare both decorators or neither, and the same scheduled object cannot
|
|
77
|
+
appear under multiple registry names. Undecorated pipelines are discoverable
|
|
78
|
+
and can be run manually. Conventional Kedro does not enforce these Oleander
|
|
79
|
+
registry rules.
|
|
80
|
+
|
|
81
|
+
The deployment service must resolve the declared email to an existing principal
|
|
82
|
+
within the organization linked to the GitHub installation, authorize the
|
|
83
|
+
repository-to-principal binding, and store the resolved UUID with the deployment.
|
|
84
|
+
Missing, ambiguous, or unauthorized principals must fail deployment. Scheduled
|
|
85
|
+
runs use that stored UUID so email changes cannot silently change the execution
|
|
86
|
+
identity. This resolution and authorization belongs to Oleander's service; neither
|
|
87
|
+
Python package performs it. Principal membership and access must be rechecked at
|
|
88
|
+
execution time.
|
|
89
|
+
|
|
90
|
+
## Metadata API
|
|
91
|
+
|
|
92
|
+
Private platform tools read metadata through the public, side-effect-free API:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from oleander_kedro import get_pipeline_metadata
|
|
96
|
+
|
|
97
|
+
metadata = get_pipeline_metadata(create_pipeline())
|
|
98
|
+
print(metadata.schedule.cron)
|
|
99
|
+
print(metadata.run_as)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The returned `Declaration` and nested `Schedule` are frozen dataclasses.
|
|
103
|
+
`Declaration.run_as` contains the normalized email string.
|
|
104
|
+
Undecorated pipelines return a `Declaration` with both fields set to `None`.
|
|
105
|
+
`ConfigurationError` subclasses `ValueError`.
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
From this directory:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
uv sync --locked
|
|
113
|
+
uv run pytest
|
|
114
|
+
uv run ruff check .
|
|
115
|
+
uv run ruff format --check .
|
|
116
|
+
uv build
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`.python-version` selects Python 3.10. Tests cover declaration validation and
|
|
120
|
+
real `kedro run` invocations with plain Python nodes and no SDK credentials.
|
|
121
|
+
|
|
122
|
+
From the repository root, also run the cross-language cron compatibility tests:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
uv sync --locked --project kedro/oleander-kedro-cli
|
|
126
|
+
yarn exec vitest run workflows/kedro/manifest-compatibility.test.ts
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
These tests require the repository's Node dependencies and `uv`. They use the
|
|
130
|
+
same cron fixtures as the Python tests, generate manifests with the actual
|
|
131
|
+
Python decorators and CLI, and validate them with the TypeScript worker's
|
|
132
|
+
`parseManifest()`. No cloud services are involved.
|
|
133
|
+
|
|
134
|
+
The separate [private CLI project](../oleander-kedro-cli/README.md) depends on this
|
|
135
|
+
package and owns discovery, runtime interval injection, and the `oleander-kedro`
|
|
136
|
+
command.
|
|
137
|
+
It is not part of this distribution.
|
|
138
|
+
|
|
139
|
+
## Publishing
|
|
140
|
+
|
|
141
|
+
The [publishing workflow](../../.github/workflows/publish-oleander-kedro.yml)
|
|
142
|
+
builds and publishes this extension when changes under `kedro/oleander-kedro-ext/`
|
|
143
|
+
reach `main`. It uses the existing GitHub Actions `PYPI_TOKEN` secret and skips
|
|
144
|
+
already-published artifacts, following the Python SDK's release pattern.
|
|
145
|
+
|
|
146
|
+
To release a new version, update `version` in `pyproject.toml` and refresh this
|
|
147
|
+
project's `uv.lock`. Update the private CLI's exact extension dependency and its
|
|
148
|
+
lockfile to the same version, then merge to `main`. The builder release workflow
|
|
149
|
+
also rebuilds its bundled packages when these directories change. The private
|
|
150
|
+
CLI is not published to PyPI.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# oleander-kedro
|
|
2
|
+
|
|
3
|
+
Public Python package for declaring Oleander metadata on standard Kedro pipelines.
|
|
4
|
+
Requires **Python >=3.10** and **Kedro >=1.7,<1.8**. Intended for distribution on
|
|
5
|
+
PyPI; it has no Oleander SDK or cloud dependencies.
|
|
6
|
+
|
|
7
|
+
## Author pipelines
|
|
8
|
+
|
|
9
|
+
Add this package to your Kedro project's dependencies, then decorate pipeline
|
|
10
|
+
factories:
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from kedro.pipeline import node, pipeline
|
|
14
|
+
from oleander_kedro import run_as, schedule
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@run_as("sales-pipeline@iam.application.oleander.dev")
|
|
18
|
+
@schedule(cron="0 * * * *", timezone="UTC")
|
|
19
|
+
def create_pipeline(**kwargs):
|
|
20
|
+
return pipeline([node(print, "params:message", None, name="print_message")])
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Register pipelines using the usual `register_pipelines()` function, optionally
|
|
24
|
+
calling `find_pipelines(raise_errors=True)`. Authors use conventional Kedro:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
uv run kedro run --pipelines orders
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This package installs **no command or Kedro hooks**. Normal `kedro run` executes
|
|
31
|
+
ordinary Kedro pipelines without applying schedules, selecting identities, or
|
|
32
|
+
injecting intervals. Kedro's catalog and parameter behavior remains unchanged.
|
|
33
|
+
Decorators still validate their arguments and factory return types; invalid
|
|
34
|
+
declarations fail early.
|
|
35
|
+
|
|
36
|
+
## Declarations
|
|
37
|
+
|
|
38
|
+
- `@schedule(cron=..., timezone=...)` requires basic five-field cron syntax:
|
|
39
|
+
numeric fields with `*`, `,`, `-`, and `/`, plus an explicit IANA timezone.
|
|
40
|
+
For example, `0 9 * * 1-5` runs on weekdays at 09:00. Named months/weekdays
|
|
41
|
+
and extensions such as `L5`, `L`, `W`, `#`, `H`, `R`, and `?` are rejected
|
|
42
|
+
at declaration time, as are macros, seconds, and year expressions. Whitespace
|
|
43
|
+
is normalized. Croniter validates field values and expression structure;
|
|
44
|
+
its day-of-month/day-of-week convention is OR. Oleander's scheduler must
|
|
45
|
+
use the same interpretation.
|
|
46
|
+
Ranges must be ascending: use `22-23,0-2` instead of `22-2` for hours that
|
|
47
|
+
cross midnight. List entries must not repeat or overlap values, including
|
|
48
|
+
overlaps introduced by steps. Sunday may be `0` or `7`, but `0,7` is a
|
|
49
|
+
duplicate. A single full-week range such as `0-7` remains valid.
|
|
50
|
+
- `@run_as(email)` requires one email address. UUIDs, principal names, display
|
|
51
|
+
names, and address lists are rejected. Surrounding whitespace is stripped and
|
|
52
|
+
the address is lowercased and normalized to match Oleander's email convention.
|
|
53
|
+
Validation checks syntax locally, without DNS queries or delivery checks.
|
|
54
|
+
It declares the desired principal for **scheduled** execution only. It grants
|
|
55
|
+
no permissions and never changes the identity of a manual run. The example
|
|
56
|
+
application-principal email is a placeholder; it need not exist for local tests.
|
|
57
|
+
- Either decorator order works. Duplicate declarations are errors. Factories
|
|
58
|
+
preserve their signatures, names, and docstrings and return ordinary Kedro
|
|
59
|
+
`Pipeline` objects.
|
|
60
|
+
- Metadata belongs to the exact returned object. Copying, composing, filtering,
|
|
61
|
+
or namespacing a pipeline does not carry declarations forward. Decorate the
|
|
62
|
+
factory returning the final scheduled pipeline.
|
|
63
|
+
|
|
64
|
+
Oleander's private discovery/runtime validates the complete registry: pipelines
|
|
65
|
+
must declare both decorators or neither, and the same scheduled object cannot
|
|
66
|
+
appear under multiple registry names. Undecorated pipelines are discoverable
|
|
67
|
+
and can be run manually. Conventional Kedro does not enforce these Oleander
|
|
68
|
+
registry rules.
|
|
69
|
+
|
|
70
|
+
The deployment service must resolve the declared email to an existing principal
|
|
71
|
+
within the organization linked to the GitHub installation, authorize the
|
|
72
|
+
repository-to-principal binding, and store the resolved UUID with the deployment.
|
|
73
|
+
Missing, ambiguous, or unauthorized principals must fail deployment. Scheduled
|
|
74
|
+
runs use that stored UUID so email changes cannot silently change the execution
|
|
75
|
+
identity. This resolution and authorization belongs to Oleander's service; neither
|
|
76
|
+
Python package performs it. Principal membership and access must be rechecked at
|
|
77
|
+
execution time.
|
|
78
|
+
|
|
79
|
+
## Metadata API
|
|
80
|
+
|
|
81
|
+
Private platform tools read metadata through the public, side-effect-free API:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from oleander_kedro import get_pipeline_metadata
|
|
85
|
+
|
|
86
|
+
metadata = get_pipeline_metadata(create_pipeline())
|
|
87
|
+
print(metadata.schedule.cron)
|
|
88
|
+
print(metadata.run_as)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The returned `Declaration` and nested `Schedule` are frozen dataclasses.
|
|
92
|
+
`Declaration.run_as` contains the normalized email string.
|
|
93
|
+
Undecorated pipelines return a `Declaration` with both fields set to `None`.
|
|
94
|
+
`ConfigurationError` subclasses `ValueError`.
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
From this directory:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
uv sync --locked
|
|
102
|
+
uv run pytest
|
|
103
|
+
uv run ruff check .
|
|
104
|
+
uv run ruff format --check .
|
|
105
|
+
uv build
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`.python-version` selects Python 3.10. Tests cover declaration validation and
|
|
109
|
+
real `kedro run` invocations with plain Python nodes and no SDK credentials.
|
|
110
|
+
|
|
111
|
+
From the repository root, also run the cross-language cron compatibility tests:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
uv sync --locked --project kedro/oleander-kedro-cli
|
|
115
|
+
yarn exec vitest run workflows/kedro/manifest-compatibility.test.ts
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
These tests require the repository's Node dependencies and `uv`. They use the
|
|
119
|
+
same cron fixtures as the Python tests, generate manifests with the actual
|
|
120
|
+
Python decorators and CLI, and validate them with the TypeScript worker's
|
|
121
|
+
`parseManifest()`. No cloud services are involved.
|
|
122
|
+
|
|
123
|
+
The separate [private CLI project](../oleander-kedro-cli/README.md) depends on this
|
|
124
|
+
package and owns discovery, runtime interval injection, and the `oleander-kedro`
|
|
125
|
+
command.
|
|
126
|
+
It is not part of this distribution.
|
|
127
|
+
|
|
128
|
+
## Publishing
|
|
129
|
+
|
|
130
|
+
The [publishing workflow](../../.github/workflows/publish-oleander-kedro.yml)
|
|
131
|
+
builds and publishes this extension when changes under `kedro/oleander-kedro-ext/`
|
|
132
|
+
reach `main`. It uses the existing GitHub Actions `PYPI_TOKEN` secret and skips
|
|
133
|
+
already-published artifacts, following the Python SDK's release pattern.
|
|
134
|
+
|
|
135
|
+
To release a new version, update `version` in `pyproject.toml` and refresh this
|
|
136
|
+
project's `uv.lock`. Update the private CLI's exact extension dependency and its
|
|
137
|
+
lockfile to the same version, then merge to `main`. The builder release workflow
|
|
138
|
+
also rebuilds its bundled packages when these directories change. The private
|
|
139
|
+
CLI is not published to PyPI.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "oleander-kedro"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Declare Oleander metadata on ordinary Kedro pipelines"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"kedro>=1.7,<1.8",
|
|
13
|
+
"croniter>=6,<7",
|
|
14
|
+
"email-validator>=2.3,<3",
|
|
15
|
+
"tzdata>=2025.2",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[dependency-groups]
|
|
19
|
+
dev = ["pytest>=8,<9", "pytest-socket>=0.7,<1", "ruff>=0.12,<1"]
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/oleander_kedro"]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
testpaths = ["tests"]
|
|
26
|
+
addopts = "--disable-socket"
|
|
27
|
+
|
|
28
|
+
[tool.ruff]
|
|
29
|
+
target-version = "py310"
|
|
30
|
+
|
|
31
|
+
[tool.ruff.lint]
|
|
32
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Oleander metadata for ordinary Kedro pipelines."""
|
|
2
|
+
|
|
3
|
+
from .decorators import Declaration, Schedule, get_pipeline_metadata, run_as, schedule
|
|
4
|
+
from .errors import ConfigurationError
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"ConfigurationError",
|
|
8
|
+
"Declaration",
|
|
9
|
+
"Schedule",
|
|
10
|
+
"get_pipeline_metadata",
|
|
11
|
+
"run_as",
|
|
12
|
+
"schedule",
|
|
13
|
+
]
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Metadata on ordinary Kedro pipelines, without an alternate DAG model."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from dataclasses import dataclass, replace
|
|
6
|
+
from functools import wraps
|
|
7
|
+
from typing import ParamSpec
|
|
8
|
+
from weakref import WeakKeyDictionary
|
|
9
|
+
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
|
10
|
+
|
|
11
|
+
from croniter import croniter
|
|
12
|
+
from email_validator import EmailNotValidError, validate_email
|
|
13
|
+
from kedro.pipeline import Pipeline
|
|
14
|
+
|
|
15
|
+
from .errors import ConfigurationError
|
|
16
|
+
|
|
17
|
+
P = ParamSpec("P")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class Schedule:
|
|
22
|
+
cron: str
|
|
23
|
+
timezone: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class Declaration:
|
|
28
|
+
schedule: Schedule | None = None
|
|
29
|
+
run_as: str | None = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
_declarations: WeakKeyDictionary[Pipeline, Declaration] = WeakKeyDictionary()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_pipeline_metadata(pipeline: Pipeline) -> Declaration:
|
|
36
|
+
"""Return immutable declarations attached to this exact pipeline object.
|
|
37
|
+
|
|
38
|
+
Undecorated and transformed pipelines have empty declarations. Reading
|
|
39
|
+
metadata never validates a registry, schedules work, or selects credentials.
|
|
40
|
+
"""
|
|
41
|
+
# Object association avoids accidental inheritance through copy/deepcopy,
|
|
42
|
+
# leaves Pipeline itself untouched, and does not keep pipelines alive.
|
|
43
|
+
return _declarations.get(pipeline, Declaration())
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _decorate(
|
|
47
|
+
field: str, value: object
|
|
48
|
+
) -> Callable[[Callable[P, Pipeline]], Callable[P, Pipeline]]:
|
|
49
|
+
def decorate(factory: Callable[P, Pipeline]) -> Callable[P, Pipeline]:
|
|
50
|
+
@wraps(factory)
|
|
51
|
+
def wrapped(*args: P.args, **kwargs: P.kwargs) -> Pipeline:
|
|
52
|
+
result = factory(*args, **kwargs)
|
|
53
|
+
if not isinstance(result, Pipeline):
|
|
54
|
+
raise ConfigurationError(
|
|
55
|
+
f"{factory.__qualname__} must return a Kedro Pipeline"
|
|
56
|
+
)
|
|
57
|
+
metadata = get_pipeline_metadata(result)
|
|
58
|
+
if getattr(metadata, field) is not None:
|
|
59
|
+
raise ConfigurationError(
|
|
60
|
+
f"{factory.__qualname__} declares {field} more than once"
|
|
61
|
+
)
|
|
62
|
+
_declarations[result] = replace(metadata, **{field: value})
|
|
63
|
+
return result
|
|
64
|
+
|
|
65
|
+
return wrapped
|
|
66
|
+
|
|
67
|
+
return decorate
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _validate_cron_fields(expression: str) -> None:
|
|
71
|
+
"""Reject numeric forms that the worker's cron-parser cannot accept.
|
|
72
|
+
|
|
73
|
+
Check each list entry before croniter deduplicates values or wraps ranges.
|
|
74
|
+
"""
|
|
75
|
+
bounds = ((0, 59), (0, 23), (1, 31), (1, 12), (0, 7))
|
|
76
|
+
for index, (field, (minimum, maximum)) in enumerate(
|
|
77
|
+
zip(expression.split(), bounds, strict=True)
|
|
78
|
+
):
|
|
79
|
+
seen: set[int] = set()
|
|
80
|
+
for item in field.split(","):
|
|
81
|
+
if re.fullmatch(r"(?:\*|[0-9]+(?:-[0-9]+)?)(?:/[0-9]+)?", item) is None:
|
|
82
|
+
raise ConfigurationError("Invalid cron expression")
|
|
83
|
+
base, _, interval = item.partition("/")
|
|
84
|
+
step = int(interval) if interval else 1
|
|
85
|
+
if base == "*":
|
|
86
|
+
start, end = minimum, maximum
|
|
87
|
+
else:
|
|
88
|
+
first, _, last = base.partition("-")
|
|
89
|
+
start = int(first)
|
|
90
|
+
end = maximum if interval else start
|
|
91
|
+
if last:
|
|
92
|
+
end = int(last)
|
|
93
|
+
if start > end:
|
|
94
|
+
raise ConfigurationError(
|
|
95
|
+
"cron ranges must be ascending; split wrapping ranges "
|
|
96
|
+
"into a comma-separated list"
|
|
97
|
+
)
|
|
98
|
+
if start < minimum or end > maximum or step < 1:
|
|
99
|
+
raise ConfigurationError("Invalid cron expression")
|
|
100
|
+
# Sunday may be 0 or 7. Deduplicate within one range (e.g. 0-7),
|
|
101
|
+
# but reject any overlap between separate comma-separated entries.
|
|
102
|
+
values = {
|
|
103
|
+
value % 7 if index == 4 else value
|
|
104
|
+
for value in range(start, end + 1, step)
|
|
105
|
+
}
|
|
106
|
+
if seen.intersection(values):
|
|
107
|
+
raise ConfigurationError(
|
|
108
|
+
"cron fields must not contain duplicate values "
|
|
109
|
+
"or overlapping list entries"
|
|
110
|
+
)
|
|
111
|
+
seen.update(values)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def schedule(
|
|
115
|
+
*, cron: str, timezone: str
|
|
116
|
+
) -> Callable[[Callable[P, Pipeline]], Callable[P, Pipeline]]:
|
|
117
|
+
"""Declare basic numeric five-field cron in an explicit IANA timezone."""
|
|
118
|
+
if not isinstance(cron, str) or len(cron.split()) != 5:
|
|
119
|
+
raise ConfigurationError("cron must be a five-field expression")
|
|
120
|
+
expression = " ".join(cron.split())
|
|
121
|
+
if re.fullmatch(r"[0-9*/,\- ]+", expression) is None:
|
|
122
|
+
raise ConfigurationError(
|
|
123
|
+
"cron supports only numeric fields and the operators *, /, , and -"
|
|
124
|
+
)
|
|
125
|
+
_validate_cron_fields(expression)
|
|
126
|
+
if not croniter.is_valid(expression):
|
|
127
|
+
raise ConfigurationError("Invalid cron expression")
|
|
128
|
+
if not isinstance(timezone, str):
|
|
129
|
+
raise ConfigurationError("timezone must be an IANA timezone name")
|
|
130
|
+
try:
|
|
131
|
+
ZoneInfo(timezone)
|
|
132
|
+
except (ValueError, ZoneInfoNotFoundError) as exc:
|
|
133
|
+
raise ConfigurationError("timezone must be an IANA timezone name") from exc
|
|
134
|
+
return _decorate("schedule", Schedule(expression, timezone))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def run_as(
|
|
138
|
+
email: str,
|
|
139
|
+
) -> Callable[[Callable[P, Pipeline]], Callable[P, Pipeline]]:
|
|
140
|
+
"""Declare a principal email for scheduled runs, with offline validation.
|
|
141
|
+
|
|
142
|
+
Oleander resolves and authorizes the email within the deployment organization.
|
|
143
|
+
This declaration never selects credentials or changes manual-run identity.
|
|
144
|
+
"""
|
|
145
|
+
if not isinstance(email, str):
|
|
146
|
+
raise ConfigurationError("run_as requires a valid principal email address")
|
|
147
|
+
try:
|
|
148
|
+
# Match Oleander's case-insensitive email identity convention. Application
|
|
149
|
+
# principals need not have mailboxes; never perform DNS or delivery checks.
|
|
150
|
+
normalized = validate_email(
|
|
151
|
+
email.strip().lower(), check_deliverability=False
|
|
152
|
+
).normalized
|
|
153
|
+
except EmailNotValidError as exc:
|
|
154
|
+
raise ConfigurationError(
|
|
155
|
+
"run_as requires a valid principal email address"
|
|
156
|
+
) from exc
|
|
157
|
+
return _decorate("run_as", normalized)
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"accepted": [
|
|
3
|
+
"* * * * *",
|
|
4
|
+
"0 * * * *",
|
|
5
|
+
"0 9 * * 1-5",
|
|
6
|
+
"*/15 * * * *",
|
|
7
|
+
"0,30 9-17/2 1,15 1-12 0,6",
|
|
8
|
+
" \t0 9\n* * 1-5 ",
|
|
9
|
+
"0 22-23,0-2 * * *",
|
|
10
|
+
"55-59,0-5 * * * *",
|
|
11
|
+
"0 0 28-31,1-3 * *",
|
|
12
|
+
"0 0 * 11-12,1-2 *",
|
|
13
|
+
"0 0 * * 5-6,0-1",
|
|
14
|
+
"0 0 * * 0",
|
|
15
|
+
"0 0 * * 7",
|
|
16
|
+
"0 0 * * 0-7",
|
|
17
|
+
"0 0 * * 1-7",
|
|
18
|
+
"0 0 * * 6-7",
|
|
19
|
+
"0 0 * * 0-7/2",
|
|
20
|
+
"0 0 * * 0-7/7",
|
|
21
|
+
"0-10/2,1-9/2 * * * *",
|
|
22
|
+
"0-10/2,3 * * * *",
|
|
23
|
+
"5/15 * * * *",
|
|
24
|
+
"*/2,1-59/2 * * * *"
|
|
25
|
+
],
|
|
26
|
+
"duplicates": [
|
|
27
|
+
"0,30 9-17/2 1,15 1-12 0,7",
|
|
28
|
+
"0 0 * * 7,0",
|
|
29
|
+
"0,0 * * * *",
|
|
30
|
+
"0 9,9 * * *",
|
|
31
|
+
"0 0 1,1 * *",
|
|
32
|
+
"0 0 * 1,1 *",
|
|
33
|
+
"0 0 * * 1,1",
|
|
34
|
+
"0-10,5 * * * *",
|
|
35
|
+
"0-10,5-15 * * * *",
|
|
36
|
+
"*/15,30 * * * *",
|
|
37
|
+
"*,0 * * * *",
|
|
38
|
+
"0 0 * * 0,6-7",
|
|
39
|
+
"0 0 * * 0-6,7",
|
|
40
|
+
"0 0 * * *,7"
|
|
41
|
+
],
|
|
42
|
+
"wrapping": [
|
|
43
|
+
"55-5 * * * *",
|
|
44
|
+
"0 22-2 * * *",
|
|
45
|
+
"0 22-2/2 * * *",
|
|
46
|
+
"0 0 28-3 * *",
|
|
47
|
+
"0 0 * 11-2 *",
|
|
48
|
+
"0 0 * * 5-1",
|
|
49
|
+
"0 0 * * 7-0"
|
|
50
|
+
]
|
|
51
|
+
}
|