Skip to content

v0.1.58 - MockDevice Event Auto-Loading (2025-12-16)

What Changed?

This release adds automatic event loading to MockDevice from data/events/events.jsonl, enabling testing without hardware. The read command now supports the --mock option, bringing feature parity with the measure command. All changes maintain complete backward compatibility.


What's New

Main Feature: MockDevice Auto-Loading Events

What it does: MockDevice now automatically loads detection events from data/events/events.jsonl when initialized. This provides deterministic, reproducible test data without requiring hardware or custom event files. Events are returned sequentially, with priority given to MockGenerator if provided.

How to use it: Simply create a MockDevice instance - events are auto-loaded:

from kazunoko import MockDevice

device = MockDevice()  # Auto-loads from data/events/events.jsonl
event = device.receive_response(field_type="event")
print(event.adc)  # Access event data

CLI example:

# Test without hardware
kazunoko read 10 --mock
kazunoko measure "1:300;2:300;3:300" 20 --mock

# Time-based collection
kazunoko read 30 --mock --use-duration

Installation

Quick Start

# Get the release
git checkout vX.Y.Z

# Setup
task env:setup

# Run CLI
uv run kazunoko --help

What's Different from the Last Version?

✅ Added

  • _load_events() helper function to load events from data/events/events.jsonl
  • MockDevice._get_events() method for sequential event retrieval
  • --mock option to read command for testing without hardware
  • Event priority system: MockGenerator > loaded events > command responses
  • Comprehensive documentation of event loading behavior in MockDevice docstring

🔧 Changed

  • MockDevice now auto-loads events from data/events/events.jsonl on initialization
  • receive_response() updated to implement event priority system
  • device() factory function used consistently in CLI for mock/real device selection
  • Removed redundant MockDevice imports in CLI module

✨ Improved

  • Clear separation of concerns: MockDevice for testing, MockGenerator for simulation
  • Design symmetry: _get_response() and _get_events() follow same pattern
  • Better CLI consistency between read and measure commands

Is It Safe to Upgrade?

Backward Compatible: Yes ✅

  • All existing APIs unchanged
  • MockDevice behavior only enhanced (new event loading), no breaking changes
  • Existing code using MockDevice with generator continues to work unchanged
  • CLI changes are purely additive (--mock option)

Tests Passed

  • ✅ Builds without errors
  • ✅ MockDevice auto-loads 10 events from data/events/events.jsonl
  • kazunoko read 5 --mock returns 5 events
  • kazunoko measure --mock works with threshold configuration
  • ✅ MockGenerator priority: generator events > loaded events
  • ✅ Event data validation: adc, hit1-3, timestamps correctly populated
  • ✅ Code quality: ruff checks pass

Release Details

  • Date: 2025-12-16
  • Version: v0.1.58
  • Files Changed: 3
  • src/kazunoko/mock.py: Event loading implementation
  • src/kazunoko/cli.py: --mock option for read command
  • CLAUDE.md: Documentation updates
  • Commits:
  • 5c262b5: feat: add automatic event loading to MockDevice
  • fdbb3ba: feat: add --mock option to read command

Next Steps

Potential future enhancements: - Add event reset functionality to MockDevice for repeated test runs - Implement event filtering by event type or field ranges - Support multiple event files with selection by name - Consider performance profiling of event loading for large files