diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 868813bc..395637d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,13 @@ exclude: ^(tests/data) default_language_version: python: python3.10 repos: + ##### Meta ##### + - repo: meta + hooks: + - id: check-useless-excludes + - id: check-hooks-apply + + ##### Style / Misc. ##### - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 @@ -28,15 +35,18 @@ repos: - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace + - repo: https://github.com/crate-ci/typos - rev: v1 + rev: v1.30.2 hooks: - id: typos args: [--force-exclude] + - repo: https://github.com/asottile/pyupgrade rev: v3.19.1 hooks: - id: pyupgrade + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.9.10 hooks: @@ -44,15 +54,18 @@ repos: args: [--fix] - id: ruff-format + ##### Security ##### - repo: https://github.com/gitleaks/gitleaks rev: v8.24.0 hooks: - id: gitleaks + - repo: https://github.com/woodruffw/zizmor-pre-commit rev: v1.4.1 hooks: - id: zizmor + - repo: https://github.com/PyCQA/bandit rev: 1.8.3 hooks: diff --git a/lerobot/scripts/visualize_dataset.py b/lerobot/scripts/visualize_dataset.py index 11feb1af..cdfea6b8 100644 --- a/lerobot/scripts/visualize_dataset.py +++ b/lerobot/scripts/visualize_dataset.py @@ -265,13 +265,25 @@ def main(): ), ) + parser.add_argument( + "--tolerance-s", + type=float, + default=1e-4, + help=( + "Tolerance in seconds used to ensure data timestamps respect the dataset fps value" + "This is argument passed to the constructor of LeRobotDataset and maps to its tolerance_s constructor argument" + "If not given, defaults to 1e-4." + ), + ) + args = parser.parse_args() kwargs = vars(args) repo_id = kwargs.pop("repo_id") root = kwargs.pop("root") + tolerance_s = kwargs.pop("tolerance_s") logging.info("Loading dataset") - dataset = LeRobotDataset(repo_id, root=root) + dataset = LeRobotDataset(repo_id, root=root, tolerance_s=tolerance_s) visualize_dataset(dataset, **vars(args)) diff --git a/lerobot/scripts/visualize_dataset_html.py b/lerobot/scripts/visualize_dataset_html.py index f944144a..0fc21a8f 100644 --- a/lerobot/scripts/visualize_dataset_html.py +++ b/lerobot/scripts/visualize_dataset_html.py @@ -446,15 +446,31 @@ def main(): help="Delete the output directory if it exists already.", ) + parser.add_argument( + "--tolerance-s", + type=float, + default=1e-4, + help=( + "Tolerance in seconds used to ensure data timestamps respect the dataset fps value" + "This is argument passed to the constructor of LeRobotDataset and maps to its tolerance_s constructor argument" + "If not given, defaults to 1e-4." + ), + ) + args = parser.parse_args() kwargs = vars(args) repo_id = kwargs.pop("repo_id") load_from_hf_hub = kwargs.pop("load_from_hf_hub") root = kwargs.pop("root") + tolerance_s = kwargs.pop("tolerance_s") dataset = None if repo_id: - dataset = LeRobotDataset(repo_id, root=root) if not load_from_hf_hub else get_dataset_info(repo_id) + dataset = ( + LeRobotDataset(repo_id, root=root, tolerance_s=tolerance_s) + if not load_from_hf_hub + else get_dataset_info(repo_id) + ) visualize_dataset_html(dataset, **vars(args))