Skip to content

v0.1.37 - Fix Read Command Event Count Bug and Refactor for Clarity (2025-12-13)

What Changed?

This release fixes a critical bug in the read command where --count parameter was not properly limiting the number of events read. The command has been redesigned to make event count a required positional argument for clarity. The event reading logic has been completely refactored following SOLID principles (SRP, YAGNI) and now uses a cleaner architecture with explicit for-loops instead of while-True patterns.


What's New

Main Feature: Redesigned read Command

What it does: The read command now requires you to specify the number of events to read as a positional argument. This makes the intent explicit and prevents accidental infinite reads. The command reads exactly N events from the detector, waiting up to --event-timeout seconds per event.

How to use it:

# Read 1 event
kazunoko read 1

# Read 10 events
kazunoko read 10

# Read 5 events with 3-second timeout per event
kazunoko read 5 --event-timeout 3.0

# Read 10 events in CSV format
kazunoko read 10 --format csv > events.csv

Code example (Python API):

from kazunoko import connect, Command

with connect() as device:
    cmd = Command(device)
    event = cmd.read()  # Returns one event
    # CLI orchestrates multiple reads

Installation

Quick Start

# Get the release
git checkout v0.1.37

# Setup
uv sync

# Run CLI
uv run kazunoko --help

What's Different from the Last Version?

✅ Added

  • Event-focused terminology throughout CLI and internal code

🔧 Changed

  • read command signature: --count Nread N (required positional argument)
  • Event reading architecture: Replaced while True loops with explicit for loops
  • _poll_cycle() removed; replaced with focused _read_one_event() function
  • Internal naming: countevent_count, poll_countevent_index, cycle_start_timeevent_start_time

🐛 Fixed

  • Critical: --count parameter not properly limiting events in read command
  • Event count now strictly enforced (reads exactly N events, then exits)
  • Removed infinite loop patterns in favor of explicit control flow

Is It Safe to Upgrade?

Backward Compatible: No (CLI breaking change)

  • The read command signature has changed: kazunoko read --count 10kazunoko read 10
  • This is a breaking change for scripts using the old syntax
  • The Python API (Command.read()) is unchanged

Tests Passed

  • ✅ Builds without errors
  • kazunoko read 1 reads exactly 1 event
  • kazunoko read 10 reads exactly 10 events
  • ✅ Event timeout respected (waits up to --event-timeout per event)

Release Details

  • Date: 2025-12-13
  • Version: v0.1.37
  • Files Changed: 1 (src/kazunoko/cli.py)
  • Commits: 6 commits
  • d59bb7c refactor: standardize naming and terminology to event-focused
  • 7c3fde3 refactor: rename poll_count to event_index for clarity
  • a43c395 refactor: rename count parameter to event_count for consistency
  • 7912cd9 refactor: make event count a required argument in read command
  • 70ae469 refactor: simplify event reading logic with SRP and YAGNI
  • 8c056e1 fix: replace infinite while loop with for loop in _read_events

Next Steps

  • Documentation update needed for users migrating from v0.1.36
  • Consider adding migration guide in CLI help text
  • Monitor feedback on the new required argument pattern