diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/__init__.py b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/__init__.py new file mode 100644 index 000000000..2c96ddf0d --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/__init__.py @@ -0,0 +1,4 @@ +"""Connectors for datasets released by Yilin Wang (``pandalin98``) and co-authors. + +Keep this regular package so pkgutil.walk_packages can discover its connector children. +""" diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/README.md b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/README.md new file mode 100644 index 000000000..cbd8ddffc --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/README.md @@ -0,0 +1,266 @@ +# EngineMT-QA + +EngineMT-QA asks questions about simulated aero-engine flights. Each question is about one 600-step +cycle, or a group of 10 cycles, of 33 signals from NASA's N-CMAPSS simulator. The authors define four +tasks, one per stage: Understanding, Perception, Reasoning and Decision-Making. They released the +dataset with the ITFormer paper (Wang et al., ICML 2025, +[arXiv 2506.20093](https://arxiv.org/abs/2506.20093)) and their code, +[ITFormer-ICML25](https://github.com/Pandalin98/ITFormer-ICML25). + +The connector builds one Record per cycle and one task per published question-answer pair, as the +authors' code reads them. It lives in one file, `connector.py`. + +## What is verified on the real release + +The connector's QA parser ran on the two pinned QA files. It accepts every line, and every count on +this page that comes from the QA files is from that run. The HDF5 header was read over HTTP. It holds +only `seq_data` and `data_ID`, as the table below shows, with no compression and no attributes. + +Nobody has run a full build yet, so the 18.8 GB signals file has not been read end to end. Before you +rely on the dataset, run the build in [Local build](#local-build) once. + +## The source data + +The release is the Hub dataset +[pandalin98/EngineMT-QA](https://huggingface.co/datasets/pandalin98/EngineMT-QA), pinned at +`ea2051a15512212976c22c1a075ec549c7d48eef`. It holds three files: + +| File | Holds | +| --- | --- | +| `time_series_data.h5` | `seq_data`: float64 shaped (118,921, 600, 33); `data_ID`: the ids 1 to 118,921 | +| `train_qa.jsonl` | 13,291 lines, 101,565 QA pairs | +| `test_qa.jsonl` | 5,539 lines, 42,477 QA pairs | + +### Signals + +Row `i` of `seq_data` has id `i + 1`. So a QA's id `n` is row `n - 1`, which is how the authors' +`TsQaDataset` reads it. The HDF5 file names no channel. The authors' channel audit +([`docs/ISSUE_23_CHANNEL_AUDIT.md`](https://github.com/Pandalin98/ITFormer-ICML25/blob/b80142f/docs/ISSUE_23_CHANNEL_AUDIT.md)) +says not to name the 33 channels without a mapping, so the connector does not. + +The release does not say how the values are scaled. In 24 random rows, each channel has a mean from +-0.29 to 0.28 and a standard deviation from 0.74 to 1.07. So the values look z-scored, with +statistics that the release does not give. This is a measurement, not a statement by the authors. + +### QA + +Each line has an `id`, a `name` and a `conversations` list of `human` questions. A `gpt` answer +follows each question. A line has one of two shapes: + +| Line | `id` | Pairs | +| --- | --- | --- | +| Single-cycle | one row id | 8 Understanding, then 7 Perception | +| Multi-cycle | a list of 10 row ids | 2 Reasoning, then 1 Decision-Making | + +Every question holds one `` marker where the series goes. + +### The four tasks + +The paper defines the tasks in Section 5.1 and Appendix C: + +| Stage | Task | Input | Format | Authors' metric | +| --- | --- | --- | --- | --- | +| 1 | Understanding | 1 cycle | open | BLEU, ROUGE | +| 2 | Perception | 1 cycle | multiple choice | accuracy, F1 | +| 3 | Reasoning | 10 cycles | multiple choice | accuracy, F1 | +| 4 | Decision-Making | 10 cycles | open | BLEU, ROUGE | + +The closed questions have fixed wording. There are nine, and the release prints each one with one +option list: + +| Stage | Question | Options | +| --- | --- | --- | +| 2 | Health status of the fan, LPC, HPC, HPT, LPT (5 questions) | a: Health, b: Fault | +| 2 | Fault cause | a to f: HPT, LPT, Fan efficiency modifier; HPT, LPT, Fan flow modifier | +| 2 | Potential health state | a: Operating Normally, b: Abnormal Degradation, c: Imminent Failure | +| 3 | Qualitative condition of the engine | a to e: Good, Moderate, Poor, Bad, Extremely Poor Condition | +| 3 | Probability range of engine failure | a to e: 1%-10%, 10%-30%, 30%-50%, 50%-70%, 70%-100% | + +An answer is one letter. The fault cause is the exception. It can hold several letters joined by +`", "`, such as `a, b, e`. + +## The TimeNet dataset + +### Records + +The dataset holds one Record for each row that a labelled QA pair names: 7,755 of the 118,921 rows. A +row that both files or several lines name is one Record, and their tasks share it. Each Record has: + +- One Source, `N-CMAPSS engine`, with 33 signals, `channel_00` to `channel_32`, in `seq_data` column + order. The values are the published float64 values, unchanged. They have no unit. +- 600 values per signal on a regular 1 Hz axis. The rate comes from the paper's "10-minute (600 + points) time-series segments" (Section 5.2). The HDF5 file states no rate. +- Metadata `row_id`: the row's `data_ID`, which the QA files use as `id`. The release names no engine + unit or flight, so the metadata holds nothing else. + +The authors' encoder pretraining also reads the rows that no QA pair names. The connector leaves them +out, because they have no task. + +### Tasks + +Each published QA pair with a label becomes one task of its stage. Its split is the split of its file: +`train_qa.jsonl` is train and `test_qa.jsonl` is test. The tasks come in file order, train file first. + +| Stage | TimeNet type | Inputs | Targets | +| --- | --- | --- | --- | +| Understanding | `AnswerTask` | 1 Record | the published answer | +| Perception | `ClassificationTask` | 1 Record | the published letters | +| Reasoning | `ClassificationTask` | 10 Records | the published letter | +| Decision-Making | `AnswerTask` | 10 Records | the published answer | + +That gives 142,273 tasks: 100,296 train and 41,977 test. + +The prompt is the published question, unchanged, with its `` marker and its options. The connector +adds no wording. + +A closed question is a classification over letters. It always offers the same options in the same +order, so a letter has one meaning per question. The authors' model answers with the letters, and +their `closed_question_metrics` scores the set of letters. So the targets are the published letters, +one item per letter, in published order, such as `("a", "b", "e")`. + +Each closed task has a label set: the allowed letters, with the option text of each letter as its +description. The five health-status questions share the label set `component_health`. The other +label sets are `fault_cause`, `health_state`, `engine_condition` and `failure_probability`. Only +`fault_cause` is multi-label. + +A Reasoning or Decision-Making task has its 10 Records as inputs, in published order. The release does +not keep the lists sorted. The authors' model reads only the first 60 steps of each row and joins them +into one (600, 33) array (`TsQaDataset.__getitem__`). One task scope cannot cut 10 inputs, so the task +holds the whole Records. Its metadata states `steps_per_cycle: 60`. To build the authors' input, take +the first 60 steps of each Record. + +### Task metadata + +| Key | Value | +| --- | --- | +| `source_file`, `source_line`, `qa_offset` | where the pair is published. The line and offset are 0-based, as in the authors' evaluation | +| `stage` | the published stage, 1 to 4 | +| `closed_question` | the closed question, such as `hpc_health` or `fault_cause`. Closed tasks only | +| `steps_per_cycle` | 60. Multi-cycle tasks only | +| `source_issues` | a list of issue names, empty for most tasks. See [Source issues](#source-issues) | + +Error messages count lines from 1, as editors do. `source_line` counts from 0, as the authors do. + +### Dataset annotations + +The annotation `unlabelled_pairs` holds the count of closed pairs with an empty answer, 1,769. Its +metadata `pairs` lists the place of each one. See [Empty answers](#empty-answers). + +## Source issues + +The connector keeps every labelled pair as published. It names two problems in the task metadata +`source_issues`, with the same names as the TSAQA connector: + +| Issue | Meaning | Tasks | +| --- | --- | --- | +| `repeated_across_splits` | the other file has a pair with the same rows, question and answer | 27,961 train, 27,955 test | +| `repeated_question` | another pair in the same file has the same rows, question and answer | 12 train | + +The overlap is in the authors' release, not in the connector. The connector keeps the authors' split +as published, and only flags the repeated tasks. + +Most of the test file repeats the train file. 4,039 of the 5,539 test lines are byte copies of a train +line. 27,955 of the 41,977 test tasks (67%) are also in train: + +| Stage | Test tasks also in train | +| --- | --- | +| 1 Understanding | 10,800 of 17,240 | +| 2 Perception | 9,088 of 14,585 | +| 3 Reasoning | 5,378 of 6,768 | +| 4 Decision-Making | 2,689 of 3,384 | + +A model that memorizes train scores well on these tasks. The authors' issue +[#34](https://github.com/Pandalin98/ITFormer-ICML25/issues/34) reports Reasoning test accuracy of 99.3% +to 99.8%. To score on unseen pairs, leave out the test tasks whose `source_issues` holds +`repeated_across_splits`. + +## Empty answers + +1,769 closed answers are empty: the fault cause 1,054 times in train and 422 times in test, the +health state 215 times in train and 78 times in test. The connector treats an empty answer as a +missing label, and the pair gets no task. The authors trained on these pairs. + +An empty fault cause does not mean "no fault". 1,031 of the 1,476 empty fault causes are on lines +where at least one component is answered `b: Fault`. The answers also disagree the other way: 1,821 +fault causes that are not empty are on lines where all five components are answered `a: Health`. + +## What the connector checks + +Conversion fails with `TimeFValidationError` when the content is wrong. For a QA line, the message +names the file and the line. Conversion fails when: + +- The signals file does not hold exactly the HDF5 datasets `seq_data` and `data_ID`, with `seq_data` + as float64 shaped (rows, 600, 33) and `data_ID` as the integers 1 to the number of rows. +- A QA file has another number of lines, pairs per stage or empty answers per question than the + pinned release. This catches a truncated or empty file. +- A QA line has other keys than `id`, `name` and `conversations`, or a `name` that does not repeat its + `id`. It also fails for an id that is not a row of the file, or a list that does not hold 10 + distinct ids. +- The conversation does not alternate a `human` question and a `gpt` answer. +- The stage, the `open` or `close` attribute and the number of rows disagree, or a question does not + hold one `` marker. +- A closed question is not one of the nine, or prints other options than its label set. Other options + would change what a letter means. +- A closed answer is not distinct letters of its options, or holds several letters for a single-label + question. +- An open answer is empty. + +The values stay in the HDF5 file until the writer reads them. When a signal reads its row, it fails +with `TimeFFormatError` if the file cannot be opened or the row cannot be read. It fails with +`TimeFValidationError` if the row holds a NaN or an infinite value. The values look z-scored, so they +must be finite. + +The task stream reads each QA file a second time. Conversion keeps a 16-byte digest of each line, and +the second read compares each line with its digest. If a line changed or was removed, or the file +cannot be read, the stream fails with `TimeFFormatError`. + +## How the connector follows the authors + +| The authors (code at `b80142f`) | The connector | +| --- | --- | +| `_build_index` flattens each line into one sample per pair | one task per labelled pair | +| `seq_data[int(id) - 1]` | the Record of row id `id` | +| first 60 steps of each of 10 rows, joined | 10 input Records, `steps_per_cycle: 60` | +| SFT target: the published answer | the target: the answer, or its letters | +| `closed_question_metrics`: the set of letters a to f | a `ClassificationTask` over a label set of letters | +| train on `train_qa.jsonl`, evaluate on `test_qa.jsonl` | `Split.TRAIN`, `Split.TEST` | +| `source_line`, `qa_offset` | `source_line`, `qa_offset` in task metadata | + +## Comparing with the paper and the card + +- Channels: the paper says 32 channels. The release has 33. The authors' audit cannot tell which + column is extra, so dropping one would be a guess. The connector keeps all 33. +- Pairs: the paper gives 11k or 110k pairs, and the Hub card gives 87k train and 25k test pairs. The + files hold 101,565 train and 42,477 test pairs. +- Reasoning: the paper says Reasoning predicts "the probability of future failures and the remaining + useful life" (Section 5.1). The release has no remaining-useful-life question. Reasoning asks for + the condition and the failure probability. +- Cycles: the paper says a multi-cycle question is about "10 consecutive cycles" (Section 5.1). Every + one of the 11,534 multi-cycle lists has gaps between its ids, and 256 of them mix two ranges of ids. +- Time: the paper calls an input both a "10-minute (600 points)" segment and a cycle of "600 time + steps". N-CMAPSS flights last hours, so a row can be a window of a flight and not a whole flight. + This is not confirmed. + +## Data limitations + +- The test split mostly repeats train. See [Source issues](#source-issues). +- The signals come from a simulator, are scaled, and have no channel names. The questions name + signals such as altitude, but no Record says which channel is which. +- The paper says an LLM rewrote the questions and answers, and experts checked them (Appendix A). The + Understanding and Decision-Making answers vary in wording for the same content. + +## Open questions + +- License: the Hub metadata says MIT, but the License section of the card is an unfilled placeholder. + The paper names no data license. The dataset card here says MIT. Confirm with the authors. +- Channel names: which N-CMAPSS variable each of the 33 channels holds, and which one the paper's 32 + leaves out. +- Sampling rate: whether a row is a 10-minute window at 1 Hz, and where in its flight it starts. + +## Local build + +```bash +uv run timenet-build build pandalin98/enginemt-qa --out .timenet-registry +``` + +The build downloads 18.8 GB. It reads the 7,755 named rows, about 1.2 GB of values. diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/__init__.py b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/__init__.py new file mode 100644 index 000000000..0f217e8c8 --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/__init__.py @@ -0,0 +1,6 @@ +"""EngineMT-QA: aero-engine question answering over simulated N-CMAPSS cycles, in four tasks.""" + +from timenet_connectors.datasets.pandalin98.enginemt_qa.connector import ( + CONNECTOR as CONNECTOR, + EngineMTQAConnector as EngineMTQAConnector, +) diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/connector.py b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/connector.py new file mode 100644 index 000000000..d5085b6b6 --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/connector.py @@ -0,0 +1,900 @@ +"""Convert the pinned EngineMT-QA files into lazy Records and one task per QA pair. + +Each HDF5 row that a QA pair names becomes a Record whose 33 signals read the row on demand. Each QA +pair that has a label becomes one task of its stage. README.md explains how this follows the authors. + +Metadata is provenance and never model input. +""" + +from collections import Counter +from collections.abc import Iterator, Mapping, Sequence +from dataclasses import dataclass, field +from enum import IntEnum, StrEnum, unique +from functools import lru_cache, partial +import hashlib +import json +import logging +from pathlib import Path +import re +import string +from typing import Any, ClassVar, NamedTuple, TypedDict, cast + +import numpy as np +import pyarrow as pa + +from timenet.dataset import Record, Signal, Source, TimeFDataset +from timenet.dataset.axis import RegularAxis +from timenet.errors import TimeFFormatError, TimeFValidationError +from timenet.json import JsonValue +from timenet.types import ( + Annotation, + AnswerTask, + ClassificationTask, + Label, + LabelSet, + Split, + Task, + TimeSeriesSpec, +) +from timenet_connectors.bases.huggingface import BaseHuggingFaceConnector, HubFileRef + + +_LOGGER = logging.getLogger(__name__) + +_N_STEPS = 600 +_N_CHANNELS = 33 +"""The released channel count. The paper says 32. The authors' audit confirms 33 and names none of them.""" +_MULTI_CYCLE_ROWS = 10 +"""How many rows a multi-cycle QA names.""" +_STEPS_PER_CYCLE = _N_STEPS // _MULTI_CYCLE_ROWS +"""The steps of each cycle that the authors' model reads in a multi-cycle task: the first 60 of 600.""" +_SAMPLE_RATE_HZ = 1 +"""The paper's "10-minute (600 points) time-series segments" (Section 5.2). The HDF5 file states no rate.""" +_ROW_SHAPE = (_N_STEPS, _N_CHANNELS) +_SEQ_DATA = "seq_data" +"""The HDF5 dataset of every row's values, shaped ``(rows, steps, channels)``.""" +_DATA_ID = "data_ID" +"""The HDF5 dataset of each row's id, which a QA's ``id`` names. Row ``i`` has id ``i + 1``.""" +_SOURCE_NAME = "N-CMAPSS engine" +_CHANNELS = tuple(f"channel_{index:02d}" for index in range(_N_CHANNELS)) +"""The release names no channel. The zero-padded names sort in the source's order.""" +# In 24 sampled rows, every channel has a mean near 0 and a standard deviation near 1, so the values +# look z-scored. The release states neither the units nor the statistics. +_SPEC = TimeSeriesSpec( + spec_type="enginemt_qa_channel", name="EngineMT-QA channel, z-scored", unit_value=None, dtype="float64" +) +_AXIS = RegularAxis.from_rate_hz(_SAMPLE_RATE_HZ) +# A published row id: a decimal number with no sign and no leading zero, such as "278". +_ROW_ID = re.compile(r"[1-9][0-9]*") +# One printed option of a closed question: its letter, then its text, such as "a: Health\n". +_OPTION = re.compile(r"([a-z]):\s+([^\n]+)\n") +_DIGEST_BYTES = 16 +"""The size of a line or pair digest. 16 bytes make an accidental match between two of the release's +144,042 pairs practically impossible, and keep the digests of a file small.""" + + +@unique +class _Key(StrEnum): + """The keys of the annotations and the metadata that the connector writes.""" + + ROW_ID = "row_id" + SOURCE_FILE = "source_file" + SOURCE_LINE = "source_line" + QA_OFFSET = "qa_offset" + STAGE = "stage" + STEPS_PER_CYCLE = "steps_per_cycle" + CLOSED_QUESTION = "closed_question" + SOURCE_ISSUES = "source_issues" + UNLABELLED_PAIRS = "unlabelled_pairs" + + +@unique +class SourceIssue(StrEnum): + """A problem in a published pair, which the connector keeps as published and names in the task's metadata. + + The names match the TSAQA connector's, so one filter can serve both datasets. + """ + + REPEATED_QUESTION = "repeated_question" + """Another pair of the same file has the same rows, question and answer.""" + REPEATED_ACROSS_SPLITS = "repeated_across_splits" + """The other file has a pair with the same rows, question and answer.""" + + +@unique +class _Part(StrEnum): + """The release's three files: the signals, and the train and test QA.""" + + SIGNALS = "signals" + TRAIN = "train" + TEST = "test" + + @property + def source_file(self) -> str: + """The file's name in the Hub repository, such as ``train_qa.jsonl``.""" + return "time_series_data.h5" if self is _Part.SIGNALS else f"{self.value}_qa.jsonl" + + @property + def task_split(self) -> Split: + """The split of a QA file: the authors train on ``train_qa`` and test on ``test_qa``. + + Raises: + TimeFValidationError: If the part is not a QA file. + """ + if self not in _SPLITS: + raise TimeFValidationError(f"{self} is not a QA file") + return _SPLITS[self] + + +_SPLITS = {_Part.TRAIN: Split.TRAIN, _Part.TEST: Split.TEST} +_QA_PARTS = tuple(_SPLITS) + + +@unique +class _Stage(IntEnum): + """The release's ``stage``: one of the paper's four tasks.""" + + UNDERSTANDING = 1 + PERCEPTION = 2 + REASONING = 3 + DECISION_MAKING = 4 + + @property + def is_closed(self) -> bool: + """Whether the stage asks closed questions, which the release marks ``close``.""" + return self in {_Stage.PERCEPTION, _Stage.REASONING} + + @property + def is_multi_cycle(self) -> bool: + """Whether the stage's questions name 10 cycles rather than one.""" + return self in {_Stage.REASONING, _Stage.DECISION_MAKING} + + +@unique +class _Attribute(StrEnum): + """The release's ``attribute`` of a question.""" + + OPEN = "open" + CLOSE = "close" + + +@unique +class _Role(StrEnum): + """The ``from`` of a turn: a question comes from ``human`` and its answer from ``gpt``.""" + + HUMAN = "human" + GPT = "gpt" + + +def _option_letters(name: str, options: Sequence[str], *, multi_label: bool = False) -> LabelSet: + """Build the label set of a closed question: one label per option letter, from ``a``. + + Returns: + The label set. Each label's name is a letter, and its description is the option the letter + stands for. + """ + labels = tuple( + Label(name=letter, description=option) + for letter, option in zip(string.ascii_lowercase[: len(options)], options, strict=True) + ) + return LabelSet(name=name, labels=labels, multi_label=multi_label) + + +_COMPONENT_HEALTH = _option_letters("component_health", ("Health", "Fault")) +_FAULT_CAUSE = _option_letters( + "fault_cause", + ( + "HPT efficiency modifier", + "LPT efficiency modifier", + "Fan efficiency modifier", + "HPT flow modifier", + "LPT flow modifier", + "Fan flow modifier", + ), + # The authors' answers list every cause that applies, such as "a, b, e". + multi_label=True, +) +_HEALTH_STATE = _option_letters("health_state", ("Operating Normally", "Abnormal Degradation", "Imminent Failure")) +_ENGINE_CONDITION = _option_letters( + "engine_condition", + ("Good Condition", "Moderate Condition", "Poor Condition", "Bad Condition", "Extremely Poor Condition"), +) +_FAILURE_PROBABILITY = _option_letters("failure_probability", ("1%-10%", "10%-30%", "30%-50%", "50%-70%", "70%-100%")) + + +class _ClosedSpec(NamedTuple): + stage: _Stage + label_set: LabelSet + stem: str + """The question's text up to its ``?``. The release publishes each closed question with one stem.""" + + +_REASONING_STEM = ( + "Given the time series signal , by perceiving the engine signal across 10 cycles to reflect different " + "health states and performing temporal inference to predict the health decline trend, " +) +_ONE_CYCLE = "of the given engine signal in one cycle" + + +def _prints_options(options: str, label_set: LabelSet) -> bool: + """Tell whether the printed options of a question are the label set's, in letter order. + + Returns: + ``True`` if each printed letter and text is a label's name and description, in label order. + """ + printed = _OPTION.findall(options) + return printed == [(label.name, label.description) for label in label_set.labels] + + +@unique +class _ClosedQuestion(StrEnum): + """A closed question, which the release always publishes with the same stem and options.""" + + FAN_HEALTH = "fan_health" + LPC_HEALTH = "lpc_health" + HPC_HEALTH = "hpc_health" + HPT_HEALTH = "hpt_health" + LPT_HEALTH = "lpt_health" + FAULT_CAUSE = "fault_cause" + HEALTH_STATE = "health_state" + ENGINE_CONDITION = "engine_condition" + FAILURE_PROBABILITY = "failure_probability" + + @property + def stage(self) -> _Stage: + """The question's stage.""" + return _CLOSED[self].stage + + @property + def label_set(self) -> LabelSet: + """The question's option letters.""" + return _CLOSED[self].label_set + + @classmethod + def of(cls, stage: _Stage, text: str) -> "_ClosedQuestion": + """Identify a published closed question by its stem, and check that it prints its label set's options. + + Args: + stage: The stage that the release gives the question. + text: The published question. + + Returns: + The question. + + Raises: + ValueError: If no closed question of the stage has this stem, or its printed options differ from + the label set's, which would change what each letter means. + """ + stem, _, options = text.partition("?") + question = _BY_STEM.get(stem) + if question is None or question.stage is not stage: + raise ValueError(f"unknown stage {stage} closed question {text[:80]!r}") + if not _prints_options(options, question.label_set): + raise ValueError(f"{question} prints options other than its label set's: {options!r}") + return question + + def parse_answer(self, answer: str) -> tuple[str, ...]: + """Parse a published answer, such as ``a`` or ``a, b, e``, into its letters. + + Returns: + The letters, in published order. + + Raises: + ValueError: If the answer isn't distinct letters of the question's options, joined by ``", "``, + or holds several letters where one is expected. + """ + letters = tuple(answer.split(", ")) + try: + self.label_set.check_targets(letters) + except TimeFValidationError as exc: + raise ValueError(f"{self}: answer {answer!r}: {exc}") from exc + return letters + + +def _health_spec(component: str) -> _ClosedSpec: + return _ClosedSpec(_Stage.PERCEPTION, _COMPONENT_HEALTH, f"What is the health status of {component} {_ONE_CYCLE}") + + +_CLOSED = { + _ClosedQuestion.FAN_HEALTH: _health_spec("fan"), + _ClosedQuestion.LPC_HEALTH: _health_spec("LPC"), + _ClosedQuestion.HPC_HEALTH: _health_spec("HPC"), + _ClosedQuestion.HPT_HEALTH: _health_spec("HPT"), + _ClosedQuestion.LPT_HEALTH: _health_spec("LPT"), + _ClosedQuestion.FAULT_CAUSE: _ClosedSpec( + _Stage.PERCEPTION, + _FAULT_CAUSE, + f"Was the timing issue in the operation {_ONE_CYCLE} caused by efficiency or flow problems", + ), + _ClosedQuestion.HEALTH_STATE: _ClosedSpec( + _Stage.PERCEPTION, _HEALTH_STATE, f"What is the potential health state {_ONE_CYCLE}" + ), + _ClosedQuestion.ENGINE_CONDITION: _ClosedSpec( + _Stage.REASONING, _ENGINE_CONDITION, _REASONING_STEM + "what is the qualitative condition of the engine" + ), + _ClosedQuestion.FAILURE_PROBABILITY: _ClosedSpec( + _Stage.REASONING, _FAILURE_PROBABILITY, _REASONING_STEM + "what is the probability range of engine failure" + ), +} +_BY_STEM = {spec.stem: question for question, spec in _CLOSED.items()} + + +class _FileCounts(NamedTuple): + """The pinned size of a QA file, which conversion checks so that a short or changed file fails.""" + + lines: int + pairs: Mapping[_Stage, int] + """The pairs of each stage, empty answers included.""" + unlabelled: Mapping[_ClosedQuestion, int] + """The closed pairs with an empty answer, for each question that has any.""" + + +class _Place(NamedTuple): + """Where a pair was published.""" + + part: _Part + line: int + """The 0-based line in the file, which the authors call ``source_line``.""" + offset: int + """The 0-based place in the line, which the authors call ``qa_offset``.""" + + @property + def metadata(self) -> dict[str, JsonValue]: + """The place as the authors' evaluation names it.""" + return {_Key.SOURCE_FILE: self.part.source_file, _Key.SOURCE_LINE: self.line, _Key.QA_OFFSET: self.offset} + + +@dataclass(frozen=True) +class _Pair: + """One published question with its answer, and the rows it is about.""" + + place: _Place + rows: tuple[int, ...] + """The row ids in published order: one for a single-cycle question and ten for a multi-cycle one.""" + stage: _Stage + question: str + """The question as published, with its ```` marker.""" + answer: str + """The answer as published: free text, or letters for a closed question.""" + closed: _ClosedQuestion | None + """The closed question, or ``None`` for an open one.""" + + @property + def missing_label(self) -> _ClosedQuestion | None: + """The closed question, if its published answer is empty. Such a pair is a missing label and has no task.""" + return None if self.answer else self.closed + + @property + def has_label(self) -> bool: + """Whether the pair has a task.""" + return self.missing_label is None + + @property + def digest(self) -> bytes: + """A digest of the rows, the question and the answer, which match for a repeated pair.""" + content = json.dumps([self.rows, self.question, self.answer]).encode() + return hashlib.blake2b(content, digest_size=_DIGEST_BYTES).digest() + + def inputs(self, records: Mapping[int, Record]) -> tuple[Record, ...]: + """Return the Records of the pair's rows, in published order. + + Raises: + TimeFFormatError: If a row has no Record, as when a QA file changed since conversion. + """ + missing = [row for row in self.rows if row not in records] + if missing: + raise TimeFFormatError( + f"{self.place.part.source_file} line {self.place.line + 1}: no Record for rows {missing}" + ) + return tuple(records[row] for row in self.rows) + + def task(self, inputs: tuple[Record, ...], issues: Sequence[SourceIssue]) -> AnswerTask | ClassificationTask: + """Build the task of a pair that has a label. + + Args: + inputs: The Records of the pair's rows, in published order. + issues: The pair's source issues, in ``SourceIssue`` order. + + Returns: + An answer task for an open question, with the published answer as target. A classification task + for a closed question, with the published letters as targets over its label set. + """ + issue_names: list[JsonValue] = [issue.value for issue in issues] + metadata = self.place.metadata | {_Key.STAGE: self.stage.value, _Key.SOURCE_ISSUES: issue_names} + if self.stage.is_multi_cycle: + metadata[_Key.STEPS_PER_CYCLE] = _STEPS_PER_CYCLE + split = self.place.part.task_split + if self.closed is None: + return AnswerTask( + inputs=inputs, prompt=self.question, targets=(self.answer,), split=split, metadata=metadata + ) + return ClassificationTask( + inputs=inputs, + prompt=self.question, + targets=self.closed.parse_answer(self.answer), + label_set=self.closed.label_set, + split=split, + metadata=metadata | {_Key.CLOSED_QUESTION: self.closed.value}, + ) + + +# The published JSON shapes. A value is ``object`` until the parser checks it. The turns use the +# functional form because their key ``from`` is a Python keyword. +class _Line(TypedDict): + id: object + name: object + conversations: object + + +_Question = TypedDict("_Question", {"from": object, "stage": object, "attribute": object, "value": object}) +_Answer = TypedDict("_Answer", {"from": object, "value": object}) + + +def _require_keys(value: object, keys: frozenset[str]) -> dict[str, object]: + """Check that a JSON value is an object with exactly these keys. + + Returns: + The object. + + Raises: + ValueError: If the value is not an object, or lacks a key or has another. + """ + if not isinstance(value, dict) or set(value) != keys: + raise ValueError(f"expected an object with the keys {sorted(keys)}, got {value!r}") + return value + + +def _parse_line(raw: bytes) -> _Line: + """Parse one JSON line and check its keys. + + Returns: + The object, typed by its keys. ``_require_keys`` raises ``ValueError`` if they differ. + """ + return cast(_Line, _require_keys(json.loads(raw), _Line.__required_keys__)) + + +def _parse_question(value: object) -> _Question: + """Check the keys of a question turn. + + Returns: + The object, typed by its keys. ``_require_keys`` raises ``ValueError`` if they differ. + """ + return cast(_Question, _require_keys(value, _Question.__required_keys__)) + + +def _parse_answer(value: object) -> _Answer: + """Check the keys of an answer turn. + + Returns: + The object, typed by its keys. ``_require_keys`` raises ``ValueError`` if they differ. + """ + return cast(_Answer, _require_keys(value, _Answer.__required_keys__)) + + +def _require_text(value: object, *, allow_blank: bool = False) -> str: + """Check that a JSON value is text. + + Returns: + The text. + + Raises: + ValueError: If the value is not text, or is blank and ``allow_blank`` is false. + """ + if not isinstance(value, str) or not (allow_blank or value.strip()): + raise ValueError(f"expected {'text' if allow_blank else 'nonblank text'}, got {value!r}") + return value + + +def _as_list(value: object) -> list[object]: + return value if isinstance(value, list) else [value] + + +def _row_ids(line: _Line, n_rows: int) -> tuple[int, ...]: + """Read the row ids of a line, and check that its ``name`` repeats them. + + Returns: + One id for a single-cycle line, ten for a multi-cycle line, in published order. + + Raises: + ValueError: If an id is not a row of the file, or the ids repeat or are not one or ten. + """ + raw_ids, raw_names = line["id"], line["name"] + is_list = isinstance(raw_ids, list) + ids = _as_list(raw_ids) + names_match = isinstance(raw_names, list) == is_list and _as_list(raw_names) == [f"{i}.csv" for i in ids] + if not names_match: + raise ValueError(f"name {raw_names!r} doesn't repeat id {raw_ids!r}") + rows: list[int] = [] + for i in ids: + if not isinstance(i, str) or not _ROW_ID.fullmatch(i): + raise ValueError(f"id {raw_ids!r} is not decimal row ids") + rows.append(int(i)) + if is_list and len(rows) != _MULTI_CYCLE_ROWS: + raise ValueError(f"a multi-cycle id names {len(rows)} rows, not {_MULTI_CYCLE_ROWS}") + if len(set(rows)) != len(rows): + raise ValueError(f"id {raw_ids!r} repeats a row") + if max(rows) > n_rows: + raise ValueError(f"id {raw_ids!r} names a row past the file's {n_rows} rows") + return tuple(rows) + + +def _parse_stage(value: object) -> _Stage: + """Read a published stage, which is the text ``"1"`` to ``"4"``. + + Returns: + The stage. + + Raises: + ValueError: If the value is not one of the four stages. + """ + if not isinstance(value, str) or value not in {str(stage.value) for stage in _Stage}: + raise ValueError(f"bad stage {value!r}") + return _Stage(int(value)) + + +def _parse_attribute(value: object) -> _Attribute: + """Read a published ``attribute``. + + Returns: + The attribute. + + Raises: + ValueError: If the value is not ``open`` or ``close``. + """ + if not isinstance(value, str) or value not in set(_Attribute): + raise ValueError(f"bad attribute {value!r}") + return _Attribute(value) + + +def _parse_pair(place: _Place, rows: tuple[int, ...], question_turn: object, answer_turn: object) -> _Pair: + """Check one question and its answer against its stage, and build the pair. + + Returns: + The pair. + + Raises: + ValueError: If the stage, the format and the number of rows disagree, a closed question is unknown, or + an answer is malformed. + """ + question, answer = _parse_question(question_turn), _parse_answer(answer_turn) + if question["from"] != _Role.HUMAN or answer["from"] != _Role.GPT: + raise ValueError("conversations must alternate a human question and a gpt answer") + stage, attribute = _parse_stage(question["stage"]), _parse_attribute(question["attribute"]) + if (attribute is _Attribute.CLOSE) != stage.is_closed: + raise ValueError(f"stage {stage} questions are not {attribute.value!r}") + if (len(rows) > 1) != stage.is_multi_cycle: + raise ValueError(f"a stage {stage} question names {len(rows)} rows") + text, reply = _require_text(question["value"]), _require_text(answer["value"], allow_blank=True) + if text.count("") != 1: + raise ValueError("a question must hold one marker") + closed = _ClosedQuestion.of(stage, text) if stage.is_closed else None + if closed is None and not reply.strip(): + raise ValueError("an open question has an empty answer") + if closed is not None and reply: + # Parse here, so a malformed answer fails the read and not the task stream. + closed.parse_answer(reply) + return _Pair(place, rows, stage, text, reply, closed) + + +@dataclass +class _QAFile: + """One QA file. It is read twice, and the second read must see the file the first one did.""" + + path: Path + part: _Part + n_rows: int + line_digests: list[bytes] | None = field(default=None, init=False) + """A digest of each line, kept by the first complete read.""" + + def pairs(self) -> Iterator[_Pair]: + """Read every line of the file and flatten it into pairs, in file order. + + The first complete read keeps a digest of each line. A later read checks each line against its + digest before it parses the line. + + Yields: + Each published pair, empty answers included. + + Raises: + TimeFValidationError: If a line or a pair is malformed, with its file, line and pair. + TimeFFormatError: If the file cannot be read, or changed since the first complete read. + """ # ruff: ignore[docstring-extraneous-exception] - TimeFValidationError is raised by _line_pairs + expected = self.line_digests + digests: list[bytes] = [] + try: + with self.path.open("rb") as lines: + for number, raw in enumerate(lines): + digest = hashlib.blake2b(raw, digest_size=_DIGEST_BYTES).digest() + if expected is not None and (number >= len(expected) or digest != expected[number]): + raise TimeFFormatError(f"{self.path} line {number + 1}: the line changed since conversion") + digests.append(digest) + yield from self._line_pairs(number, raw) + except OSError as exc: + raise TimeFFormatError(f"{self.path}: cannot read the file: {exc}") from exc + if expected is None: + self.line_digests = digests + elif len(digests) != len(expected): + raise TimeFFormatError(f"{self.path}: lines were removed since conversion") + + def _line_pairs(self, number: int, raw: bytes) -> Iterator[_Pair]: + where = f"{self.part.source_file} line {number + 1}" + try: + line = _parse_line(raw) + rows = _row_ids(line, self.n_rows) + turns = line["conversations"] + if not isinstance(turns, list) or not turns or len(turns) % 2: + raise ValueError("conversations must alternate a human question and a gpt answer") + for offset in range(len(turns) // 2): + where = f"{self.part.source_file} line {number + 1}, pair {offset}" + place = _Place(self.part, number, offset) + yield _parse_pair(place, rows, turns[2 * offset], turns[2 * offset + 1]) + except ValueError as exc: + raise TimeFValidationError(f"{where}: {exc}") from exc + + +def _import_h5py() -> Any: + """Import ``h5py`` when a file is read, so the connector can load without it. + + Returns: + The ``h5py`` module. + + Raises: + ImportError: If ``h5py``, declared in this connector's requirements, is not installed. + """ + try: + import h5py # ruff: ignore[import-outside-top-level] + except ImportError as exc: + raise ImportError("reading EngineMT-QA needs h5py, declared in this connector's requirements.txt") from exc + return h5py + + +def _open_signals(path: Path) -> Any: + """Open the signals file for reading. + + Returns: + The open ``h5py.File``, to use as a context manager. + + Raises: + TimeFFormatError: If the file cannot be opened as HDF5, as with a truncated download. + """ + h5py = _import_h5py() + try: + return h5py.File(path, "r") + except OSError as exc: + raise TimeFFormatError(f"{path}: cannot open the signals file: {exc}") from exc + + +def _check_layout(path: Path) -> int: + """Check that the signals file holds exactly ``seq_data`` and ``data_ID``, with the ids ``1..n``. + + Returns: + The number of rows ``n``. + + Raises: + TimeFValidationError: If the layout, the shape, the dtype or the ids differ from the published file's. + TimeFFormatError: If the file cannot be opened or read as HDF5. + """ + h5py = _import_h5py() + with _open_signals(path) as file: + if set(file) != {_SEQ_DATA, _DATA_ID}: + raise TimeFValidationError(f"{path}: expected {_SEQ_DATA} and {_DATA_ID}, got {sorted(file)}") + values, ids = file[_SEQ_DATA], file[_DATA_ID] + for name, node in ((_SEQ_DATA, values), (_DATA_ID, ids)): + if not isinstance(node, h5py.Dataset): + raise TimeFValidationError(f"{path}: {name} is a {type(node).__name__}, not an HDF5 dataset") + if values.shape[1:] != _ROW_SHAPE or values.dtype != np.float64: + raise TimeFValidationError(f"{path}: {_SEQ_DATA} is {values.dtype} {values.shape}") + n_rows = values.shape[0] + if ids.shape != (n_rows,) or not np.issubdtype(ids.dtype, np.integer): + raise TimeFValidationError(f"{path}: {_DATA_ID} is {ids.dtype} {ids.shape}, not {n_rows} integer ids") + try: + published_ids = ids[:] + except OSError as exc: + raise TimeFFormatError(f"{path}: cannot read {_DATA_ID}: {exc}") from exc + if not np.array_equal(published_ids, np.arange(1, n_rows + 1)): + raise TimeFValidationError(f"{path}: {_DATA_ID} is not the row ids 1 to {n_rows}") + return n_rows + + +def _read_row(file: Any, path: Path, row_id: int) -> np.ndarray: + """Read one row's values from an open signals file. + + Returns: + The values, shaped ``(600, 33)``: steps, then channels. + + Raises: + TimeFFormatError: If the file no longer holds the row, as when it changed since conversion, or a + block of the file cannot be read. + TimeFValidationError: If the row holds a NaN or an infinite value. z-scored values are finite. + """ + try: + values = np.asarray(file[_SEQ_DATA][row_id - 1], dtype=np.float64) + except (KeyError, IndexError, ValueError, OSError) as exc: + raise TimeFFormatError(f"{path}: cannot read row id {row_id}: {exc}") from exc + if values.shape != _ROW_SHAPE: + raise TimeFFormatError(f"{path}: row id {row_id} is shaped {values.shape}; the file changed") + if not np.isfinite(values).all(): + raise TimeFValidationError(f"{path}: row id {row_id} holds a NaN or an infinite value") + return values + + +class _RowReader: + """Read one channel of a row when a signal asks for it. + + The writer loads a Record's signals one after another, so caching the last row reads each row once + for all 33 channels. + """ + + def __init__(self, path: Path) -> None: + self._path = path + self._row = lru_cache(maxsize=1)(self._read) + + def _read(self, row_id: int) -> np.ndarray: + with _open_signals(self._path) as file: + return _read_row(file, self._path, row_id) + + def __call__(self, row_id: int, channel: int) -> pa.Array: + """Return one channel of a row. + + Returns: + The channel's 600 float64 values. + """ + return pa.array(self._row(row_id)[:, channel], type=pa.float64()) + + +def _record(row_id: int, reader: _RowReader) -> Record: + """Build a row's Record: one Source of 33 lazy signals, and the row id as metadata. + + Returns: + The Record, whose values stay in the HDF5 file until read. + """ + signals = tuple( + Signal.from_loader( + name=name, spec=_SPEC, time_axis=_AXIS, n_values=_N_STEPS, loader=partial(reader, row_id, channel) + ) + for channel, name in enumerate(_CHANNELS) + ) + return Record(sources=(Source(name=_SOURCE_NAME, signals=signals),), metadata={_Key.ROW_ID: row_id}) + + +@dataclass +class _Scan: + """What one read of every QA pair finds.""" + + named_rows: set[int] = field(default_factory=set) + """The rows that the pairs with a label name.""" + unlabelled: list[_Place] = field(default_factory=list) + """The places of the closed pairs with an empty answer.""" + digests: dict[_Part, Counter[bytes]] = field(default_factory=dict) + """How often each labelled pair's digest occurs in each file.""" + + def issues(self, pair: _Pair) -> list[SourceIssue]: + """Name the source issues of a labelled pair. + + Returns: + The issues, in ``SourceIssue`` order. + """ + digest = pair.digest + found = [] + if self.digests[pair.place.part][digest] > 1: + found.append(SourceIssue.REPEATED_QUESTION) + if any(self.digests[part][digest] for part in _QA_PARTS if part is not pair.place.part): + found.append(SourceIssue.REPEATED_ACROSS_SPLITS) + return found + + +def _scan(qa_files: Sequence[_QAFile], counts: Mapping[_Part, _FileCounts]) -> _Scan: + """Check every pair once, and collect what the dataset needs from all of them. + + Returns: + The rows that labelled pairs name, the unlabelled pairs, and the digests of the labelled pairs. + + Raises: + TimeFValidationError: If a file's counts differ from the pinned ones. + """ + scan = _Scan() + for qa in qa_files: + digests: Counter[bytes] = Counter() + pairs: Counter[_Stage] = Counter() + unlabelled: Counter[_ClosedQuestion] = Counter() + for pair in qa.pairs(): + pairs[pair.stage] += 1 + question = pair.missing_label + if question is None: + scan.named_rows.update(pair.rows) + digests[pair.digest] += 1 + else: + scan.unlabelled.append(pair.place) + unlabelled[question] += 1 + found = _FileCounts(len(qa.line_digests or ()), dict(pairs), dict(unlabelled)) + if found != counts[qa.part]: + raise TimeFValidationError(f"{qa.path}: expected {counts[qa.part]}, found {found}") + scan.digests[qa.part] = digests + if scan.unlabelled: + _LOGGER.warning("%d closed pairs have an empty answer and get no task", len(scan.unlabelled)) + return scan + + +def _unlabelled_annotation(places: Sequence[_Place]) -> Annotation: + pairs: list[JsonValue] = [place.metadata for place in places] + return Annotation( + key=_Key.UNLABELLED_PAIRS, + value=len(places), + description="How many closed pairs have an empty published answer. They are missing labels and have no task.", + metadata={"pairs": pairs}, + ) + + +class EngineMTQAConnector(BaseHuggingFaceConnector): + """Build EngineMT-QA from the pinned files of its Hugging Face release.""" + + HF_REPO = "pandalin98/EngineMT-QA" + SOURCE_REVISION = "ea2051a15512212976c22c1a075ec549c7d48eef" + SOURCE_FILES: ClassVar[Mapping[str, str]] = {part.value: part.source_file for part in _Part} + # Counted on the pinned files. They match the authors' README: 101,565 train and 42,477 test pairs. + SOURCE_COUNTS: ClassVar[Mapping[_Part, _FileCounts]] = { + _Part.TRAIN: _FileCounts( + lines=13_291, + pairs={ + _Stage.UNDERSTANDING: 41_128, + _Stage.PERCEPTION: 35_987, + _Stage.REASONING: 16_300, + _Stage.DECISION_MAKING: 8_150, + }, + unlabelled={_ClosedQuestion.FAULT_CAUSE: 1_054, _ClosedQuestion.HEALTH_STATE: 215}, + ), + _Part.TEST: _FileCounts( + lines=5_539, + pairs={ + _Stage.UNDERSTANDING: 17_240, + _Stage.PERCEPTION: 15_085, + _Stage.REASONING: 6_768, + _Stage.DECISION_MAKING: 3_384, + }, + unlabelled={_ClosedQuestion.FAULT_CAUSE: 422, _ClosedQuestion.HEALTH_STATE: 78}, + ), + } + + def convert(self, raw_refs: list[HubFileRef]) -> TimeFDataset: + """Convert the files into one lazy Record per named row, and a stream of one task per labelled pair. + + Conversion checks the signals file's layout and every QA line once, and compares each QA file's + counts with the pinned ones. The values stay in the HDF5 file until written, so the files must stay + available until then. A closed pair with an empty answer is a missing label and gets no task. + + Args: + raw_refs: The downloaded files, one per part. + + Returns: + A dataset with the Records, the unlabelled pairs as an annotation, and a stream of every task. + + Raises: + TimeFValidationError: If a part is missing, or a file is malformed or has other counts. + TimeFFormatError: If a file cannot be read. + """ # ruff: ignore[docstring-extraneous-exception] - raised by the helpers it calls + paths = {_Part(ref.part): ref.path for ref in raw_refs} + if paths.keys() != set(_Part): + raise TimeFValidationError(f"EngineMT-QA needs the parts {[part.value for part in _Part]}") + signals_path = paths[_Part.SIGNALS] + n_rows = _check_layout(signals_path) + qa_files = [_QAFile(paths[part], part, n_rows) for part in _QA_PARTS] + scan = _scan(qa_files, self.SOURCE_COUNTS) + reader = _RowReader(signals_path) + records = {row_id: _record(row_id, reader) for row_id in sorted(scan.named_rows)} + + dataset = TimeFDataset(metadata=self.metadata()) + dataset.annotate(_unlabelled_annotation(scan.unlabelled)) + for record in records.values(): + dataset.add_record(record=record) + + def tasks() -> Iterator[Task]: + for qa in qa_files: + for pair in qa.pairs(): + if pair.has_label: + yield pair.task(pair.inputs(records), scan.issues(pair)) + + dataset.set_task_stream((AnswerTask, ClassificationTask), tasks) + return dataset + + +CONNECTOR = EngineMTQAConnector diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/dataset.yaml b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/dataset.yaml new file mode 100644 index 000000000..37caae758 --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/dataset.yaml @@ -0,0 +1,35 @@ +# yaml-language-server: $schema=https://docs.timenet.ai/schemas/dataset-card-v1.schema.json +# Dataset Card for the pandalin98/enginemt-qa connector: the single source for this dataset's metadata. +# +# Training convention: the tasks are the authors' four stages, one task per published QA pair, split as +# the authors train and test (train_qa.jsonl, test_qa.jsonl). Closed questions are classifications over +# their option letters, as the authors' model answers and their metric scores. 1,769 closed pairs with an +# empty answer have no task. Signals are the release's z-scored values at 1 Hz, 33 unnamed channels per +# 600-step cycle. Tasks that the other split repeats name repeated_across_splits in their +# source_issues metadata. +yaml_schema_version: 1 +dataset_id: pandalin98/enginemt-qa +dataset_version: 1.0.0 +name: EngineMT-QA +description: >- + Aero-engine time-series question answering over simulated N-CMAPSS flight cycles: 142,273 labelled + QA pairs (100,296 train, 41,977 test) in four tasks. Understanding and Perception ask about one + 600-step cycle of 33 z-scored channels; Reasoning and Decision-Making ask about 10 cycles. + Perception and Reasoning are multiple choice; Understanding and Decision-Making are open-ended + answers written with LLMs and checked by experts. +license: MIT +source_url: https://huggingface.co/datasets/pandalin98/EngineMT-QA +source_revision: ea2051a15512212976c22c1a075ec549c7d48eef +citation: >- + Wang et al. ITFormer: Bridging Time Series and Natural Language for Multi-Modal QA with + Large-Scale Multitask Dataset. ICML 2025. https://arxiv.org/abs/2506.20093 +domains: + - industrial +tags: + - aero-engine + - n-cmapss + - simulated + - question-answering + - classification + - generated-supervision + - huggingface diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/requirements.txt b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/requirements.txt new file mode 100644 index 000000000..ef2960923 --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/requirements.txt @@ -0,0 +1,4 @@ +# huggingface_hub downloads the source dataset from the HuggingFace Hub; 1.1 adds tqdm_class. +huggingface_hub>=1.1 +# h5py reads the signals file, time_series_data.h5. +h5py>=3.10 diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/README.md b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/README.md new file mode 100644 index 000000000..6aa23ee20 --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/README.md @@ -0,0 +1,23 @@ +# Test fixtures + +`fixtures/` holds real lines of the pinned release, copied byte for byte. The tests write the +signals file themselves, because the real one is 18.8 GB. Its values encode the row, the step and +the channel, so a misplaced value cannot pass. + +| File | Release lines (0-based), in fixture order | +| --- | --- | +| `train_qa.jsonl` | 316, 92, 11228, 3503 | +| `test_qa.jsonl` | 2786, 456, 1082 | + +- Train line 316 (row 278) has an empty health state. +- Train line 92 (row 8435) has the fault cause `a, b, e`. +- Train line 11228 (row 20) is the same line as test line 2786. +- Train line 3503 and test line 456 are multi-cycle lines. They share five of their ten rows. +- Test line 1082 (row 37669) has an empty fault cause. + +To make a file again, download the release's QA file and copy the lines above, in this order: + +```python +lines = open("train_qa.jsonl", "rb").read().splitlines(keepends=True) +open("fixtures/train_qa.jsonl", "wb").write(b"".join(lines[n] for n in (316, 92, 11228, 3503))) +``` diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/fixtures/test_qa.jsonl b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/fixtures/test_qa.jsonl new file mode 100644 index 000000000..7ac9b44ae --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/fixtures/test_qa.jsonl @@ -0,0 +1,3 @@ +{"id": "20", "name": "20.csv", "conversations": [{"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the given engine signal over one cycle, what does the change in altitude signify?\n "}, {"from": "gpt", "value": "The altitude remains constant throughout the cycle. This stable altitude reflects consistent engine performance, indicating that the engine operates efficiently without experiencing additional strain or requiring adjustments."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the specific representation of the change in Throttle Resolver Angle within the provided engine signal over the course of a single cycle?\n "}, {"from": "gpt", "value": "The Throttle Resolver Angle exhibits a steady and controlled increase. This signifies a deliberate and balanced augmentation of engine power, ensuring an optimal equilibrium between thrust generation and fuel consumption efficiency."}, {"from": "human", "stage": "1", "attribute": "open", "value": "So, what does the change in total temperature at the fan inlet tell us about the engine signal we're analyzing in this one cycle?\n "}, {"from": "gpt", "value": "The fan inlet temperature stays the same throughout the cycle. This shows that the engine is running smoothly without any ups and downs in temperature, which is a good sign of stable operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the engine signal provided, what is the precise representation and analytical interpretation of the change in total pressure at the fan inlet observed over the duration of a single cycle?\n "}, {"from": "gpt", "value": "The total pressure at the fan inlet is maintained at a constant level. This indicates the presence of stable airflow and consistent engine performance, with no significant pressure fluctuations occurring during the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the given engine signal during one cycle, what does the variation in Total Temperature at the LPC outlet signify?\n "}, {"from": "gpt", "value": "The LPC outlet temperature exhibits a slow and steady rise. This indicates a gradual adaptation in the compressor's workload, which contributes to maintaining stable and efficient engine performance."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Hey, can you explain what the change in Total temperature at the HPC outlet means for this engine signal we're analyzing in one cycle?\n "}, {"from": "gpt", "value": "Well, the HPC outlet temperature is increasing slowly over time. This indicates that the engine is making gradual adjustments to its power output, which helps maintain stable operation and ensures the fuel is being used as efficiently as possible."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Hey, can you explain what the change in Total temperature at the HPT outlet means for the engine signal we're analyzing in this one cycle?\n "}, {"from": "gpt", "value": "Well, the HPT outlet temperature is increasing slowly. This indicates that the engine is making gradual adjustments to its power output, which helps maintain stable operation and ensures the engine is using fuel efficiently."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the provided engine signal during a single cycle, what does the variation in the Total Temperature at the LPT outlet signify?\n "}, {"from": "gpt", "value": "The LPT outlet temperature exhibits a gradual rise. This indicates that the engine is making incremental adjustments to its power output, which supports stable operational conditions and enhances fuel efficiency."}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of fan of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "Was the timing issue in the operation of the given engine signal in one cycle caused by efficiency or flow problems?\n a: HPT efficiency modifier\n b: LPT efficiency modifier\n c: Fan efficiency modifier\n d: HPT flow modifier\n e: LPT flow modifier\n f: Fan flow modifier\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the potential health state of the given engine signal in one cycle?\n a: Operating Normally\n b: Abnormal Degradation\n c: Imminent Failure\n"}, {"from": "gpt", "value": "a"}]} +{"id": ["279", "287", "295", "304", "309", "319", "326", "334", "339", "346"], "name": ["279.csv", "287.csv", "295.csv", "304.csv", "309.csv", "319.csv", "326.csv", "334.csv", "339.csv", "346.csv"], "conversations": [{"from": "human", "stage": "3", "attribute": "close", "value": "Given the time series signal , by perceiving the engine signal across 10 cycles to reflect different health states and performing temporal inference to predict the health decline trend, what is the qualitative condition of the engine? a: Good Condition\n b: Moderate Condition\n c: Poor Condition\n d: Bad Condition\n e: Extremely Poor Condition\n"}, {"from": "gpt", "value": "b"}, {"from": "human", "stage": "3", "attribute": "close", "value": "Given the time series signal , by perceiving the engine signal across 10 cycles to reflect different health states and performing temporal inference to predict the health decline trend, what is the probability range of engine failure? a: 1%-10%\n b: 10%-30%\n c: 30%-50%\n d: 50%-70%\n e: 70%-100%\n"}, {"from": "gpt", "value": "b"}, {"from": "human", "stage": "4", "attribute": "open", "value": "With respect to the engine signal provided across a span of 10 cycles, what specific actions should be undertaken to ensure optimal performance and safety?\n "}, {"from": "gpt", "value": "It is imperative to closely monitor the engine's condition and proactively schedule maintenance in the near future to mitigate potential risks and maintain operational reliability."}]} +{"id": "37669", "name": "37669.csv", "conversations": [{"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the provided engine signal over one operational cycle, what does the change in altitude signify?\n "}, {"from": "gpt", "value": "The altitude remains constant throughout the cycle. This stable altitude reflects consistent engine performance, ensuring that the engine operates smoothly without experiencing any additional strain or the need for adjustments."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the engine signal provided, what is the precise interpretation and operational significance of the observed change in the throttle resolver angle during a single cycle?\n "}, {"from": "gpt", "value": "The throttle resolver angle exhibits a slow and gradual increase. This indicates that the engine is undergoing incremental power adjustments, which facilitates smoother engine operation and ensures optimal fuel efficiency."}, {"from": "human", "stage": "1", "attribute": "open", "value": "What does the change in Total temperature at fan inlet represent of the given engine signal in one cycle?\n "}, {"from": "gpt", "value": "The fan inlet temperature appears to remain constant. This observation might indicate stable engine operation without significant temperature fluctuations."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the provided engine signal over a single cycle, what does the variation in total pressure at the fan inlet indicate?\n "}, {"from": "gpt", "value": "The total pressure at the fan inlet exhibits a slow decline. This gradual drop could indicate either a controlled reduction in throttle settings or minor inefficiencies in compressor performance. Despite these changes, the engine maintains stable operational performance throughout the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "What does the change in Total temperature at LPC outlet represent of the given engine signal in one cycle?\n "}, {"from": "gpt", "value": "The LPC outlet temperature appears to be rising slowly. This could reflect gradual adjustments in the compressor workload, which may contribute to promoting stable engine operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "What does the change in Total temperature at HPC outlet represent of the given engine signal in one cycle?\n "}, {"from": "gpt", "value": "The HPC outlet temperature appears to remain constant. This observation might suggest stable compressor performance, with no significant temperature fluctuations detected during the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the given engine signal over a single cycle, what does the variation in the Total Temperature at the High-Pressure Turbine (HPT) outlet signify?\n "}, {"from": "gpt", "value": "The HPT outlet temperature exhibits a slow and steady rise. This gradual increase indicates controlled adjustments in engine power output, which contributes to maintaining stable engine operation and ensures optimal fuel efficiency throughout the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the significance of the variation in Total temperature at the LPT outlet as it pertains to the engine signal provided within a single cycle?\n "}, {"from": "gpt", "value": "The LPT outlet temperature exhibits a gradual increase. This reflects incremental adjustments in engine power, which contribute to stable operation and the efficient utilization of fuel resources."}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of fan of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "Was the timing issue in the operation of the given engine signal in one cycle caused by efficiency or flow problems?\n a: HPT efficiency modifier\n b: LPT efficiency modifier\n c: Fan efficiency modifier\n d: HPT flow modifier\n e: LPT flow modifier\n f: Fan flow modifier\n"}, {"from": "gpt", "value": ""}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the potential health state of the given engine signal in one cycle?\n a: Operating Normally\n b: Abnormal Degradation\n c: Imminent Failure\n"}, {"from": "gpt", "value": "a"}]} diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/fixtures/train_qa.jsonl b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/fixtures/train_qa.jsonl new file mode 100644 index 000000000..69b8967fd --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/fixtures/train_qa.jsonl @@ -0,0 +1,4 @@ +{"id": "278", "name": "278.csv", "conversations": [{"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the precise interpretation of the fluctuation in altitude with regard to the engine signal that has been presented within the confines of a singular cycle?\n "}, {"from": "gpt", "value": "The altitude is observed to be dropping rapidly. A swift descent reduces the engine's workload; however, it may necessitate rapid adjustments to maintain stability and operational efficiency, which could potentially lead to increased wear on critical components over time."}, {"from": "human", "stage": "1", "attribute": "open", "value": "What does the change in Throttle resolver angle represent in the given engine signal over one cycle?\n "}, {"from": "gpt", "value": "The Throttle Resolver Angle appears to be decreasing slowly. This gradual reduction may suggest a controlled decrease in power, which could contribute to smoother engine operation and potentially support optimal fuel conservation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the precise interpretation of the alteration in the total temperature at the fan inlet with regard to the engine signal that has been presented within the confines of a singular cycle?\n "}, {"from": "gpt", "value": "The fan inlet temperature remains unchanged. This indicates stable engine operation, as there are no significant temperature fluctuations observed during the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the precise interpretation of the variation in total pressure at the fan inlet with regard to the engine signal that has been presented within the confines of a singular cycle?\n "}, {"from": "gpt", "value": "The total pressure at the fan inlet remains unchanged. This indicates a stable airflow and consistent engine performance, with no significant pressure fluctuations observed."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the engine signal data over a single cycle, what does the variation in Total Temperature at the LPC outlet signify?\n "}, {"from": "gpt", "value": "The Total Temperature at the LPC outlet remains constant throughout the cycle. This stability indicates that the compressor is performing consistently, with no significant temperature fluctuations, which reflects reliable and efficient compressor operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Hey, can you explain what the change in Total temperature at the HPC outlet means in relation to the engine signal we're analyzing for this one cycle?\n "}, {"from": "gpt", "value": "Well, the HPC outlet temperature stays steady. That tells us the compressor is performing consistently without any ups and downs in temperature, which is a good sign for stable engine operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Hey, could you explain what the change in Total Temperature at the High-Pressure Turbine (HPT) outlet signifies in the context of the engine signal we're analyzing for this single cycle?\n "}, {"from": "gpt", "value": "Well, the HPT outlet temperature stays constant throughout the cycle. This suggests that the turbine is performing steadily, with no significant temperature fluctuations, which is a good sign of stable operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the engine signal provided, what is the precise representation and analytical significance of the change in Total Temperature observed at the Low-Pressure Turbine (LPT) outlet during the duration of a single cycle?\n "}, {"from": "gpt", "value": "The Total Temperature at the LPT outlet is maintained at a constant level. This stability signifies consistent compressor performance, reflecting the absence of temperature fluctuations and ensuring reliable engine operation."}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of fan of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "Was the timing issue in the operation of the given engine signal in one cycle caused by efficiency or flow problems?\n a: HPT efficiency modifier\n b: LPT efficiency modifier\n c: Fan efficiency modifier\n d: HPT flow modifier\n e: LPT flow modifier\n f: Fan flow modifier\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the potential health state of the given engine signal in one cycle?\n a: Operating Normally\n b: Abnormal Degradation\n c: Imminent Failure\n"}, {"from": "gpt", "value": ""}]} +{"id": "8435", "name": "8435.csv", "conversations": [{"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the engine signal for a single cycle, what does the change in altitude signify?\n "}, {"from": "gpt", "value": "The altitude remains constant throughout the cycle. This stable altitude suggests that the engine is performing consistently without encountering any additional strain or operational challenges."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the provided engine signal, what is the precise interpretation and operational significance of the observed change in the throttle resolver angle over the duration of a single cycle?\n "}, {"from": "gpt", "value": "The throttle resolver angle exhibits a gradual and steady increase. This indicates that the engine is undergoing incremental power adjustments, which facilitate smooth and controlled engine performance while simultaneously optimizing fuel efficiency."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the significance of the variation in the total temperature at the fan inlet with respect to the engine signal provided within a single cycle?\n "}, {"from": "gpt", "value": "The fan inlet temperature remains unchanged. This indicates stable engine operation, demonstrating the absence of any temperature fluctuations during the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "What does the change in Total pressure at fan inlet represent of the given engine signal in one cycle?\n "}, {"from": "gpt", "value": "The fan inlet pressure appears to remain constant. This could indicate stable airflow and consistent engine performance, suggesting the absence of significant pressure fluctuations during the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the specific significance of the variation in the total temperature at the LPC outlet within the context of the provided engine signal over a single cycle?\n "}, {"from": "gpt", "value": "The LPC outlet temperature remains unchanged. This indicates stable compressor performance, with no significant temperature fluctuations observed."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Regarding the provided engine signal within a single cycle, what is the significance of the variation in the total temperature at the high-pressure compressor (HPC) outlet?\n "}, {"from": "gpt", "value": "The total temperature at the HPC outlet remains consistent. This stability signifies reliable compressor performance, devoid of any temperature fluctuations, ensuring optimal engine operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the provided engine signal, what is the precise interpretation and operational significance of the change in total temperature observed at the high-pressure turbine (HPT) outlet over the course of a single cycle?\n "}, {"from": "gpt", "value": "The total temperature at the HPT outlet is maintained at a constant level. This stability signifies consistent turbine performance, highlighting the absence of temperature fluctuations and ensuring reliable engine operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "With respect to the engine signal provided within a single cycle, what does the variation in the Total Temperature at the Low-Pressure Turbine (LPT) outlet signify?\n "}, {"from": "gpt", "value": "The temperature at the LPT outlet remains consistent. This indicates stable compressor performance, with no significant temperature fluctuations observed during the cycle."}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of fan of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "Was the timing issue in the operation of the given engine signal in one cycle caused by efficiency or flow problems?\n a: HPT efficiency modifier\n b: LPT efficiency modifier\n c: Fan efficiency modifier\n d: HPT flow modifier\n e: LPT flow modifier\n f: Fan flow modifier\n"}, {"from": "gpt", "value": "a, b, e"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the potential health state of the given engine signal in one cycle?\n a: Operating Normally\n b: Abnormal Degradation\n c: Imminent Failure\n"}, {"from": "gpt", "value": "a"}]} +{"id": "20", "name": "20.csv", "conversations": [{"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the given engine signal over one cycle, what does the change in altitude signify?\n "}, {"from": "gpt", "value": "The altitude remains constant throughout the cycle. This stable altitude reflects consistent engine performance, indicating that the engine operates efficiently without experiencing additional strain or requiring adjustments."}, {"from": "human", "stage": "1", "attribute": "open", "value": "May I inquire as to the specific representation of the change in Throttle Resolver Angle within the provided engine signal over the course of a single cycle?\n "}, {"from": "gpt", "value": "The Throttle Resolver Angle exhibits a steady and controlled increase. This signifies a deliberate and balanced augmentation of engine power, ensuring an optimal equilibrium between thrust generation and fuel consumption efficiency."}, {"from": "human", "stage": "1", "attribute": "open", "value": "So, what does the change in total temperature at the fan inlet tell us about the engine signal we're analyzing in this one cycle?\n "}, {"from": "gpt", "value": "The fan inlet temperature stays the same throughout the cycle. This shows that the engine is running smoothly without any ups and downs in temperature, which is a good sign of stable operation."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the engine signal provided, what is the precise representation and analytical interpretation of the change in total pressure at the fan inlet observed over the duration of a single cycle?\n "}, {"from": "gpt", "value": "The total pressure at the fan inlet is maintained at a constant level. This indicates the presence of stable airflow and consistent engine performance, with no significant pressure fluctuations occurring during the cycle."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the given engine signal during one cycle, what does the variation in Total Temperature at the LPC outlet signify?\n "}, {"from": "gpt", "value": "The LPC outlet temperature exhibits a slow and steady rise. This indicates a gradual adaptation in the compressor's workload, which contributes to maintaining stable and efficient engine performance."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Hey, can you explain what the change in Total temperature at the HPC outlet means for this engine signal we're analyzing in one cycle?\n "}, {"from": "gpt", "value": "Well, the HPC outlet temperature is increasing slowly over time. This indicates that the engine is making gradual adjustments to its power output, which helps maintain stable operation and ensures the fuel is being used as efficiently as possible."}, {"from": "human", "stage": "1", "attribute": "open", "value": "Hey, can you explain what the change in Total temperature at the HPT outlet means for the engine signal we're analyzing in this one cycle?\n "}, {"from": "gpt", "value": "Well, the HPT outlet temperature is increasing slowly. This indicates that the engine is making gradual adjustments to its power output, which helps maintain stable operation and ensures the engine is using fuel efficiently."}, {"from": "human", "stage": "1", "attribute": "open", "value": "In the context of the provided engine signal during a single cycle, what does the variation in the Total Temperature at the LPT outlet signify?\n "}, {"from": "gpt", "value": "The LPT outlet temperature exhibits a gradual rise. This indicates that the engine is making incremental adjustments to its power output, which supports stable operational conditions and enhances fuel efficiency."}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of fan of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPC of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of HPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the health status of LPT of the given engine signal in one cycle?\n a: Health\n b: Fault\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "Was the timing issue in the operation of the given engine signal in one cycle caused by efficiency or flow problems?\n a: HPT efficiency modifier\n b: LPT efficiency modifier\n c: Fan efficiency modifier\n d: HPT flow modifier\n e: LPT flow modifier\n f: Fan flow modifier\n"}, {"from": "gpt", "value": "a"}, {"from": "human", "stage": "2", "attribute": "close", "value": "What is the potential health state of the given engine signal in one cycle?\n a: Operating Normally\n b: Abnormal Degradation\n c: Imminent Failure\n"}, {"from": "gpt", "value": "a"}]} +{"id": ["279", "287", "295", "305", "310", "319", "327", "335", "340", "346"], "name": ["279.csv", "287.csv", "295.csv", "305.csv", "310.csv", "319.csv", "327.csv", "335.csv", "340.csv", "346.csv"], "conversations": [{"from": "human", "stage": "3", "attribute": "close", "value": "Given the time series signal , by perceiving the engine signal across 10 cycles to reflect different health states and performing temporal inference to predict the health decline trend, what is the qualitative condition of the engine? a: Good Condition\n b: Moderate Condition\n c: Poor Condition\n d: Bad Condition\n e: Extremely Poor Condition\n"}, {"from": "gpt", "value": "b"}, {"from": "human", "stage": "3", "attribute": "close", "value": "Given the time series signal , by perceiving the engine signal across 10 cycles to reflect different health states and performing temporal inference to predict the health decline trend, what is the probability range of engine failure? a: 1%-10%\n b: 10%-30%\n c: 30%-50%\n d: 50%-70%\n e: 70%-100%\n"}, {"from": "gpt", "value": "b"}, {"from": "human", "stage": "4", "attribute": "open", "value": "How should we approach the analysis and management of the provided engine signal, which spans across 10 operational cycles?\n "}, {"from": "gpt", "value": "It is essential to closely monitor the engine's condition throughout these cycles and proactively schedule maintenance in the near future to ensure optimal performance and prevent potential issues."}]} diff --git a/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/test_connector.py b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/test_connector.py new file mode 100644 index 000000000..fc369ca7b --- /dev/null +++ b/packages/timenet-connectors/src/timenet_connectors/datasets/pandalin98/enginemt_qa/tests/test_connector.py @@ -0,0 +1,423 @@ +import json +from pathlib import Path +import shutil +from typing import Any, NamedTuple + +import h5py +import numpy as np +import pytest + +from timenet.dataset import Record, TimeFDataset +from timenet.dataset.axis import RegularAxis +from timenet.errors import TimeFFormatError, TimeFValidationError +from timenet.reader import TimeFReader +from timenet.registry import LocalRegistry +from timenet.types import AnswerTask, ClassificationTask, Task +from timenet.types.text import read_value +from timenet_connectors.bases.huggingface import HubFileRef +from timenet_connectors.datasets.pandalin98.enginemt_qa import EngineMTQAConnector +from timenet_connectors.datasets.pandalin98.enginemt_qa.connector import _ClosedQuestion, _FileCounts, _Part, _Stage + + +_FIXTURES = Path(__file__).parent / "fixtures" +_TRAIN, _TEST, _SIGNALS = "train_qa.jsonl", "test_qa.jsonl", "time_series_data.h5" +_STEPS = 600 +_CHANNELS = 33 +_N_ROWS = 37_669 +"""The largest row id that a fixture line names, so the fixture file has just enough rows.""" +_MULTI_TRAIN = (279, 287, 295, 305, 310, 319, 327, 335, 340, 346) +_MULTI_TEST = (279, 287, 295, 304, 309, 319, 326, 334, 339, 346) +_NAMED_ROWS = sorted({278, 8435, 20, 37669, *_MULTI_TRAIN, *_MULTI_TEST}) + +# See tests/README.md for where each fixture line comes from. +_COUNTS = { + _Part.TRAIN: _FileCounts( + lines=4, + pairs={_Stage.UNDERSTANDING: 24, _Stage.PERCEPTION: 21, _Stage.REASONING: 2, _Stage.DECISION_MAKING: 1}, + unlabelled={_ClosedQuestion.HEALTH_STATE: 1}, + ), + _Part.TEST: _FileCounts( + lines=3, + pairs={_Stage.UNDERSTANDING: 16, _Stage.PERCEPTION: 14, _Stage.REASONING: 2, _Stage.DECISION_MAKING: 1}, + unlabelled={_ClosedQuestion.FAULT_CAUSE: 1}, + ), +} + + +def _values(row_id: int) -> np.ndarray: + """Every value names its row, step and channel, so a misplaced value can't pass.""" + steps = np.arange(_STEPS, dtype=np.float64)[:, None] + channels = np.arange(_CHANNELS, dtype=np.float64)[None, :] + return row_id * 1000 + steps + channels / 100 + + +def _write_signals(path: Path, rows: int = _N_ROWS) -> None: + """Write the signals file. Only the named rows hold values, so the chunked file stays small.""" + with h5py.File(path, "w") as file: + file["data_ID"] = np.arange(1, rows + 1, dtype=np.int64) + values = file.create_dataset("seq_data", shape=(rows, _STEPS, _CHANNELS), dtype=np.float64, chunks=True) + for row_id in _NAMED_ROWS: + if row_id <= rows: + values[row_id - 1] = _values(row_id) + + +def _lines(name: str) -> list[dict[str, Any]]: + return [json.loads(line) for line in (_FIXTURES / name).read_text(encoding="utf-8").splitlines()] + + +def _write_qa(path: Path, lines: list[dict[str, Any]]) -> None: + path.write_text("".join(json.dumps(line) + "\n" for line in lines), encoding="utf-8") + + +@pytest.fixture(autouse=True) +def _fixture_counts(monkeypatch): + monkeypatch.setattr(EngineMTQAConnector, "SOURCE_COUNTS", _COUNTS) + + +@pytest.fixture +def refs(tmp_path) -> list[HubFileRef]: + """The release in ``tmp_path``: real QA lines and synthetic signals.""" + _write_signals(tmp_path / _SIGNALS) + for name in (_TRAIN, _TEST): + shutil.copyfile(_FIXTURES / name, tmp_path / name) + return [HubFileRef(tmp_path / name, part) for part, name in EngineMTQAConnector.SOURCE_FILES.items()] + + +@pytest.fixture +def dataset(refs) -> TimeFDataset: + return EngineMTQAConnector().convert(refs) + + +def _row_id(record: Record) -> int: + value = record.metadata["row_id"] + assert isinstance(value, int) + return value + + +class _View(NamedTuple): + """A task as plain values.""" + + kind: str + split: str + rows: tuple[int, ...] + prompt: str + targets: tuple[str, ...] + label_set: str | None + metadata: dict[str, Any] + + +def _view(task: Task) -> _View: + assert isinstance(task, AnswerTask | ClassificationTask) + assert task.split is not None + return _View( + kind=type(task).__name__, + split=task.split.value, + rows=tuple(_row_id(record) for record in task.inputs), + prompt=str(read_value(task.prompt)), + targets=tuple(str(read_value(target)) for target in task.targets or ()), + label_set=task.label_set.name if isinstance(task, ClassificationTask) and task.label_set else None, + metadata=dict(task.metadata), + ) + + +def _views(dataset: TimeFDataset) -> list[_View]: + return [_view(task) for task in dataset.iter_tasks()] + + +def _find(views: list[_View], split: str, line: int, offset: int) -> _View: + return next( + view + for view in views + if view.split == split and view.metadata["source_line"] == line and view.metadata["qa_offset"] == offset + ) + + +def test_converts_the_fixture(dataset): + # Each named row once, though rows 20, 279, 287, 295, 319 and 346 are named in both files. + assert [_row_id(record) for record in dataset.records] == _NAMED_ROWS + views = _views(dataset) + # Per single-cycle line: 8 answer and 7 classification tasks, less one for an empty answer. + # Per multi-cycle line: 2 classification tasks and 1 answer task. + single = ["AnswerTask"] * 8 + ["ClassificationTask"] * 7 + train = single[:-1] + single + single + ["ClassificationTask"] * 2 + ["AnswerTask"] + test = single + ["ClassificationTask"] * 2 + ["AnswerTask"] + single[:-2] + single[-1:] + assert [view.kind for view in views] == train + test + assert [view.split for view in views] == ["train"] * len(train) + ["test"] * len(test) + + +def test_fault_cause_targets_its_letters_over_a_multi_label_set(dataset): + tasks = [task for task in dataset.iter_tasks() if task.metadata.get("closed_question") == "fault_cause"] + letters = {_view(task).rows: _view(task).targets for task in tasks} + assert letters[8435,] == ("a", "b", "e") + assert letters[278,] == ("a",) + label_set = next(task.label_set for task in tasks if isinstance(task, ClassificationTask)) + assert label_set is not None + assert label_set.multi_label + assert [(label.name, label.description) for label in label_set.labels] == [ + ("a", "HPT efficiency modifier"), + ("b", "LPT efficiency modifier"), + ("c", "Fan efficiency modifier"), + ("d", "HPT flow modifier"), + ("e", "LPT flow modifier"), + ("f", "Fan flow modifier"), + ] + + +def test_closed_questions_keep_their_place_and_label_set(dataset): + view = _find(_views(dataset), "train", line=1, offset=13) + published = _lines(_TRAIN)[1]["conversations"][26]["value"] + assert view == _View( + kind="ClassificationTask", + split="train", + rows=(8435,), + prompt=published, + targets=("a", "b", "e"), + label_set="fault_cause", + metadata={ + "source_file": _TRAIN, + "source_line": 1, + "qa_offset": 13, + "stage": 2, + "source_issues": [], + "closed_question": "fault_cause", + }, + ) + health = _find(_views(dataset), "train", line=0, offset=8) + assert (health.label_set, health.metadata["closed_question"]) == ("component_health", "fan_health") + + +def test_open_questions_keep_the_published_text(dataset): + lines = _lines(_TEST) + view = _find(_views(dataset), "test", line=1, offset=2) + assert view == _View( + kind="AnswerTask", + split="test", + rows=_MULTI_TEST, + prompt=lines[1]["conversations"][4]["value"], + targets=(lines[1]["conversations"][5]["value"],), + label_set=None, + metadata={ + "source_file": _TEST, + "source_line": 1, + "qa_offset": 2, + "stage": 4, + "source_issues": [], + "steps_per_cycle": 60, + }, + ) + + +def test_reasoning_takes_the_ten_rows_in_published_order(dataset): + view = _find(_views(dataset), "train", line=3, offset=0) + assert view.rows == _MULTI_TRAIN + assert (view.metadata["stage"], view.metadata["closed_question"], view.targets) == (3, "engine_condition", ("b",)) + + +def test_empty_closed_answers_get_no_task_and_are_listed(dataset): + views = _views(dataset) + with pytest.raises(StopIteration): + _find(views, "train", line=0, offset=14) + with pytest.raises(StopIteration): + _find(views, "test", line=2, offset=13) + unlabelled = next(a for a in dataset.annotations if a.key == "unlabelled_pairs") + assert unlabelled.value == 2 + assert unlabelled.metadata["pairs"] == [ + {"source_file": _TRAIN, "source_line": 0, "qa_offset": 14}, + {"source_file": _TEST, "source_line": 2, "qa_offset": 13}, + ] + + +def test_pairs_repeated_across_files_are_flagged_on_both_sides(dataset): + # Test line 0 is a byte copy of train line 2. The multi-cycle lines name other rows. + issues = {(view.split, view.metadata["source_line"]): view.metadata["source_issues"] for view in _views(dataset)} + assert issues["train", 2] == ["repeated_across_splits"] + assert issues["test", 0] == ["repeated_across_splits"] + assert issues["train", 3] == issues["test", 1] == [] + + +def test_a_pair_repeated_in_its_file_is_flagged(refs, tmp_path, monkeypatch): + train = _lines(_TRAIN) + _write_qa(tmp_path / _TRAIN, [*train, train[3]]) + counts = _COUNTS[_Part.TRAIN] + pairs = {**counts.pairs, _Stage.REASONING: 4, _Stage.DECISION_MAKING: 2} + monkeypatch.setitem(_COUNTS, _Part.TRAIN, counts._replace(lines=5, pairs=pairs)) + views = _views(EngineMTQAConnector().convert(refs)) + assert {tuple(v.metadata["source_issues"]) for v in views if v.rows == _MULTI_TRAIN} == {("repeated_question",)} + + +def test_every_signal_of_a_record_holds_its_row(dataset): + record = dataset.records[0] + assert [source.name for source in record.sources] == ["N-CMAPSS engine"] + assert [signal.name for signal in record.signals] == [f"channel_{c:02d}" for c in range(_CHANNELS)] + for channel, signal in enumerate(record.signals): + assert isinstance(signal.time_axis, RegularAxis) + assert signal.time_axis.period_us == 1_000_000 + np.testing.assert_array_equal(signal.to_numpy(), _values(_row_id(record))[:, channel]) + + +def test_storage_round_trip_keeps_every_task_and_value(dataset, tmp_path): + registry = LocalRegistry(tmp_path / "registry") + registry.store(dataset) + with TimeFReader(registry.open_version("pandalin98/enginemt-qa", "1.0.0")) as reader: + restored = reader.read() + assert _views(restored) == _views(dataset) + for record in restored.records: + for channel, signal in enumerate(record.signals): + np.testing.assert_array_equal(signal.to_numpy(), _values(_row_id(record))[:, channel]) + + +@pytest.mark.parametrize( + ("change", "message"), + [ + (lambda lines: lines[:-1], "expected"), + (lambda lines: [], "expected"), + ], + ids=["a-line-short", "empty"], +) +def test_a_qa_file_with_other_counts_fails(refs, tmp_path, change, message): + _write_qa(tmp_path / _TRAIN, change(_lines(_TRAIN))) + with pytest.raises(TimeFValidationError, match=message) as raised: + EngineMTQAConnector().convert(refs) + assert _TRAIN in str(raised.value) + + +def test_a_shortened_signals_file_fails_when_read(dataset, tmp_path): + _write_signals(tmp_path / _SIGNALS, rows=4) + with pytest.raises(TimeFFormatError, match="cannot read row id"): + dataset.records[-1].signals[0].to_numpy() + + +def test_a_missing_signals_file_fails_when_read(dataset, tmp_path): + (tmp_path / _SIGNALS).unlink() + with pytest.raises(TimeFFormatError, match="cannot open the signals file"): + dataset.records[0].signals[0].to_numpy() + + +def test_a_row_with_a_nan_fails_when_read(dataset, tmp_path): + with h5py.File(tmp_path / _SIGNALS, "a") as file: + file["seq_data"][19, 5, 3] = np.nan + with pytest.raises(TimeFValidationError, match="row id 20 holds a NaN"): + dataset.records[0].signals[0].to_numpy() + + +@pytest.mark.parametrize( + ("name", "change"), + [ + ("changed", lambda lines: [{**lines[0], "id": "8435", "name": "8435.csv"}, *lines[1:]]), + ("removed", lambda lines: lines[:-1]), + ], +) +def test_a_qa_file_changed_after_conversion_fails_when_the_tasks_are_read(dataset, tmp_path, name, change): + _write_qa(tmp_path / _TRAIN, change(_lines(_TRAIN))) + message = "line 1: the line changed since conversion" if name == "changed" else "lines were removed" + with pytest.raises(TimeFFormatError, match=message): + list(dataset.iter_tasks()) + + +def test_a_missing_qa_file_fails_when_the_tasks_are_read(dataset, tmp_path): + (tmp_path / _TRAIN).unlink() + with pytest.raises(TimeFFormatError, match="cannot read the file"): + list(dataset.iter_tasks()) + + +def test_a_file_that_is_not_hdf5_fails_with_its_path(refs, tmp_path): + (tmp_path / _SIGNALS).write_bytes(b"not hdf5") + with pytest.raises(TimeFFormatError, match="cannot open the signals file"): + EngineMTQAConnector().convert(refs) + + +def _rewrite(path: Path, **datasets: Any) -> None: + with h5py.File(path, "w") as file: + for name, value in datasets.items(): + if value is None: + file.create_group(name) + else: + file[name] = value + + +_IDS = np.arange(1, 4) +_ZEROS = np.zeros((3, _STEPS, _CHANNELS)) + + +@pytest.mark.parametrize( + ("datasets", "message"), + [ + ({"data_ID": _IDS, "seq_data": _ZEROS, "extra": 1}, "expected seq_data and data_ID"), + ({"data_ID": _IDS, "seq_data": np.zeros((3, _STEPS, _CHANNELS - 1))}, r"seq_data is float64 \(3, 600, 32\)"), + ({"data_ID": _IDS, "seq_data": _ZEROS.astype(np.float32)}, "seq_data is float32"), + ({"data_ID": _IDS, "seq_data": None}, "seq_data is a Group, not an HDF5 dataset"), + ({"data_ID": _IDS.astype(np.float64), "seq_data": _ZEROS}, "data_ID is float64"), + ({"data_ID": np.array([2, 2, 3]), "seq_data": _ZEROS}, "data_ID is not the row ids 1 to 3"), + ], + ids=["extra-key", "32-channels", "float32", "group", "float-ids", "ids-not-1-to-n"], +) +def test_a_signals_file_with_another_layout_fails(refs, tmp_path, datasets, message): + _rewrite(tmp_path / _SIGNALS, **datasets) + with pytest.raises(TimeFValidationError, match=message): + EngineMTQAConnector().convert(refs) + + +def _with_pair(offset: int, **changes: Any) -> dict[str, Any]: + """Train line 0 with one pair changed: ``answer`` sets the answer, other keys the question.""" + line = _lines(_TRAIN)[0] + conversations = [dict(turn) for turn in line["conversations"]] + question, answer = conversations[2 * offset], conversations[2 * offset + 1] + answer["value"] = changes.pop("answer", answer["value"]) + question.update(changes) + return {**line, "conversations": conversations} + + +def _with(**changes: Any) -> dict[str, Any]: + """A train line with its own keys changed: the multi-cycle line 3 if ``multi``, else line 0.""" + line = _lines(_TRAIN)[3 if changes.pop("multi", False) else 0] + return {**line, **changes} + + +def _health_state(text: str) -> str: + return _lines(_TRAIN)[0]["conversations"][28]["value"].replace("Imminent", text) + + +# In a single-cycle line, pairs 8 to 14 are the Perception questions: 13 is the fault cause and 14 the +# health state. +@pytest.mark.parametrize( + ("line", "message"), + [ + (_with_pair(13, answer="a, g"), "labels not in label set 'fault_cause'"), + (_with_pair(13, answer="a,b"), "labels not in label set 'fault_cause'"), + (_with_pair(13, answer="a, a"), "repeated labels"), + (_with_pair(14, answer="a, b"), "takes exactly one"), + (_with_pair(8, value="What is the health status of the fan?\n "), "unknown stage 2"), + (_with_pair(14, value=_health_state("Near")), "prints options other than"), + (_with_pair(0, answer=""), "open question has an empty answer"), + (_with_pair(0, attribute="close"), "stage 1 questions are not 'close'"), + (_with_pair(0, stage="5"), "bad stage '5'"), + (_with_pair(0, stage=[2]), r"bad stage \[2\]"), + (_with_pair(0, attribute={}), "bad attribute"), + (_with_pair(0, value="Describe the signal."), "one marker"), + (_with_pair(0, **{"from": "gpt"}), "alternate a human question"), + (_with(name="4.csv"), "doesn't repeat id"), + (_with(multi=True, id=["1"] * 10, name=["1.csv"] * 10), "repeats a row"), + (_with(multi=True, id=["1"] * 9, name=["1.csv"] * 9), "names 9 rows"), + (_with(id="0278", name="0278.csv"), "not decimal row ids"), + (_with(id="37670", name="37670.csv"), "past the file's 37669 rows"), + (_with(extra=1), "expected an object with the keys"), + (_with(conversations=[]), "alternate"), + ], +) +def test_a_malformed_line_fails_with_its_place(refs, tmp_path, line, message): + _write_qa(tmp_path / _TRAIN, [_lines(_TRAIN)[0], line]) + with pytest.raises(TimeFValidationError, match=message) as raised: + EngineMTQAConnector().convert(refs) + assert "train_qa.jsonl line 2" in str(raised.value) + + +def test_a_line_that_is_not_json_fails_with_its_place(refs, tmp_path): + with (tmp_path / _TRAIN).open("a", encoding="utf-8") as file: + file.write("not json\n") + with pytest.raises(TimeFValidationError, match=r"train_qa.jsonl line 5"): + EngineMTQAConnector().convert(refs) + + +def test_a_missing_part_fails(refs): + with pytest.raises(TimeFValidationError, match="needs the parts"): + EngineMTQAConnector().convert(refs[1:]) diff --git a/pyproject.toml b/pyproject.toml index 7a846ab8a..ec68301f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ dev = [ "ruff>=0.17.3", "ty>=0.0.92", "edfio>=0.4.14", + "h5py>=3.10", "wfdb>=4.1", "xlrd>=2.0", ] diff --git a/uv.lock b/uv.lock index 947c37354..ce985c87f 100644 --- a/uv.lock +++ b/uv.lock @@ -25,6 +25,7 @@ members = [ [manifest.dependency-groups] dev = [ { name = "edfio", specifier = ">=0.4.14" }, + { name = "h5py", specifier = ">=3.10" }, { name = "huggingface-hub", specifier = ">=0.20" }, { name = "hypothesis", specifier = ">=6.140" }, { name = "jsonschema", specifier = ">=4.18" }, @@ -1106,6 +1107,58 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, ] +[[package]] +name = "h5py" +version = "3.16.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, + { name = "numpy", version = "2.5.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/db/33/acd0ce6863b6c0d7735007df01815403f5589a21ff8c2e1ee2587a38f548/h5py-3.16.0.tar.gz", hash = "sha256:a0dbaad796840ccaa67a4c144a0d0c8080073c34c76d5a6941d6818678ef2738", size = 446526, upload-time = "2026-03-06T13:49:08.07Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ba/95/a825894f3e45cbac7554c4e97314ce886b233a20033787eda755ca8fecc7/h5py-3.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:719439d14b83f74eeb080e9650a6c7aa6d0d9ea0ca7f804347b05fac6fbf18af", size = 3721663, upload-time = "2026-03-06T13:47:49.599Z" }, + { url = "https://files.pythonhosted.org/packages/bf/3b/38ff88b347c3e346cda1d3fc1b65a7aa75d40632228d8b8a5d7b58508c24/h5py-3.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c3f0a0e136f2e95dd0b67146abb6668af4f1a69c81ef8651a2d316e8e01de447", size = 3087630, upload-time = "2026-03-06T13:47:51.249Z" }, + { url = "https://files.pythonhosted.org/packages/98/a8/2594cef906aee761601eff842c7dc598bea2b394a3e1c00966832b8eeb7c/h5py-3.16.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:a6fbc5367d4046801f9b7db9191b31895f22f1c6df1f9987d667854cac493538", size = 4823472, upload-time = "2026-03-06T13:47:53.085Z" }, + { url = "https://files.pythonhosted.org/packages/52/a0/c1f604538ff6db22a0690be2dc44ab59178e115f63c917794e529356ab23/h5py-3.16.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:fb1720028d99040792bb2fb31facb8da44a6f29df7697e0b84f0d79aff2e9bd3", size = 5027150, upload-time = "2026-03-06T13:47:55.043Z" }, + { url = "https://files.pythonhosted.org/packages/2e/fd/301739083c2fc4fd89950f9bcfce75d6e14b40b0ca3d40e48a8993d1722c/h5py-3.16.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:314b6054fe0b1051c2b0cb2df5cbdab15622fb05e80f202e3b6a5eee0d6fe365", size = 4814544, upload-time = "2026-03-06T13:47:56.893Z" }, + { url = "https://files.pythonhosted.org/packages/4c/42/2193ed41ccee78baba8fcc0cff2c925b8b9ee3793305b23e1f22c20bf4c7/h5py-3.16.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ffbab2fedd6581f6aa31cf1639ca2cb86e02779de525667892ebf4cc9fd26434", size = 5034013, upload-time = "2026-03-06T13:47:59.01Z" }, + { url = "https://files.pythonhosted.org/packages/f7/20/e6c0ff62ca2ad1a396a34f4380bafccaaf8791ff8fccf3d995a1fc12d417/h5py-3.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:17d1f1630f92ad74494a9a7392ab25982ce2b469fc62da6074c0ce48366a2999", size = 3191673, upload-time = "2026-03-06T13:48:00.626Z" }, + { url = "https://files.pythonhosted.org/packages/f2/48/239cbe352ac4f2b8243a8e620fa1a2034635f633731493a7ff1ed71e8658/h5py-3.16.0-cp311-cp311-win_arm64.whl", hash = "sha256:85b9c49dd58dc44cf70af944784e2c2038b6f799665d0dcbbc812a26e0faa859", size = 2673834, upload-time = "2026-03-06T13:48:02.579Z" }, + { url = "https://files.pythonhosted.org/packages/c8/c0/5d4119dba94093bbafede500d3defd2f5eab7897732998c04b54021e530b/h5py-3.16.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c5313566f4643121a78503a473f0fb1e6dcc541d5115c44f05e037609c565c4d", size = 3685604, upload-time = "2026-03-06T13:48:04.198Z" }, + { url = "https://files.pythonhosted.org/packages/b0/42/c84efcc1d4caebafb1ecd8be4643f39c85c47a80fe254d92b8b43b1eadaf/h5py-3.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:42b012933a83e1a558c673176676a10ce2fd3759976a0fedee1e672d1e04fc9d", size = 3061940, upload-time = "2026-03-06T13:48:05.783Z" }, + { url = "https://files.pythonhosted.org/packages/89/84/06281c82d4d1686fde1ac6b0f307c50918f1c0151062445ab3b6fa5a921d/h5py-3.16.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:ff24039e2573297787c3063df64b60aab0591980ac898329a08b0320e0cf2527", size = 5198852, upload-time = "2026-03-06T13:48:07.482Z" }, + { url = "https://files.pythonhosted.org/packages/9e/e9/1a19e42cd43cc1365e127db6aae85e1c671da1d9a5d746f4d34a50edb577/h5py-3.16.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:dfc21898ff025f1e8e67e194965a95a8d4754f452f83454538f98f8a3fcb207e", size = 5405250, upload-time = "2026-03-06T13:48:09.628Z" }, + { url = "https://files.pythonhosted.org/packages/b7/8e/9790c1655eabeb85b92b1ecab7d7e62a2069e53baefd58c98f0909c7a948/h5py-3.16.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:698dd69291272642ffda44a0ecd6cd3bda5faf9621452d255f57ce91487b9794", size = 5190108, upload-time = "2026-03-06T13:48:11.26Z" }, + { url = "https://files.pythonhosted.org/packages/51/d7/ab693274f1bd7e8c5f9fdd6c7003a88d59bedeaf8752716a55f532924fbb/h5py-3.16.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2b2c02b0a160faed5fb33f1ba8a264a37ee240b22e049ecc827345d0d9043074", size = 5419216, upload-time = "2026-03-06T13:48:13.322Z" }, + { url = "https://files.pythonhosted.org/packages/03/c1/0976b235cf29ead553e22f2fb6385a8252b533715e00d0ae52ed7b900582/h5py-3.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:96b422019a1c8975c2d5dadcf61d4ba6f01c31f92bbde6e4649607885fe502d6", size = 3182868, upload-time = "2026-03-06T13:48:15.759Z" }, + { url = "https://files.pythonhosted.org/packages/14/d9/866b7e570b39070f92d47b0ff1800f0f8239b6f9e45f02363d7112336c1f/h5py-3.16.0-cp312-cp312-win_arm64.whl", hash = "sha256:39c2838fb1e8d97bcf1755e60ad1f3dd76a7b2a475928dc321672752678b96db", size = 2653286, upload-time = "2026-03-06T13:48:17.279Z" }, + { url = "https://files.pythonhosted.org/packages/0f/9e/6142ebfda0cb6e9349c091eae73c2e01a770b7659255248d637bec54a88b/h5py-3.16.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:370a845f432c2c9619db8eed334d1e610c6015796122b0e57aa46312c22617d9", size = 3671808, upload-time = "2026-03-06T13:48:19.737Z" }, + { url = "https://files.pythonhosted.org/packages/b0/65/5e088a45d0f43cd814bc5bec521c051d42005a472e804b1a36c48dada09b/h5py-3.16.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:42108e93326c50c2810025aade9eac9d6827524cdccc7d4b75a546e5ab308edb", size = 3045837, upload-time = "2026-03-06T13:48:21.854Z" }, + { url = "https://files.pythonhosted.org/packages/da/1e/6172269e18cc5a484e2913ced33339aad588e02ba407fafd00d369e22ef3/h5py-3.16.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:099f2525c9dcf28de366970a5fb34879aab20491589fa89ce2863a84218bb524", size = 5193860, upload-time = "2026-03-06T13:48:24.071Z" }, + { url = "https://files.pythonhosted.org/packages/bd/98/ef2b6fe2903e377cbe870c3b2800d62552f1e3dbe81ce49e1923c53d1c5c/h5py-3.16.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:9300ad32dea9dfc5171f94d5f6948e159ed93e4701280b0f508773b3f582f402", size = 5400417, upload-time = "2026-03-06T13:48:25.728Z" }, + { url = "https://files.pythonhosted.org/packages/bc/81/5b62d760039eed64348c98129d17061fdfc7839fc9c04eaaad6dee1004e4/h5py-3.16.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:171038f23bccddfc23f344cadabdfc9917ff554db6a0d417180d2747fe4c75a7", size = 5185214, upload-time = "2026-03-06T13:48:27.436Z" }, + { url = "https://files.pythonhosted.org/packages/28/c4/532123bcd9080e250696779c927f2cb906c8bf3447df98f5ceb8dcded539/h5py-3.16.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:7e420b539fb6023a259a1b14d4c9f6df8cf50d7268f48e161169987a57b737ff", size = 5414598, upload-time = "2026-03-06T13:48:29.49Z" }, + { url = "https://files.pythonhosted.org/packages/c3/d9/a27997f84341fc0dfcdd1fe4179b6ba6c32a7aa880fdb8c514d4dad6fba3/h5py-3.16.0-cp313-cp313-win_amd64.whl", hash = "sha256:18f2bbcd545e6991412253b98727374c356d67caa920e68dc79eab36bf5fedad", size = 3175509, upload-time = "2026-03-06T13:48:31.131Z" }, + { url = "https://files.pythonhosted.org/packages/a5/23/bb8647521d4fd770c30a76cfc6cb6a2f5495868904054e92f2394c5a78ff/h5py-3.16.0-cp313-cp313-win_arm64.whl", hash = "sha256:656f00e4d903199a1d58df06b711cf3ca632b874b4207b7dbec86185b5c8c7d4", size = 2647362, upload-time = "2026-03-06T13:48:33.411Z" }, + { url = "https://files.pythonhosted.org/packages/48/3c/7fcd9b4c9eed82e91fb15568992561019ae7a829d1f696b2c844355d95dd/h5py-3.16.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:9c9d307c0ef862d1cd5714f72ecfafe0a5d7529c44845afa8de9f46e5ba8bd65", size = 3678608, upload-time = "2026-03-06T13:48:35.183Z" }, + { url = "https://files.pythonhosted.org/packages/6a/b7/9366ed44ced9b7ef357ab48c94205280276db9d7f064aa3012a97227e966/h5py-3.16.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:8c1eff849cdd53cbc73c214c30ebdb6f1bb8b64790b4b4fc36acdb5e43570210", size = 3054773, upload-time = "2026-03-06T13:48:37.139Z" }, + { url = "https://files.pythonhosted.org/packages/58/a5/4964bc0e91e86340c2bbda83420225b2f770dcf1eb8a39464871ad769436/h5py-3.16.0-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:e2c04d129f180019e216ee5f9c40b78a418634091c8782e1f723a6ca3658b965", size = 5198886, upload-time = "2026-03-06T13:48:38.879Z" }, + { url = "https://files.pythonhosted.org/packages/f1/16/d905e7f53e661ce2c24686c38048d8e2b750ffc4350009d41c4e6c6c9826/h5py-3.16.0-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:e4360f15875a532bc7b98196c7592ed4fc92672a57c0a621355961cafb17a6dd", size = 5404883, upload-time = "2026-03-06T13:48:41.324Z" }, + { url = "https://files.pythonhosted.org/packages/4b/f2/58f34cb74af46d39f4cd18ea20909a8514960c5a3e5b92fd06a28161e0a8/h5py-3.16.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:3fae9197390c325e62e0a1aa977f2f62d994aa87aab182abbea85479b791197c", size = 5192039, upload-time = "2026-03-06T13:48:43.117Z" }, + { url = "https://files.pythonhosted.org/packages/ce/ca/934a39c24ce2e2db017268c08da0537c20fa0be7e1549be3e977313fc8f5/h5py-3.16.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:43259303989ac8adacc9986695b31e35dba6fd1e297ff9c6a04b7da5542139cc", size = 5421526, upload-time = "2026-03-06T13:48:44.838Z" }, + { url = "https://files.pythonhosted.org/packages/3e/14/615a450205e1b56d16c6783f5ccd116cde05550faad70ae077c955654a75/h5py-3.16.0-cp314-cp314-win_amd64.whl", hash = "sha256:fa48993a0b799737ba7fd21e2350fa0a60701e58180fae9f2de834bc39a147ab", size = 3183263, upload-time = "2026-03-06T13:48:47.117Z" }, + { url = "https://files.pythonhosted.org/packages/7b/48/a6faef5ed632cae0c65ac6b214a6614a0b510c3183532c521bdb0055e117/h5py-3.16.0-cp314-cp314-win_arm64.whl", hash = "sha256:1897a771a7f40d05c262fc8f37376ec37873218544b70216872876c627640f63", size = 2663450, upload-time = "2026-03-06T13:48:48.707Z" }, + { url = "https://files.pythonhosted.org/packages/5d/32/0c8bb8aedb62c772cf7c1d427c7d1951477e8c2835f872bc0a13d1f85f86/h5py-3.16.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:15922e485844f77c0b9d275396d435db3baa58292a9c2176a386e072e0cf2491", size = 3760693, upload-time = "2026-03-06T13:48:50.453Z" }, + { url = "https://files.pythonhosted.org/packages/1d/1f/fcc5977d32d6387c5c9a694afee716a5e20658ac08b3ff24fdec79fb05f2/h5py-3.16.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:df02dd29bd247f98674634dfe41f89fd7c16ba3d7de8695ec958f58404a4e618", size = 3181305, upload-time = "2026-03-06T13:48:52.221Z" }, + { url = "https://files.pythonhosted.org/packages/f5/a1/af87f64b9f986889884243643621ebbd4ac72472ba8ec8cec891ac8e2ca1/h5py-3.16.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:0f456f556e4e2cebeebd9d66adf8dc321770a42593494a0b6f0af54a7567b242", size = 5074061, upload-time = "2026-03-06T13:48:54.089Z" }, + { url = "https://files.pythonhosted.org/packages/cc/d0/146f5eaff3dc246a9c7f6e5e4f42bd45cc613bce16693bcd4d1f7c958bf5/h5py-3.16.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:3e6cb3387c756de6a9492d601553dffea3fe11b5f22b443aac708c69f3f55e16", size = 5279216, upload-time = "2026-03-06T13:48:56.75Z" }, + { url = "https://files.pythonhosted.org/packages/a1/9d/12a13424f1e604fc7df9497b73c0356fb78c2fb206abd7465ce47226e8fd/h5py-3.16.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8389e13a1fd745ad2856873e8187fd10268b2d9677877bb667b41aebd771d8b7", size = 5070068, upload-time = "2026-03-06T13:48:59.169Z" }, + { url = "https://files.pythonhosted.org/packages/41/8c/bbe98f813722b4873818a8db3e15aa3e625b59278566905ac439725e8070/h5py-3.16.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:346df559a0f7dcb31cf8e44805319e2ab24b8957c45e7708ce503b2ec79ba725", size = 5300253, upload-time = "2026-03-06T13:49:02.033Z" }, + { url = "https://files.pythonhosted.org/packages/32/9e/87e6705b4d6890e7cecdf876e2a7d3e40654a2ae37482d79a6f1b87f7b92/h5py-3.16.0-cp314-cp314t-win_amd64.whl", hash = "sha256:4c6ab014ab704b4feaa719ae783b86522ed0bf1f82184704ed3c9e4e3228796e", size = 3381671, upload-time = "2026-03-06T13:49:04.351Z" }, + { url = "https://files.pythonhosted.org/packages/96/91/9fad90cfc5f9b2489c7c26ad897157bce82f0e9534a986a221b99760b23b/h5py-3.16.0-cp314-cp314t-win_arm64.whl", hash = "sha256:faca8fb4e4319c09d83337adc80b2ca7d5c5a343c2d6f1b6388f32cfecca13c1", size = 2740706, upload-time = "2026-03-06T13:49:06.347Z" }, +] + [[package]] name = "hf-xet" version = "1.6.0"