refactor(imports): conditionally import pandas based on availability

This commit is contained in:
Khalil Meftah
2026-04-15 16:43:40 +02:00
parent 1c2fbc7143
commit 21eb4860c4
2 changed files with 10 additions and 1 deletions
+7 -1
View File
@@ -30,14 +30,20 @@ See: https://arxiv.org/abs/2509.25358 for the SARM paper.
import logging
from pathlib import Path
from typing import TYPE_CHECKING
import numpy as np
import pandas as pd
import torch
from huggingface_hub import hf_hub_download
from lerobot.utils.import_utils import _pandas_available
from lerobot.utils.sample_weighting import SampleWeighter
if TYPE_CHECKING or _pandas_available:
import pandas as pd
else:
pd = None # type: ignore[assignment]
def resolve_hf_path(path: str | Path) -> Path:
"""Resolve a path that may be a HuggingFace URL (hf://datasets/...) to a local path."""
+3
View File
@@ -19,6 +19,9 @@
from unittest.mock import Mock
import pytest
pytest.importorskip("pandas", reason="pandas is required (install lerobot[dataset])")
import torch
from lerobot.utils.sample_weighting import (