continuo-python-runtime 0.12.0__py3-none-any.whl → 0.14.0__py3-none-any.whl

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.
@@ -1,25 +1,27 @@
1
1
  continuo_python_runtime/__init__.py,sha256=otNaXEPsTtRXJV5FLtDUsFO8VD4OC-MLAzwhtimHfOE,70
2
- continuo_python_runtime/cli.py,sha256=2FfzvorKZ0RcWkdn_Nb6TpGqO7CYfmjfqLZs-3dcr9Q,6117
2
+ continuo_python_runtime/cli.py,sha256=cBrtT5FfOscsPsqBS0HhYYAC-GXCN8pqqBq_1wAmwYI,11331
3
3
  continuo_python_runtime/closure.py,sha256=6e-IAQp8Lieb0bGKP1F6JE4TgVBJ_COTGXRUult2xeI,12991
4
4
  continuo_python_runtime/conform.py,sha256=a9CKCA-gT9Zerzr6c5H8aByTFOUd6uBMo02sNKSDnXg,9199
5
- continuo_python_runtime/content_check.py,sha256=7tQAalRbgNZR54yyWZ51SvkmLjKgprEZQy9NRH75pCw,2956
5
+ continuo_python_runtime/content_check.py,sha256=FbngEt-lEwpfxO-qrhsDWXbBignmpP3ATLQ4hdkcWR4,2972
6
6
  continuo_python_runtime/context.py,sha256=K-9XXYlQ4OZ250rCOq6EJNq7fg_D5sK6tOcu7DLZfVg,1856
7
7
  continuo_python_runtime/csv_loader.py,sha256=a5Hwu-YIzIiko8X1_vqShsnzjs2-OsKEUSCHLXg_dio,3346
8
8
  continuo_python_runtime/csv_source.py,sha256=7g8Tu6ieiJLvWH4Ep4nwYlOdGkjeePr12K5UHuO8TNc,4136
9
9
  continuo_python_runtime/errors.py,sha256=WCqMMbuy5iXMB-FUzbVmB6AuUbjU95y2iyGGv8zj-LU,1361
10
- continuo_python_runtime/harness.py,sha256=N0nFJp7IgJwXFt-hyXIX40GxqGZrSDgb02X6WF8c1pg,17459
10
+ continuo_python_runtime/harness.py,sha256=CxDXcVcBWK3J70rwtzY_1ytucjFBThTfY3-9oONeiHk,18102
11
11
  continuo_python_runtime/hash_inputs.py,sha256=lKCiCFhfeE80o030JfjPosonEbr_4zWK7CsEgM_g0FM,2376
12
- continuo_python_runtime/hashing.py,sha256=zqP4vFOAflIReZcvvQweRCEfOZe-oThjLQEFdBMgsrI,3591
12
+ continuo_python_runtime/hashing.py,sha256=naBygHNmiPiJi6K6ZWBYdr21vw2ja_-A8qQF7vJ7iSs,3230
13
13
  continuo_python_runtime/lint.py,sha256=Q8G-AOv6hx0d9hVXAJ5xpBvMZZpNaWRsoj9ES0NxsBg,21575
14
+ continuo_python_runtime/packages.py,sha256=pFADmg7em7_q42ijKIDqk1BTkuYm-xwcLz5eE9M_ZmI,2080
14
15
  continuo_python_runtime/shape.py,sha256=C-5ClSxPYgoO9pUiGqw7pCnmlBbsEl-sIm7Twbf-H4o,3693
15
16
  continuo_python_runtime/types.py,sha256=_ssxNE2Lq5782n9_Ihs-u_6ybCCy8XaL6iYbE35tBug,5057
16
17
  continuo_python_runtime/contract/__init__.py,sha256=S79x6j_P0CmaSuCGzeWoK1U0507KvD2MZXwQl9DFWMM,37
