diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 6af062de..cac1ec21 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -27,7 +27,7 @@ jobs: - name: do_unittest timeout-minutes: 40 run: | - pytest tests --cov=openrl --cov-report=xml -m unittest --cov-report=term-missing --durations=0 -v --color=yes + python3 -m pytest tests --cov=openrl --cov-report=xml -m unittest --cov-report=term-missing --durations=0 -v --color=yes - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v3 with: diff --git a/README.md b/README.md index 8e42b402..741fdef2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Hits-of-Code](https://hitsofcode.com/github/OpenRL-Lab/openrl?branch=main)](https://hitsofcode.com/github/OpenRL-Lab/openrl/view?branch=main) -[![codecov](https://codecov.io/gh/OpenRL-Lab/openrl_release/branch/main/graph/badge.svg?token=4FMEYMR83U)](https://codecov.io/gh/OpenRL-Lab/openrl_release) +[![codecov](https://codecov.io/gh/OpenRL-Lab/openrl/graph/badge.svg?token=T6BqaTiT0l)](https://codecov.io/gh/OpenRL-Lab/openrl) [![Documentation Status](https://readthedocs.org/projects/openrl-docs/badge/?version=latest)](https://openrl-docs.readthedocs.io/en/latest/?badge=latest) [![Read the Docs](https://img.shields.io/readthedocs/openrl-docs-zh?label=%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3)](https://openrl-docs.readthedocs.io/zh/latest/) diff --git a/README_zh.md b/README_zh.md index b00f498a..c8fb4619 100644 --- a/README_zh.md +++ b/README_zh.md @@ -12,7 +12,7 @@ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Hits-of-Code](https://hitsofcode.com/github/OpenRL-Lab/openrl?branch=main)](https://hitsofcode.com/github/OpenRL-Lab/openrl/view?branch=main) -[![codecov](https://codecov.io/gh/OpenRL-Lab/openrl/branch/main/graph/badge.svg?token=T6BqaTiT0l)](https://codecov.io/gh/OpenRL-Lab/openrl) +[![codecov](https://codecov.io/gh/OpenRL-Lab/openrl/graph/badge.svg?token=T6BqaTiT0l)](https://codecov.io/gh/OpenRL-Lab/openrl) [![Documentation Status](https://readthedocs.org/projects/openrl-docs/badge/?version=latest)](https://openrl-docs.readthedocs.io/zh/latest/?badge=latest) [![Read the Docs](https://img.shields.io/readthedocs/openrl-docs-zh?label=%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3)](https://openrl-docs.readthedocs.io/zh/latest/) diff --git a/openrl/supports/opendata/utils/opendata_utils.py b/openrl/supports/opendata/utils/opendata_utils.py index 087d9fd5..7b387d70 100644 --- a/openrl/supports/opendata/utils/opendata_utils.py +++ b/openrl/supports/opendata/utils/opendata_utils.py @@ -19,8 +19,6 @@ from pathlib import Path from typing import Optional -from datasets import load_from_disk - def data_abs_path(path: str, data_server_dir: Optional[str] = None) -> str: if "data_server://" in path: @@ -49,6 +47,7 @@ def data_server_wrapper(fp): def load_dataset(data_path: str, split: str): + from datasets import load_from_disk if Path(data_path).exists(): dataset = load_from_disk("{}/{}".format(data_path, split)) elif "data_server:" in data_path: diff --git a/tests/test_supports/test_opendata/test_opendata.py b/tests/test_supports/test_opendata/test_opendata.py new file mode 100644 index 00000000..4a0fe64f --- /dev/null +++ b/tests/test_supports/test_opendata/test_opendata.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright 2023 The OpenRL Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""""" + +import os +import sys + +import pytest + +from openrl.supports.opendata.utils.opendata_utils import data_abs_path + + +@pytest.mark.unittest +def test_data_abs_path(): + data_path = "./" + assert data_abs_path(data_path) == data_path + + + + +if __name__ == "__main__": + sys.exit(pytest.main(["-sv", os.path.basename(__file__)]))