{"record":{"id":"516f515c0f9ea7f0","repo":"xai-org/x-algorithm","slug":"not-a-partition-batch-file-path-batch-file-path","errorCode":null,"errorMessage":"not a partition batch file path: {batch_file_path}","messagePattern":"not a partition batch file path: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/data/conversion_labels.py","lineNumber":44,"sourceCode":"\ndef action_delay_columns(sidecar_path: str) -> list[str]:\n    names = pq.ParquetFile(sidecar_path).schema_arrow.names\n    return sorted(\n        (n for n in names if n.startswith(ACTION_DELAY_PREFIX)),\n        key=lambda n: int(n[len(ACTION_DELAY_PREFIX) :]),\n    )\n\n\ndef action_index_of(column: str) -> int:\n    if not column.startswith(ACTION_DELAY_PREFIX):\n        raise ValueError(f\"not an action delay column: {column}\")\n    return int(column[len(ACTION_DELAY_PREFIX) :])\n\n\ndef sidecar_path_for(batch_file_path: str) -> str:\n    m = _PARTITION_SEG_RE.search(batch_file_path)\n    if m is None:\n        raise ValueError(f\"not a partition batch file path: {batch_file_path}\")\n    root = batch_file_path[: m.start()]\n    rel = batch_file_path[m.start() :]\n    if not rel.endswith(\".parquet\"):\n        raise ValueError(f\"not a parquet path: {batch_file_path}\")\n    return os.path.join(root, \"labels\", rel[: -len(\".parquet\")] + \".labels.parquet\")\n\n\ndef load_sidecar_delays(\n    sidecar_path: str, columns: list[str] | None = None\n) -> dict[str, np.ndarray]:\n    columns = columns or [DELAY_COLUMN]\n    schema_names = pq.ParquetFile(sidecar_path).schema_arrow.names\n    missing = [c for c in columns if c not in schema_names]\n    if missing:\n        raise ValueError(\n            f\"sidecar {sidecar_path} missing column(s) {missing}; available: {schema_names}\"\n        )\n    t = pq.read_table(sidecar_path, columns=columns)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/data/conversion_labels.py#L26-L62","documentation":"sidecar_path_for() computes the conversion-label sidecar path for a partition batch file by regex-matching a Hive-style partition segment (e.g. 'date=.../hour=...') in the path. If the regex _PARTITION_SEG_RE finds no partition segment, the path cannot be relocated into the 'labels/' sibling directory, so the function raises ValueError. This almost always means the caller passed a file path that was not produced under the expected partitioned topic layout.","triggerScenarios":"Calling seek() or sidecar_path_for() directly with a path like '/data/batch-42.parquet' that lacks any 'key=value/' partition directory; passing an index_path entry pointing at flat, non-Hive-partitioned files; passing a directory or URL instead of a partition file path.","commonSituations":"Pointing the dataset at a directory tree written before Hive partitioning was adopted; mixing index files that list relative, un-partitioned paths; typos in topic_dir that strip the partition component.","solutions":["Ensure batch file paths passed to the dataset contain a Hive partition segment such as 'date=2026-08-28/hour=13/' before the .parquet filename.","Regenerate or fix the index file / .valid_batches.json so every listed path includes the partition directories.","If your data genuinely has no partitions, skip conversion-label features (do not set include_action_delay_columns / conversion_delay_columns) so sidecar_path_for is never called."],"exampleFix":"// before\npath = '/data/batch-0007.parquet'\nsidecar = sidecar_path_for(path)  # ValueError\n\n// after\npath = '/data/date=2026-08-28/hour=13/batch-0007.parquet'\nsidecar = sidecar_path_for(path)  # '/data/labels/date=2026-08-28/hour=13/batch-0007.labels.parquet'","handlingStrategy":"validation","validationCode":"import re\nPARTITION_SEG = re.compile(r'[^/]+=[^/]+/')\ndef is_partition_batch_path(p: str) -> bool:\n    return PARTITION_SEG.search(p) is not None and p.endswith('.parquet')","typeGuard":"def is_partition_batch_path(p: str) -> bool:\n    return bool(PARTITION_SEG.search(p)) and p.endswith('.parquet')","tryCatchPattern":"try:\n    sidecar = sidecar_path_for(p)\nexcept ValueError as e:\n    logger.warning('skipping non-partition path %s: %s', p, e)\n    sidecar = None","preventionTips":["Validate index/metadata listings once at startup with the same partition regex.","Keep topic_dir layout Hive-partitioned (key=value directories) end to end."],"tags":["paths","hive-partition","conversion-labels","validation"],"backgroundTag":"invalid-file-path","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}