17
- continuo_python_runtime/contract/kinds.py,sha256=D-mM9oq4GeGFXlfpjRjLuGVIMDSwqBDpNBo5DSHi9oM,5524
18
- continuo_python_runtime/contract/loader.py,sha256=pKDYyZvJP5h_NV3rWM5XJPAti2oNHOZUJGsh4I4_WMI,21184
19
- continuo_python_runtime/contract/merge.py,sha256=c22GOUSf8Yspent73GZ1eMMYZRv7987BFpt8m2jnWaw,7539
20
- continuo_python_runtime/contract/model.py,sha256=fWV1LWGTZwPmuwXhF4bzO1640ArnqE3ZzYn_nPSzP68,1507
21
- continuo_python_runtime/contract/paths.py,sha256=h48DbhFHGEf-PHvnaYy1RCrjDcNY62Eux3iIN0rRf3g,2807
22
- continuo_python_runtime/contract/secret_ref.py,sha256=96jh2G81clpabiEWGIsxbd9r5GKEGLb4Sa1-WJ9G59Q,1131
18
+ continuo_python_runtime/contract/kinds.py,sha256=nGX1KdYgENzUETbc48V6ru7qU9K8dOUQ54N05ZRAwf0,6163
19
+ continuo_python_runtime/contract/loader.py,sha256=-I_ijjdK2VmYII-Zs-yfyPy_NuZOw6jQN8_T025ySUo,14228
20
+ continuo_python_runtime/contract/model.py,sha256=NCjOZni6n9oEK0K2QyoQcu6D9snefqz1wx2l_M_RgKg,1754
21
+ continuo_python_runtime/contract/ontology_check.py,sha256=cJes2QjeOJSgMzJAeZdi0x6JnPnX4P86XS43pNHRd3M,4150
22
+ continuo_python_runtime/contract/pack.py,sha256=9dcHYohaM4m5MUGD54Zorage2c16XloSEORj2Pl-KWs,12926
23
+ continuo_python_runtime/contract/paths.py,sha256=uncZxz11Lfqom4eXFZeErU3dZUy8ShI9NpmiIJ20Abc,2804
24
+ continuo_python_runtime/contract/read_tables.py,sha256=bz3CHplIh9L3ecUuTudiu4D6y4aGcvdiTbopOkF5C2M,4036
23
25
  continuo_python_runtime/csv_readers/__init__.py,sha256=9TKvjC37C77uRaJQZuO0--zVj2OvuNwpJE6nWx7j2S8,806
24
26
  continuo_python_runtime/csv_readers/https.py,sha256=tMJ9k5F0b9SAydpon0ZlOznfjvjhF2BBLltyVmvRneE,4998
25
27
  continuo_python_runtime/csv_readers/s3.py,sha256=zmvHs3TxlN2alPKrdaHzPyREmkve2nBiAsHRXXe1mE0,2246
@@ -27,9 +29,9 @@ continuo_python_runtime/validation/__init__.py,sha256=hz5oGXsoaUoygR0_pBby9PS6cE
27
29
  continuo_python_runtime/validation/preflight.py,sha256=3DSVbPMPqsYg5yMEEDv_1YedN2_e7aYcSh8d2i7vEf8,16093
28
30
  continuo_python_runtime/validation/runner.py,sha256=fsTI_XdFG_LWhv9IrgknLI-_FxM1GQXoLmV7xIoIvF8,15034
29
31
  continuo_python_runtime/validation/s3.py,sha256=q8nRrT9R7L1-M4dSlDnkL7CUJMPmq86MHY_UKYFlEf8,1785
