Remove extra info token pathway
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
import csv
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Iterable, Tuple
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
@@ -61,41 +60,6 @@ def set_seed(seed: int) -> None:
|
||||
torch.cuda.manual_seed(seed)
|
||||
|
||||
|
||||
def load_extra_info_types_file(path: str) -> list[int]:
|
||||
file_path = Path(path)
|
||||
if not file_path.is_file():
|
||||
raise FileNotFoundError(f"extra_info_types_file not found: {path}")
|
||||
|
||||
text = file_path.read_text(encoding="utf-8").strip()
|
||||
if not text:
|
||||
return []
|
||||
|
||||
if text.startswith("["):
|
||||
raw_items = json.loads(text)
|
||||
if not isinstance(raw_items, list):
|
||||
raise ValueError("extra_info_types_file JSON must be a list")
|
||||
else:
|
||||
raw_items = []
|
||||
for line in text.splitlines():
|
||||
line = line.split("#", 1)[0].strip()
|
||||
if line:
|
||||
raw_items.extend(line.replace(",", " ").replace(";", " ").split())
|
||||
|
||||
try:
|
||||
return [int(x) for x in raw_items]
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValueError(f"Invalid extra info type id in {path}") from exc
|
||||
|
||||
|
||||
def format_extra_info_types(extra_info_types: Iterable[int] | None) -> str:
|
||||
if extra_info_types is None:
|
||||
return "all"
|
||||
values = [int(x) for x in extra_info_types]
|
||||
if not values:
|
||||
return "none"
|
||||
return str(values)
|
||||
|
||||
|
||||
def load_eid_file(path: str | Path) -> set[int]:
|
||||
file_path = Path(path)
|
||||
if not file_path.is_file():
|
||||
|
||||
Reference in New Issue
Block a user