From 12f95e917851986ae4c5c9c8995c9fc2c2d1946b Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:15:38 +0800 Subject: [PATCH 01/16] [ENH] add CI dir --- .github/workflow/test_learnware_with_pip.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflow/test_learnware_with_pip.yaml diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/test_learnware_with_pip.yaml new file mode 100644 index 0000000..e69de29 From 9063f9fd8424f0116c1809c4390d2755d2e22ec2 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:16:11 +0800 Subject: [PATCH 02/16] [MNT] update test with pip --- .github/workflow/test_learnware_with_pip.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/test_learnware_with_pip.yaml index e69de29..78a801e 100644 --- a/.github/workflow/test_learnware_with_pip.yaml +++ b/.github/workflow/test_learnware_with_pip.yaml @@ -0,0 +1,8 @@ +name: Test leanrnware from pip + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + From 8c520f9bc810c09151f4e420508a1c4bb5a3efc6 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:16:49 +0800 Subject: [PATCH 03/16] [MNT] update test with pip --- .github/workflow/test_learnware_with_pip.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/test_learnware_with_pip.yaml index 78a801e..30056de 100644 --- a/.github/workflow/test_learnware_with_pip.yaml +++ b/.github/workflow/test_learnware_with_pip.yaml @@ -6,3 +6,14 @@ on: pull_request: branches: [ main ] +jobs: + build: + timeout-minutes: 120 + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-11, macos-latest] + python-version: [3.8, 3.9, 3.10] + + \ No newline at end of file From 132e041361c5d5271df4064791553d077b69b4f0 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:30:50 +0800 Subject: [PATCH 04/16] [MNT] create conda env for CI --- .github/workflow/test_learnware_with_pip.yaml | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/test_learnware_with_pip.yaml index 30056de..453413e 100644 --- a/.github/workflow/test_learnware_with_pip.yaml +++ b/.github/workflow/test_learnware_with_pip.yaml @@ -16,4 +16,26 @@ jobs: os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-11, macos-latest] python-version: [3.8, 3.9, 3.10] - \ No newline at end of file + steps: + - name: Test learnware from pip + uses: actions/checkout@v3 + + # Since version 3.7 of python for MacOS is installed in CI, version 3.7.17, this version causes "_bz not found error". + # So we make the version number of python 3.7 for MacOS more specific. + # refs: https://github.com/actions/setup-python/issues/682 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + + - name: Create conda env for macos + run: | + conda create -n learnware python=${{ matrix.python-version }} + + \ No newline at end of file From 403636fddb6c7d46bd4e4f910a14f361b67400c2 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:34:48 +0800 Subject: [PATCH 05/16] [MNT] finish test with pip CI --- .github/workflow/test_learnware_with_pip.yaml | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/test_learnware_with_pip.yaml index 453413e..7995a87 100644 --- a/.github/workflow/test_learnware_with_pip.yaml +++ b/.github/workflow/test_learnware_with_pip.yaml @@ -20,10 +20,6 @@ jobs: - name: Test learnware from pip uses: actions/checkout@v3 - # Since version 3.7 of python for MacOS is installed in CI, version 3.7.17, this version causes "_bz not found error". - # So we make the version number of python 3.7 for MacOS more specific. - # refs: https://github.com/actions/setup-python/issues/682 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -38,4 +34,20 @@ jobs: run: | conda create -n learnware python=${{ matrix.python-version }} - \ No newline at end of file + - name: Update pip to the latest version + run: | + conda run -n learnware python -m pip install --upgrade pip + + - name: Install learnware + run: | + conda run -n learnware python -m pip install learnware + + - name: Install faiss for MacOS + if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }} + run: | + conda install -c pytorch faiss + + - name: Test workflow + run: | + conda install pytest + pytest tests/test_workflow/test_workflow.py \ No newline at end of file From 61d3eb6b83276abe4e82608f5b2f42663b49c99f Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:35:49 +0800 Subject: [PATCH 06/16] [MNT] add test with source --- .../workflow/test_learnware_with_source.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflow/test_learnware_with_source.yaml diff --git a/.github/workflow/test_learnware_with_source.yaml b/.github/workflow/test_learnware_with_source.yaml new file mode 100644 index 0000000..55bd585 --- /dev/null +++ b/.github/workflow/test_learnware_with_source.yaml @@ -0,0 +1,53 @@ +name: Test leanrnware from pip + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + timeout-minutes: 120 + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-11, macos-latest] + python-version: [3.8, 3.9, 3.10] + + steps: + - name: Test learnware from pip + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + + - name: Create conda env for macos + run: | + conda create -n learnware python=${{ matrix.python-version }} + + - name: Update pip to the latest version + run: | + conda run -n learnware python -m pip install --upgrade pip + + - name: Install learnware + run: | + conda run -n learnware python -m pip install . + + - name: Install faiss for MacOS + if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }} + run: | + conda install -c pytorch faiss + + - name: Test workflow + run: | + conda install pytest + pytest tests/test_workflow/test_workflow.py \ No newline at end of file From 436dcb1be37430abfdad6b683c220ec6b45595bf Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:45:09 +0800 Subject: [PATCH 07/16] [MNT] update install CI --- .github/workflow/test_learnware_with_pip.yaml | 7 ++++--- .github/workflow/test_learnware_with_source.yaml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/test_learnware_with_pip.yaml index 7995a87..18658a1 100644 --- a/.github/workflow/test_learnware_with_pip.yaml +++ b/.github/workflow/test_learnware_with_pip.yaml @@ -33,14 +33,15 @@ jobs: - name: Create conda env for macos run: | conda create -n learnware python=${{ matrix.python-version }} + conda create activate learnware - name: Update pip to the latest version run: | - conda run -n learnware python -m pip install --upgrade pip + python -m pip install --upgrade pip - name: Install learnware run: | - conda run -n learnware python -m pip install learnware + python -m pip install learnware - name: Install faiss for MacOS if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }} @@ -50,4 +51,4 @@ jobs: - name: Test workflow run: | conda install pytest - pytest tests/test_workflow/test_workflow.py \ No newline at end of file + conda run -n learnware pytest tests/test_workflow/test_workflow.py \ No newline at end of file diff --git a/.github/workflow/test_learnware_with_source.yaml b/.github/workflow/test_learnware_with_source.yaml index 55bd585..f855b11 100644 --- a/.github/workflow/test_learnware_with_source.yaml +++ b/.github/workflow/test_learnware_with_source.yaml @@ -33,14 +33,15 @@ jobs: - name: Create conda env for macos run: | conda create -n learnware python=${{ matrix.python-version }} + conda create activate learnware - name: Update pip to the latest version run: | - conda run -n learnware python -m pip install --upgrade pip + python -m pip install --upgrade pip - name: Install learnware run: | - conda run -n learnware python -m pip install . + python -m pip install . - name: Install faiss for MacOS if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }} @@ -50,4 +51,4 @@ jobs: - name: Test workflow run: | conda install pytest - pytest tests/test_workflow/test_workflow.py \ No newline at end of file + conda run -n learnware pytest tests/test_workflow/test_workflow.py \ No newline at end of file From 888c8f89e30d327f011fe68fc962cc027564cf76 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:45:39 +0800 Subject: [PATCH 08/16] [MNT] rename CI --- ...st_learnware_with_pip.yaml => install_learnware_with_pip.yaml} | 0 ...rnware_with_source.yaml => install_learnware_with_source.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflow/{test_learnware_with_pip.yaml => install_learnware_with_pip.yaml} (100%) rename .github/workflow/{test_learnware_with_source.yaml => install_learnware_with_source.yaml} (100%) diff --git a/.github/workflow/test_learnware_with_pip.yaml b/.github/workflow/install_learnware_with_pip.yaml similarity index 100% rename from .github/workflow/test_learnware_with_pip.yaml rename to .github/workflow/install_learnware_with_pip.yaml diff --git a/.github/workflow/test_learnware_with_source.yaml b/.github/workflow/install_learnware_with_source.yaml similarity index 100% rename from .github/workflow/test_learnware_with_source.yaml rename to .github/workflow/install_learnware_with_source.yaml From 01d9aedd7db68480dcb4cbd25d67c96b8d5ddb8d Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:48:23 +0800 Subject: [PATCH 09/16] [MNT] update CI --- .github/workflow/install_learnware_with_source.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflow/install_learnware_with_source.yaml b/.github/workflow/install_learnware_with_source.yaml index f855b11..2d323c4 100644 --- a/.github/workflow/install_learnware_with_source.yaml +++ b/.github/workflow/install_learnware_with_source.yaml @@ -38,6 +38,7 @@ jobs: - name: Update pip to the latest version run: | python -m pip install --upgrade pip + pip install flake8 pytest - name: Install learnware run: | From f50eec3be03d9e079cfbf93ba9fe590946298747 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 20:57:32 +0800 Subject: [PATCH 10/16] [FIX] fix bugs --- learnware/client/learnware_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/learnware/client/learnware_client.py b/learnware/client/learnware_client.py index b466be7..266d45f 100644 --- a/learnware/client/learnware_client.py +++ b/learnware/client/learnware_client.py @@ -408,7 +408,8 @@ class LearnwareClient: try: for key in ["Data", "Task", "Library"]: value = semantic_spec[key]["Values"] - if len(value) != 1 and value[0] not in key_list: + key_list = C["semantic_specs"][key]["Values"] + if len(value) != 1 or value[0] not in key_list: logger.error(f"{key} must be in {key_list}!") return False From c892452e0bbba1266deed55be611bf9b08aa6748 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 21:02:10 +0800 Subject: [PATCH 11/16] [MNT] update CI with updaye with flake8 --- .github/workflow/install_learnware_with_source.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflow/install_learnware_with_source.yaml b/.github/workflow/install_learnware_with_source.yaml index 2d323c4..630ce39 100644 --- a/.github/workflow/install_learnware_with_source.yaml +++ b/.github/workflow/install_learnware_with_source.yaml @@ -39,7 +39,12 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pytest - + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - name: Install learnware run: | python -m pip install . From 0470a9284c7393766d4f6dab48e5db8cc4ec7002 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 21:03:59 +0800 Subject: [PATCH 12/16] [MNT] update CI with install faiss with conda --- .github/workflow/install_learnware_with_pip.yaml | 12 ++++++------ .github/workflow/install_learnware_with_source.yaml | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflow/install_learnware_with_pip.yaml b/.github/workflow/install_learnware_with_pip.yaml index 18658a1..137909e 100644 --- a/.github/workflow/install_learnware_with_pip.yaml +++ b/.github/workflow/install_learnware_with_pip.yaml @@ -38,17 +38,17 @@ jobs: - name: Update pip to the latest version run: | python -m pip install --upgrade pip - - - name: Install learnware - run: | - python -m pip install learnware + python -m pip install pytest - name: Install faiss for MacOS if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }} run: | conda install -c pytorch faiss + - name: Install learnware + run: | + python -m pip install learnware + - name: Test workflow run: | - conda install pytest - conda run -n learnware pytest tests/test_workflow/test_workflow.py \ No newline at end of file + pytest tests/test_workflow/test_workflow.py \ No newline at end of file diff --git a/.github/workflow/install_learnware_with_source.yaml b/.github/workflow/install_learnware_with_source.yaml index 630ce39..bfe4e9c 100644 --- a/.github/workflow/install_learnware_with_source.yaml +++ b/.github/workflow/install_learnware_with_source.yaml @@ -38,23 +38,22 @@ jobs: - name: Update pip to the latest version run: | python -m pip install --upgrade pip - pip install flake8 pytest + python -m pip install flake8 pytest - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - - - name: Install learnware - run: | - python -m pip install . - name: Install faiss for MacOS if: ${{ matrix.os == 'macos-11' || matrix.os == 'macos-latest' }} run: | conda install -c pytorch faiss + - name: Install learnware + run: | + python -m pip install . + - name: Test workflow run: | - conda install pytest - conda run -n learnware pytest tests/test_workflow/test_workflow.py \ No newline at end of file + pytest tests/test_workflow/test_workflow.py \ No newline at end of file From 9abb65fd5f6c13640805928b5aa3b7b88f478fe1 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 21:05:30 +0800 Subject: [PATCH 13/16] [MNT] update CI name --- .github/workflow/install_learnware_with_source.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflow/install_learnware_with_source.yaml b/.github/workflow/install_learnware_with_source.yaml index bfe4e9c..e9589e3 100644 --- a/.github/workflow/install_learnware_with_source.yaml +++ b/.github/workflow/install_learnware_with_source.yaml @@ -1,4 +1,4 @@ -name: Test leanrnware from pip +name: Test leanrnware from source code on: push: From cd0e16fad9c4f09600fcb9520a5a6ee17551d3de Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 22:38:32 +0800 Subject: [PATCH 14/16] [MNT] refactor specification --- learnware/specification/__init__.py | 2 +- learnware/specification/base.py | 7 ++----- learnware/specification/regular/__init__.py | 1 + learnware/specification/regular/base.py | 13 +++++++++++++ .../specification/{ => regular}/table/__init__.py | 0 .../specification/{ => regular}/table/rkme.py | 6 +++--- learnware/specification/system/__init__.py | 0 learnware/specification/system/heter_table.py | 15 +++++++++++++++ 8 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 learnware/specification/regular/__init__.py create mode 100644 learnware/specification/regular/base.py rename learnware/specification/{ => regular}/table/__init__.py (100%) rename learnware/specification/{ => regular}/table/rkme.py (99%) create mode 100644 learnware/specification/system/__init__.py create mode 100644 learnware/specification/system/heter_table.py diff --git a/learnware/specification/__init__.py b/learnware/specification/__init__.py index 0bb0502..28100e7 100644 --- a/learnware/specification/__init__.py +++ b/learnware/specification/__init__.py @@ -1,3 +1,3 @@ from .utils import generate_stat_spec from .base import Specification, BaseStatSpecification -from .table import RKMEStatSpecification +from .regular import RKMEStatSpecification diff --git a/learnware/specification/base.py b/learnware/specification/base.py index 655e5a4..1c340fa 100644 --- a/learnware/specification/base.py +++ b/learnware/specification/base.py @@ -15,11 +15,8 @@ class BaseStatSpecification: """ self.type = type - def generate_stat_spec_from_data(self, **kwargs): - """Construct statistical specification from raw dataset - - kwargs may include the feature, label and model - - kwargs also can include hyperparameters of specific method for specifaction generation - """ + def generate_stat_spec(self, **kwargs): + """Construct statistical specification""" raise NotImplementedError("generate_stat_spec_from_data is not implemented") def save(self, filepath: str): diff --git a/learnware/specification/regular/__init__.py b/learnware/specification/regular/__init__.py new file mode 100644 index 0000000..64fe041 --- /dev/null +++ b/learnware/specification/regular/__init__.py @@ -0,0 +1 @@ +from .table import RKMEStatSpecification diff --git a/learnware/specification/regular/base.py b/learnware/specification/regular/base.py new file mode 100644 index 0000000..48a7e1f --- /dev/null +++ b/learnware/specification/regular/base.py @@ -0,0 +1,13 @@ +from ..base import BaseStatSpecification + + +class RegularStatsSpecification(BaseStatSpecification): + def generate_stat_spec(self, **kwargs): + self.generate_stat_spec_from_data(**kwargs) + + def generate_stat_spec_from_data(self, **kwargs): + """Construct statistical specification from raw dataset + - kwargs may include the feature, label and model + - kwargs also can include hyperparameters of specific method for specifaction generation + """ + raise NotImplementedError("generate_stat_spec_from_data is not implemented") diff --git a/learnware/specification/table/__init__.py b/learnware/specification/regular/table/__init__.py similarity index 100% rename from learnware/specification/table/__init__.py rename to learnware/specification/regular/table/__init__.py diff --git a/learnware/specification/table/rkme.py b/learnware/specification/regular/table/rkme.py similarity index 99% rename from learnware/specification/table/rkme.py rename to learnware/specification/regular/table/rkme.py index 9769800..32dea8d 100644 --- a/learnware/specification/table/rkme.py +++ b/learnware/specification/regular/table/rkme.py @@ -20,8 +20,8 @@ try: except ImportError: _FAISS_INSTALLED = False -from ..base import BaseStatSpecification -from ...logger import get_module_logger +from ..base import RegularStatsSpecification +from ....logger import get_module_logger logger = get_module_logger("rkme") @@ -30,7 +30,7 @@ if not _FAISS_INSTALLED: logger.warning('Please run "conda install -c pytorch faiss-cpu" first.') -class RKMEStatSpecification(BaseStatSpecification): +class RKMEStatSpecification(RegularStatsSpecification): """Reduced Kernel Mean Embedding (RKME) Specification""" def __init__(self, gamma: float = 0.1, cuda_idx: int = -1): diff --git a/learnware/specification/system/__init__.py b/learnware/specification/system/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/learnware/specification/system/heter_table.py b/learnware/specification/system/heter_table.py new file mode 100644 index 0000000..ae24a1c --- /dev/null +++ b/learnware/specification/system/heter_table.py @@ -0,0 +1,15 @@ +from ..base import BaseStatSpecification + + +class HeterMapTableSpecification(BaseStatSpecification): + def generate_stat_spec(self, **kwargs): + pass + + def save(self, filepath: str): + pass + + def load(self, filepath: str): + pass + + def dist(self, other_spec): + pass From 3b33676c96dd885eaf7b2772408793293481a595 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 22:41:54 +0800 Subject: [PATCH 15/16] [FIX] fix bugs --- learnware/specification/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learnware/specification/utils.py b/learnware/specification/utils.py index c3693b7..5f1a689 100644 --- a/learnware/specification/utils.py +++ b/learnware/specification/utils.py @@ -4,7 +4,7 @@ import pandas as pd from typing import Union from .base import BaseStatSpecification -from .table import RKMEStatSpecification +from .regular import RKMEStatSpecification from ..config import C From 701606923b161614e2c95ba3ea8af65ff2352e9a Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 30 Oct 2023 22:45:30 +0800 Subject: [PATCH 16/16] [FIX] fix ci dir name --- .github/{workflow => workflows}/install_learnware_with_pip.yaml | 0 .../{workflow => workflows}/install_learnware_with_source.yaml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/install_learnware_with_pip.yaml (100%) rename .github/{workflow => workflows}/install_learnware_with_source.yaml (100%) diff --git a/.github/workflow/install_learnware_with_pip.yaml b/.github/workflows/install_learnware_with_pip.yaml similarity index 100% rename from .github/workflow/install_learnware_with_pip.yaml rename to .github/workflows/install_learnware_with_pip.yaml diff --git a/.github/workflow/install_learnware_with_source.yaml b/.github/workflows/install_learnware_with_source.yaml similarity index 100% rename from .github/workflow/install_learnware_with_source.yaml rename to .github/workflows/install_learnware_with_source.yaml