Repository navigation
fix(storage): persist instrument file in the column order the reader parses - #2390
Open
hz c (chz03) wants to merge 1 commit into
Open
hz c (chz03) wants to merge 1 commit into
hz c (chz03) wants to merge 1 commit into
Conversation
…parses FileInstrumentStorage._write_instrument persisted the concatenated frame with column order [start_time, end_time, symbol] via a bare df.to_csv, immediately overwriting the reordered [symbol, start_time, end_time] write above it, while _read_instrument parses [symbol, start, end]. Writing and reading through the storage API therefore never round-tripped (KeyError on read; DateParseError from list_instruments). dump_bin writes the reader's order directly, which masked the mismatch. Persist only the reordered frame, add encoding="utf-8" for parity with _write_calendar, and cover the round-trip with a regression test. Co-Authored-By: Claude Code <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
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.
Description
FileInstrumentStorage._write_instrumentbuilt a DataFrame with column order[start_time, end_time, symbol]and persisted it with a baredf.to_csv, immediately overwriting the reordered[symbol, start_time, end_time]write above it._read_instrumentparses the file as[symbol, start_time, end_time](usecols=[0, 1, 2],names=[SYMBOL, START, END]), so writing and then reading through the storage API never round-tripped:__getitem__raisesKeyErrorfor the symbol, andlist_instrumentsraisesDateParseError(a symbol string arrives where an end date is expected).scripts/dump_bin.py, which writes the reader's column order directly and bypasses this class. Existing tests only read bundled data, so the write→read round-trip was never covered.dump_bin's on-disk layout), drop the overwriting bare write, and passencoding="utf-8"for parity with_write_calendar. AddsTestInstrumentStorageRoundTrip, which writes through the public__setitem__and reads back via__getitem__/.data.Motivation and Context
FileInstrumentStoragecurrently corrupts the instruments file for subsequent reads on both the 0.9.7 release and currentmain._write_instrumentis identical tomain), on Windows 11 / Python 3.12.10; CI coversmaindirectly.🤖 Generated with Claude Code