mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-26 11:16:00 +00:00
refactor(imports): conditionally import pandas based on availability
This commit is contained in:
@@ -30,14 +30,20 @@ See: https://arxiv.org/abs/2509.25358 for the SARM paper.
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
|
||||||
import torch
|
import torch
|
||||||
from huggingface_hub import hf_hub_download
|
from huggingface_hub import hf_hub_download
|
||||||
|
|
||||||
|
from lerobot.utils.import_utils import _pandas_available
|
||||||
from lerobot.utils.sample_weighting import SampleWeighter
|
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:
|
def resolve_hf_path(path: str | Path) -> Path:
|
||||||
"""Resolve a path that may be a HuggingFace URL (hf://datasets/...) to a local path."""
|
"""Resolve a path that may be a HuggingFace URL (hf://datasets/...) to a local path."""
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
pytest.importorskip("pandas", reason="pandas is required (install lerobot[dataset])")
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from lerobot.utils.sample_weighting import (
|
from lerobot.utils.sample_weighting import (
|
||||||
|
|||||||
Reference in New Issue
Block a user