From ed4d8541e9bd12f7d52ccc3892549690473420d8 Mon Sep 17 00:00:00 2001 From: huangshiyu Date: Thu, 12 Oct 2023 14:27:15 +0800 Subject: [PATCH 1/6] update test --- .../test_opendata/test_opendata.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/test_supports/test_opendata/test_opendata.py 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__)])) From 9f7c81cbb51a329c76748fe2de0dc3df85a20d95 Mon Sep 17 00:00:00 2001 From: huangshiyu Date: Thu, 12 Oct 2023 14:32:33 +0800 Subject: [PATCH 2/6] update --- openrl/supports/opendata/utils/opendata_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openrl/supports/opendata/utils/opendata_utils.py b/openrl/supports/opendata/utils/opendata_utils.py index 087d9fd5..fe0d22c5 100644 --- a/openrl/supports/opendata/utils/opendata_utils.py +++ b/openrl/supports/opendata/utils/opendata_utils.py @@ -19,7 +19,7 @@ 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: @@ -49,6 +49,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: From ccfcb9c4f3478e4cee8f1df9b5befa29895a8808 Mon Sep 17 00:00:00 2001 From: huangshiyu Date: Thu, 12 Oct 2023 15:07:13 +0800 Subject: [PATCH 3/6] update test --- .github/workflows/unit_test.yml | 2 +- openrl/supports/opendata/utils/opendata_utils.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 6af062de..56f88e01 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -22,7 +22,7 @@ jobs: python -m pip install --upgrade pip setuptools wheel - name: Install dependencies run: | - python -m pip install . + python -m pip install -e . python -m pip install ".[test]" --upgrade - name: do_unittest timeout-minutes: 40 diff --git a/openrl/supports/opendata/utils/opendata_utils.py b/openrl/supports/opendata/utils/opendata_utils.py index fe0d22c5..7b387d70 100644 --- a/openrl/supports/opendata/utils/opendata_utils.py +++ b/openrl/supports/opendata/utils/opendata_utils.py @@ -20,8 +20,6 @@ from typing import Optional - - def data_abs_path(path: str, data_server_dir: Optional[str] = None) -> str: if "data_server://" in path: if data_server_dir is None: From 22418d13bd746b87fb346e6c45e1155a7921328e Mon Sep 17 00:00:00 2001 From: huangshiyu Date: Thu, 12 Oct 2023 15:25:28 +0800 Subject: [PATCH 4/6] update test --- .github/workflows/unit_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 56f88e01..5c7cba41 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -22,12 +22,12 @@ jobs: python -m pip install --upgrade pip setuptools wheel - name: Install dependencies run: | - python -m pip install -e . + python -m pip install . python -m pip install ".[test]" --upgrade - 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 + 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: From 698ffc3824a515501a668d8cd7234406b5575bda Mon Sep 17 00:00:00 2001 From: huangshiyu Date: Thu, 12 Oct 2023 16:27:46 +0800 Subject: [PATCH 5/6] update test --- .github/workflows/unit_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 5c7cba41..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: From 9a43301dc432b3cb85b3239765216e860437c500 Mon Sep 17 00:00:00 2001 From: huangshiyu Date: Thu, 12 Oct 2023 17:00:00 +0800 Subject: [PATCH 6/6] update codecov budge --- README.md | 2 +- README_zh.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/)