Fix: support Wyscout auto-detection for direct streams - #601
Open
Litju wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes Wyscout automatic data-version detection for caller-provided direct streams.
When
data_versionwas not supplied, the Wyscout provider parsed the complete JSON document to identify V2 or V3. The selected deserializer then attempted to parse the same direct stream again.For caller-provided streams, the first parse left the stream at EOF, so the second parse failed with a JSON decoding error.
The repaired lifecycle is:
The public
wyscout.load()API is unchanged.Root cause and repair
The previous automatic path had two independent owners of JSON parsing:
This was hidden for some path-backed inputs because Kloppy could materialize a fresh stream for each open. Direct file-like inputs retained the same object and stream position across both operations.
Rewinding would not be an appropriate repair: it would preserve the duplicated full-document parse and would require every direct input to support random access.
The provider already had the complete parsed document, so this PR passes that dictionary forward through
WyscoutInputs.The V2 and V3 deserializers now consume the parsed dictionary instead of reopening or reparsing the raw stream. The existing
EventDataDeserializer.deserialize()lifecycle remains unchanged.Stream ownership
Caller-provided streams remain caller-owned.
Kloppy reads a direct stream to its natural final position but does not close it. Automatic loading no longer requires the stream to implement
seek()ortell().Tests
The permanent regression tests cover:
The public Wyscout behavior matrix changed from:
For automatic loading, the document lifecycle changed from:
Explicit version loading remains behaviorally equivalent.
Validation
The Wyscout-only change passed the complete Kloppy test suite with frozen dependencies on Python 3.9 through 3.13.
The exact combined state containing this PR and the SkillCorner repair from #599 was also validated across Python 3.9 through 3.13:
A final fresh Python 3.13 run of Kloppy's native repository suite reproduced:
Frozen
uvsynchronization, repository pre-commit hooks, package build, import smoke, and patch checks also passed.Combined validation confirmed that the Wyscout and SkillCorner changes preserve each other's provider behavior and introduce no functional, semantic, structural, ownership, or full-suite regression.
Compatibility
The public
wyscout.load()API and its supported inputs are unchanged.WyscoutInputsis an internal serializer data structure. Itsevent_datafield now contains the parsed JSON dictionary instead of a raw byte stream.Code that directly constructs this internal type with a stream is not preserved. Normal use through
wyscout.load()is unaffected.Scope
This PR changes only:
kloppy/_providers/wyscout.pykloppy/infra/serializers/event/wyscout/deserializer_v2.pykloppy/infra/serializers/event/wyscout/deserializer_v3.pykloppy/tests/test_wyscout.pyIt does not change generic Kloppy I/O, adapters, compression handling, dependencies, lockfiles, CI configuration, or the public loading API.
Relationship to #469
Issue #469 affects both SkillCorner and Wyscout, but the providers fail through different serialization lifecycles.
SkillCorner is addressed separately in #599. This PR addresses the Wyscout-specific complete-document reparse.
Keeping the repairs separate makes each change provider-local and independently reviewable.
Related to #469.