diff --git a/.zed/rules b/.zed/rules index bcfb8afbf..a1fcbb009 100644 --- a/.zed/rules +++ b/.zed/rules @@ -822,15 +822,15 @@ convenient call and pod.process(a, b) the exact primitive: must equal those of a pipeline with that select written by hand (the stream's `select_data_columns` method builds the same operator, and `a.join(b)` the same `Join`). Nothing to drop means no step. One info log names the dropped columns; it is not a warning. -- pod(a, b, strict=True) and pod.process(a, b) reject an extra column. strict is part of - no identity. process never takes a strict argument and never drops a column. +- pod(a, b, strict_columns=True) and pod.process(a, b) reject an extra column. + strict_columns is part of no identity. process always uses the exact column contract. - A missing required column is an error in every form. Tags are never dropped. A data column shared by two inputs fails at the join, used or not: no special handling. - No select is added when the data function's accepts_arbitrary_keywords is true (no kind today; PythonDataFunction rejects variadic keyword arguments). - Function pods only. An operator's and a SideEffectPod's __call__ stay aliases of - process with no strict argument. There is no global setting. -- A test of the exact input contract uses process or strict=True. + process with no strict_columns argument. There is no global setting. +- A test of the exact input contract uses process or strict_columns=True. Operator (core/operators/) — structural pod transforming streams without adding or synthesizing data; it may add a tag (AddTags). All subclass StaticOutputPod: diff --git a/CLAUDE.md b/CLAUDE.md index dd9e6450e..003718852 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -837,15 +837,15 @@ convenient call and `pod.process(a, b)` the exact primitive: must equal those of a pipeline with that select written by hand (the stream's `select_data_columns` method builds the same operator, and `a.join(b)` the same `Join`). Nothing to drop means no step. One info log names the dropped columns; it is not a warning. -- `pod(a, b, strict=True)` and `pod.process(a, b)` reject an extra column. `strict` is part of - no identity. `process` never takes a `strict` argument and never drops a column. +- `pod(a, b, strict_columns=True)` and `pod.process(a, b)` reject an extra column. + `strict_columns` is part of no identity. `process` always uses the exact column contract. - A missing required column is an error in every form. Tags are never dropped. A data column shared by two inputs fails at the join, used or not: no special handling. - No select is added when the data function's `accepts_arbitrary_keywords` is true (no kind today; `PythonDataFunction` rejects `**kwargs`). - Function pods only. An operator's and a `SideEffectPod`'s `__call__` stay aliases of - `process` with no `strict` argument. There is no global setting. -- A test of the exact input contract uses `process` or `strict=True`. + `process` with no `strict_columns` argument. There is no global setting. +- A test of the exact input contract uses `process` or `strict_columns=True`. **Operator** (`core/operators/`) — structural pod transforming streams without adding or synthesizing data; it may add a tag (`AddTags`). All subclass `StaticOutputPod`: diff --git a/README.md b/README.md index 4adfa9657..261a80eae 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,9 @@ print(job.nodes["fahrenheit"].as_table().sort_by("experiment").to_pylist()) # [{'experiment': 'exp_001', 'temp_fahrenheit': 68.9}, {'experiment': 'exp_002', 'temp_fahrenheit': 72.14}] ``` +A function pod drops unused data columns by default. Pass `strict_columns=True` to reject +them. + Add a row and run a new job over the same database. The two stored results are found again by their input values, and only the new row is computed: diff --git a/changelog.d/ITL-1023.md b/changelog.d/ITL-1023.md index 2291c82a0..d66345a0f 100644 --- a/changelog.d/ITL-1023.md +++ b/changelog.d/ITL-1023.md @@ -164,8 +164,8 @@ holds the data-tag, and how to make the two agree: `tag_only_columns` on the source, or a slot declared with the column in both roles (ITL-1142). The bind stays strict. - - `pod.process(stream)` and `pod(stream, strict=True)` refusing a data-tag the - function does not read name the data-tags and the two ways out: `pod(stream)`, + - `pod.process(stream)` and `pod(stream, strict_columns=True)` refusing a data-tag + the function does not read name the data-tags and the two ways out: `pod(stream)`, or `tag_only_columns`, each only where it can work (not when no data column of the input is a parameter of the function, except a plain `FunctionPod`'s call). - "Not supported with data-tags yet" names `tag_only_columns=True`, which keeps diff --git a/changelog.d/ITL-1585.md b/changelog.d/ITL-1585.md new file mode 100644 index 000000000..fde8a4c0c --- /dev/null +++ b/changelog.d/ITL-1585.md @@ -0,0 +1,5 @@ +### Breaking changes and migration + +- Rename the function pod call keyword `strict` to `strict_columns`. Use + `pod(a, b, strict_columns=True)` to reject unused input data columns. By default, + the call still drops those columns with one automatic select. diff --git a/docs/concepts/data-tags.md b/docs/concepts/data-tags.md index dcc4d2fec..ec563b6fe 100644 --- a/docs/concepts/data-tags.md +++ b/docs/concepts/data-tags.md @@ -426,7 +426,7 @@ example a copy in the source's data under another name, or ## Errors that name a data-tag -- `pod.process(stream)` and `pod(stream, strict=True)` are exact: they hand every data +- `pod.process(stream)` and `pod(stream, strict_columns=True)` are exact: they hand every data column to the function, so a data-tag the function does not read is refused like any extra column. The error names the data-tags and the two ways out: call the pod, `pod(stream)`, which for a plain `FunctionPod` lets them pass through as diff --git a/docs/concepts/function-pods.md b/docs/concepts/function-pods.md index 9de222bca..8eefc68f2 100644 --- a/docs/concepts/function-pods.md +++ b/docs/concepts/function-pods.md @@ -158,14 +158,14 @@ Each call that drops columns logs one message at `INFO` level (logger value: a misspelt column (`Height` for a parameter `height=1.0`) is dropped like any other unused column and the default is used, and that message is the only trace. -### Exact calls: `strict=True` and `.process()` +### Exact calls: `strict_columns=True` and `.process()` -To have an extra column rejected instead of dropped, pass `strict=True`, or call +To have an extra column rejected instead of dropped, pass `strict_columns=True`, or call `.process()`, which is the exact primitive and never drops a column: ```python try: - compute_bmi.pod(wide, strict=True) + compute_bmi.pod(wide, strict_columns=True) except ValueError as err: print(type(err).__name__) # ValueError @@ -182,9 +182,9 @@ The error message names both schemas and the first column that does not fit, for compatible with expected input schema Schema({'weight': float, 'height': float}): column 'age' is not a parameter of the function`. -`strict` decides only whether an extra column is an error. It is not part of any hash: when -there is nothing to drop, `pod(stream)`, `pod(stream, strict=True)` and `pod.process(stream)` -build the same pipeline. +`strict_columns` controls whether an extra column is an error. When there is nothing to +drop, `pod(stream)`, `pod(stream, strict_columns=True)` and `pod.process(stream)` build +the same pipeline and produce identical hashes. ### What is an error in every form diff --git a/docs/dev/design_issues/ITL-807-F16.md b/docs/dev/design_issues/ITL-807-F16.md index fc161fd42..796db5390 100644 --- a/docs/dev/design_issues/ITL-807-F16.md +++ b/docs/dev/design_issues/ITL-807-F16.md @@ -22,3 +22,5 @@ be dropped no step is added. One info message names the dropped columns. `strict `process` reject an extra column as before; `strict` is in no identity. No select is added for a data function whose `accepts_arbitrary_keywords` is true (none today). Operators and `SideEffectPod` keep `__call__` as an alias of `process`. + +ITL-1585 renamed the call keyword to `strict_columns`. diff --git a/docs/dev/plans/2026-11-12-itl-807-function-pod-auto-select.md b/docs/dev/plans/2026-11-12-itl-807-function-pod-auto-select.md index 939672662..6caacca52 100644 --- a/docs/dev/plans/2026-11-12-itl-807-function-pod-auto-select.md +++ b/docs/dev/plans/2026-11-12-itl-807-function-pod-auto-select.md @@ -1,5 +1,7 @@ # Function pod `__call__` drops unused data columns (ITL-807, ITL-193) Implementation Plan +ITL-1585 renamed the function pod call keyword to `strict_columns`. + > **For agentic workers:** REQUIRED SUB-SKILL: Use sensei:subagent-driven-development (recommended) or sensei:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** `pod(a, b)` on a function pod drops the data columns the function does not take, by diff --git a/docs/getting-started.md b/docs/getting-started.md index af8141a46..a46155264 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -129,7 +129,7 @@ def analyze_conditions(temperature: float, pressure: float) -> tuple[float, bool - **Parameter names match data column names.** Each parameter takes the data column with exactly its name, here `temperature` and `pressure`. - **Data columns the function does not take are dropped** when you call the pod. - `pod(stream, strict=True)` and `pod.process(stream)` reject them instead (see + `pod(stream, strict_columns=True)` and `pod.process(stream)` reject them instead (see [Function Pods](concepts/function-pods.md#input-columns)). - **Type annotations define the schemas.** Orcapod uses them to build the output schema and to validate compatibility when the pod is applied. A parameter without an annotation needs diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 46dbf8ba1..fed7b5d4b 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -126,7 +126,7 @@ the message names the first offending column: `pa.table(...)` without a schema has nullable columns. - `column 'q' is not a parameter of the function`: the stream has a column the function does not take. `pod(stream)` drops such columns for you (it adds a `SelectDataColumns` - step), so you see this only from `pod.process(stream)`, from `pod(stream, strict=True)`, + step), so you see this only from `pod.process(stream)`, from `pod(stream, strict_columns=True)`, or when **no** column of the stream is a parameter. **Fix.** For a missing column, rename with `stream.map_data({"old": "new"})`. For a type diff --git a/docs/tutorial/02-function-pods.md b/docs/tutorial/02-function-pods.md index 032f6b283..3473e1cc4 100644 --- a/docs/tutorial/02-function-pods.md +++ b/docs/tutorial/02-function-pods.md @@ -120,8 +120,8 @@ print(units.drop_data_columns(["region", "n_spikes"]).keys()) !!! note "Why drop the other columns?" Dropped columns are not part of the inputs Orcapod stores a result under. A change in an unused column therefore does not make Orcapod compute the result again (Part 6 shows - this). To reject extra columns instead, pass `strict=True`: - `to_mm.pod(units, strict=True)` raises `ValueError`. See [Input columns](../concepts/function-pods.md#input-columns). + this). To reject extra columns instead, pass `strict_columns=True`: + `to_mm.pod(units, strict_columns=True)` raises `ValueError`. See [Input columns](../concepts/function-pods.md#input-columns). ## Returning more than one output diff --git a/src/orcapod/core/function_pod.py b/src/orcapod/core/function_pod.py index d2ff1fb3e..1d0f7d9ce 100644 --- a/src/orcapod/core/function_pod.py +++ b/src/orcapod/core/function_pod.py @@ -303,7 +303,7 @@ def _validate_input(self, tag_schema: Schema, data_schema: Schema) -> None: raise ValueError( f"{error}. {unread} are data-tags of the input (each a tag " "and a data column of one name) that the function does not read, and " - "the exact form, pod.process(stream) or pod(stream, strict=True), " + "the exact form, pod.process(stream) or pod(stream, strict_columns=True), " f"hands every data column to the function: {way_out}" ) from error self._validate_output_keys(tag_schema.keys()) @@ -768,7 +768,7 @@ def __call__( self, *streams: StreamProtocol, label: str | None = None, - strict: bool = False, + strict_columns: bool = False, ) -> StreamProtocol: """Apply the pod, dropping the data columns its function does not take. @@ -784,7 +784,7 @@ def __call__( Args: *streams: Input streams to process. label: Optional label for tracking. - strict: If ``True``, an extra data column is an error, as in + strict_columns: If ``True``, an extra data column is an error, as in ``process``. It decides only that; it is part of no identity. Returns: @@ -792,14 +792,14 @@ def __call__( Raises: ValueError: If a parameter without a default has no column, a column's - type is incompatible with its parameter, or (``strict=True``) the + type is incompatible with its parameter, or (``strict_columns=True``) the input carries a data column that is not a parameter. """ logger.debug("Invoking pod %s on streams through __call__: %s", self, streams) # A function that accepts arbitrary keywords takes every column, so # nothing is unused and no select is added (developer, November 12, 2026, # ITL-807). No data function kind accepts them today. - if strict or self.data_function.accepts_arbitrary_keywords: + if strict_columns or self.data_function.accepts_arbitrary_keywords: return self.process(*streams, label=label) input_stream = self.handle_input_streams(*streams) @@ -982,7 +982,7 @@ def __call__( self, *streams: StreamProtocol, label: str | None = None, - strict: bool = False, + strict_columns: bool = False, ) -> FunctionPodStream: """Apply the pod, dropping the data columns its function does not take. @@ -992,13 +992,14 @@ def __call__( Args: *streams: Input streams to process. label: Optional label for tracking. - strict: If ``True``, an extra data column is an error, as in ``process``. + strict_columns: If ``True``, an extra data column is an error, as in ``process``. Returns: A ``FunctionPodStream`` wrapping the computation. """ return cast( - FunctionPodStream, super().__call__(*streams, label=label, strict=strict) + FunctionPodStream, + super().__call__(*streams, label=label, strict_columns=strict_columns), ) def to_config(self) -> dict[str, Any]: diff --git a/tests/test_core/data_tags/test_error_messages.py b/tests/test_core/data_tags/test_error_messages.py index cbb1220f5..72f7515e7 100644 --- a/tests/test_core/data_tags/test_error_messages.py +++ b/tests/test_core/data_tags/test_error_messages.py @@ -138,7 +138,7 @@ def test_a_plain_mismatch_says_nothing_about_data_tags() -> None: assert "data-tag" not in str(excinfo.value) -# ── pod.process and strict=True: the exact form (ITL-1022) ────────────────── +# ── pod.process and strict_columns=True: the exact form (ITL-1022) ────────────────── @op.function_pod(output_keys=["half"]) @@ -148,8 +148,8 @@ def half(y: int) -> float: @pytest.mark.parametrize( "call", - [lambda s: half.pod.process(s), lambda s: half.pod(s, strict=True)], - ids=["process", "strict"], + [lambda s: half.pod.process(s), lambda s: half.pod(s, strict_columns=True)], + ids=["process", "strict_columns"], ) def test_the_exact_form_names_unread_data_tags_and_the_ways_out( call: Callable[[op.sources.DictSource], object], @@ -159,6 +159,7 @@ def test_the_exact_form_names_unread_data_tags_and_the_ways_out( _ = call(source) message = str(excinfo.value) assert "['x'] are data-tags of the input" in message + assert "pod(stream, strict_columns=True)" in message assert "pod(stream) to let them pass through as data-tags" in message assert "add ['x'] to the tag_only_columns of the source" in message diff --git a/tests/test_core/data_tags/test_function_pods.py b/tests/test_core/data_tags/test_function_pods.py index c6522d286..c6874ba7a 100644 --- a/tests/test_core/data_tags/test_function_pods.py +++ b/tests/test_core/data_tags/test_function_pods.py @@ -138,7 +138,7 @@ def test_strict_call_is_process() -> None: def double(t: int, amp: float) -> float: return t * amp - strict = double.pod(_source(), strict=True) + strict = double.pod(_source(), strict_columns=True) assert stream_data_tags(strict) == () diff --git a/tests/test_core/function_pod/test_function_pod_auto_select.py b/tests/test_core/function_pod/test_function_pod_auto_select.py index 67d7ef81b..2f58b1a01 100644 --- a/tests/test_core/function_pod/test_function_pod_auto_select.py +++ b/tests/test_core/function_pod/test_function_pod_auto_select.py @@ -2,7 +2,7 @@ ``pod(a, b)`` is the convenient call: the inputs are joined as before and, when the joined stream carries data columns that are not parameters of the function, one automatic -``SelectDataColumns`` is placed between the join and the pod. ``pod(a, b, strict=True)`` and +``SelectDataColumns`` is placed between the join and the pod. ``pod(a, b, strict_columns=True)`` and ``pod.process(a, b)`` are exact: an extra column is an error. Every test drives the public interface. @@ -277,7 +277,7 @@ def test_stream_passed_for_its_tags_restricts_the_rows() -> None: def test_matching_inputs_build_the_pipeline_they_built_before() -> None: """With nothing to drop, all three calls give the stream ``pod(a, b)`` gave before.""" convenient = add.pod(_xs(), _ys()) - strict = add.pod(_xs(), _ys(), strict=True) + strict = add.pod(_xs(), _ys(), strict_columns=True) exact = add.pod.process(_xs(), _ys()) _assert_same_stream(convenient, exact) @@ -328,10 +328,16 @@ def test_matching_input_adds_no_select_node_to_a_job() -> None: # --------------------------------------------------------------------------- -def test_strict_call_rejects_an_extra_column() -> None: - """``strict=True`` raises the error ``process`` raises.""" +def test_strict_columns_call_rejects_an_extra_column() -> None: + """``strict_columns=True`` raises the error ``process`` raises.""" with pytest.raises(ValueError, match="column 'extra' is not a parameter"): - add.pod(_wide(), strict=True) + add.pod(_wide(), strict_columns=True) + + +def test_call_rejects_the_old_strict_keyword() -> None: + """The renamed option is the only keyword for exact column validation.""" + with pytest.raises(TypeError, match="unexpected keyword argument 'strict'"): + add.pod(_wide(), strict=True) # pyright: ignore[reportCallIssue] def test_process_rejects_an_extra_column() -> None: @@ -340,13 +346,13 @@ def test_process_rejects_an_extra_column() -> None: add.pod.process(_wide()) -def test_process_takes_no_strict_argument() -> None: - """``process`` has no ``strict`` argument: it is always strict.""" +def test_process_takes_no_strict_columns_argument() -> None: + """``process`` has no ``strict_columns`` argument: it is always strict.""" with pytest.raises(TypeError): - add.pod.process(_wide(), strict=False) # pyright: ignore[reportCallIssue] + add.pod.process(_wide(), strict_columns=False) # pyright: ignore[reportCallIssue] -@pytest.mark.parametrize("mode", ["convenient", "strict", "process"]) +@pytest.mark.parametrize("mode", ["convenient", "strict_columns", "process"]) def test_missing_required_column_is_an_error_in_every_mode(mode: str) -> None: """A parameter without a default must have a column, however the pod is applied. @@ -356,8 +362,8 @@ def test_missing_required_column_is_an_error_in_every_mode(mode: str) -> None: with pytest.raises(ValueError, match="'y'"): if mode == "convenient": add.pod(_xs(extra=1)) - elif mode == "strict": - add.pod(_xs(), strict=True) + elif mode == "strict_columns": + add.pod(_xs(), strict_columns=True) else: add.pod.process(_xs()) @@ -455,7 +461,7 @@ def test_misspelt_column_for_a_defaulted_parameter_is_dropped_and_logged( assert len(records) == 1 assert "'Y'" in records[0].getMessage() with pytest.raises(ValueError, match="column 'Y' is not a parameter"): - add_default.pod(misspelt, strict=True) + add_default.pod(misspelt, strict_columns=True) # --------------------------------------------------------------------------- @@ -485,7 +491,7 @@ def add_with_ctx(x: int, y: int, ctx: InvocationContext) -> int: _assert_same_stream(automatic, by_hand) with pytest.raises(ValueError, match="column 'extra' is not a parameter"): - add_with_ctx.pod(_wide(), strict=True) + add_with_ctx.pod(_wide(), strict_columns=True) def test_cached_function_pod_drops_unused_columns() -> None: @@ -506,7 +512,7 @@ def test_cached_function_pod_drops_unused_columns() -> None: assert [(row["k"], row["total"]) for row in _rows(by_hand)] == [(1, 5), (2, 9)] assert [row["total"] for row in _rows(automatic)] == [5, 9] with pytest.raises(ValueError, match="column 'extra' is not a parameter"): - cached(_wide(), strict=True) + cached(_wide(), strict_columns=True) with pytest.raises(ValueError, match="column 'extra' is not a parameter"): cached.process(_wide()) @@ -528,6 +534,8 @@ def cached_add(x: int, y: int) -> int: return x + y assert [row["total"] for row in _rows(cached_add.pod(_wide()))] == [5, 9] + with pytest.raises(ValueError, match="column 'extra' is not a parameter"): + _ = cached_add.pod(_wide(), strict_columns=True) def test_wrapped_function_pod_drops_unused_columns() -> None: @@ -539,7 +547,7 @@ def test_wrapped_function_pod_drops_unused_columns() -> None: _assert_same_stream(automatic, by_hand) with pytest.raises(ValueError, match="column 'extra' is not a parameter"): - wrapped(_wide(), strict=True) + wrapped(_wide(), strict_columns=True) def test_function_taking_arbitrary_keywords_gets_no_select() -> None: @@ -566,7 +574,7 @@ def accepts_arbitrary_keywords(self) -> bool: pod(_wide()) -def test_other_pods_take_no_strict_argument() -> None: +def test_other_pods_take_no_strict_columns_argument() -> None: """Operators and side-effect pods keep ``__call__`` as an alias of ``process``.""" def record(x: int, y: int, extra: int, ctx: InvocationContext) -> None: @@ -582,9 +590,9 @@ def record(x: int, y: int, extra: int, ctx: InvocationContext) -> None: pod = SideEffectPod(record) with pytest.raises(TypeError): - pod(_wide(), strict=False) # pyright: ignore[reportCallIssue] + pod(_wide(), strict_columns=False) # pyright: ignore[reportCallIssue] with pytest.raises(TypeError): - Join()(_xs(), _ys(), strict=False) + Join()(_xs(), _ys(), strict_columns=False) assert tuple(pod(_wide()).keys()[1]) == ("x", "y", "extra") diff --git a/tests/test_core/test_newcomer_papercuts.py b/tests/test_core/test_newcomer_papercuts.py index 6ebd76218..578b4083e 100644 --- a/tests/test_core/test_newcomer_papercuts.py +++ b/tests/test_core/test_newcomer_papercuts.py @@ -98,13 +98,13 @@ def _wide_source() -> DictSource: ) -@pytest.mark.parametrize("call", ["process", "strict"]) +@pytest.mark.parametrize("call", ["process", "strict_columns"]) def test_extra_column_error_names_the_column_and_logs_nothing( caplog: pytest.LogCaptureFixture, call: str ) -> None: """An extra column raises one error naming it, with no log line and no "data data". - The exact calls raise it: ``pod.process(stream)`` and ``pod(stream, strict=True)``. + The exact calls raise it: ``pod.process(stream)`` and ``pod(stream, strict_columns=True)``. A plain ``pod(stream)`` drops the extra column instead (ITL-807). Args: @@ -115,7 +115,7 @@ def test_extra_column_error_names_the_column_and_logs_nothing( if call == "process": compute_bmi.pod.process(_wide_source()) else: - compute_bmi.pod(_wide_source(), strict=True) + compute_bmi.pod(_wide_source(), strict_columns=True) message = str(excinfo.value) assert "data data" not in message