v1.10.0 マイグレーションガイド#

概要#

haniwers v1.10.0では、2つの古い設定モデルが非推奨となりました:

  • DaqConfig (v1.5.0から非推奨、v1.11.0で削除予定)

  • ScanConfig (v1.5.0から非推奨、v1.11.0で削除予定)

これらは統一された SamplerConfig に統合されました。本ガイドでは、設定ファイルをアップグレードする方法を説明します。

警告メッセージについて#

v1.10.0で古い設定形式を使用すると、以下のような警告が表示されます:

DeprecationWarning: DaqConfig is deprecated since v1.5.0 and will be removed in v1.11.0.
Please migrate to SamplerConfig with mode='count_based'.

これはエラーではありません。設定は引き続き機能しますが、v1.11.0では削除される予定です。

マイグレーション: DaqConfig から SamplerConfig#

旧形式(非推奨)#

[device]
label = "OSECHI_Main"
port = "/dev/cu.usbserial-140"
baudrate = 115200
timeout = 1.0

[daq]
label = "main"
workspace = "."
filename_prefix = "osechi_data"
filename_suffix = ".csv"
events_per_file = 10000
number_of_files = 10000
stream_mode = true

[sensors.top]
label = "top"
step_size = 10
threshold = "none"
center = 512
nsteps = 3

[mocker]
csv_path = null
shuffle = false
speed = 1.0
jitter = 0.0
loop = true

新形式(推奨)#

[device]
label = "OSECHI_Main"
port = "/dev/cu.usbserial-140"
baudrate = 115200
timeout = 1.0

[sampler]
label = "main"
workspace = "."
filename_prefix = "osechi_data"
filename_suffix = ".csv"
events_per_file = 10000
number_of_files = 10000
stream_mode = true
mode = "count_based"

[sensors.top]
label = "top"
step_size = 10
threshold = "none"
center = 512
nsteps = 3

[mocker]
csv_path = null
shuffle = false
speed = 1.0
jitter = 0.0
loop = true

主な変更点:

  1. [daq] セクションを [sampler] に変更

  2. mode = "count_based" フィールドを追加

比較表#

項目

旧形式(DaqConfig)

新形式(SamplerConfig)

注記

セクション名

[daq]

[sampler]

統一されたセクション名

モード

暗黙的にcount-based

mode = "count_based"

明示的に指定

他のフィールド

同じ

同じ

workspace, filename_prefix等は変更なし

マイグレーション: ScanConfig から SamplerConfig#

旧形式(非推奨)#

[device]
label = "OSECHI_Main"
port = "/dev/cu.usbserial-140"
baudrate = 115200
timeout = 1.0

[scan]
label = "main_scan"
workspace = "scan_data"
filename_prefix = "scan_"
filename_suffix = ".dat"
events_per_file = 10000
number_of_files = 10
stream_mode = false
duration = 60.0
suppress_threshold = 1000
max_retry = 3

[sensors.top]
label = "top"
step_size = 10
threshold = "none"
center = 512
nsteps = 3

[mocker]
csv_path = null

新形式(推奨)#

[device]
label = "OSECHI_Main"
port = "/dev/cu.usbserial-140"
baudrate = 115200
timeout = 1.0

[sampler]
label = "main_scan"
workspace = "scan_data"
filename_prefix = "scan_"
filename_suffix = ".dat"
events_per_file = 10000
number_of_files = 10
stream_mode = false
duration = 60.0
suppress_threshold = 1000
max_retry = 3
mode = "time_based"

[sensors.top]
label = "top"
step_size = 10
threshold = "none"
center = 512
nsteps = 3

[mocker]
csv_path = null

主な変更点:

  1. [scan] セクションを [sampler] に変更

  2. mode = "time_based" フィールドを追加

比較表#

項目

旧形式(ScanConfig)

新形式(SamplerConfig)

注記

セクション名

[scan]

[sampler]

統一されたセクション名

モード

暗黙的にtime-based

mode = "time_based"

明示的に指定

他のフィールド

同じ

同じ

duration, suppress_threshold等は変更なし

SamplerConfig の詳細#

新しいSamplerConfigは以下の2つのモードをサポートします:

count_based モード(旧 DaqConfig相当)#

一定数のイベントを取得したら次のファイルに移行します:

[sampler]
mode = "count_based"
events_per_file = 10000
number_of_files = 100
# duration は不要

time_based モード(旧 ScanConfig相当)#

一定時間データ取得した後に停止します:

[sampler]
mode = "time_based"
duration = 60.0
events_per_file = 10000
number_of_files = 10
suppress_threshold = 1000
max_retry = 3

設定ファイルの更新手順#

ステップ1: 現在の設定形式を確認#

# あなたの設定ファイルがどのセクションを使用しているか確認
grep -E "^\[(daq|scan|sampler)\]" config.toml

ステップ2: セクション名を更新#

  • [daq][sampler]mode = "count_based" を追加

  • [scan][sampler]mode = "time_based" を追加

ステップ3: 設定を検証#

# 新しい設定で haniwers を起動して動作確認
haniwers-v1 config show --config-file config.toml

ステップ4: 警告が消えたことを確認#

新しい設定で実行しても deprecation警告が表示されなくなります。

トラブルシューティング#

Q: 「daq セクションが見つからない」エラーが出た#

A: 新しい設定形式では、[daq] の代わりに [sampler] を使用してください。

Q: 警告を無視して古い設定を続けたい#

A: v1.11.0までなら古い設定は動作します。ただし、できるだけ早く移行することをお勧めします。

Q: 実装コードを変更する必要がありますか?#

A: いいえ。HaniwersConfig は後方互換性を保つように設計されています。設定ファイルだけを更新してください。

サポート#

質問や問題がある場合は、プロジェクトの issue を作成してください。

タイムライン#

  • v1.10.0 (現在): Deprecation警告を表示

  • v1.11.0 (予定): DaqConfig, ScanConfig を削除