Sitelet https://github.com/datachain-ai/datachain/pull/1913
Skip to content

fix: include class UDF constructor state in cache identity - #1913

Open
atirna wants to merge 6 commits into
datachain-ai:mainfrom
atirna:fix/udf-hash-constructor-state
Open

fix: include class UDF constructor state in cache identity#1913
atirna wants to merge 6 commits into
datachain-ai:mainfrom
atirna:fix/udf-hash-constructor-state

Conversation

@atirna

@atirna atirna commented Aug 16, 2026

Copy link
Copy Markdown

Description

I included class UDF constructor state in the UDF hash. Previously two Mapper/Aggregator instances that only differed in constructor args hashed the same, so the second call reused the first instance's cached rows. Now those instances get distinct cache keys. setup() runtime attrs (locks, loaded models) still dont move the hash until the UDF is rebound.

Fixes #1903

Why

Wrong answers that look plausible. The second configured UDF was served the first one's rows with no error or version bump.

Verification

  • before, on current main: CountAbove(0) then CountAbove(3) both returned [(1, 5), (2, 5)]
  • after: CountAbove(3) returns [(1, 2), (2, 2)]
  • python -m pytest tests/unit/test_query_steps_hash.py tests/unit/test_datachain_hash.py tests/unit/lib/test_udf.py -q --benchmark-skip
  • ruff + mypy on the touched files

Differently configured Mapper/Aggregator instances were hashing as the same step, so the second call reused the first instance's cached rows.
@atirna
atirna force-pushed the fix/udf-hash-constructor-state branch from 5f86cbd to 4e736ec Compare August 17, 2026 05:58
@atirna

atirna commented Aug 18, 2026

Copy link
Copy Markdown
Author

looks like there is competing work in progress, i am leaving it for them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agg/Map-er constructor state is not part of the UDF hash - 2nd call returns the 1st call's rows.

1 participant