30
- continuo_python_runtime-0.12.0.dist-info/METADATA,sha256=h3aHs7obXyvOauEZVCvCo1kRaBho-blJtpI99tJeexY,31247
31
- continuo_python_runtime-0.12.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
32
- continuo_python_runtime-0.12.0.dist-info/entry_points.txt,sha256=ZvIwSm9f9B9ZmZMf6CyF5Zt4QONn8rqaIk-u-B1CF2Y,70
33
- continuo_python_runtime-0.12.0.dist-info/licenses/LICENSE,sha256=hfXfFCk-8gnps4YvHA6bjCNaSYqOrq2gAdqkXYycAQc,11345
34
- continuo_python_runtime-0.12.0.dist-info/licenses/NOTICE,sha256=ykgYyQkAMx3uas90FZHzt0aTca9IgJQCLpZ4d74Pl3U,465
35
- continuo_python_runtime-0.12.0.dist-info/RECORD,,
32
+ continuo_python_runtime-0.14.0.dist-info/METADATA,sha256=xPC5qK2wxA_jeby70kZH9pf3zBMXtqYCyx_NHT_0iww,39322
33
+ continuo_python_runtime-0.14.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
34
+ continuo_python_runtime-0.14.0.dist-info/entry_points.txt,sha256=ZvIwSm9f9B9ZmZMf6CyF5Zt4QONn8rqaIk-u-B1CF2Y,70
35
+ continuo_python_runtime-0.14.0.dist-info/licenses/LICENSE,sha256=hfXfFCk-8gnps4YvHA6bjCNaSYqOrq2gAdqkXYycAQc,11345
36
+ continuo_python_runtime-0.14.0.dist-info/licenses/NOTICE,sha256=ykgYyQkAMx3uas90FZHzt0aTca9IgJQCLpZ4d74Pl3U,465
37
+ continuo_python_runtime-0.14.0.dist-info/RECORD,,
@@ -1,178 +0,0 @@
1
- """Contract v1 merger: wire contract builder."""
2
-
3
- from pathlib import Path
4
-
5
- import yaml
6
-
7
- from continuo_python_runtime.contract.loader import load_contract_dir
8
- from continuo_python_runtime.contract.model import CONTRACT_VERSION, DEFAULT_MODE_TYPE, Node
9
- from continuo_python_runtime.errors import ContractError
10
- from continuo_python_runtime.hash_inputs import gather_hash_inputs
11
- from continuo_python_runtime.hashing import hash_parts
12
- from continuo_python_runtime.lint import lint_source
13
-
14
-
15
- def node_entry(node: Node) -> dict:
16
- """Convert a Node to its wire form dict.
17
-
18
- Returns the node as a dict with all fields, output_columns as list of
19
- dicts. The entry carries no hash fields: build_wire_contract adds all
20
- four (source_hash, shared_code_hash, config_hash, content_hash). The
21
- nullable field is always present in output_columns. ``secret_ref``,
22
- ``mode_type``, ``primary_key`` and ``assets`` appear only when they differ
23
- from their default, so the entry of a node that does not use them stays
24
- minimal.
25
- """
26
- entry = {
27
- "schema": node.schema,
28
- "table": node.table,
29
- "owner": node.owner,
30
- "schedule": node.schedule,
31
- "criticality": node.criticality,
32
- "kind": node.kind,
33
- "script": node.script,
34
- "reads": node.reads,
35
- "output_columns": [
36
- {
37
- "name": col.name,
38
- "type": col.type,
39
- "nullable": col.nullable,
40
- }
41
- for col in node.output_columns
42
- ],
43
- "description": node.description,
44
- "extra_columns": node.extra_columns,
45
- "config": dict(node.config),
46
- }
47
- # Only a kind that may name a Secret ever carries one; the key is emitted
48
- # only when set.
49
- if node.secret_ref:
50
- entry["secret_ref"] = node.secret_ref
51
- # Same reasoning: a replace node's entry carries no mode_type.
52
- if node.mode_type != DEFAULT_MODE_TYPE:
53
- entry["mode_type"] = node.mode_type
54
- if node.mode_type == "upsert":
55
- entry["primary_key"] = list(node.primary_key)
56
- if node.assets:
57
- entry["assets"] = list(node.assets)
58
- return entry
59
-
60
-
61
- def _lint_node_closure(
62
- node: Node,
63
- repo_root: Path,
64
- code_files: tuple[tuple[Path, bytes], ...],
65
- ) -> None:
66
- """Lint the node's script and every resolved closure member.
67
-
68
- Every file that executes for this node — the script plus its transitive
69
- in-repo import closure — is held to the same lint rules
70
- (``continuo_python_runtime.lint.lint_source``: L1 forbidden driver
71
- imports, L2 SQL string literals, L3 forbidden data-access calls, L4
72
- private-attribute access, L5 dynamic-import constructs, L6 constructs
73
- that run code the hash cannot see) that CI's
74
- ``continuo-runtime lint`` applies to ``scripts/``. Enforcing it again
75
- here, at merge time, means a helper file outside ``scripts/`` — which
76
- the CI lint step never looks at — cannot become a side channel around
77
- the harness's sole write sink, and the check cannot be defeated by a
78
- stale or hand-edited workflow file: whatever produces the release
79
- artifact is the thing that checked.
80
-
81
- Paths in violation messages are repo-root-relative (``str(path.relative_to
82
- (repo_root))``), so a message reads ``lib/shared.py:1: ...`` identically
83
- in CI and on a laptop, never an absolute path that differs between the
84
- two.
85
-
86
- Raises ``ContractError`` naming the node and listing every violation
87
- from every offending file — not just the first file's — so an author
88
- can act on the full report in one pass instead of an iterative guessing
89
- game.
90
-
91
- Every file is decoded as ``"utf-8-sig"`` (identical to plain ``"utf-8"``
92
- except that a leading BOM, if present, is stripped rather than kept as a
93
- literal ``U+FEFF`` character) — this matches what ``ast.parse(bytes)``
94
- already does for the same file in ``resolve_closure`` (bytes-mode
95
- parsing treats a UTF-8 BOM as an implicit encoding declaration and
96
- strips it), so a BOM file that parses and runs fine is not rejected here
97
- on a mismatch between the two decoders. A file that isn't valid UTF-8 at
98
- all (e.g. a PEP 263 ``# -*- coding: latin-1 -*-`` cookie plus a
99
- non-ASCII byte — valid input to ``ast.parse(bytes)``, which honors the
100
- cookie) raises ``UnicodeDecodeError``; that is caught and re-raised as a
101
- ``ContractError`` naming the node and the offending repo-relative path,
102
- so it joins the same error taxonomy as every other rejection here
103
- instead of escaping as a bare stdlib exception past ``cli.main``, which
104
- catches only ``HarnessError``/``OSError``.
105
- """
106
- repo_root_resolved = repo_root.resolve()
107
- violations: list[str] = []
108
- for path, data in code_files:
109
- rel = path.relative_to(repo_root_resolved)
110
- try:
111
- text = data.decode("utf-8-sig")
112
- except UnicodeDecodeError as exc:
113
- raise ContractError(f"{node.relation}: {rel}: not valid UTF-8: {exc}") from exc
114
- violations.extend(lint_source(text, str(rel)))
115
-
116
- if violations:
117
- report = "\n".join(violations)
118
- raise ContractError(
119
- f"{node.relation}: lint violations in script or import closure:\n{report}"
120
- )
121
-
122
-
123
- def build_wire_contract(
124
- contract_dir: Path, repo_root: Path, service: str, *, dialect: str | None = None
125
- ) -> dict:
126
- """Build and return a wire contract document.
127
-
128
- Loads contracts from contract_dir, resolves script paths against repo_root,
129
- computes content hashes, and returns a contract document sorted by relation.
130
- ``dialect`` is forwarded to :func:`~continuo_python_runtime.contract.loader
131
- .load_contract_dir` so every declared read is checked against that sqlglot
132
- dialect (``None`` -- the default -- uses sqlglot's dialect-neutral parser).
133
-
134
- Raises ContractError if any script file is missing, or if the repository
135
- root holds a ``sitecustomize.py`` or ``usercustomize.py``: Python imports
136
- either at startup, before the harness, so nothing in a node's import
137
- closure reaches it.
138
- """
139
- nodes = load_contract_dir(contract_dir, dialect=dialect)
140
-
141
- for hook in ("sitecustomize.py", "usercustomize.py"):
142
- if (repo_root / hook).exists():
143
- raise ContractError(
144
- f"{hook} at the repository root runs before the harness and is not in the hash"
145
- )
146
-
147
- wire_nodes = []
148
- for node in nodes:
149
- entry = node_entry(node)
150
-
151
- inputs = gather_hash_inputs(node, repo_root)
152
- _lint_node_closure(node, repo_root, inputs.code_files)
153
- entry.update(hash_parts(node, inputs.primary, inputs.units))
154
- # The one wire key outside config_hash: it is written after the hashes
155
- # are computed, so changing it alone never changes content_hash.
156
- if node.timeout_minutes is not None:
157
- entry["timeout_minutes"] = node.timeout_minutes
158
-
159
- wire_nodes.append(entry)
160
-
161
- # Sort by relation (schema.table)
162
- wire_nodes.sort(key=lambda entry: f"{entry['schema']}.{entry['table']}")
163
-
164
- return {
165
- "contract_version": CONTRACT_VERSION,
166
- "service": service,
167
- "nodes": wire_nodes,
168
- }
169
-
170
-
171
- def write_wire_contract(doc: dict, out: Path) -> None:
172
- """Write a wire contract document to a YAML file.
173
-
174
- Creates ``out``'s parent directory (and any missing ancestors) first, so
175
- callers don't need to pre-create the output directory.
176
- """
177
- out.parent.mkdir(parents=True, exist_ok=True)
178
- out.write_text(yaml.safe_dump(doc, sort_keys=False))
@@ -1,31 +0,0 @@
1
- """The name of the Kubernetes Secret a node's pod receives as env vars.
2
-
3
- The ``continuo-api-`` prefix keeps a contract from naming any other Secret in
4
- the namespace (the warehouse credentials, the platform's own credentials).
5
- continuo's topology-controller and execution-controller enforce the same
6
- pattern; this check gives the author the error in CI instead.
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- import re
12
-
13
- from continuo_python_runtime.errors import ContractError
14
-
15
- SECRET_REF_PATTERN = re.compile(r"^continuo-api-[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
16
- SECRET_REF_MAX_LEN = 253
17
-
18
-
19
- def validate_secret_ref(value: object, label: str) -> str:
20
- """Return ``value`` if it is a valid ``continuo-api-*`` Secret name."""
21
- if (
22
- not isinstance(value, str)
23
- or len(value) > SECRET_REF_MAX_LEN
24
- or not SECRET_REF_PATTERN.fullmatch(value)
25
- ):
26
- raise ContractError(
27
- f"{label}: 'secret_ref' must be a Kubernetes Secret name starting with "
28
- f"'continuo-api-' (lowercase letters, digits, '-'; at most "
29
- f"{SECRET_REF_MAX_LEN} chars), got {value!r}"
30
- )
31
- return value