From a53c15564ce73092be09e7c15946828c40d46c34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:34:01 +0000 Subject: [PATCH 01/19] Bump actions/github-script from 6 to 7 Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/label-issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label-issue.yml b/.github/workflows/label-issue.yml index d0c4860..8836f5b 100644 --- a/.github/workflows/label-issue.yml +++ b/.github/workflows/label-issue.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v2 - name: Check if issue has a milestone id: check_milestone - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const issue = context.payload.issue; From 074ca7226a67b31b575af1c31cae79df2c8863b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:34:02 +0000 Subject: [PATCH 02/19] Bump actions/setup-node from 3 to 4 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/main-branch-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-branch-testing.yml b/.github/workflows/main-branch-testing.yml index f6fc0de..96f84e9 100644 --- a/.github/workflows/main-branch-testing.yml +++ b/.github/workflows/main-branch-testing.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} From 9763e6e617111ebe7e68a380058eb61c9c4a7e8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:34:02 +0000 Subject: [PATCH 03/19] Bump actions/checkout from 2 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/label-issue.yml | 2 +- .github/workflows/main-branch-testing.yml | 2 +- .github/workflows/publish-package.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- .github/workflows/version-branch-testing.yml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/label-issue.yml b/.github/workflows/label-issue.yml index d0c4860..1d2b0d7 100644 --- a/.github/workflows/label-issue.yml +++ b/.github/workflows/label-issue.yml @@ -13,7 +13,7 @@ jobs: issues: write steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Check if issue has a milestone id: check_milestone uses: actions/github-script@v6 diff --git a/.github/workflows/main-branch-testing.yml b/.github/workflows/main-branch-testing.yml index f6fc0de..9be2589 100644 --- a/.github/workflows/main-branch-testing.yml +++ b/.github/workflows/main-branch-testing.yml @@ -25,7 +25,7 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 3626ef0..39277b3 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4 - name: Install the latest version of Rye uses: eifinger/setup-rye@v3.0.2 - name: Build the package diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index e8f2247..a9a063a 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python 3.10.14 diff --git a/.github/workflows/version-branch-testing.yml b/.github/workflows/version-branch-testing.yml index 264ac2a..c9f6050 100644 --- a/.github/workflows/version-branch-testing.yml +++ b/.github/workflows/version-branch-testing.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install the latest version of Rye @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4 - name: Install the latest version of Rye uses: eifinger/setup-rye@v3.0.2 - name: Build the package From 942e49445f7794423f69c35a82f9a1b0741d52a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:34:04 +0000 Subject: [PATCH 04/19] Bump actions/setup-python from 3 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/main-branch-testing.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main-branch-testing.yml b/.github/workflows/main-branch-testing.yml index f6fc0de..97e5133 100644 --- a/.github/workflows/main-branch-testing.yml +++ b/.github/workflows/main-branch-testing.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index e8f2247..50a12cd 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,7 +15,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python 3.10.14 - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5 with: python-version: 3.10.14 - name: Run pre-commit From 7308c69619833fedced352d044ed5130fc4a302b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:23:59 +0000 Subject: [PATCH 05/19] Bump eifinger/setup-rye from 3.0.2 to 4.2.1 Bumps [eifinger/setup-rye](https://github.com/eifinger/setup-rye) from 3.0.2 to 4.2.1. - [Release notes](https://github.com/eifinger/setup-rye/releases) - [Commits](https://github.com/eifinger/setup-rye/compare/v3.0.2...v4.2.1) --- updated-dependencies: - dependency-name: eifinger/setup-rye dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/publish-package.yml | 2 +- .github/workflows/version-branch-testing.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 3626ef0..087dc6e 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -10,7 +10,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4.1.6 - name: Install the latest version of Rye - uses: eifinger/setup-rye@v3.0.2 + uses: eifinger/setup-rye@v4.2.1 - name: Build the package run: rye build - uses: actions/upload-artifact@v4.3.3 diff --git a/.github/workflows/version-branch-testing.yml b/.github/workflows/version-branch-testing.yml index 264ac2a..001997f 100644 --- a/.github/workflows/version-branch-testing.yml +++ b/.github/workflows/version-branch-testing.yml @@ -13,7 +13,7 @@ jobs: with: fetch-depth: 0 - name: Install the latest version of Rye - uses: eifinger/setup-rye@v3.0.2 + uses: eifinger/setup-rye@v4.2.1 - name: Setup the environment run: rye sync --all-features - name: Test with pytest @@ -25,7 +25,7 @@ jobs: - name: Check out repository uses: actions/checkout@v4.1.6 - name: Install the latest version of Rye - uses: eifinger/setup-rye@v3.0.2 + uses: eifinger/setup-rye@v4.2.1 - name: Build the package run: rye build - uses: actions/upload-artifact@v4.3.3 From 4b4c1a026ab43d6b426ceb1f220404bc06686f5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:48:32 +0000 Subject: [PATCH 06/19] Bump the python-packages group across 1 directory with 7 updates Updates the requirements on [torch](https://github.com/pytorch/pytorch), [numpy](https://github.com/numpy/numpy), [sphinx](https://github.com/sphinx-doc/sphinx), [sphinx-autodoc-typehints](https://github.com/tox-dev/sphinx-autodoc-typehints), [sphinxawesome-theme](https://github.com/kai687/sphinxawesome-theme), [myst-parser](https://github.com/executablebooks/MyST-Parser) and [pygit2](https://github.com/libgit2/pygit2) to permit the latest version. Updates `torch` from 2.2.2 to 2.4.0 - [Release notes](https://github.com/pytorch/pytorch/releases) - [Changelog](https://github.com/pytorch/pytorch/blob/main/RELEASE.md) - [Commits](https://github.com/pytorch/pytorch/compare/v2.2.2...v2.4.0) Updates `numpy` to 2.0.1 - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v1.22.4...v2.0.1) Updates `sphinx` from 7.2.6 to 8.0.2 - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/v8.0.2/CHANGES.rst) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.2.6...v8.0.2) Updates `sphinx-autodoc-typehints` from 2.0.0 to 2.2.3 - [Release notes](https://github.com/tox-dev/sphinx-autodoc-typehints/releases) - [Changelog](https://github.com/tox-dev/sphinx-autodoc-typehints/blob/main/CHANGELOG.md) - [Commits](https://github.com/tox-dev/sphinx-autodoc-typehints/compare/2.0.0...2.2.3) Updates `sphinxawesome-theme` from 5.1.3 to 5.2.0 - [Release notes](https://github.com/kai687/sphinxawesome-theme/releases) - [Commits](https://github.com/kai687/sphinxawesome-theme/compare/5.1.3...5.2.0) Updates `myst-parser` from 2.0.0 to 3.0.1 - [Release notes](https://github.com/executablebooks/MyST-Parser/releases) - [Changelog](https://github.com/executablebooks/MyST-Parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/executablebooks/MyST-Parser/compare/v2.0.0...v3.0.1) Updates `pygit2` from 1.14.1 to 1.15.1 - [Changelog](https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md) - [Commits](https://github.com/libgit2/pygit2/compare/v1.14.1...v1.15.1) --- updated-dependencies: - dependency-name: torch dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python-packages - dependency-name: numpy dependency-type: direct:production dependency-group: python-packages - dependency-name: sphinx dependency-type: direct:production update-type: version-update:semver-major dependency-group: python-packages - dependency-name: sphinx-autodoc-typehints dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python-packages - dependency-name: sphinxawesome-theme dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python-packages - dependency-name: myst-parser dependency-type: direct:production update-type: version-update:semver-major dependency-group: python-packages - dependency-name: pygit2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python-packages ... Signed-off-by: dependabot[bot] --- docs/requirements.txt | 12 ++++++------ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 0b6c140..cc9fac7 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,7 @@ -sphinx==7.2.6 -sphinx-autodoc-typehints==2.0.0 -sphinxawesome-theme==5.1.3 -myst-parser==2.0.0 -pygit2==1.14.1 +sphinx==8.0.2 +sphinx-autodoc-typehints==2.2.3 +sphinxawesome-theme==5.2.0 +myst-parser==3.0.1 +pygit2==1.15.1 agogos==0.4.0 -torch==2.2.2 +torch==2.4.0 diff --git a/pyproject.toml b/pyproject.toml index ca4ff9a..1e156fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ image = [ "timm>=0.9.16", ] numpy = [ - "numpy>=1.22.4, < 2", + "numpy>= 1.22.4, < 3", ] pandas = [ "pandas[performance, parquet]>=2.0.0", From c8b89b7f0fbbd886d76aba4776ee7a97bab6d232 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:51:18 +0200 Subject: [PATCH 07/19] Update CODEOWNERS --- .github/CODEOWNERS | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1ec9ffd..77b7eb4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,6 @@ -*.yaml jmvanselm@gmail.com -*.yml jmvanselm@gmail.com -*.toml jmvanselm@gmail.com +*.py @TeamEpochGithub/packages +*.md @TeamEpochGithub/packages +*.yaml @TeamEpochGithub/packages +*.yml @TeamEpochGithub/packages +*.toml @TeamEpochGithub/packages +*.txt @TeamEpochGithub/packages From 8e3bc7ed12bccc1cda2a558c9590a08c4e09e7f7 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Sun, 11 Aug 2024 14:55:03 +0200 Subject: [PATCH 08/19] Fix pre-commit --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bf000e1..77b7eb4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,4 +3,4 @@ *.yaml @TeamEpochGithub/packages *.yml @TeamEpochGithub/packages *.toml @TeamEpochGithub/packages -*.txt @TeamEpochGithub/packages \ No newline at end of file +*.txt @TeamEpochGithub/packages From 895330147a3b7be693fdb995e3034e593908cd1e Mon Sep 17 00:00:00 2001 From: JasperVS Date: Sun, 11 Aug 2024 16:08:04 +0200 Subject: [PATCH 09/19] Unprivatize functions --- epochalyst/training/torch_trainer.py | 14 +++++++------- tests/test_ensemble.py | 2 -- tests/test_model.py | 2 -- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/epochalyst/training/torch_trainer.py b/epochalyst/training/torch_trainer.py index 7f49c05..cf594ae 100644 --- a/epochalyst/training/torch_trainer.py +++ b/epochalyst/training/torch_trainer.py @@ -281,7 +281,7 @@ def custom_train(self, x: npt.NDArray[np.float32], y: npt.NDArray[np.float32], * self._load_model() # Return the predictions - return self._predict_after_train( + return self.predict_after_train( x, y, train_dataset, @@ -337,7 +337,7 @@ def custom_train(self, x: npt.NDArray[np.float32], y: npt.NDArray[np.float32], * if save_model: self._save_model() - return self._predict_after_train( + return self.predict_after_train( x, y, train_dataset, @@ -346,7 +346,7 @@ def custom_train(self, x: npt.NDArray[np.float32], y: npt.NDArray[np.float32], * validation_indices, ) - def _predict_after_train( + def predict_after_train( self, x: npt.NDArray[np.float32], y: npt.NDArray[np.float32], @@ -615,7 +615,7 @@ def _training_loop( for epoch in range(start_epoch, self.epochs): # Train using train_loader - train_loss = self._train_one_epoch(train_loader, epoch) + train_loss = self.train_one_epoch(train_loader, epoch) self.log_to_debug(f"Epoch {epoch} Train Loss: {train_loss}") train_losses.append(train_loss) @@ -642,7 +642,7 @@ def _training_loop( # Compute validation loss if len(validation_loader) > 0: - self.last_val_loss = self._val_one_epoch( + self.last_val_loss = self.val_one_epoch( validation_loader, desc=f"Epoch {epoch} Valid", ) @@ -681,7 +681,7 @@ def _training_loop( # Log the trained epochs to wandb if we finished training self.log_to_external(message={self.wrap_log(f"Epochs{fold_no}"): epoch + 1}) - def _train_one_epoch( + def train_one_epoch( self, dataloader: DataLoader[tuple[Tensor, ...]], epoch: int, @@ -724,7 +724,7 @@ def _train_one_epoch( return sum(losses) / len(losses) - def _val_one_epoch( + def val_one_epoch( self, dataloader: DataLoader[tuple[Tensor, ...]], desc: str, diff --git a/tests/test_ensemble.py b/tests/test_ensemble.py index b998bc9..f3c1d35 100644 --- a/tests/test_ensemble.py +++ b/tests/test_ensemble.py @@ -1,5 +1,3 @@ -import shutil -from pathlib import Path from typing import Any import numpy as np diff --git a/tests/test_model.py b/tests/test_model.py index f33554b..8e1cd24 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,5 +1,3 @@ -import shutil -from pathlib import Path from typing import Any import numpy as np From dfe14362db97395de33e26c1da1146299510dbf6 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Sat, 17 Aug 2024 01:01:51 +0200 Subject: [PATCH 10/19] Add dataset that can take a training pipeline (#236) * Add DataRetrieval, Data and PipelineDataset classes * Add tests and update enum * Add tests for Data & DataRetrieval * Finish testing PipelineDataset * Turn TrainingPipeline into dataclass * Add dataclass to Logger --- .gitignore | 3 - CITATION.cff | 10 +- README.md | 4 +- epochalyst/data/__init__.py | 1 + epochalyst/data/enum_data_format.py | 45 +++++++ epochalyst/data/pipeline_dataset.py | 134 +++++++++++++++++++++ epochalyst/logging/logger.py | 4 +- epochalyst/training/training.py | 2 + pyproject.toml | 2 +- requirements-dev.lock | 3 +- requirements.lock | 1 + ruff.toml | 13 ++ tests/data/test_enum_data_format.py | 131 ++++++++++++++++++++ tests/data/test_pipeline_dataset.py | 177 ++++++++++++++++++++++++++++ 14 files changed, 516 insertions(+), 14 deletions(-) create mode 100644 epochalyst/data/__init__.py create mode 100644 epochalyst/data/enum_data_format.py create mode 100644 epochalyst/data/pipeline_dataset.py create mode 100644 tests/data/test_enum_data_format.py create mode 100644 tests/data/test_pipeline_dataset.py diff --git a/.gitignore b/.gitignore index 6407b02..9077972 100644 --- a/.gitignore +++ b/.gitignore @@ -164,9 +164,6 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ -# Ignore data files -data/ - # Ignore logs /logging/ /wandb/ diff --git a/CITATION.cff b/CITATION.cff index f012da8..1b88b63 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,6 +1,11 @@ cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: +- family-names: "Selm" + name-particle: "van" + given-names: "Jasper" + affiliation: "TU Delft Dream Team Epoch" + email: "jmvanselm@gmail.com" - family-names: "Lim" given-names: "Jeffrey" affiliation: "TU Delft Dream Team Epoch" @@ -18,11 +23,6 @@ authors: given-names: "Cahit Tolga" affiliation: "TU Delft Dream Team Epoch" email: "cahittolgakopar@gmail.com" -- family-names: "Selm" - name-particle: "van" - given-names: "Jasper" - affiliation: "TU Delft Dream Team Epoch" - email: "jmvanselm@gmail.com" - family-names: "Ebersberger" given-names: "Ariel" affiliation: "TU Delft Dream Team Epoch" diff --git a/README.md b/README.md index e1c33c9..0fcd1dd 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ Epochalyst is the base for [Team Epoch](https://teamepoch.ai/) competitions. This package contains many modules and classes necessary to construct the src code for machine learning competitions. -Epochalyst: A fusion of "Epoch" and "Catalyst," this name positions your pipeline as a catalyst in the field of machine learning, sparking significant advancements and transformations. - ## Installation Install `epochalyst` using [Rye](https://rye.astral.sh/): @@ -81,10 +79,10 @@ The documentation can then be found in `docs/_build/html/index.html`. Epochalyst was created by [Team Epoch IV](https://teamepoch.ai/team#iv), based in the [Dream Hall](https://www.tudelft.nl/ddream) of the [Delft University of Technology](https://www.tudelft.nl/). +[![Github Badge](https://img.shields.io/badge/-Jasper_van_Selm-24292e?style=flat&logo=Github)](https://github.com/schobbejak) [![Github Badge](https://img.shields.io/badge/-Emiel_Witting-24292e?style=flat&logo=Github)](https://github.com/EWitting) [![Github Badge](https://img.shields.io/badge/-Jeffrey_Lim-24292e?style=flat&logo=Github)](https://github.com/Jeffrey-Lim) [![Github Badge](https://img.shields.io/badge/-Hugo_de_Heer-24292e?style=flat&logo=Github)](https://github.com/hjdeheer) -[![Github Badge](https://img.shields.io/badge/-Jasper_van_Selm-24292e?style=flat&logo=Github)](https://github.com/schobbejak) [![Github Badge](https://img.shields.io/badge/-Tolga_Kopar-24292e?style=flat&logo=Github)](https://github.com/tolgakopar) [![Github Badge](https://img.shields.io/badge/-Ariel_Ebersberger-24292e?style=flat&logo=Github)](https://github.com/justanotherariel) [![Github Badge](https://img.shields.io/badge/-Gregoire_Dumont-24292e?style=flat&logo=Github)](https://github.com/Gregoire-Andre-Dumont) diff --git a/epochalyst/data/__init__.py b/epochalyst/data/__init__.py new file mode 100644 index 0000000..2b2f177 --- /dev/null +++ b/epochalyst/data/__init__.py @@ -0,0 +1 @@ +"""Module containing data related classes and functions.""" diff --git a/epochalyst/data/enum_data_format.py b/epochalyst/data/enum_data_format.py new file mode 100644 index 0000000..3c66bca --- /dev/null +++ b/epochalyst/data/enum_data_format.py @@ -0,0 +1,45 @@ +"""Module containing classes to allow for the creation of enum based retrieval data formats.""" + +from dataclasses import dataclass, field +from enum import IntFlag +from typing import Any + +import numpy as np +import numpy.typing as npt + + +class DataRetrieval(IntFlag): + """Class to select which data to retrieve in Data.""" + + +@dataclass +class Data: + """Class to describe a data format. + + :param retrieval: What data to retrieve + """ + + retrieval: DataRetrieval = field(init=False) + + def __getitem__(self, idx: int | npt.NDArray[np.int_] | list[int] | slice) -> npt.NDArray[Any] | list[Any]: + """Get item from the data. + + :param idx: Index to retrieve + :return: Relevant data + """ + raise NotImplementedError("__getitem__ should be implemented when inheriting from Data.") + + def __getitems__(self, indices: npt.NDArray[np.int_] | list[int] | slice) -> npt.NDArray[Any]: + """Retrieve items for all indices based on specified retrieval flags. + + :param indices: List of indices to retrieve + :return: Relevant data + """ + raise NotImplementedError("__getitems__ should be implemented when inheriting from Data.") + + def __len__(self) -> int: + """Return length of the data. + + :return: Length of data + """ + raise NotImplementedError("__len__ should be implemented when inheriting from Data.") diff --git a/epochalyst/data/pipeline_dataset.py b/epochalyst/data/pipeline_dataset.py new file mode 100644 index 0000000..55692ec --- /dev/null +++ b/epochalyst/data/pipeline_dataset.py @@ -0,0 +1,134 @@ +"""Module that contains a dataset that can take a training pipeline.""" + +import logging +from dataclasses import dataclass +from typing import Any, Callable, Tuple, TypeVar + +import numpy as np +import numpy.typing as npt + +from epochalyst.data.enum_data_format import Data, DataRetrieval +from epochalyst.training import TrainingBlock, TrainingPipeline + +try: + from torch.utils.data import Dataset +except ImportError: + """User doesn't require torch""" + +T = TypeVar("T") +DataTuple = Tuple[T, T] + + +@dataclass +class PipelineDataset(Dataset[Tuple[T, T]]): + """Pipeline dataset takes in a pipeline to be able to process the original data. + + Useful for lazy loading data for training, where computing would take a long time or the device would run out of memory. + + :param retrieval: Data retrieval object. + :param retrieval_type: Data retrieval enum + :param steps: Steps to apply to the dataset + :param result_formatter: + + :param x: Input data + :param y: Labels + :param indices: Indices to use + + """ + + retrieval: list[str] | None = None + retrieval_type: DataRetrieval | None = None + steps: list[TrainingBlock] | None = None + result_formatter: Callable[[Any], Any] = lambda a: a + + x: Data | None = None + y: Data | None = None + indices: npt.NDArray[np.int_] | None = None + + def __post_init__(self) -> None: + """Set up the dataset.""" + if self.retrieval is None: + raise ValueError("Retrieval object must be set.") + if self.retrieval_type is None: + raise ValueError("Retrieval type must be set.") + + # Setup data retrieval + self._retrieval_enum = getattr(self.retrieval_type, self.retrieval[0]) + for retrieval in self.retrieval[1:]: + self._retrieval_enum = self._retrieval_enum | getattr(self.retrieval_type, retrieval) + + # Setup pipeline + self.setup_pipeline(use_augmentations=False) + + def initialize(self, x: Data, y: Data, indices: list[int] | npt.NDArray[np.int_] | None = None) -> None: + """Set up the dataset for training. + + :param x: X data to initialize with + :param y: Y data to initialize with + :param indices: Indices to filter on + """ + self.x = x + self.y = y + self.indices = np.array(indices, dtype=np.int32) if isinstance(indices, list) else indices + + def setup_pipeline(self, *, use_augmentations: bool) -> None: + """Set whether to use the augmentations. + + :param use_augmentations: Whether to use augmentations while passing data through pipeline + """ + self._enabled_steps = [] + + if self.steps is not None: + for step in self.steps: + if (step.is_augmentation and use_augmentations) or not step.is_augmentation: + self._enabled_steps.append(step) + + self._pipeline = TrainingPipeline(steps=self._enabled_steps) + logging.getLogger("TrainingPipeline").setLevel(logging.WARNING) + + def __len__(self) -> int: + """Get the length of the dataset.""" + if self.x is None: + raise ValueError("Dataset is not initialized.") + if self.indices is None: + return len(self.x) + return len(self.indices) + + def __getitem__(self, idx: int | list[int] | npt.NDArray[np.int_]) -> tuple[Any, Any]: + """Get an item from the dataset. + + :param idx: Index to retrieve + :return: Data and labels at the Index + """ + if not isinstance(idx, (int | np.integer)): + return self.__getitems__(idx) + + if self.x is None: + raise ValueError("Dataset not initialized or has no x data.") + if self.indices is not None: + idx = self.indices[idx] + + self.x.retrieval = self._retrieval_enum + x = np.expand_dims(self.x[idx], axis=0) + y = np.expand_dims(self.y[idx], axis=0) if self.y is not None else None + + x, y = self._pipeline.train(x, y) + return self.result_formatter(x)[0], self.result_formatter(y)[0] if y is not None else None + + def __getitems__(self, indices: list[int] | npt.NDArray[np.int_]) -> tuple[Any, Any]: + """Get items from the dataset. + + :param indices: The indices to retrieve + :return: Data and labels at the indices. + """ + if self.x is None: + raise ValueError("Dataset not initialized or has no x data.") + if self.indices is not None: + indices = self.indices[indices] + + self.x.retrieval = self._retrieval_enum + x = self.x[indices] + y = self.y[indices] if self.y is not None else None + + x, y = self._pipeline.train(x, y) + return self.result_formatter(x), self.result_formatter(y) if y is not None else None diff --git a/epochalyst/logging/logger.py b/epochalyst/logging/logger.py index 8836e70..ceab1ad 100644 --- a/epochalyst/logging/logger.py +++ b/epochalyst/logging/logger.py @@ -2,9 +2,11 @@ import logging import os +from dataclasses import dataclass from typing import Any, Mapping +@dataclass class Logger: """Logger base class for logging methods. @@ -21,7 +23,7 @@ def log_to_external(self, message: dict[str, Any], **kwargs: Any) -> None: # Log def external_define_metric(self, metric: str, metric_type: str) -> None: # Defines an external metric """ - def __init__(self) -> None: + def __post_init__(self) -> None: """Initialize the logger.""" self.logger = logging.getLogger(self.__class__.__name__) self.logger.setLevel(logging.DEBUG) diff --git a/epochalyst/training/training.py b/epochalyst/training/training.py index 5453719..7b0153c 100644 --- a/epochalyst/training/training.py +++ b/epochalyst/training/training.py @@ -1,5 +1,6 @@ """TrainingPipeline for creating a sequential pipeline of TrainType classes.""" +from dataclasses import dataclass from typing import Any from agogos.training import TrainingSystem, TrainType @@ -7,6 +8,7 @@ from epochalyst.caching import CacheArgs, Cacher +@dataclass class TrainingPipeline(TrainingSystem, Cacher): """The training pipeline. This is the class used to create the pipeline for the training of the model. diff --git a/pyproject.toml b/pyproject.toml index 1e156fe..497247a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ managed = true lock-with-sources = true dev-dependencies = [ "pre-commit>=3.7.1", - "pytest>=8.1.1", + "pytest>=8.3.2", "pytest-cov>=5.0.0", "sphinx>=7.2.6", "sphinx-autodoc-typehints>=2.0.0", diff --git a/requirements-dev.lock b/requirements-dev.lock index 230a345..ee768ea 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -7,6 +7,7 @@ # all-features: true # with-sources: true # generate-hashes: false +# universal: false --index-url https://pypi.org/simple/ @@ -220,7 +221,7 @@ pycparser==2.22 pygit2==1.15.0 pygments==2.18.0 # via sphinx -pytest==8.2.2 +pytest==8.3.2 # via pytest-cov pytest-cov==5.0.0 python-dateutil==2.9.0.post0 diff --git a/requirements.lock b/requirements.lock index 55fabe4..6aedb18 100644 --- a/requirements.lock +++ b/requirements.lock @@ -7,6 +7,7 @@ # all-features: true # with-sources: true # generate-hashes: false +# universal: false --index-url https://pypi.org/simple/ diff --git a/ruff.toml b/ruff.toml index 1db4a53..905d827 100644 --- a/ruff.toml +++ b/ruff.toml @@ -72,6 +72,19 @@ external = [ # Pylint (PL), Refactor (R) "PLR2004", # Magic values in comparison allowed in tests ] +"test_*.py" = [ + # flake8-bandit (S) + "S101", # Asserts allowed in tests + # flake8-pytest-style (PT) + "PT009", # Use a regular assert instead of unittest-style {assertion} + # Pylint (PL), Refactor (R) + "PLR2004", # Magic values in comparison allowed in tests + # + # "ANN201", # Missing return value allowed in tests + "D100", # Docstring methods + "D101", + "D102", +] [lint.flake8-annotations] allow-star-arg-any = true diff --git a/tests/data/test_enum_data_format.py b/tests/data/test_enum_data_format.py new file mode 100644 index 0000000..b0fafdf --- /dev/null +++ b/tests/data/test_enum_data_format.py @@ -0,0 +1,131 @@ +from unittest import TestCase +from dataclasses import dataclass + +from epochalyst.data.enum_data_format import DataRetrieval, Data +import numpy as np +import numpy.typing as npt +from typing import Any + + +class TestDataRetrieval(TestCase): + def test_inherited_retrieval(self) -> None: + class ExpandedDataRetrieval(DataRetrieval): + BASE = 2**0 + NEW = 2**1 + + self.assertTrue(ExpandedDataRetrieval.BASE == 2**0) + self.assertTrue(ExpandedDataRetrieval.NEW == 2**1) + +class TestData(TestCase): + + def test___get_item__(self) -> None: + """Should raise an error if getitem has not been implemented.""" + non_implemented = Data() + with self.assertRaises(NotImplementedError): + non_implemented[0] + + def test___get_items__(self) -> None: + """Should raise an error if getitems has not been implemented.""" + non_implemented = Data() + with self.assertRaises(NotImplementedError): + non_implemented[0:1] + + def test___len__(self) -> None: + """Should raise an error if length has not been implemented.""" + non_implemented = Data() + with self.assertRaises(NotImplementedError): + len(non_implemented) + +class TestDataRetrievalCombination(TestCase): + + def test_get_empty_data(self) -> None: + test_data = CustomData() + with self.assertRaises(TypeError): + test_data[0] + + def test_get_data1(self) -> None: + test_data = CustomData() + test_data.retrieval = TestRetrieval.BASE + test_data.data1 = [0,1] + self.assertTrue(test_data[1] == 1) + + def test_get_data2(self) -> None: + test_data = CustomData() + test_data.retrieval = TestRetrieval.NEW + test_data.data2 = [0,1] + self.assertTrue(test_data[1] == 1) + + def test_get_data2_with_both(self) -> None: + test_data = CustomData() + test_data.retrieval = TestRetrieval.NEW + test_data.data1 = [1,0] + test_data.data2 = [0,1] + self.assertTrue(test_data[1] == 1) + + def test_get_items(self) -> None: + test_data = CustomData() + test_data.data1 = [0, 1, 2] + self.assertTrue(test_data[0:1] == [0]) + + def test_len(self) -> None: + test_data = CustomData() + test_data.data1 = [0,1] + self.assertTrue(len(test_data) == 2) + + +class TestRetrieval(DataRetrieval): + BASE = 2**0 + NEW = 2**1 + +@dataclass +class CustomData(Data): + data1: npt.NDArray[np.int_] | None = None + data2: npt.NDArray[np.int_] | None = None + + def __post_init__(self) -> None: + self.retrieval = TestRetrieval.BASE + + def __getitem__(self, idx: int | npt.NDArray[np.int_] | list[int] | slice) -> npt.NDArray[Any] | list[Any]: + """Get item from the data. + + :param idx: Index to retrieve + :return: Relevant data + """ + result = [] + if self.retrieval & TestRetrieval.BASE: + result.append(self.data1[idx]) + if self.retrieval & TestRetrieval.NEW: + result.append(self.data2[idx]) + + if len(result) == 1: + return result[0] + + return result + + def __getitems__(self, indices: npt.NDArray[np.int_] | list[int] | slice) -> npt.NDArray[Any]: + """Retrieve items for all indices based on specified retrieval flags. + + :param indices: List of indices to retrieve + :return: Relevant data + """ + result = [] + if self.retrieval & TestRetrieval.BASE: + result.append(self.data1[indices]) + if self.retrieval & TestRetrieval.NEW: + result.append(self.data2[indices]) + + if len(result) == 1: + return result[0] + + return result + + def __len__(self) -> int: + if self.data1: + return len(self.data1) + if self.data2: + return len(self.data2) + return 0 + + + + diff --git a/tests/data/test_pipeline_dataset.py b/tests/data/test_pipeline_dataset.py new file mode 100644 index 0000000..de6c3cf --- /dev/null +++ b/tests/data/test_pipeline_dataset.py @@ -0,0 +1,177 @@ +from unittest import TestCase +from dataclasses import dataclass + +from epochalyst.data.enum_data_format import Data, DataRetrieval +from epochalyst.data.pipeline_dataset import PipelineDataset +from epochalyst.training.training_block import TrainingBlock +import numpy as np +import numpy.typing as npt +from typing import Any +import torch + +class TestDataRetrieval(DataRetrieval): + BASE = 2**0 + FIRST = 2**1 + +@dataclass +class CustomData(Data): + data1: npt.NDArray[np.int_] | None = None + data2: npt.NDArray[np.int_] | None = None + + def __post_init__(self) -> None: + self.retrieval = TestDataRetrieval.BASE + + def __getitem__(self, idx: int | npt.NDArray[np.int_] | list[int] | slice) -> npt.NDArray[Any] | list[Any]: + """Get item from the data. + + :param idx: Index to retrieve + :return: Relevant data + """ + if not isinstance(idx, (int | np.integer)): + return self.__getitems__(idx) # type: ignore[arg-type] + + result = [] + if self.retrieval & TestDataRetrieval.BASE: + result.append(self.data1[idx]) + if self.retrieval & TestDataRetrieval.FIRST: + result.append(self.data2[idx]) + + if len(result) == 1: + return result[0] + + return result + + def __getitems__(self, indices: npt.NDArray[np.int_] | list[int] | slice) -> npt.NDArray[Any]: + """Retrieve items for all indices based on specified retrieval flags. + + :param indices: List of indices to retrieve + :return: Relevant data + """ + result = [] + if self.retrieval & TestDataRetrieval.BASE: + result.append(self.data1[indices]) + if self.retrieval & TestDataRetrieval.FIRST: + result.append(self.data2[indices]) + + if len(result) == 1: + return result[0] + + return result + + def __len__(self) -> int: + if self.data1 is not None: + return len(self.data1) + if self.data2 is not None: + return len(self.data2) + return 0 + +class TestTrainingBlockNoAug(TrainingBlock): + + def train( + self, + x: npt.NDArray[np.str_], + y: npt.NDArray[np.str_], + **train_args: Any, + ) -> tuple[npt.NDArray[np.str_], npt.NDArray[np.uint8]]: + """Randomize the SMILES string.""" + return x, y + + @property + def is_augmentation(self) -> bool: + """Check if augmentation is enabled.""" + return False + +class TestTrainingBlockWithAug(TrainingBlock): + + def train( + self, + x: npt.NDArray[np.str_], + y: npt.NDArray[np.str_], + **train_args: Any, + ) -> tuple[npt.NDArray[np.str_], npt.NDArray[np.uint8]]: + """Randomize the SMILES string.""" + return x, y + + @property + def is_augmentation(self) -> bool: + """Check if augmentation is enabled.""" + return True + +class TestPipelineDataset(TestCase): + + def test_initialization_errors(self) -> None: + with self.assertRaises(ValueError): + PipelineDataset() + with self.assertRaises(ValueError): + PipelineDataset(retrieval=['BASE']) + + def test_initialization_steps(self) -> None: + pd = PipelineDataset(retrieval=['BASE'], retrieval_type=TestDataRetrieval) + step1 = TestTrainingBlockNoAug() + pd_with_step = PipelineDataset(retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step1]) + self.assertEqual(pd_with_step._enabled_steps, [step1]) + + step_with_aug = TestTrainingBlockWithAug() + pd_aug = PipelineDataset(retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step_with_aug]) + self.assertEqual(pd_aug._enabled_steps, []) + + pd_aug.setup_pipeline(use_augmentations=True) + self.assertEqual(pd_aug._enabled_steps, [step_with_aug]) + + def test_get_item(self) -> None: + test_data = CustomData() + test_data.data1 = [0, 1] + step = TestTrainingBlockNoAug() + + pd_with_data = PipelineDataset( + retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step], x=test_data + ) + self.assertEqual(pd_with_data[0][0], 0) + + pd_with_indices = PipelineDataset( + retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step], x=test_data, indices=[1] + ) + self.assertEqual(pd_with_indices[0][0], 1) + + pd_no_data = PipelineDataset(retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step]) + with self.assertRaises(ValueError): + pd_no_data[0] + + def test_get_items(self) -> None: + test_data = CustomData() + test_data.data1 = np.array([0, 1, 2]) + step = TestTrainingBlockNoAug() + + pd_with_data = PipelineDataset( + retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step], x=test_data + ) + self.assertTrue((pd_with_data[[0,1]][0] == [0,1]).all()) + + pd_with_indices = PipelineDataset( + retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step], x=test_data, indices=np.array([0,2]) + ) + self.assertTrue((pd_with_indices[[0,1]][0] == [0,2]).all()) + + pd_no_data = PipelineDataset(retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step]) + with self.assertRaises(ValueError): + pd_no_data[[0,1]] + + def test_len(self) -> None: + test_data = CustomData() + test_data.data1 = np.array([0, 1, 2]) + step = TestTrainingBlockNoAug() + + pd_with_data = PipelineDataset( + retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step], x=test_data + ) + self.assertTrue(len(pd_with_data) == 3) + + pd_with_data.initialize(x=test_data, y=test_data, indices=np.array([0,2])) + # pd_with_indices = PipelineDataset( + # retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step], x=test_data, indices=np.array([0,2]) + # ) + self.assertTrue(len(pd_with_data) == 2) + + pd_no_data = PipelineDataset(retrieval=['BASE'], retrieval_type=TestDataRetrieval, steps=[step]) + with self.assertRaises(ValueError): + self.assertTrue(len(pd_no_data)) From 641a70e3c8e60641afdaa31799f95654ddac856a Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Sat, 17 Aug 2024 15:24:59 +0200 Subject: [PATCH 11/19] Add mixed precision to torch trainer (#237) * Add mixed precision to torch trainer * Add tests for batch_to_device * Add tests for torch trainer --- epochalyst/training/torch_trainer.py | 28 ++++++++++++++++--- tests/training/test_torch_trainer.py | 20 +++++++++++++ tests/training/utils/test_tensor_functions.py | 11 ++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 tests/training/utils/test_tensor_functions.py diff --git a/epochalyst/training/torch_trainer.py b/epochalyst/training/torch_trainer.py index cf594ae..ee007da 100644 --- a/epochalyst/training/torch_trainer.py +++ b/epochalyst/training/torch_trainer.py @@ -1,5 +1,6 @@ """TorchTrainer is a module that allows for the training of Torch models.""" +import contextlib import copy import functools import gc @@ -61,6 +62,10 @@ class TorchTrainer(TrainingBlock): - `checkpointing_keep_every` (int): Keep every i'th checkpoint (1 to keep all, 0 to keep only the last one) - `checkpointing_resume_if_exists` (bool): Resume training if a checkpoint exists + Parameters Precision + ---------- + - `use_mixed_precision` (bool): Whether to use mixed precision for the model training + Parameters Misc ---------- - `to_predict` (str): Whether to predict on the 'validation' set, 'all' data or 'none' @@ -173,6 +178,9 @@ def log_to_terminal(self, message: str) -> None: checkpointing_keep_every: Annotated[int, Gt(0)] = field(default=0, init=True, repr=False, compare=False) checkpointing_resume_if_exists: bool = field(default=True, init=True, repr=False, compare=False) + # Precision + use_mixed_precision: bool = field(default=False) + # Misc model_name: str | None = None # No spaces allowed trained_models_directory: PathLike[str] = field(default=Path("tm/"), repr=False, compare=False) @@ -233,6 +241,12 @@ def __post_init__(self) -> None: self.last_val_loss = np.inf self.lowest_val_loss = np.inf + # Mixed precision + if self.use_mixed_precision: + self.log_to_terminal("Using mixed precision training.") + self.scaler = torch.GradScaler(device=self.device.type) + torch.set_float32_matmul_precision("high") + # Check validity of model_name if " " in self.model_name: raise ValueError("Spaces in model_name not allowed") @@ -706,13 +720,19 @@ def train_one_epoch( y_batch = batch_to_device(y_batch, self.y_tensor_type, self.device) # Forward pass - y_pred = self.model(X_batch).squeeze(1) - loss = self.criterion(y_pred, y_batch) + with torch.autocast(self.device.type) if self.use_mixed_precision else contextlib.nullcontext(): # type: ignore[attr-defined] + y_pred = self.model(X_batch).squeeze(1) + loss = self.criterion(y_pred, y_batch) # Backward pass self.initialized_optimizer.zero_grad() - loss.backward() - self.initialized_optimizer.step() + if self.use_mixed_precision: + self.scaler.scale(loss).backward() + self.scaler.step(self.initialized_optimizer) + self.scaler.update() + else: + loss.backward() + self.initialized_optimizer.step() # Print tqdm losses.append(loss.item()) diff --git a/tests/training/test_torch_trainer.py b/tests/training/test_torch_trainer.py index 4e88d58..24fd6c9 100644 --- a/tests/training/test_torch_trainer.py +++ b/tests/training/test_torch_trainer.py @@ -78,6 +78,26 @@ def test_init_none_args(self): n_folds=1, ) + def test_model_name_none(self): + with pytest.raises(ValueError): + TorchTrainer( + model=self.simple_model, + criterion=torch.nn.MSELoss(), + optimizer=self.optimizer, + n_folds=0, + model_name=None, + ) + + def test_model_name_invalid(self): + with pytest.raises(ValueError): + TorchTrainer( + model=self.simple_model, + criterion=torch.nn.MSELoss(), + optimizer=self.optimizer, + n_folds=0, + model_name=" ", + ) + def test_init_not_implemented(self): with pytest.raises(NotImplementedError): TorchTrainer( diff --git a/tests/training/utils/test_tensor_functions.py b/tests/training/utils/test_tensor_functions.py new file mode 100644 index 0000000..a61d1b8 --- /dev/null +++ b/tests/training/utils/test_tensor_functions.py @@ -0,0 +1,11 @@ +from unittest import TestCase +from epochalyst.training.utils import batch_to_device +from torch import Tensor + + +class TestTensorFunctions(TestCase): + + def test_unsupported_tensor_type(self) -> None: + with self.assertRaises(ValueError): + batch_to_device(Tensor([0,1]), 'failure', None) + From e8009270432f2017995b8fc35e6135ee9f079067 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Sat, 17 Aug 2024 21:26:42 +0200 Subject: [PATCH 12/19] Remove numpy as an optional dependency (#238) --- epochalyst/caching/cacher.py | 6 ++---- pyproject.toml | 4 +--- tests/transformation/test_transformation.py | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/epochalyst/caching/cacher.py b/epochalyst/caching/cacher.py index 6a4dcc3..85bf3cb 100644 --- a/epochalyst/caching/cacher.py +++ b/epochalyst/caching/cacher.py @@ -6,6 +6,8 @@ import sys from typing import Any, Literal, TypedDict +import numpy as np + from epochalyst.logging import Logger try: @@ -14,10 +16,6 @@ except ImportError: """User doesn't require these packages""" -try: - import numpy as np -except ImportError: - """User doesn't require these packages""" try: import pandas as pd diff --git a/pyproject.toml b/pyproject.toml index 497247a..9c62e51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ dependencies = [ "joblib>=1.4.0", "annotated-types>=0.6.0", "typing-extensions>=4.9.0; python_version<'3.12'", + "numpy>= 1.22.4, < 3", ] [project.optional-dependencies] @@ -41,9 +42,6 @@ image = [ "kornia>=0.7.2", "timm>=0.9.16", ] -numpy = [ - "numpy>= 1.22.4, < 3", -] pandas = [ "pandas[performance, parquet]>=2.0.0", ] diff --git a/tests/transformation/test_transformation.py b/tests/transformation/test_transformation.py index 453462f..a8efe6a 100644 --- a/tests/transformation/test_transformation.py +++ b/tests/transformation/test_transformation.py @@ -1,4 +1,3 @@ -import shutil from pathlib import Path import numpy as np From ae8572d92cba7b97dba72d55f7c2820e4437fe31 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Sun, 18 Aug 2024 23:34:28 +0200 Subject: [PATCH 13/19] Add new action and update dependabot (#240) --- .github/dependabot.yml | 1 + .github/workflows/retarget-dependabot-pr.yml | 35 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/retarget-dependabot-pr.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 586279b..06c5e39 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,6 +4,7 @@ updates: directory: "/" schedule: interval: "monthly" + target-branch: "dependabot-updates" - package-ecosystem: "pip" directory: "/" schedule: diff --git a/.github/workflows/retarget-dependabot-pr.yml b/.github/workflows/retarget-dependabot-pr.yml new file mode 100644 index 0000000..2b89d24 --- /dev/null +++ b/.github/workflows/retarget-dependabot-pr.yml @@ -0,0 +1,35 @@ +name: Retarget Dependabot PR + +on: + pull_request: + branches: + - dependabot-updates + types: + - opened + - synchronize + +jobs: + retarget: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get all branches + run: | + git fetch --all + git branch -r > branches.txt + cat branches.txt + + - name: Find the lowest version branch + id: find_branch + run: | + lowest_branch=$(grep -o 'origin/v[0-9]*\.[0-9]*' branches.txt | sort -V | head -n 1 | sed 's/origin\///') + echo "lowest_branch=$lowest_branch" >> $GITHUB_ENV + + - name: Retarget PR to lowest version branch + if: success() + run: | + gh pr edit ${{ github.event.pull_request.number }} --base ${{ env.lowest_branch }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 35729c2724efc6ac025ad0f614d1220d7a6aa438 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:14:17 +0200 Subject: [PATCH 14/19] Add Conv1dBnRelu block (#241) * Add Conv1dBnRelu block * Improve test coverage and fix spelling mistake for Conv1dBnRelu --- epochalyst/training/models/__init__.py | 2 ++ epochalyst/training/models/conv1d_bn_relu.py | 35 ++++++++++++++++++++ tests/training/models/test_conv1d_bn_relu.py | 23 +++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 epochalyst/training/models/conv1d_bn_relu.py create mode 100644 tests/training/models/test_conv1d_bn_relu.py diff --git a/epochalyst/training/models/__init__.py b/epochalyst/training/models/__init__.py index 165fb70..655d4ab 100644 --- a/epochalyst/training/models/__init__.py +++ b/epochalyst/training/models/__init__.py @@ -1,7 +1,9 @@ """Module for reusable models or wrappers.""" +from .conv1d_bn_relu import Conv1dBnRelu from .timm import Timm __all__ = [ "Timm", + "Conv1dBnRelu", ] diff --git a/epochalyst/training/models/conv1d_bn_relu.py b/epochalyst/training/models/conv1d_bn_relu.py new file mode 100644 index 0000000..e1e5278 --- /dev/null +++ b/epochalyst/training/models/conv1d_bn_relu.py @@ -0,0 +1,35 @@ +"""Conv1dBnRelu block for 1d cnn layer with batch normalization and relu.""" + +from torch import Tensor, nn + + +class Conv1dBnRelu(nn.Module): + """Conv1dBnRelu model.""" + + def __init__(self, in_channels: int, out_channels: int, kernel_size: int = 3, stride: int = 1, padding: int = 1, *, is_bn: bool = True) -> None: + """Initialize Conv1dBnRelu block. + + :param in_channels: Number of in channels + :param out_channels: Number of out channels + :param kernel_size: Number of kernels + :param stride: Stride length + :param padding: Padding size + :param is_bn: Whether to use batch norm + """ + super().__init__() + self.conv1 = nn.Conv1d(in_channels, out_channels, kernel_size, stride, padding) + self.is_bn = is_bn + if self.is_bn: + self.bn1 = nn.BatchNorm1d(out_channels, eps=5e-3, momentum=0.1) + self.relu = nn.ReLU() + + def forward(self, x: Tensor) -> Tensor: + """Forward tensor function. + + :param x: Input tensor + :return: Output tensor + """ + x = self.conv1(x) + if self.is_bn: + x = self.bn1(x) + return self.relu(x) diff --git a/tests/training/models/test_conv1d_bn_relu.py b/tests/training/models/test_conv1d_bn_relu.py new file mode 100644 index 0000000..749ff61 --- /dev/null +++ b/tests/training/models/test_conv1d_bn_relu.py @@ -0,0 +1,23 @@ +import torch +from unittest import TestCase + +from epochalyst.training.models import Conv1dBnRelu + + +class TestConv1dBnRelu(TestCase): + + conv1d_bn_relu = Conv1dBnRelu(in_channels=3, out_channels=1) + + def test_conv1d_bn_relu_init(self): + assert self.conv1d_bn_relu is not None + + def test_conv1d_bn_relu_forward(self): + input = torch.rand(16, 3, 1) + # Check there is no error thrown + self.conv1d_bn_relu.forward(input) + + def test_conv1d_bn_relu_forward_without_bn(self): + conv1d_relu = Conv1dBnRelu(in_channels=3, out_channels=1, is_bn=False) + input = torch.rand(16, 3, 1) + # Check there is no error thrown + conv1d_relu.forward(input) From 627fad565088e47ecd739a41080d36794b61808b Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:38:20 +0200 Subject: [PATCH 15/19] Add custom dataset capability to torch trainer (#242) --- epochalyst/data/__init__.py | 9 +++++++ epochalyst/data/pipeline_dataset.py | 11 +++++---- epochalyst/training/torch_trainer.py | 35 +++++++++++++++++----------- tests/data/test_enum_data_format.py | 2 +- tests/data/test_pipeline_dataset.py | 5 ++-- tests/training/models/test_timm.py | 9 +++++++ 6 files changed, 48 insertions(+), 23 deletions(-) diff --git a/epochalyst/data/__init__.py b/epochalyst/data/__init__.py index 2b2f177..e00a0ad 100644 --- a/epochalyst/data/__init__.py +++ b/epochalyst/data/__init__.py @@ -1 +1,10 @@ """Module containing data related classes and functions.""" + +from .enum_data_format import Data, DataRetrieval +from .pipeline_dataset import PipelineDataset + +__all__ = [ + "Data", + "DataRetrieval", + "PipelineDataset", +] diff --git a/epochalyst/data/pipeline_dataset.py b/epochalyst/data/pipeline_dataset.py index 55692ec..3643c8c 100644 --- a/epochalyst/data/pipeline_dataset.py +++ b/epochalyst/data/pipeline_dataset.py @@ -8,7 +8,8 @@ import numpy.typing as npt from epochalyst.data.enum_data_format import Data, DataRetrieval -from epochalyst.training import TrainingBlock, TrainingPipeline +from epochalyst.training.training import TrainingPipeline +from epochalyst.training.training_block import TrainingBlock try: from torch.utils.data import Dataset @@ -36,15 +37,15 @@ class PipelineDataset(Dataset[Tuple[T, T]]): """ + x: Data | None = None + y: Data | None = None + indices: npt.NDArray[np.int_] | None = None + retrieval: list[str] | None = None retrieval_type: DataRetrieval | None = None steps: list[TrainingBlock] | None = None result_formatter: Callable[[Any], Any] = lambda a: a - x: Data | None = None - y: Data | None = None - indices: npt.NDArray[np.int_] | None = None - def __post_init__(self) -> None: """Set up the dataset.""" if self.retrieval is None: diff --git a/epochalyst/training/torch_trainer.py b/epochalyst/training/torch_trainer.py index ee007da..0daaddb 100644 --- a/epochalyst/training/torch_trainer.py +++ b/epochalyst/training/torch_trainer.py @@ -8,7 +8,7 @@ from dataclasses import dataclass, field from os import PathLike from pathlib import Path -from typing import Annotated, Any, Literal, TypeVar +from typing import Annotated, Any, Literal, Tuple, TypeVar import numpy as np import numpy.typing as npt @@ -20,6 +20,8 @@ from torch.utils.data import DataLoader, Dataset, TensorDataset from tqdm import tqdm +from epochalyst.data import Data + from ._custom_data_parallel import _CustomDataParallel from .training_block import TrainingBlock from .utils import _get_onnxrt, _get_openvino, batch_to_device @@ -166,6 +168,7 @@ def log_to_terminal(self, message: str) -> None: criterion: nn.Module scheduler: Callable[[Optimizer], LRScheduler] | None = None dataloader_args: dict[str, Any] = field(default_factory=dict, repr=False) + dataset: functools.partial[Dataset[Tuple[Tensor, Tensor]]] | None = None # Training parameters epochs: Annotated[int, Gt(0)] = 10 @@ -531,8 +534,8 @@ def get_hash(self) -> str: def create_datasets( self, - x: npt.NDArray[np.float32], - y: npt.NDArray[np.float32], + x: npt.NDArray[np.float32] | Data, + y: npt.NDArray[np.float32] | Data, train_indices: list[int], validation_indices: list[int], ) -> tuple[Dataset[tuple[Tensor, ...]], Dataset[tuple[Tensor, ...]]]: @@ -544,27 +547,31 @@ def create_datasets( :param validation_indices: The indices to validate on. :return: The training and validation datasets. """ - train_dataset = TensorDataset( - torch.from_numpy(x[train_indices]), - torch.from_numpy(y[train_indices]), - ) - validation_dataset = TensorDataset( - torch.from_numpy(x[validation_indices]), - torch.from_numpy(y[validation_indices]), - ) + if self.dataset is None: + train_dataset = TensorDataset( + torch.from_numpy(x[train_indices]), + torch.from_numpy(y[train_indices]), + ) + validation_dataset = TensorDataset( + torch.from_numpy(x[validation_indices]), + torch.from_numpy(y[validation_indices]), + ) + return train_dataset, validation_dataset - return train_dataset, validation_dataset + return self.dataset(x[train_indices], y[train_indices]), self.dataset(x[validation_indices], y[validation_indices]) def create_prediction_dataset( self, - x: npt.NDArray[np.float32], + x: npt.NDArray[np.float32] | Data, ) -> Dataset[tuple[Tensor, ...]]: """Create the prediction dataset. :param x: The input data. :return: The prediction dataset. """ - return TensorDataset(torch.from_numpy(x)) + if self.dataset is None: + return TensorDataset(torch.from_numpy(x)) + return self.dataset(x) def create_dataloaders( self, diff --git a/tests/data/test_enum_data_format.py b/tests/data/test_enum_data_format.py index b0fafdf..2223f53 100644 --- a/tests/data/test_enum_data_format.py +++ b/tests/data/test_enum_data_format.py @@ -1,7 +1,7 @@ from unittest import TestCase from dataclasses import dataclass -from epochalyst.data.enum_data_format import DataRetrieval, Data +from epochalyst.data import DataRetrieval, Data import numpy as np import numpy.typing as npt from typing import Any diff --git a/tests/data/test_pipeline_dataset.py b/tests/data/test_pipeline_dataset.py index de6c3cf..15aebfe 100644 --- a/tests/data/test_pipeline_dataset.py +++ b/tests/data/test_pipeline_dataset.py @@ -1,9 +1,8 @@ from unittest import TestCase from dataclasses import dataclass -from epochalyst.data.enum_data_format import Data, DataRetrieval -from epochalyst.data.pipeline_dataset import PipelineDataset -from epochalyst.training.training_block import TrainingBlock +from epochalyst.data import Data, DataRetrieval, PipelineDataset +from epochalyst.training import TrainingBlock import numpy as np import numpy.typing as npt from typing import Any diff --git a/tests/training/models/test_timm.py b/tests/training/models/test_timm.py index ab847d7..61caf4d 100644 --- a/tests/training/models/test_timm.py +++ b/tests/training/models/test_timm.py @@ -1,6 +1,7 @@ import torch from epochalyst.training.models import Timm +from torch import nn class TestTimm: @@ -12,4 +13,12 @@ def test_timm_init(self): def test_timm_forward(self): input = torch.rand(16, 3, 1, 1) + # Should not throw error self.timm.forward(input) + + def test_timm_activation(self): + timm_act = Timm(in_chans=3, num_classes=3, activation=nn.ReLU(), model_name="resnet18") + input = torch.rand(16, 3, 1, 1) + # Should not throw error + timm_act.forward(input) + From fcccd49119ea3453d16dbfcb063bb51c0de4664a Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:50:11 +0200 Subject: [PATCH 16/19] Update log message for inference on loader (#243) --- README.md | 16 +++------------- epochalyst/training/torch_trainer.py | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0fcd1dd..1f369af 100644 --- a/README.md +++ b/README.md @@ -75,16 +75,6 @@ Documentation is generated using [Sphinx](https://www.sphinx-doc.org/en/master/) To make the documentation yourself, run `make html` with `docs` as the working directory. The documentation can then be found in `docs/_build/html/index.html`. -## Contributors - -Epochalyst was created by [Team Epoch IV](https://teamepoch.ai/team#iv), based in the [Dream Hall](https://www.tudelft.nl/ddream) of the [Delft University of Technology](https://www.tudelft.nl/). - -[![Github Badge](https://img.shields.io/badge/-Jasper_van_Selm-24292e?style=flat&logo=Github)](https://github.com/schobbejak) -[![Github Badge](https://img.shields.io/badge/-Emiel_Witting-24292e?style=flat&logo=Github)](https://github.com/EWitting) -[![Github Badge](https://img.shields.io/badge/-Jeffrey_Lim-24292e?style=flat&logo=Github)](https://github.com/Jeffrey-Lim) -[![Github Badge](https://img.shields.io/badge/-Hugo_de_Heer-24292e?style=flat&logo=Github)](https://github.com/hjdeheer) -[![Github Badge](https://img.shields.io/badge/-Tolga_Kopar-24292e?style=flat&logo=Github)](https://github.com/tolgakopar) -[![Github Badge](https://img.shields.io/badge/-Ariel_Ebersberger-24292e?style=flat&logo=Github)](https://github.com/justanotherariel) -[![Github Badge](https://img.shields.io/badge/-Gregoire_Dumont-24292e?style=flat&logo=Github)](https://github.com/Gregoire-Andre-Dumont) -[![Github Badge](https://img.shields.io/badge/-Kristóf_Sándor-24292e?style=flat&logo=Github)](https://github.com/emherk) -[![Github Badge](https://img.shields.io/badge/-Daniel_De_Dios_Allegue-24292e?style=flat&logo=Github)](https://github.com/daniallegue) +## Maintainers + +Epochalyst is maintained by [Team Epoch](https://teamepoch.ai), based in the [Dream Hall](https://www.tudelft.nl/ddream) of the [Delft University of Technology](https://www.tudelft.nl/). diff --git a/epochalyst/training/torch_trainer.py b/epochalyst/training/torch_trainer.py index 0daaddb..e1b337b 100644 --- a/epochalyst/training/torch_trainer.py +++ b/epochalyst/training/torch_trainer.py @@ -465,7 +465,7 @@ def predict_on_loader( :param loader: The loader to predict on. :return: The predictions. """ - self.log_to_terminal("Predicting on the validation data") + self.log_to_terminal("Running inference on the given dataloader") self.model.eval() predictions = [] # Create a new dataloader from the dataset of the input dataloader with collate_fn From 90810195ed09955fbcc1017b434fcd8608304590 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Mon, 26 Aug 2024 22:18:09 +0200 Subject: [PATCH 17/19] Reduce cyclomatic complexity of caching (#244) * Refactor _get_cache to reduce cyclomatic complexity * Refactor store cache * Fix errors with cacher * Remove unused arguments and fix typing --- epochalyst/caching/cacher.py | 353 ++++++++++++++++++----------------- pyproject.toml | 2 +- 2 files changed, 182 insertions(+), 173 deletions(-) diff --git a/epochalyst/caching/cacher.py b/epochalyst/caching/cacher.py index 85bf3cb..c6d5b2d 100644 --- a/epochalyst/caching/cacher.py +++ b/epochalyst/caching/cacher.py @@ -4,7 +4,8 @@ import os import pickle import sys -from typing import Any, Literal, TypedDict +from pathlib import Path +from typing import Any, Callable, Dict, Literal, TypedDict import numpy as np @@ -75,6 +76,10 @@ class CacheArgs(TypedDict): store_args: NotRequired[dict[str, Any]] +LoaderFunction = Callable[[str, Path, str, Any], Any] +StoreFunction = Callable[[str, Path, Any, str, Any], Any] + + class Cacher(Logger): """The cacher is a flexible class that allows for caching of any data. @@ -136,7 +141,7 @@ def cache_exists(self, name: str, cache_args: CacheArgs | None = None) -> bool: return path_exists - def _get_cache(self, name: str, cache_args: CacheArgs | None = None) -> Any: # noqa: ANN401 C901 PLR0911 PLR0912 + def _get_cache(self, name: str, cache_args: CacheArgs | None = None) -> Any: # noqa: ANN401 """Load the cache. :param name: The name of the cache. @@ -148,207 +153,211 @@ def _get_cache(self, name: str, cache_args: CacheArgs | None = None) -> Any: # raise ValueError("cache_args is empty") # Check if storage type, storage_path and output_data_type are in cache_args + required_keys = ["storage_type", "storage_path", "output_data_type"] + for key in required_keys: + if key not in cache_args: + raise ValueError(f"cache_args must contain {', '.join(required_keys)}") + if "storage_type" not in cache_args or "storage_path" not in cache_args or "output_data_type" not in cache_args: raise ValueError( "cache_args must contain storage_type, storage_path and output_data_type", ) storage_type = cache_args["storage_type"] - storage_path = cache_args["storage_path"] + storage_path = Path(cache_args["storage_path"]) output_data_type = cache_args["output_data_type"] read_args = cache_args.get("read_args", {}) - # If storage path does not end a slash, add it - if storage_path[-1] != "/": - storage_path += "/" + load_functions: Dict[str, LoaderFunction] = { + ".npy": self._load_npy, + ".parquet": self._load_parquet, + ".csv": self._load_csv, + ".npy_stack": self._load_npy_stack, + ".pkl": self._load_pkl, + } - # Load the cache - if storage_type == ".npy": - # Check if output_data_type is supported and load cache to output_data_type - self.log_to_debug(f"Loading .npy file from {storage_path + name}") - if output_data_type == "numpy_array": - return np.load(storage_path + name + ".npy", **read_args) - if output_data_type == "dask_array": - return da.from_array(np.load(storage_path + name + ".npy"), **read_args) + if storage_type in load_functions: + return load_functions[storage_type](name, storage_path, output_data_type, read_args) - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for loading .npy file.", - ) - raise ValueError( - "output_data_type must be numpy_array or dask_array, other types not supported yet", - ) - if storage_type == ".parquet": - # Check if output_data_type is supported and load cache to output_data_type - self.log_to_debug(f"Loading .parquet file from {storage_path + name}") - if output_data_type == "pandas_dataframe": - return pd.read_parquet(storage_path + name + ".parquet", **read_args) - if output_data_type == "dask_dataframe": - return dd.read_parquet(storage_path + name + ".parquet", **read_args) - if output_data_type == "numpy_array": - return pd.read_parquet( - storage_path + name + ".parquet", - **read_args, - ).to_numpy() - if output_data_type == "dask_array": - return dd.read_parquet( - storage_path + name + ".parquet", - **read_args, - ).to_dask_array() - if output_data_type == "polars_dataframe": - return pl.read_parquet(storage_path + name + ".parquet", **read_args) - - self.log_to_debug( # type: ignore[unreachable] - f"Invalid output data type: {output_data_type}, for loading .parquet file.", - ) - raise ValueError( - "output_data_type must be pandas_dataframe, dask_dataframe, numpy_array, dask_array, or polars_dataframe, other types not supported yet", - ) - if storage_type == ".csv": - # Check if output_data_type is supported and load cache to output_data_type - self.log_to_debug(f"Loading .csv file from {storage_path + name}") - if output_data_type == "pandas_dataframe": - return pd.read_csv(storage_path + name + ".csv", **read_args) - if output_data_type == "dask_dataframe": - return dd.read_csv(storage_path + name + "/*.part", **read_args) - if output_data_type == "polars_dataframe": - return pl.read_csv(storage_path + name + ".csv", **read_args) + self.log_to_debug(f"Invalid storage type: {storage_type}") + raise ValueError( + "storage_type must be .npy, .parquet, .csv, or .npy_stack, other types not supported yet", + ) - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for loading .csv file.", - ) - raise ValueError( - "output_data_type must be pandas_dataframe, dask_dataframe, or polars_dataframe, other types not supported yet", - ) - if storage_type == ".npy_stack": - # Check if output_data_type is supported and load cache to output_data_type - self.log_to_debug(f"Loading .npy_stack file from {storage_path + name}") - if output_data_type == "dask_array": - return da.from_npy_stack(storage_path + name, **read_args) + def _load_npy(self, name: str, storage_path: Path, output_data_type: str, read_args: Any) -> Any: # noqa: ANN401 + # Check if output_data_type is supported and load cache to output_data_type + self.log_to_debug(f"Loading .npy file from {storage_path / name}") + if output_data_type == "numpy_array": + return np.load(storage_path / f"{name}.npy", **read_args) + if output_data_type == "dask_array": + return da.from_array(np.load(storage_path / f"{name}.npy"), **read_args) - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for loading .npy_stack file.", - ) - raise ValueError( - "output_data_type must be dask_array, other types not supported yet", - ) - if storage_type == ".pkl": - # Load the pickle file - self.log_to_debug( - f"Loading pickle file from {storage_path + name + '.pkl'}", - ) - with open(storage_path + name + ".pkl", "rb") as file: - return pickle.load(file, **read_args) # noqa: S301 + self.log_to_debug( + f"Invalid output data type: {output_data_type}, for loading .npy file.", + ) + raise ValueError( + "output_data_type must be numpy_array or dask_array, other types not supported yet", + ) - self.log_to_debug(f"Invalid storage type: {storage_type}") # type: ignore[unreachable] + def _load_parquet(self, name: str, storage_path: Path, output_data_type: str, read_args: Any) -> Any: # noqa: ANN401 + # Check if output_data_type is supported and load cache to output_data_type + self.log_to_debug(f"Loading .parquet file from {storage_path}/{name}") + if output_data_type == "pandas_dataframe": + return pd.read_parquet(storage_path / f"{name}.parquet", **read_args) + if output_data_type == "dask_dataframe": + return dd.read_parquet(storage_path / f"{name}.parquet", **read_args) + if output_data_type == "numpy_array": + return pd.read_parquet( + storage_path / f"{name}.parquet", + **read_args, + ).to_numpy() + if output_data_type == "dask_array": + return dd.read_parquet( + storage_path / f"{name}.parquet", + **read_args, + ).to_dask_array() + if output_data_type == "polars_dataframe": + return pl.read_parquet(storage_path / f"{name}.parquet", **read_args) + + self.log_to_debug( + f"Invalid output data type: {output_data_type}, for loading .parquet file.", + ) raise ValueError( - "storage_type must be .npy, .parquet, .csv, or .npy_stack, other types not supported yet", + "output_data_type must be pandas_dataframe, dask_dataframe, numpy_array, dask_array, or polars_dataframe, other types not supported yet", + ) + + def _load_csv(self, name: str, storage_path: Path, output_data_type: str, read_args: Any) -> Any: # noqa: ANN401 + # Check if output_data_type is supported and load cache to output_data_type + self.log_to_debug(f"Loading .csv file from {storage_path / name}") + if output_data_type == "pandas_dataframe": + return pd.read_csv(storage_path / f"{name}.csv", **read_args) + if output_data_type == "dask_dataframe": + return dd.read_csv(storage_path / f"{name}/*.part", **read_args) + if output_data_type == "polars_dataframe": + return pl.read_csv(storage_path / f"{name}.csv", **read_args) + + self.log_to_debug( + f"Invalid output data type: {output_data_type}, for loading .csv file.", + ) + raise ValueError( + "output_data_type must be pandas_dataframe, dask_dataframe, or polars_dataframe, other types not supported yet", + ) + + def _load_npy_stack(self, name: str, storage_path: Path, output_data_type: str, read_args: Any) -> Any: # noqa: ANN401 + # Check if output_data_type is supported and load cache to output_data_type + self.log_to_debug(f"Loading .npy_stack file from {storage_path / name}") + if output_data_type == "dask_array": + return da.from_npy_stack(storage_path / name, **read_args) + + self.log_to_debug( + f"Invalid output data type: {output_data_type}, for loading .npy_stack file.", + ) + raise ValueError( + "output_data_type must be dask_array, other types not supported yet", ) - def _store_cache(self, name: str, data: Any, cache_args: CacheArgs | None = None) -> None: # noqa: ANN401 C901 PLR0915 PLR0912 + def _load_pkl(self, name: str, storage_path: Path, _output_data_type: str, read_args: Any) -> Any: # noqa: ANN401 + # Load the pickle file + self.log_to_debug( + f"Loading pickle file from {storage_path}/{name}.pkl", + ) + with open(storage_path / f"{name}.pkl", "rb") as file: + return pickle.load(file, **read_args) # noqa: S301 + + def _store_cache(self, name: str, data: Any, cache_args: CacheArgs | None = None) -> None: # noqa: ANN401 """Store one set of data. :param name: The name of the cache. :param data: The data to store. :param cache_args: The cache arguments. """ - # Check if cache_args is empty if not cache_args: raise ValueError("cache_args is empty") - # Check if storage type, storage_path and output_data_type are in cache_args - if "storage_type" not in cache_args or "storage_path" not in cache_args or "output_data_type" not in cache_args: - raise ValueError( - "cache_args must contain storage_type, storage_path and output_data_type", - ) + required_keys = ["storage_type", "storage_path", "output_data_type"] + for key in required_keys: + if key not in cache_args: + raise ValueError(f"cache_args must contain {', '.join(required_keys)}") storage_type = cache_args["storage_type"] - storage_path = cache_args["storage_path"] + storage_path = Path(cache_args["storage_path"]) output_data_type = cache_args["output_data_type"] store_args = cache_args.get("store_args", {}) - # If storage path does not end a slash, add it - if storage_path[-1] != "/": - storage_path += "/" - - # Store the cache - if storage_type == ".npy": - # Check if output_data_type is supported and store cache to output_data_type - self.log_to_debug(f"Storing .npy file to {storage_path + name}") - if output_data_type == "numpy_array": - np.save(storage_path + name + ".npy", data, **store_args) - elif output_data_type == "dask_array": - np.save(storage_path + name + ".npy", data.compute(), **store_args) - else: - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for storing .npy file.", - ) - raise ValueError( - "output_data_type must be numpy_array or dask_array, other types not supported yet", - ) - elif storage_type == ".parquet": - # Check if output_data_type is supported and store cache to output_data_type - self.log_to_debug(f"Storing .parquet file to {storage_path + name}") - if output_data_type in {"pandas_dataframe", "dask_dataframe"}: - data.to_parquet(storage_path + name + ".parquet", **store_args) - elif output_data_type == "numpy_array": - pd.DataFrame(data).to_parquet( - storage_path + name + ".parquet", - **store_args, - ) - elif output_data_type == "dask_array": - new_dd = dd.from_dask_array(data) - new_dd = new_dd.rename( - columns={col: str(col) for col in new_dd.columns}, - ) - new_dd.to_parquet(storage_path + name + ".parquet", **store_args) - elif output_data_type == "polars_dataframe": - data.write_parquet(storage_path + name + ".parquet", **store_args) - else: - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for storing .parquet file.", - ) - raise ValueError( - "output_data_type must be pandas_dataframe, dask_dataframe, numpy_array, dask_array, or polars_dataframe, other types not supported yet", - ) - elif storage_type == ".csv": - # Check if output_data_type is supported and store cache to output_data_type - self.log_to_debug(f"Storing .csv file to {storage_path + name}") - if output_data_type == "pandas_dataframe": - data.to_csv(storage_path + name + ".csv", **({"index": False} | store_args)) - elif output_data_type == "dask_dataframe": - data.to_csv(storage_path + name, **({"index": False} | store_args)) - elif output_data_type == "polars_dataframe": - data.write_csv(storage_path + name + ".csv", **store_args) - else: - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for storing .csv file.", - ) - raise ValueError( - "output_data_type must be pandas_dataframe, dask_dataframe, or polars_dataframe, other types not supported yet", - ) - elif storage_type == ".npy_stack": - # Check if output_data_type is supported and store cache to output_data_type - self.log_to_debug(f"Storing .npy_stack file to {storage_path + name}") - if output_data_type == "dask_array": - da.to_npy_stack(storage_path + name, data, **store_args) - else: - self.log_to_debug( - f"Invalid output data type: {output_data_type}, for storing .npy_stack file.", - ) - raise ValueError( - "output_data_type must be numpy_array other types not supported yet", - ) - elif storage_type == ".pkl": - # Store the pickle file - self.log_to_debug(f"Storing pickle file to {storage_path + name + '.pkl'}") - with open(storage_path + name + ".pkl", "wb") as f: - pickle.dump( - data, - f, - **({"protocol": pickle.HIGHEST_PROTOCOL} | store_args), - ) + store_functions: Dict[str, StoreFunction] = { + ".npy": self._store_npy, + ".parquet": self._store_parquet, + ".csv": self._store_csv, + ".npy_stack": self._store_npy_stack, + ".pkl": self._store_pkl, + } + + if storage_type in store_functions: + return store_functions[storage_type](name, storage_path, data, output_data_type, store_args) + + self.log_to_debug(f"Invalid storage type: {storage_type}") + raise ValueError(f"storage_type is {storage_type} must be .npy, .parquet, .csv, .npy_stack, or .pkl, other types not supported yet") + + def _store_npy(self, name: str, storage_path: Path, data: Any, output_data_type: str, store_args: Any) -> None: # noqa: ANN401 + file_path = storage_path / f"{name}.npy" + self.log_to_debug(f"Storing .npy file to {file_path}") + if output_data_type == "numpy_array": + np.save(file_path, data, **store_args) + elif output_data_type == "dask_array": + np.save(file_path, data.compute(), **store_args) else: - self.log_to_debug(f"Invalid storage type: {storage_type}") # type: ignore[unreachable] + raise ValueError("output_data_type must be numpy_array or dask_array") + + def _store_parquet(self, name: str, storage_path: Path, data: Any, output_data_type: str, store_args: Any) -> None: # noqa: ANN401 + # Check if output_data_type is supported and store cache to output_data_type + self.log_to_debug(f"Storing .parquet file to {storage_path / name}") + if output_data_type in {"pandas_dataframe", "dask_dataframe"}: + data.to_parquet(storage_path / f"{name}.parquet", **store_args) + elif output_data_type == "numpy_array": + pd.DataFrame(data).to_parquet( + storage_path / f"{name}.parquet", + **store_args, + ) + elif output_data_type == "dask_array": + new_dd = dd.from_dask_array(data) + new_dd = new_dd.rename( + columns={col: str(col) for col in new_dd.columns}, + ) + new_dd.to_parquet(storage_path / f"{name}.parquet", **store_args) + elif output_data_type == "polars_dataframe": + data.write_parquet(storage_path / f"{name}.parquet", **store_args) + else: + self.log_to_debug( + f"Invalid output data type: {output_data_type}, for storing .parquet file.", + ) raise ValueError( - "storage_type must be .npy, .parquet, .csv or .npy_stack, other types not supported yet", + "output_data_type must be pandas_dataframe, dask_dataframe, numpy_array, dask_array, or polars_dataframe, other types not supported yet", ) + + def _store_csv(self, name: str, storage_path: Path, data: Any, output_data_type: str, store_args: Any) -> None: # noqa: ANN401 + if output_data_type == "pandas_dataframe": + data.to_csv(storage_path / f"{name}.csv", index=False, **store_args) + self.log_to_debug(f"Storing .csv file to {storage_path}/{name}.csv") + elif output_data_type == "dask_dataframe": + data.to_csv(storage_path / name, index=False, **store_args) + self.log_to_debug(f"Storing .csv file to {storage_path}/{name}") + elif output_data_type == "polars_dataframe": + data.write_csv(storage_path / f"{name}.csv", **store_args) + self.log_to_debug(f"Storing .csv file to {storage_path}/{name}.csv") + else: + raise ValueError("output_data_type must be pandas_dataframe, dask_dataframe, or polars_dataframe") + + def _store_npy_stack(self, name: str, storage_path: Path, data: Any, output_data_type: str, store_args: Any) -> None: # noqa: ANN401 + # Handling npy_stack case differently as it might need a different path structure + storage_path /= name # Treat name as a directory here + self.log_to_debug(f"Storing .npy_stack file to {storage_path}") + if output_data_type == "dask_array": + da.to_npy_stack(storage_path, data, **store_args) + else: + raise ValueError("output_data_type must be dask_array") + + def _store_pkl(self, name: str, storage_path: Path, data: Any, _output_data_type: str, store_args: Any) -> None: # noqa: ANN401 + file_path = storage_path / f"{name}.pkl" + self.log_to_debug(f"Storing pickle file to {file_path}") + with open(file_path, "wb") as f: + pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL, **store_args) diff --git a/pyproject.toml b/pyproject.toml index 9c62e51..6d85844 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "epochalyst" -version = "4.0" +version = "4.1.0" authors = [ { name = "Jasper van Selm", email = "jmvanselm@gmail.com" }, { name = "Ariel Ebersberger", email = "arielebersberger@gmail.com" }, From 578af6bf4a695db5366968cb864b937d7ab3e154 Mon Sep 17 00:00:00 2001 From: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:39:44 +0200 Subject: [PATCH 18/19] Rename epochalyst to epochlib (#253) --- .github/workflows/main-branch-testing.yml | 2 +- .github/workflows/publish-package.yml | 2 +- .github/workflows/version-branch-testing.yml | 2 +- CITATION.cff | 4 +-- README.md | 30 ++++++++--------- ...{Epochalyst_Icon.svg => EpochLib_Icon.svg} | 4 +-- ...t_Logo_Auto.svg => EpochLib_Logo_Auto.svg} | 2 +- ...t_Logo_Dark.svg => EpochLib_Logo_Dark.svg} | 2 +- ...Logo_Light.svg => EpochLib_Logo_Light.svg} | 2 +- docs/_static/logo.css | 8 ++--- docs/conf.py | 4 +-- docs/index.rst | 4 +-- {epochalyst => epochlib}/__init__.py | 2 +- {epochalyst => epochlib}/caching/__init__.py | 2 +- {epochalyst => epochlib}/caching/cacher.py | 2 +- {epochalyst => epochlib}/data/__init__.py | 0 .../data/enum_data_format.py | 0 .../data/pipeline_dataset.py | 6 ++-- {epochalyst => epochlib}/ensemble.py | 2 +- {epochalyst => epochlib}/logging/__init__.py | 0 {epochalyst => epochlib}/logging/logger.py | 0 {epochalyst => epochlib}/model.py | 2 +- {epochalyst => epochlib}/training/__init__.py | 2 +- .../training/_custom_data_parallel.py | 0 .../training/augmentation/__init__.py | 4 +-- .../augmentation/image_augmentations.py | 0 .../augmentation/time_series_augmentations.py | 0 .../training/augmentation/utils.py | 2 +- .../training/models/__init__.py | 0 .../training/models/conv1d_bn_relu.py | 0 .../training/models/timm.py | 0 .../training/pretrain_block.py | 2 +- .../training/torch_trainer.py | 4 +-- {epochalyst => epochlib}/training/training.py | 2 +- .../training/training_block.py | 4 +-- .../training/utils/__init__.py | 0 .../training/utils/get_dependencies.py | 0 .../training/utils/recursive_repr.py | 0 .../training/utils/tensor_functions.py | 0 .../transformation/__init__.py | 0 .../transformation/transformation.py | 4 +-- .../transformation/transformation_block.py | 4 +-- pyproject.toml | 16 +++++----- requirements-dev.lock | 32 +++++++++---------- requirements.lock | 32 +++++++++---------- tests/caching/test__cacher.py | 4 +-- tests/data/test_enum_data_format.py | 2 +- tests/data/test_pipeline_dataset.py | 4 +-- tests/logging/test_logger.py | 2 +- tests/test_ensemble.py | 8 ++--- tests/test_model.py | 6 ++-- .../augmentation/test_image_augmentations.py | 2 +- .../test_time_series_augmentations.py | 2 +- tests/training/augmentation/test_utils.py | 2 +- tests/training/models/test_conv1d_bn_relu.py | 2 +- tests/training/models/test_timm.py | 2 +- tests/training/test_pretrain_block.py | 2 +- tests/training/test_torch_trainer.py | 6 ++-- tests/training/test_training.py | 4 +-- tests/training/test_training_block.py | 2 +- tests/training/utils/test_get_dependencies.py | 2 +- tests/training/utils/test_recursive_repr.py | 2 +- tests/training/utils/test_tensor_functions.py | 2 +- tests/transformation/test_transformation.py | 4 +-- .../test_transformation_block.py | 2 +- 65 files changed, 126 insertions(+), 126 deletions(-) rename assets/{Epochalyst_Icon.svg => EpochLib_Icon.svg} (99%) rename assets/{Epochalyst_Logo_Auto.svg => EpochLib_Logo_Auto.svg} (99%) rename assets/{Epochalyst_Logo_Dark.svg => EpochLib_Logo_Dark.svg} (99%) rename assets/{Epochalyst_Logo_Light.svg => EpochLib_Logo_Light.svg} (99%) rename {epochalyst => epochlib}/__init__.py (81%) rename {epochalyst => epochlib}/caching/__init__.py (66%) rename {epochalyst => epochlib}/caching/cacher.py (99%) rename {epochalyst => epochlib}/data/__init__.py (100%) rename {epochalyst => epochlib}/data/enum_data_format.py (100%) rename {epochalyst => epochlib}/data/pipeline_dataset.py (96%) rename {epochalyst => epochlib}/ensemble.py (97%) rename {epochalyst => epochlib}/logging/__init__.py (100%) rename {epochalyst => epochlib}/logging/logger.py (100%) rename {epochalyst => epochlib}/model.py (98%) rename {epochalyst => epochlib}/training/__init__.py (80%) rename {epochalyst => epochlib}/training/_custom_data_parallel.py (100%) rename {epochalyst => epochlib}/training/augmentation/__init__.py (74%) rename {epochalyst => epochlib}/training/augmentation/image_augmentations.py (100%) rename {epochalyst => epochlib}/training/augmentation/time_series_augmentations.py (100%) rename {epochalyst => epochlib}/training/augmentation/utils.py (98%) rename {epochalyst => epochlib}/training/models/__init__.py (100%) rename {epochalyst => epochlib}/training/models/conv1d_bn_relu.py (100%) rename {epochalyst => epochlib}/training/models/timm.py (100%) rename {epochalyst => epochlib}/training/pretrain_block.py (97%) rename {epochalyst => epochlib}/training/torch_trainer.py (99%) rename {epochalyst => epochlib}/training/training.py (99%) rename {epochalyst => epochlib}/training/training_block.py (97%) rename {epochalyst => epochlib}/training/utils/__init__.py (100%) rename {epochalyst => epochlib}/training/utils/get_dependencies.py (100%) rename {epochalyst => epochlib}/training/utils/recursive_repr.py (100%) rename {epochalyst => epochlib}/training/utils/tensor_functions.py (100%) rename {epochalyst => epochlib}/transformation/__init__.py (100%) rename {epochalyst => epochlib}/transformation/transformation.py (96%) rename {epochalyst => epochlib}/transformation/transformation_block.py (95%) diff --git a/.github/workflows/main-branch-testing.yml b/.github/workflows/main-branch-testing.yml index 249a330..ffb66c3 100644 --- a/.github/workflows/main-branch-testing.yml +++ b/.github/workflows/main-branch-testing.yml @@ -48,4 +48,4 @@ jobs: - name: Test with pytest run: | - venv/bin/python -m pytest --cov=epochalyst --cov-branch --cov-fail-under=95 tests + venv/bin/python -m pytest --cov=epochlib --cov-branch --cov-fail-under=95 tests diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 16344e5..af56331 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest environment: name: pypi - url: https://pypi.org/p/epochalyst + url: https://pypi.org/p/epochlib permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write diff --git a/.github/workflows/version-branch-testing.yml b/.github/workflows/version-branch-testing.yml index 6b9e232..c922128 100644 --- a/.github/workflows/version-branch-testing.yml +++ b/.github/workflows/version-branch-testing.yml @@ -17,7 +17,7 @@ jobs: - name: Setup the environment run: rye sync --all-features - name: Test with pytest - run: rye run pytest --cov=epochalyst --cov-branch --cov-fail-under=95 tests + run: rye run pytest --cov=epochlib --cov-branch --cov-fail-under=95 tests build: runs-on: ubuntu-latest diff --git a/CITATION.cff b/CITATION.cff index 1b88b63..617d1f0 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -39,7 +39,7 @@ authors: given-names: "Daniel" affiliation: "TU Delft Dream Team Epoch" email: "danieldediosallegue@gmail.com" -title: "Epochalyst" +title: "EpochLib" version: 1.0.0 date-released: 2024-03-19 -url: "https://github.com/TeamEpochGithub/epochalyst" +url: "https://github.com/TeamEpochGithub/epochlib" diff --git a/README.md b/README.md index 1f369af..57f8f5e 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,47 @@ -![image](https://raw.githubusercontent.com/TeamEpochGithub/epochalyst/main/assets/Epochalyst_Logo_Auto.svg) +![image](https://raw.githubusercontent.com/TeamEpochGithub/epochlib/main/assets/EpochLib_Logo_Auto.svg) [![Team Epoch](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FJeffrey-Lim%2Fepoch-dvdscreensaver%2Fmaster%2Fbadge.json)](https://teamepoch.ai/) -[![PyPI Latest Release](https://img.shields.io/pypi/v/epochalyst.svg)](https://pypi.org/project/epochalyst/) -[![PyPI Downloads](https://img.shields.io/pypi/dm/epochalyst.svg?label=PyPI%20downloads)](https://pypi.org/project/epochalyst/) +[![PyPI Latest Release](https://img.shields.io/pypi/v/epochlib.svg)](https://pypi.org/project/epochlib/) +[![PyPI Downloads](https://img.shields.io/pypi/dm/epochlib.svg?label=PyPI%20downloads)](https://pypi.org/project/epochlib/) [![Python Version](https://img.shields.io/badge/Python-3.10_|_3.11_|_3.12-4584b6.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDMyIDMyIj48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9IkEiIHgxPSI4MTEuNTI3IiB5MT0iNTc0Ljg5NSIgeDI9IjY2NS4yNTUiIHkyPSI1NzMuNzMyIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjMzY2YTk2Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjMzY3OWIwIi8+PC9saW5lYXJHcmFkaWVudD48bGluZWFyR3JhZGllbnQgaWQ9IkIiIHgxPSI4NjIuODI0IiB5MT0iNjQyLjE3NiIgeDI9IjU3My4yNzYiIHkyPSI2NDIuMTc2IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZmZjODM2Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmZlODczIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PGcgdHJhbnNmb3JtPSJtYXRyaXgoLjE2MTcgMCAwIC4xNTgwODkgLTEwNy41Mzc2NCAtODEuNjYxODcpIj48cGF0aCBkPSJNNzE2LjI1NSA1NDQuNDg3YzAtMTMuNjIzIDMuNjUzLTIxLjAzNCAyMy44MjItMjQuNTYzIDEzLjY5My0yLjQgMzEuMjUtMi43IDQ3LjYyNyAwIDEyLjkzNSAyLjEzNSAyMy44MjIgMTEuNzcgMjMuODIyIDI0LjU2M3Y0NC45NDVjMCAxMy4xODItMTAuNTcgMjMuOTgtMjMuODIyIDIzLjk4aC00Ny42MjdjLTE2LjE2NCAwLTI5Ljc4NyAxMy43ODItMjkuNzg3IDI5LjM2M3YyMS41NjRoLTE2LjM3NmMtMTMuODUyIDAtMjEuOTE3LTkuOTg4LTI1LjMwNS0yMy45NjQtNC41Ny0xOC43NzYtNC4zNzYtMjkuOTYzIDAtNDcuOTQ1IDMuNzk0LTE1LjY4NyAxNS45MTctMjMuOTY0IDI5Ljc3LTIzLjk2NGg2NS41MnYtNmgtNDcuNjQ1di0xNy45OHoiIGZpbGw9InVybCgjQSkiLz48cGF0aCBkPSJNODExLjUyNyA2ODguMzJjMCAxMy42MjMtMTEuODIzIDIwLjUyMy0yMy44MjIgMjMuOTY0LTE4LjA1MiA1LjE4OC0zMi41NCA0LjM5NC00Ny42MjcgMC0xMi42LTMuNjctMjMuODIyLTExLjE3LTIzLjgyMi0yMy45NjR2LTQ0Ljk0NWMwLTEyLjkzNSAxMC43ODItMjMuOTggMjMuODIyLTIzLjk4aDQ3LjYyN2MxNS44NjQgMCAyOS43ODctMTMuNzEgMjkuNzg3LTI5Ljk2M3YtMjAuOTY0aDE3Ljg1OGMxMy44NyAwIDIwLjQgMTAuMzA1IDIzLjgyMiAyMy45NjQgNC43NjQgMTguOTcgNC45NzYgMzMuMTU3IDAgNDcuOTQ1LTQuODE3IDE0LjM2NC05Ljk3IDIzLjk2NC0yMy44MjIgMjMuOTY0SDc2My45djZoNDcuNjI3djE3Ljk4eiIgZmlsbD0idXJsKCNCKSIvPjxwYXRoIGQ9Ik03MjguMTY2IDU0MS41MDVjMC00Ljk3NiAzLjk4OC05IDguOTMtOSA0LjkyMyAwIDguOTMgNC4wMjMgOC45MyA5IDAgNC45Ni00LjAwNiA4Ljk4Mi04LjkzIDguOTgyLTQuOTQgMC04LjkzLTQuMDIzLTguOTMtOC45ODJ6bTUzLjU5IDE0OS43OThjMC00Ljk2IDQuMDA2LTguOTgyIDguOTMtOC45ODIgNC45NCAwIDguOTMgNC4wMjMgOC45MyA4Ljk4MiAwIDQuOTc2LTMuOTg4IDktOC45MyA5LTQuOTIzIDAtOC45My00LjAyMy04LjkzLTl6IiBmaWxsPSIjZmZmIi8+PC9nPjwvc3ZnPg==)](https://www.python.org/downloads/) [![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/rye/main/artwork/badge.json)](https://rye-up.com) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/) -[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/TeamEpochGithub/epochalyst/main.svg)](https://results.pre-commit.ci/latest/github/TeamEpochGithub/epochalyst/main) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/TeamEpochGithub/epochlib/main.svg)](https://results.pre-commit.ci/latest/github/TeamEpochGithub/epochlib/main) -Epochalyst is the base for [Team Epoch](https://teamepoch.ai/) competitions. +EpochLib is the base for [Team Epoch](https://teamepoch.ai/) competitions. -This package contains many modules and classes necessary to construct the src code for machine learning competitions. +This library package contains many modules and classes necessary to construct the src code for machine learning competitions. ## Installation -Install `epochalyst` using [Rye](https://rye.astral.sh/): +Install `epochlib` using [Rye](https://rye.astral.sh/): ```shell -rye add epochalyst +rye add epochlib ``` Or via pip: ```shell -pip install epochalyst +pip install epochlib ``` ### Optional Dependencies Depending on what data libraries you use, you can install the following optional dependencies: ```shell -rye add epochalyst[numpy,pandas,dask,polars] # Pick one or more of these +rye add epochlib[numpy,pandas,dask,polars] # Pick one or more of these ``` Depending on what type of competition you are participating in, you can install the following optional dependencies: ```shell -rye add epochalyst[image,audio] # Pick one or more of these +rye add epochlib[image,audio] # Pick one or more of these ``` Aside from that, you can install the following optional dependencies: ```shell -rye add epochalyst[onnx,openvino] # Optimizing model inference +rye add epochlib[onnx,openvino] # Optimizing model inference ``` ## Pytest coverage report @@ -49,7 +49,7 @@ rye add epochalyst[onnx,openvino] # Optimizing model inference To generate pytest coverage report run ```shell -rye run pytest --cov=epochalyst --cov-branch --cov-report=html:coverage_re +rye run pytest --cov=epochlib --cov-branch --cov-report=html:coverage_re ``` ## pre-commit @@ -70,11 +70,11 @@ rye run pre-commit run --all-files ## Documentation -Documentation is generated using [Sphinx](https://www.sphinx-doc.org/en/master/) and can be found [here](https://teamepochgithub.github.io/epochalyst). +Documentation is generated using [Sphinx](https://www.sphinx-doc.org/en/master/) and can be found [here](https://teamepochgithub.github.io/epochlib). To make the documentation yourself, run `make html` with `docs` as the working directory. The documentation can then be found in `docs/_build/html/index.html`. ## Maintainers -Epochalyst is maintained by [Team Epoch](https://teamepoch.ai), based in the [Dream Hall](https://www.tudelft.nl/ddream) of the [Delft University of Technology](https://www.tudelft.nl/). +EpochLib is maintained by [Team Epoch](https://teamepoch.ai), based in the [Dream Hall](https://www.tudelft.nl/ddream) of the [Delft University of Technology](https://www.tudelft.nl/). diff --git a/assets/Epochalyst_Icon.svg b/assets/EpochLib_Icon.svg similarity index 99% rename from assets/Epochalyst_Icon.svg rename to assets/EpochLib_Icon.svg index 0971d2f..aaf4e69 100644 --- a/assets/Epochalyst_Icon.svg +++ b/assets/EpochLib_Icon.svg @@ -8,7 +8,7 @@ version="1.1" id="svg1" xml:space="preserve" - sodipodi:docname="Epochalyst_Icon.svg" + sodipodi:docname="EpochLib.svg" inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -54,4 +54,4 @@ clip-path="url(#clipPath4)" transform="matrix(1.3085863,0,0,1.3085863,-523.43452,-130.85863)" style="display:inline" - inkscape:label="Epochalyst Icon" /> + inkscape:label="EpochLib Icon" /> diff --git a/assets/Epochalyst_Logo_Auto.svg b/assets/EpochLib_Logo_Auto.svg similarity index 99% rename from assets/Epochalyst_Logo_Auto.svg rename to assets/EpochLib_Logo_Auto.svg index d482271..09b0f71 100644 --- a/assets/Epochalyst_Logo_Auto.svg +++ b/assets/EpochLib_Logo_Auto.svg @@ -40,4 +40,4 @@ style="-inkscape-font-specification:'Plus Jakarta Sans Semi-Bold';stroke-width:0.157377" d="M -6.2972931,202.17036 V 170.90473 H 14.308651 v 4.40656 H -1.3451516 v 8.981 H 13.469305 v 4.40657 H -1.3451516 v 9.06494 H 14.308651 v 4.40656 z m 24.7606991,8.39346 v -31.09777 h 4.532469 v 4.70034 L 22.4503,183.07524 q 1.259019,-1.93049 3.357384,-3.02164 2.098365,-1.09115 4.784272,-1.09115 3.231482,0 5.791488,1.55279 2.601972,1.55279 4.070828,4.23869 1.510822,2.68591 1.510822,6.0433 0,3.35738 -1.510822,6.04329 -1.468856,2.6859 -4.028861,4.28066 -2.560006,1.55279 -5.833455,1.55279 -2.64394,0 -4.826239,-1.09115 -2.140333,-1.09115 -3.315417,-3.14755 l 0.755411,-0.88131 v 13.00986 z m 11.66691,-12.29641 q 2.01443,0 3.56722,-0.96525 1.55279,-0.96525 2.434104,-2.64394 0.92328,-1.72066 0.92328,-3.86099 0,-2.14034 -0.92328,-3.81903 -0.881314,-1.67869 -2.434104,-2.64394 -1.55279,-0.96525 -3.56722,-0.96525 -1.972463,0 -3.567221,0.96525 -1.55279,0.96525 -2.476071,2.64394 -0.881313,1.67869 -0.881313,3.81903 0,2.14033 0.881313,3.86099 0.923281,1.67869 2.476071,2.64394 1.594758,0.96525 3.567221,0.96525 z m 27.404651,4.40656 q -3.273449,0 -6.001324,-1.55279 -2.685907,-1.55279 -4.280665,-4.2387 -1.594757,-2.6859 -1.594757,-6.08525 0,-3.44132 1.594757,-6.08526 1.594758,-2.68591 4.280665,-4.19673 2.685907,-1.55279 6.001324,-1.55279 3.357384,0 6.001324,1.55279 2.685907,1.51082 4.238697,4.19673 1.594758,2.64394 1.594758,6.08526 0,3.44131 -1.594758,6.12722 -1.594757,2.68591 -4.280664,4.2387 -2.685908,1.51082 -5.959357,1.51082 z m 0,-4.40656 q 2.01443,0 3.567221,-0.96525 1.55279,-0.96525 2.434103,-2.64394 0.923281,-1.72066 0.923281,-3.86099 0,-2.14034 -0.923281,-3.81903 -0.881313,-1.67869 -2.434103,-2.64394 -1.552791,-0.96525 -3.567221,-0.96525 -1.972463,0 -3.56722,0.96525 -1.552791,0.96525 -2.476071,2.64394 -0.881314,1.67869 -0.881314,3.81903 0,2.14033 0.881314,3.86099 0.92328,1.67869 2.476071,2.64394 1.594757,0.96525 3.56722,0.96525 z m 27.236775,4.40656 q -3.399351,0 -6.043291,-1.55279 -2.601973,-1.59476 -4.154763,-4.28066 -1.510823,-2.68591 -1.510823,-6.08526 0,-3.35739 1.510823,-6.04329 1.510823,-2.68591 4.154763,-4.19673 2.64394,-1.55279 6.043291,-1.55279 2.308201,0 4.322632,0.83934 2.01443,0.79738 3.483286,2.22427 1.510823,1.42689 2.224267,3.31542 l -4.154763,1.93049 q -0.713444,-1.76262 -2.308202,-2.81181 -1.55279,-1.09115 -3.56722,-1.09115 -1.930496,0 -3.483286,0.96525 -1.510823,0.92328 -2.392136,2.64394 -0.881314,1.67869 -0.881314,3.81903 0,2.14033 0.881314,3.86099 0.881313,1.67869 2.392136,2.64394 1.55279,0.96525 3.483286,0.96525 2.056398,0 3.56722,-1.04919 1.552791,-1.09115 2.308202,-2.89574 l 4.154763,1.97246 q -0.671477,1.8046 -2.1823,3.27345 -1.468855,1.42689 -3.483286,2.26624 -2.01443,0.83934 -4.364599,0.83934 z m 14.646624,-0.50361 v -31.76924 h 4.742304 v 13.51347 l -0.75541,-0.58754 q 0.83935,-2.14034 2.68591,-3.23149 1.84656,-1.13311 4.28066,-1.13311 2.51804,0 4.44854,1.09115 1.93049,1.09115 3.02164,3.02164 1.09115,1.9305 1.09115,4.40657 v 14.68855 h -4.70034 V 188.7828 q 0,-1.72066 -0.67147,-2.89575 -0.62951,-1.21705 -1.76263,-1.84656 -1.13312,-0.67148 -2.60197,-0.67148 -1.42689,0 -2.60198,0.67148 -1.13311,0.62951 -1.80459,1.84656 -0.62951,1.21705 -0.62951,2.89575 v 13.38756 z m 31.391564,0.50361 q -2.30821,0 -4.07083,-0.79738 -1.72066,-0.83934 -2.68591,-2.26623 -0.96525,-1.46886 -0.96525,-3.44132 0,-1.84656 0.79738,-3.31542 0.83935,-1.46885 2.56001,-2.47607 1.72066,-1.00721 4.32263,-1.42689 l 7.88985,-1.30098 v 3.73509 l -6.96657,1.21705 q -1.88853,0.33574 -2.76984,1.21705 -0.88132,0.83935 -0.88132,2.1823 0,1.30099 0.96525,2.14033 1.00722,0.79738 2.56001,0.79738 1.93049,0 3.35738,-0.83934 1.46886,-0.83935 2.26624,-2.22427 0.79737,-1.42689 0.79737,-3.14755 v -5.83345 q 0,-1.67869 -1.25901,-2.72788 -1.21706,-1.09115 -3.27345,-1.09115 -1.88853,0 -3.31542,1.00722 -1.38492,0.96525 -2.0564,2.51804 l -3.94492,-1.97247 q 0.6295,-1.67869 2.05639,-2.93771 1.42689,-1.30098 3.31542,-2.01443 1.9305,-0.71344 4.07083,-0.71344 2.68591,0 4.7423,1.00721 2.09837,1.00722 3.23149,2.81181 1.17508,1.76263 1.17508,4.1128 v 15.27609 h -4.53247 v -4.11279 l 0.96525,0.1259 q -0.79738,1.38492 -2.0564,2.39214 -1.21705,1.00721 -2.81181,1.55279 -1.55279,0.54557 -3.48328,0.54557 z m 17.45836,-0.50361 v -31.76924 h 4.7423 v 31.76924 z m 12.29646,9.27478 q -0.83935,0 -1.6787,-0.16787 -0.79737,-0.1259 -1.46885,-0.41967 v -4.07083 q 0.50361,0.1259 1.21705,0.20983 0.71345,0.12591 1.38492,0.12591 1.97247,0 2.89575,-0.88132 0.96524,-0.83934 1.72066,-2.64394 l 1.51082,-3.44132 -0.0839,3.9869 -9.82035,-24.67678 h 5.07805 l 7.26034,18.92726 h -1.72066 l 7.21838,-18.92726 h 5.12001 l -10.03019,25.18039 q -0.79738,2.01443 -2.01443,3.52525 -1.17508,1.55279 -2.81181,2.39213 -1.59475,0.88132 -3.77705,0.88132 z m 30.25842,-8.77117 q -3.48328,0 -6.12722,-1.72066 -2.60198,-1.72066 -3.65116,-4.6164 l 3.65116,-1.72066 q 0.92328,1.9305 2.51803,3.06361 1.63673,1.13312 3.60919,1.13312 1.67869,0 2.72788,-0.75541 1.04918,-0.75541 1.04918,-2.0564 0,-0.83934 -0.46164,-1.34295 -0.46164,-0.54558 -1.17509,-0.88132 -0.67147,-0.33573 -1.38492,-0.5036 l -3.56722,-1.00722 q -2.93771,-0.83934 -4.40656,-2.51804 -1.42689,-1.72066 -1.42689,-3.98689 0,-2.0564 1.04918,-3.56722 1.04918,-1.55279 2.89574,-2.39214 1.84656,-0.83934 4.15477,-0.83934 3.10558,0 5.53968,1.55279 2.4341,1.51082 3.44132,4.23869 l -3.65116,1.72066 q -0.67147,-1.63672 -2.14033,-2.60197 -1.42689,-0.96525 -3.23148,-0.96525 -1.55279,0 -2.47607,0.75541 -0.92328,0.71345 -0.92328,1.88853 0,0.79738 0.41967,1.34296 0.41967,0.5036 1.09115,0.83934 0.67148,0.29377 1.38492,0.50361 l 3.69312,1.09115 q 2.81181,0.79738 4.32264,2.51804 1.51082,1.67869 1.51082,4.02886 0,2.01443 -1.09115,3.56722 -1.04918,1.51082 -2.93771,2.39214 -1.88853,0.83934 -4.40657,0.83934 z m 22.91412,-0.2518 q -3.56722,0 -5.53969,-2.01443 -1.97246,-2.01443 -1.97246,-5.66559 v -10.99543 h -3.98689 v -4.28067 h 0.62951 q 1.59475,0 2.47607,-0.92328 0.88131,-0.92328 0.88131,-2.51803 v -1.76263 h 4.74231 v 5.20394 h 5.16197 v 4.28067 h -5.16197 v 10.7856 q 0,1.17508 0.3777,2.01443 0.37771,0.79737 1.21705,1.25902 0.83935,0.41967 2.1823,0.41967 0.33574,0 0.75541,-0.042 0.41968,-0.042 0.79738,-0.0839 v 4.07082 q -0.58754,0.0839 -1.30098,0.16787 -0.71345,0.0839 -1.25902,0.0839 z" id="text14" - aria-label="Epochalyst" /> + aria-label="EpochLib" /> diff --git a/assets/Epochalyst_Logo_Dark.svg b/assets/EpochLib_Logo_Dark.svg similarity index 99% rename from assets/Epochalyst_Logo_Dark.svg rename to assets/EpochLib_Logo_Dark.svg index 4e00cb6..fb538a2 100644 --- a/assets/Epochalyst_Logo_Dark.svg +++ b/assets/EpochLib_Logo_Dark.svg @@ -32,4 +32,4 @@ style="font-weight:600;font-size:41.9673px;line-height:0;font-family:'Plus Jakarta Sans';-inkscape-font-specification:'Plus Jakarta Sans Semi-Bold';stroke-width:0.157377" d="M -6.2972931,202.17036 V 170.90473 H 14.308651 v 4.40656 H -1.3451516 v 8.981 H 13.469305 v 4.40657 H -1.3451516 v 9.06494 H 14.308651 v 4.40656 z m 24.7606991,8.39346 v -31.09777 h 4.532469 v 4.70034 L 22.4503,183.07524 q 1.259019,-1.93049 3.357384,-3.02164 2.098365,-1.09115 4.784272,-1.09115 3.231482,0 5.791488,1.55279 2.601972,1.55279 4.070828,4.23869 1.510822,2.68591 1.510822,6.0433 0,3.35738 -1.510822,6.04329 -1.468856,2.6859 -4.028861,4.28066 -2.560006,1.55279 -5.833455,1.55279 -2.64394,0 -4.826239,-1.09115 -2.140333,-1.09115 -3.315417,-3.14755 l 0.755411,-0.88131 v 13.00986 z m 11.66691,-12.29641 q 2.01443,0 3.56722,-0.96525 1.55279,-0.96525 2.434104,-2.64394 0.92328,-1.72066 0.92328,-3.86099 0,-2.14034 -0.92328,-3.81903 -0.881314,-1.67869 -2.434104,-2.64394 -1.55279,-0.96525 -3.56722,-0.96525 -1.972463,0 -3.567221,0.96525 -1.55279,0.96525 -2.476071,2.64394 -0.881313,1.67869 -0.881313,3.81903 0,2.14033 0.881313,3.86099 0.923281,1.67869 2.476071,2.64394 1.594758,0.96525 3.567221,0.96525 z m 27.404651,4.40656 q -3.273449,0 -6.001324,-1.55279 -2.685907,-1.55279 -4.280665,-4.2387 -1.594757,-2.6859 -1.594757,-6.08525 0,-3.44132 1.594757,-6.08526 1.594758,-2.68591 4.280665,-4.19673 2.685907,-1.55279 6.001324,-1.55279 3.357384,0 6.001324,1.55279 2.685907,1.51082 4.238697,4.19673 1.594758,2.64394 1.594758,6.08526 0,3.44131 -1.594758,6.12722 -1.594757,2.68591 -4.280664,4.2387 -2.685908,1.51082 -5.959357,1.51082 z m 0,-4.40656 q 2.01443,0 3.567221,-0.96525 1.55279,-0.96525 2.434103,-2.64394 0.923281,-1.72066 0.923281,-3.86099 0,-2.14034 -0.923281,-3.81903 -0.881313,-1.67869 -2.434103,-2.64394 -1.552791,-0.96525 -3.567221,-0.96525 -1.972463,0 -3.56722,0.96525 -1.552791,0.96525 -2.476071,2.64394 -0.881314,1.67869 -0.881314,3.81903 0,2.14033 0.881314,3.86099 0.92328,1.67869 2.476071,2.64394 1.594757,0.96525 3.56722,0.96525 z m 27.236775,4.40656 q -3.399351,0 -6.043291,-1.55279 -2.601973,-1.59476 -4.154763,-4.28066 -1.510823,-2.68591 -1.510823,-6.08526 0,-3.35739 1.510823,-6.04329 1.510823,-2.68591 4.154763,-4.19673 2.64394,-1.55279 6.043291,-1.55279 2.308201,0 4.322632,0.83934 2.01443,0.79738 3.483286,2.22427 1.510823,1.42689 2.224267,3.31542 l -4.154763,1.93049 q -0.713444,-1.76262 -2.308202,-2.81181 -1.55279,-1.09115 -3.56722,-1.09115 -1.930496,0 -3.483286,0.96525 -1.510823,0.92328 -2.392136,2.64394 -0.881314,1.67869 -0.881314,3.81903 0,2.14033 0.881314,3.86099 0.881313,1.67869 2.392136,2.64394 1.55279,0.96525 3.483286,0.96525 2.056398,0 3.56722,-1.04919 1.552791,-1.09115 2.308202,-2.89574 l 4.154763,1.97246 q -0.671477,1.8046 -2.1823,3.27345 -1.468855,1.42689 -3.483286,2.26624 -2.01443,0.83934 -4.364599,0.83934 z m 14.646624,-0.50361 v -31.76924 h 4.742304 v 13.51347 l -0.75541,-0.58754 q 0.83935,-2.14034 2.68591,-3.23149 1.84656,-1.13311 4.28066,-1.13311 2.51804,0 4.44854,1.09115 1.93049,1.09115 3.02164,3.02164 1.09115,1.9305 1.09115,4.40657 v 14.68855 h -4.70034 V 188.7828 q 0,-1.72066 -0.67147,-2.89575 -0.62951,-1.21705 -1.76263,-1.84656 -1.13312,-0.67148 -2.60197,-0.67148 -1.42689,0 -2.60198,0.67148 -1.13311,0.62951 -1.80459,1.84656 -0.62951,1.21705 -0.62951,2.89575 v 13.38756 z m 31.391564,0.50361 q -2.30821,0 -4.07083,-0.79738 -1.72066,-0.83934 -2.68591,-2.26623 -0.96525,-1.46886 -0.96525,-3.44132 0,-1.84656 0.79738,-3.31542 0.83935,-1.46885 2.56001,-2.47607 1.72066,-1.00721 4.32263,-1.42689 l 7.88985,-1.30098 v 3.73509 l -6.96657,1.21705 q -1.88853,0.33574 -2.76984,1.21705 -0.88132,0.83935 -0.88132,2.1823 0,1.30099 0.96525,2.14033 1.00722,0.79738 2.56001,0.79738 1.93049,0 3.35738,-0.83934 1.46886,-0.83935 2.26624,-2.22427 0.79737,-1.42689 0.79737,-3.14755 v -5.83345 q 0,-1.67869 -1.25901,-2.72788 -1.21706,-1.09115 -3.27345,-1.09115 -1.88853,0 -3.31542,1.00722 -1.38492,0.96525 -2.0564,2.51804 l -3.94492,-1.97247 q 0.6295,-1.67869 2.05639,-2.93771 1.42689,-1.30098 3.31542,-2.01443 1.9305,-0.71344 4.07083,-0.71344 2.68591,0 4.7423,1.00721 2.09837,1.00722 3.23149,2.81181 1.17508,1.76263 1.17508,4.1128 v 15.27609 h -4.53247 v -4.11279 l 0.96525,0.1259 q -0.79738,1.38492 -2.0564,2.39214 -1.21705,1.00721 -2.81181,1.55279 -1.55279,0.54557 -3.48328,0.54557 z m 17.45836,-0.50361 v -31.76924 h 4.7423 v 31.76924 z m 12.29646,9.27478 q -0.83935,0 -1.6787,-0.16787 -0.79737,-0.1259 -1.46885,-0.41967 v -4.07083 q 0.50361,0.1259 1.21705,0.20983 0.71345,0.12591 1.38492,0.12591 1.97247,0 2.89575,-0.88132 0.96524,-0.83934 1.72066,-2.64394 l 1.51082,-3.44132 -0.0839,3.9869 -9.82035,-24.67678 h 5.07805 l 7.26034,18.92726 h -1.72066 l 7.21838,-18.92726 h 5.12001 l -10.03019,25.18039 q -0.79738,2.01443 -2.01443,3.52525 -1.17508,1.55279 -2.81181,2.39213 -1.59475,0.88132 -3.77705,0.88132 z m 30.25842,-8.77117 q -3.48328,0 -6.12722,-1.72066 -2.60198,-1.72066 -3.65116,-4.6164 l 3.65116,-1.72066 q 0.92328,1.9305 2.51803,3.06361 1.63673,1.13312 3.60919,1.13312 1.67869,0 2.72788,-0.75541 1.04918,-0.75541 1.04918,-2.0564 0,-0.83934 -0.46164,-1.34295 -0.46164,-0.54558 -1.17509,-0.88132 -0.67147,-0.33573 -1.38492,-0.5036 l -3.56722,-1.00722 q -2.93771,-0.83934 -4.40656,-2.51804 -1.42689,-1.72066 -1.42689,-3.98689 0,-2.0564 1.04918,-3.56722 1.04918,-1.55279 2.89574,-2.39214 1.84656,-0.83934 4.15477,-0.83934 3.10558,0 5.53968,1.55279 2.4341,1.51082 3.44132,4.23869 l -3.65116,1.72066 q -0.67147,-1.63672 -2.14033,-2.60197 -1.42689,-0.96525 -3.23148,-0.96525 -1.55279,0 -2.47607,0.75541 -0.92328,0.71345 -0.92328,1.88853 0,0.79738 0.41967,1.34296 0.41967,0.5036 1.09115,0.83934 0.67148,0.29377 1.38492,0.50361 l 3.69312,1.09115 q 2.81181,0.79738 4.32264,2.51804 1.51082,1.67869 1.51082,4.02886 0,2.01443 -1.09115,3.56722 -1.04918,1.51082 -2.93771,2.39214 -1.88853,0.83934 -4.40657,0.83934 z m 22.91412,-0.2518 q -3.56722,0 -5.53969,-2.01443 -1.97246,-2.01443 -1.97246,-5.66559 v -10.99543 h -3.98689 v -4.28067 h 0.62951 q 1.59475,0 2.47607,-0.92328 0.88131,-0.92328 0.88131,-2.51803 v -1.76263 h 4.74231 v 5.20394 h 5.16197 v 4.28067 h -5.16197 v 10.7856 q 0,1.17508 0.3777,2.01443 0.37771,0.79737 1.21705,1.25902 0.83935,0.41967 2.1823,0.41967 0.33574,0 0.75541,-0.042 0.41968,-0.042 0.79738,-0.0839 v 4.07082 q -0.58754,0.0839 -1.30098,0.16787 -0.71345,0.0839 -1.25902,0.0839 z" id="text14" - aria-label="Epochalyst" /> + aria-label="EpochLib" /> diff --git a/assets/Epochalyst_Logo_Light.svg b/assets/EpochLib_Logo_Light.svg similarity index 99% rename from assets/Epochalyst_Logo_Light.svg rename to assets/EpochLib_Logo_Light.svg index 4defe20..e959efe 100644 --- a/assets/Epochalyst_Logo_Light.svg +++ b/assets/EpochLib_Logo_Light.svg @@ -33,4 +33,4 @@ style="font-weight:600;font-size:41.9673px;line-height:0;font-family:'Plus Jakarta Sans';-inkscape-font-specification:'Plus Jakarta Sans Semi-Bold';stroke-width:0.157377" d="M -6.2972931,202.17036 V 170.90473 H 14.308651 v 4.40656 H -1.3451516 v 8.981 H 13.469305 v 4.40657 H -1.3451516 v 9.06494 H 14.308651 v 4.40656 z m 24.7606991,8.39346 v -31.09777 h 4.532469 v 4.70034 L 22.4503,183.07524 q 1.259019,-1.93049 3.357384,-3.02164 2.098365,-1.09115 4.784272,-1.09115 3.231482,0 5.791488,1.55279 2.601972,1.55279 4.070828,4.23869 1.510822,2.68591 1.510822,6.0433 0,3.35738 -1.510822,6.04329 -1.468856,2.6859 -4.028861,4.28066 -2.560006,1.55279 -5.833455,1.55279 -2.64394,0 -4.826239,-1.09115 -2.140333,-1.09115 -3.315417,-3.14755 l 0.755411,-0.88131 v 13.00986 z m 11.66691,-12.29641 q 2.01443,0 3.56722,-0.96525 1.55279,-0.96525 2.434104,-2.64394 0.92328,-1.72066 0.92328,-3.86099 0,-2.14034 -0.92328,-3.81903 -0.881314,-1.67869 -2.434104,-2.64394 -1.55279,-0.96525 -3.56722,-0.96525 -1.972463,0 -3.567221,0.96525 -1.55279,0.96525 -2.476071,2.64394 -0.881313,1.67869 -0.881313,3.81903 0,2.14033 0.881313,3.86099 0.923281,1.67869 2.476071,2.64394 1.594758,0.96525 3.567221,0.96525 z m 27.404651,4.40656 q -3.273449,0 -6.001324,-1.55279 -2.685907,-1.55279 -4.280665,-4.2387 -1.594757,-2.6859 -1.594757,-6.08525 0,-3.44132 1.594757,-6.08526 1.594758,-2.68591 4.280665,-4.19673 2.685907,-1.55279 6.001324,-1.55279 3.357384,0 6.001324,1.55279 2.685907,1.51082 4.238697,4.19673 1.594758,2.64394 1.594758,6.08526 0,3.44131 -1.594758,6.12722 -1.594757,2.68591 -4.280664,4.2387 -2.685908,1.51082 -5.959357,1.51082 z m 0,-4.40656 q 2.01443,0 3.567221,-0.96525 1.55279,-0.96525 2.434103,-2.64394 0.923281,-1.72066 0.923281,-3.86099 0,-2.14034 -0.923281,-3.81903 -0.881313,-1.67869 -2.434103,-2.64394 -1.552791,-0.96525 -3.567221,-0.96525 -1.972463,0 -3.56722,0.96525 -1.552791,0.96525 -2.476071,2.64394 -0.881314,1.67869 -0.881314,3.81903 0,2.14033 0.881314,3.86099 0.92328,1.67869 2.476071,2.64394 1.594757,0.96525 3.56722,0.96525 z m 27.236775,4.40656 q -3.399351,0 -6.043291,-1.55279 -2.601973,-1.59476 -4.154763,-4.28066 -1.510823,-2.68591 -1.510823,-6.08526 0,-3.35739 1.510823,-6.04329 1.510823,-2.68591 4.154763,-4.19673 2.64394,-1.55279 6.043291,-1.55279 2.308201,0 4.322632,0.83934 2.01443,0.79738 3.483286,2.22427 1.510823,1.42689 2.224267,3.31542 l -4.154763,1.93049 q -0.713444,-1.76262 -2.308202,-2.81181 -1.55279,-1.09115 -3.56722,-1.09115 -1.930496,0 -3.483286,0.96525 -1.510823,0.92328 -2.392136,2.64394 -0.881314,1.67869 -0.881314,3.81903 0,2.14033 0.881314,3.86099 0.881313,1.67869 2.392136,2.64394 1.55279,0.96525 3.483286,0.96525 2.056398,0 3.56722,-1.04919 1.552791,-1.09115 2.308202,-2.89574 l 4.154763,1.97246 q -0.671477,1.8046 -2.1823,3.27345 -1.468855,1.42689 -3.483286,2.26624 -2.01443,0.83934 -4.364599,0.83934 z m 14.646624,-0.50361 v -31.76924 h 4.742304 v 13.51347 l -0.75541,-0.58754 q 0.83935,-2.14034 2.68591,-3.23149 1.84656,-1.13311 4.28066,-1.13311 2.51804,0 4.44854,1.09115 1.93049,1.09115 3.02164,3.02164 1.09115,1.9305 1.09115,4.40657 v 14.68855 h -4.70034 V 188.7828 q 0,-1.72066 -0.67147,-2.89575 -0.62951,-1.21705 -1.76263,-1.84656 -1.13312,-0.67148 -2.60197,-0.67148 -1.42689,0 -2.60198,0.67148 -1.13311,0.62951 -1.80459,1.84656 -0.62951,1.21705 -0.62951,2.89575 v 13.38756 z m 31.391564,0.50361 q -2.30821,0 -4.07083,-0.79738 -1.72066,-0.83934 -2.68591,-2.26623 -0.96525,-1.46886 -0.96525,-3.44132 0,-1.84656 0.79738,-3.31542 0.83935,-1.46885 2.56001,-2.47607 1.72066,-1.00721 4.32263,-1.42689 l 7.88985,-1.30098 v 3.73509 l -6.96657,1.21705 q -1.88853,0.33574 -2.76984,1.21705 -0.88132,0.83935 -0.88132,2.1823 0,1.30099 0.96525,2.14033 1.00722,0.79738 2.56001,0.79738 1.93049,0 3.35738,-0.83934 1.46886,-0.83935 2.26624,-2.22427 0.79737,-1.42689 0.79737,-3.14755 v -5.83345 q 0,-1.67869 -1.25901,-2.72788 -1.21706,-1.09115 -3.27345,-1.09115 -1.88853,0 -3.31542,1.00722 -1.38492,0.96525 -2.0564,2.51804 l -3.94492,-1.97247 q 0.6295,-1.67869 2.05639,-2.93771 1.42689,-1.30098 3.31542,-2.01443 1.9305,-0.71344 4.07083,-0.71344 2.68591,0 4.7423,1.00721 2.09837,1.00722 3.23149,2.81181 1.17508,1.76263 1.17508,4.1128 v 15.27609 h -4.53247 v -4.11279 l 0.96525,0.1259 q -0.79738,1.38492 -2.0564,2.39214 -1.21705,1.00721 -2.81181,1.55279 -1.55279,0.54557 -3.48328,0.54557 z m 17.45836,-0.50361 v -31.76924 h 4.7423 v 31.76924 z m 12.29646,9.27478 q -0.83935,0 -1.6787,-0.16787 -0.79737,-0.1259 -1.46885,-0.41967 v -4.07083 q 0.50361,0.1259 1.21705,0.20983 0.71345,0.12591 1.38492,0.12591 1.97247,0 2.89575,-0.88132 0.96524,-0.83934 1.72066,-2.64394 l 1.51082,-3.44132 -0.0839,3.9869 -9.82035,-24.67678 h 5.07805 l 7.26034,18.92726 h -1.72066 l 7.21838,-18.92726 h 5.12001 l -10.03019,25.18039 q -0.79738,2.01443 -2.01443,3.52525 -1.17508,1.55279 -2.81181,2.39213 -1.59475,0.88132 -3.77705,0.88132 z m 30.25842,-8.77117 q -3.48328,0 -6.12722,-1.72066 -2.60198,-1.72066 -3.65116,-4.6164 l 3.65116,-1.72066 q 0.92328,1.9305 2.51803,3.06361 1.63673,1.13312 3.60919,1.13312 1.67869,0 2.72788,-0.75541 1.04918,-0.75541 1.04918,-2.0564 0,-0.83934 -0.46164,-1.34295 -0.46164,-0.54558 -1.17509,-0.88132 -0.67147,-0.33573 -1.38492,-0.5036 l -3.56722,-1.00722 q -2.93771,-0.83934 -4.40656,-2.51804 -1.42689,-1.72066 -1.42689,-3.98689 0,-2.0564 1.04918,-3.56722 1.04918,-1.55279 2.89574,-2.39214 1.84656,-0.83934 4.15477,-0.83934 3.10558,0 5.53968,1.55279 2.4341,1.51082 3.44132,4.23869 l -3.65116,1.72066 q -0.67147,-1.63672 -2.14033,-2.60197 -1.42689,-0.96525 -3.23148,-0.96525 -1.55279,0 -2.47607,0.75541 -0.92328,0.71345 -0.92328,1.88853 0,0.79738 0.41967,1.34296 0.41967,0.5036 1.09115,0.83934 0.67148,0.29377 1.38492,0.50361 l 3.69312,1.09115 q 2.81181,0.79738 4.32264,2.51804 1.51082,1.67869 1.51082,4.02886 0,2.01443 -1.09115,3.56722 -1.04918,1.51082 -2.93771,2.39214 -1.88853,0.83934 -4.40657,0.83934 z m 22.91412,-0.2518 q -3.56722,0 -5.53969,-2.01443 -1.97246,-2.01443 -1.97246,-5.66559 v -10.99543 h -3.98689 v -4.28067 h 0.62951 q 1.59475,0 2.47607,-0.92328 0.88131,-0.92328 0.88131,-2.51803 v -1.76263 h 4.74231 v 5.20394 h 5.16197 v 4.28067 h -5.16197 v 10.7856 q 0,1.17508 0.3777,2.01443 0.37771,0.79737 1.21705,1.25902 0.83935,0.41967 2.1823,0.41967 0.33574,0 0.75541,-0.042 0.41968,-0.042 0.79738,-0.0839 v 4.07082 q -0.58754,0.0839 -1.30098,0.16787 -0.71345,0.0839 -1.25902,0.0839 z" id="text14" - aria-label="Epochalyst" /> + aria-label="EpochLib" /> diff --git a/docs/_static/logo.css b/docs/_static/logo.css index a267b32..c8e0f3b 100644 --- a/docs/_static/logo.css +++ b/docs/_static/logo.css @@ -1,11 +1,11 @@ -.epochalyst-logo { - content: url('https://raw.githubusercontent.com/TeamEpochGithub/epochalyst/main/assets/Epochalyst_Logo_Dark.svg'); +.epochlib-logo { + content: url('https://raw.githubusercontent.com/TeamEpochGithub/epochlib/main/assets/EpochLib.svg'); max-width: 100%; height: auto; background-size: contain; background-repeat: no-repeat; } -html.dark .epochalyst-logo { - content: url('https://raw.githubusercontent.com/TeamEpochGithub/epochalyst/main/assets/Epochalyst_Logo_Light.svg'); +html.dark .epochlib-logo { + content: url('https://raw.githubusercontent.com/TeamEpochGithub/epochlib/main/assets/EpochLib.svg'); } diff --git a/docs/conf.py b/docs/conf.py index 05594f5..25af310 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,11 +9,11 @@ from pathlib import Path from typing import Any, Final -REPO_URL: Final[str] = "https://github.com/TeamEpochGithub/epochalyst" +REPO_URL: Final[str] = "https://github.com/TeamEpochGithub/epochlib" sys.path.insert(0, Path("../..").resolve().as_posix()) -project: Final[str] = "Epochalyst" +project: Final[str] = "EpochLib" copyright: Final[str] = "2024, Team Epoch." # noqa: A001 author: Final[str] = "Team Epoch" diff --git a/docs/index.rst b/docs/index.rst index 36484c2..07c8421 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,6 +1,6 @@ .. raw:: html - + ------------------- @@ -22,7 +22,7 @@ API :toctree: _autosummary :recursive: - epochalyst.epochalyst + epochlib.epochlib Indices and tables ================== diff --git a/epochalyst/__init__.py b/epochlib/__init__.py similarity index 81% rename from epochalyst/__init__.py rename to epochlib/__init__.py index 64eaef1..6119a4a 100644 --- a/epochalyst/__init__.py +++ b/epochlib/__init__.py @@ -1,4 +1,4 @@ -"""The epochalyst package.""" +"""The epochlib package.""" from .ensemble import EnsemblePipeline from .model import ModelPipeline diff --git a/epochalyst/caching/__init__.py b/epochlib/caching/__init__.py similarity index 66% rename from epochalyst/caching/__init__.py rename to epochlib/caching/__init__.py index c4f989f..a22b347 100644 --- a/epochalyst/caching/__init__.py +++ b/epochlib/caching/__init__.py @@ -1,4 +1,4 @@ -"""Caching module for epochalyst.""" +"""Caching module for epochlib.""" from .cacher import CacheArgs, Cacher diff --git a/epochalyst/caching/cacher.py b/epochlib/caching/cacher.py similarity index 99% rename from epochalyst/caching/cacher.py rename to epochlib/caching/cacher.py index c6d5b2d..1f2f950 100644 --- a/epochalyst/caching/cacher.py +++ b/epochlib/caching/cacher.py @@ -9,7 +9,7 @@ import numpy as np -from epochalyst.logging import Logger +from epochlib.logging import Logger try: import dask.array as da diff --git a/epochalyst/data/__init__.py b/epochlib/data/__init__.py similarity index 100% rename from epochalyst/data/__init__.py rename to epochlib/data/__init__.py diff --git a/epochalyst/data/enum_data_format.py b/epochlib/data/enum_data_format.py similarity index 100% rename from epochalyst/data/enum_data_format.py rename to epochlib/data/enum_data_format.py diff --git a/epochalyst/data/pipeline_dataset.py b/epochlib/data/pipeline_dataset.py similarity index 96% rename from epochalyst/data/pipeline_dataset.py rename to epochlib/data/pipeline_dataset.py index 3643c8c..af171a5 100644 --- a/epochalyst/data/pipeline_dataset.py +++ b/epochlib/data/pipeline_dataset.py @@ -7,9 +7,9 @@ import numpy as np import numpy.typing as npt -from epochalyst.data.enum_data_format import Data, DataRetrieval -from epochalyst.training.training import TrainingPipeline -from epochalyst.training.training_block import TrainingBlock +from epochlib.data.enum_data_format import Data, DataRetrieval +from epochlib.training.training import TrainingPipeline +from epochlib.training.training_block import TrainingBlock try: from torch.utils.data import Dataset diff --git a/epochalyst/ensemble.py b/epochlib/ensemble.py similarity index 97% rename from epochalyst/ensemble.py rename to epochlib/ensemble.py index 400986c..11fe35a 100644 --- a/epochalyst/ensemble.py +++ b/epochlib/ensemble.py @@ -4,7 +4,7 @@ from agogos.training import ParallelTrainingSystem -from epochalyst.caching import CacheArgs +from epochlib.caching import CacheArgs class EnsemblePipeline(ParallelTrainingSystem): diff --git a/epochalyst/logging/__init__.py b/epochlib/logging/__init__.py similarity index 100% rename from epochalyst/logging/__init__.py rename to epochlib/logging/__init__.py diff --git a/epochalyst/logging/logger.py b/epochlib/logging/logger.py similarity index 100% rename from epochalyst/logging/logger.py rename to epochlib/logging/logger.py diff --git a/epochalyst/model.py b/epochlib/model.py similarity index 98% rename from epochalyst/model.py rename to epochlib/model.py index f91b6c7..08f7929 100644 --- a/epochalyst/model.py +++ b/epochlib/model.py @@ -4,7 +4,7 @@ from agogos.training import Pipeline -from epochalyst.caching import CacheArgs +from epochlib.caching import CacheArgs class ModelPipeline(Pipeline): diff --git a/epochalyst/training/__init__.py b/epochlib/training/__init__.py similarity index 80% rename from epochalyst/training/__init__.py rename to epochlib/training/__init__.py index 46e26fa..a51b642 100644 --- a/epochalyst/training/__init__.py +++ b/epochlib/training/__init__.py @@ -1,4 +1,4 @@ -"""Module containing training functionality for the epochalyst package.""" +"""Module containing training functionality for the epochlib package.""" from .pretrain_block import PretrainBlock from .torch_trainer import TorchTrainer, TrainValidationDataset diff --git a/epochalyst/training/_custom_data_parallel.py b/epochlib/training/_custom_data_parallel.py similarity index 100% rename from epochalyst/training/_custom_data_parallel.py rename to epochlib/training/_custom_data_parallel.py diff --git a/epochalyst/training/augmentation/__init__.py b/epochlib/training/augmentation/__init__.py similarity index 74% rename from epochalyst/training/augmentation/__init__.py rename to epochlib/training/augmentation/__init__.py index 700a6a0..92d6e51 100644 --- a/epochalyst/training/augmentation/__init__.py +++ b/epochlib/training/augmentation/__init__.py @@ -1,7 +1,7 @@ """Module containing implementation for augmentations.""" -from epochalyst.training.augmentation.image_augmentations import CutMix, MixUp -from epochalyst.training.augmentation.time_series_augmentations import ( +from epochlib.training.augmentation.image_augmentations import CutMix, MixUp +from epochlib.training.augmentation.time_series_augmentations import ( AddBackgroundNoiseWrapper, CutMix1D, EnergyCutmix, diff --git a/epochalyst/training/augmentation/image_augmentations.py b/epochlib/training/augmentation/image_augmentations.py similarity index 100% rename from epochalyst/training/augmentation/image_augmentations.py rename to epochlib/training/augmentation/image_augmentations.py diff --git a/epochalyst/training/augmentation/time_series_augmentations.py b/epochlib/training/augmentation/time_series_augmentations.py similarity index 100% rename from epochalyst/training/augmentation/time_series_augmentations.py rename to epochlib/training/augmentation/time_series_augmentations.py diff --git a/epochalyst/training/augmentation/utils.py b/epochlib/training/augmentation/utils.py similarity index 98% rename from epochalyst/training/augmentation/utils.py rename to epochlib/training/augmentation/utils.py index 2dcd370..908e6ec 100644 --- a/epochalyst/training/augmentation/utils.py +++ b/epochlib/training/augmentation/utils.py @@ -12,7 +12,7 @@ import torch -from epochalyst.training.utils.recursive_repr import recursive_repr +from epochlib.training.utils.recursive_repr import recursive_repr def get_audiomentations() -> ModuleType: diff --git a/epochalyst/training/models/__init__.py b/epochlib/training/models/__init__.py similarity index 100% rename from epochalyst/training/models/__init__.py rename to epochlib/training/models/__init__.py diff --git a/epochalyst/training/models/conv1d_bn_relu.py b/epochlib/training/models/conv1d_bn_relu.py similarity index 100% rename from epochalyst/training/models/conv1d_bn_relu.py rename to epochlib/training/models/conv1d_bn_relu.py diff --git a/epochalyst/training/models/timm.py b/epochlib/training/models/timm.py similarity index 100% rename from epochalyst/training/models/timm.py rename to epochlib/training/models/timm.py diff --git a/epochalyst/training/pretrain_block.py b/epochlib/training/pretrain_block.py similarity index 97% rename from epochalyst/training/pretrain_block.py rename to epochlib/training/pretrain_block.py index 7aaef74..487bc1b 100644 --- a/epochalyst/training/pretrain_block.py +++ b/epochlib/training/pretrain_block.py @@ -34,7 +34,7 @@ def train_split_hash(self, train_indices: list[int]) -> str: # Split the hash on Usage: .. code-block:: python - from epochalyst.pipeline.model.training.pretrain_block import PretrainBlock + from epochlib.pipeline.model.training.pretrain_block import PretrainBlock class CustomPretrainBlock(PretrainBlock): diff --git a/epochalyst/training/torch_trainer.py b/epochlib/training/torch_trainer.py similarity index 99% rename from epochalyst/training/torch_trainer.py rename to epochlib/training/torch_trainer.py index e1b337b..ead30bf 100644 --- a/epochalyst/training/torch_trainer.py +++ b/epochlib/training/torch_trainer.py @@ -20,7 +20,7 @@ from torch.utils.data import DataLoader, Dataset, TensorDataset from tqdm import tqdm -from epochalyst.data import Data +from epochlib.data import Data from ._custom_data_parallel import _CustomDataParallel from .training_block import TrainingBlock @@ -134,7 +134,7 @@ def update_model_directory(model_directory: str) -> None: Usage: .. code-block:: python - from epochalyst.pipeline.model.training.torch_trainer import TorchTrainer + from epochlib.pipeline.model.training.torch_trainer import TorchTrainer from torch import nn from torch.optim import Adam from torch.optim.lr_scheduler import StepLR diff --git a/epochalyst/training/training.py b/epochlib/training/training.py similarity index 99% rename from epochalyst/training/training.py rename to epochlib/training/training.py index 7b0153c..5ce4569 100644 --- a/epochalyst/training/training.py +++ b/epochlib/training/training.py @@ -5,7 +5,7 @@ from agogos.training import TrainingSystem, TrainType -from epochalyst.caching import CacheArgs, Cacher +from epochlib.caching import CacheArgs, Cacher @dataclass diff --git a/epochalyst/training/training_block.py b/epochlib/training/training_block.py similarity index 97% rename from epochalyst/training/training_block.py rename to epochlib/training/training_block.py index d64cf8f..7ce5b0b 100644 --- a/epochalyst/training/training_block.py +++ b/epochlib/training/training_block.py @@ -5,7 +5,7 @@ from agogos.training import Trainer -from epochalyst.caching import CacheArgs, Cacher +from epochlib.caching import CacheArgs, Cacher class TrainingBlock(Trainer, Cacher): @@ -41,7 +41,7 @@ def predict(self, x: Any, cache_args: dict[str, Any] = {}, **pred_args: Any) -> Usage: .. code-block:: python - from epochalyst.pipeline.model.training.training_block import TrainingBlock + from epochlib.pipeline.model.training.training_block import TrainingBlock class CustomTrainingBlock(TrainingBlock): def custom_train(self, x: Any, y: Any) -> tuple[Any, Any]: diff --git a/epochalyst/training/utils/__init__.py b/epochlib/training/utils/__init__.py similarity index 100% rename from epochalyst/training/utils/__init__.py rename to epochlib/training/utils/__init__.py diff --git a/epochalyst/training/utils/get_dependencies.py b/epochlib/training/utils/get_dependencies.py similarity index 100% rename from epochalyst/training/utils/get_dependencies.py rename to epochlib/training/utils/get_dependencies.py diff --git a/epochalyst/training/utils/recursive_repr.py b/epochlib/training/utils/recursive_repr.py similarity index 100% rename from epochalyst/training/utils/recursive_repr.py rename to epochlib/training/utils/recursive_repr.py diff --git a/epochalyst/training/utils/tensor_functions.py b/epochlib/training/utils/tensor_functions.py similarity index 100% rename from epochalyst/training/utils/tensor_functions.py rename to epochlib/training/utils/tensor_functions.py diff --git a/epochalyst/transformation/__init__.py b/epochlib/transformation/__init__.py similarity index 100% rename from epochalyst/transformation/__init__.py rename to epochlib/transformation/__init__.py diff --git a/epochalyst/transformation/transformation.py b/epochlib/transformation/transformation.py similarity index 96% rename from epochalyst/transformation/transformation.py rename to epochlib/transformation/transformation.py index cbd342c..34437e3 100644 --- a/epochalyst/transformation/transformation.py +++ b/epochlib/transformation/transformation.py @@ -5,7 +5,7 @@ from agogos.transforming import TransformingSystem, TransformType -from epochalyst.caching.cacher import CacheArgs, Cacher +from epochlib.caching.cacher import CacheArgs, Cacher @dataclass @@ -43,7 +43,7 @@ def get_hash(self) -> str: # Get the hash of the pipeline. Usage: .. code-block:: python - from epochalyst.pipeline.model.transformation import TransformationPipeline + from epochlib.pipeline.model.transformation import TransformationPipeline class MyTransformationPipeline(TransformationPipeline): def log_to_terminal(self, message: str) -> None: diff --git a/epochalyst/transformation/transformation_block.py b/epochlib/transformation/transformation_block.py similarity index 95% rename from epochalyst/transformation/transformation_block.py rename to epochlib/transformation/transformation_block.py index a163c7b..db817f2 100644 --- a/epochalyst/transformation/transformation_block.py +++ b/epochlib/transformation/transformation_block.py @@ -5,7 +5,7 @@ from agogos.transforming import Transformer -from epochalyst.caching.cacher import CacheArgs, Cacher +from epochlib.caching.cacher import CacheArgs, Cacher class TransformationBlock(Transformer, Cacher): @@ -36,7 +36,7 @@ def transform(self, data: Any, cache_args: dict[str, Any] = {}, **transform_args Usage: .. code-block:: python - from epochalyst.pipeline.model.transformation.transformation_block import TransformationBlock + from epochlib.pipeline.model.transformation.transformation_block import TransformationBlock class CustomTransformationBlock(TransformationBlock): def custom_transform(self, data: Any) -> Any: diff --git a/pyproject.toml b/pyproject.toml index 6d85844..d32526e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "epochalyst" +name = "epochlib" version = "4.1.0" authors = [ { name = "Jasper van Selm", email = "jmvanselm@gmail.com" }, @@ -12,7 +12,7 @@ authors = [ { name = "Kristóf Sandor", email = "emherk512@gmail.com"}, { name = "Daniel De Dios Allegue", email = "danieldediosallegue@gmail.com"} ] -description = "Epochalyst is the base for Team Epoch competitions." +description = "Epoch Libraries is the base for Team Epoch competitions." readme = "README.md" license = {file = "LICENSE"} requires-python = ">=3.10" @@ -65,11 +65,11 @@ audio = [ [project.urls] Homepage = "https://teamepoch.ai/" -Documentation = "https://TeamEpochGithub.github.io/epochalyst/" -Repository = "https://github.com/TeamEpochGithub/epochalyst" -Download = "https://pypi.org/project/epochalyst/#files" -Issues = "https://github.com/TeamEpochGithub/epochalyst/issues" -"Release notes" = "https://github.com/TeamEpochGithub/epochalyst/releases" +Documentation = "https://TeamEpochGithub.github.io/epochlib/" +Repository = "https://github.com/TeamEpochGithub/epochlib" +Download = "https://pypi.org/project/epochlib/#files" +Issues = "https://github.com/TeamEpochGithub/epochlib/issues" +"Release notes" = "https://github.com/TeamEpochGithub/epochlib/releases" [tool.rye] managed = true @@ -93,7 +93,7 @@ build-backend = "hatchling.build" allow-direct-references = true [tool.hatch.build.targets.wheel] -packages = ["epochalyst"] +packages = ["epochlib"] [tool.pydoclint] style = "sphinx" diff --git a/requirements-dev.lock b/requirements-dev.lock index ee768ea..e428ece 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -13,13 +13,13 @@ -e file:. agogos==0.4 - # via epochalyst + # via epochlib alabaster==0.7.16 # via sphinx annotated-types==0.7.0 - # via epochalyst + # via epochlib audiomentations==0.36.0 - # via epochalyst + # via epochlib audioread==3.0.1 # via librosa babel==2.15.0 @@ -47,10 +47,10 @@ coverage==7.5.4 # via pytest-cov dask==2024.6.2 # via dask-expr - # via epochalyst + # via epochlib dask-expr==1.1.6 # via dask - # via epochalyst + # via epochlib decorator==5.1.1 # via librosa distlib==0.3.8 @@ -91,11 +91,11 @@ jinja2==3.1.4 # via torch joblib==1.4.2 # via agogos - # via epochalyst + # via epochlib # via librosa # via scikit-learn kornia==0.7.2 - # via epochalyst + # via epochlib kornia-rs==0.1.3 # via kornia lazy-loader==0.4 @@ -133,7 +133,7 @@ numpy==1.26.4 # via audiomentations # via bottleneck # via dask - # via epochalyst + # via epochlib # via librosa # via numba # via numexpr @@ -175,11 +175,11 @@ nvidia-nvjitlink-cu12==12.5.40 nvidia-nvtx-cu12==12.1.105 # via torch onnx==1.16.1 - # via epochalyst + # via epochlib onnxruntime==1.18.0 - # via epochalyst + # via epochlib openvino==2024.2.0 - # via epochalyst + # via epochlib openvino-telemetry==2024.1.0 # via openvino packaging==24.1 @@ -195,7 +195,7 @@ packaging==24.1 pandas==2.2.2 # via dask # via dask-expr - # via epochalyst + # via epochlib partd==1.4.2 # via dask pillow==10.3.0 @@ -206,7 +206,7 @@ platformdirs==4.2.2 pluggy==1.5.0 # via pytest polars==0.20.31 - # via epochalyst + # via epochlib pooch==1.8.2 # via librosa pre-commit==3.7.1 @@ -281,7 +281,7 @@ sympy==1.12.1 threadpoolctl==3.5.0 # via scikit-learn timm==1.0.7 - # via epochalyst + # via epochlib tomli==2.0.1 # via coverage # via pytest @@ -290,7 +290,7 @@ toolz==0.12.1 # via dask # via partd torch==2.3.1 - # via epochalyst + # via epochlib # via kornia # via timm # via torchvision @@ -301,7 +301,7 @@ tqdm==4.66.4 triton==2.3.1 # via torch typing-extensions==4.12.2 - # via epochalyst + # via epochlib # via huggingface-hub # via librosa # via torch diff --git a/requirements.lock b/requirements.lock index 6aedb18..c7fbfd3 100644 --- a/requirements.lock +++ b/requirements.lock @@ -13,11 +13,11 @@ -e file:. agogos==0.4 - # via epochalyst + # via epochlib annotated-types==0.7.0 - # via epochalyst + # via epochlib audiomentations==0.36.0 - # via epochalyst + # via epochlib audioread==3.0.1 # via librosa bottleneck==1.4.0 @@ -36,10 +36,10 @@ coloredlogs==15.0.1 # via onnxruntime dask==2024.6.2 # via dask-expr - # via epochalyst + # via epochlib dask-expr==1.1.6 # via dask - # via epochalyst + # via epochlib decorator==5.1.1 # via librosa filelock==3.15.4 @@ -64,11 +64,11 @@ jinja2==3.1.4 # via torch joblib==1.4.2 # via agogos - # via epochalyst + # via epochlib # via librosa # via scikit-learn kornia==0.7.2 - # via epochalyst + # via epochlib kornia-rs==0.1.3 # via kornia lazy-loader==0.4 @@ -96,7 +96,7 @@ numpy==1.26.4 # via audiomentations # via bottleneck # via dask - # via epochalyst + # via epochlib # via librosa # via numba # via numexpr @@ -138,11 +138,11 @@ nvidia-nvjitlink-cu12==12.5.40 nvidia-nvtx-cu12==12.1.105 # via torch onnx==1.16.1 - # via epochalyst + # via epochlib onnxruntime==1.18.0 - # via epochalyst + # via epochlib openvino==2024.2.0 - # via epochalyst + # via epochlib openvino-telemetry==2024.1.0 # via openvino packaging==24.1 @@ -156,7 +156,7 @@ packaging==24.1 pandas==2.2.2 # via dask # via dask-expr - # via epochalyst + # via epochlib partd==1.4.2 # via dask pillow==10.3.0 @@ -164,7 +164,7 @@ pillow==10.3.0 platformdirs==4.2.2 # via pooch polars==0.20.31 - # via epochalyst + # via epochlib pooch==1.8.2 # via librosa protobuf==5.27.1 @@ -207,12 +207,12 @@ sympy==1.12.1 threadpoolctl==3.5.0 # via scikit-learn timm==1.0.7 - # via epochalyst + # via epochlib toolz==0.12.1 # via dask # via partd torch==2.3.1 - # via epochalyst + # via epochlib # via kornia # via timm # via torchvision @@ -223,7 +223,7 @@ tqdm==4.66.4 triton==2.3.1 # via torch typing-extensions==4.12.2 - # via epochalyst + # via epochlib # via huggingface-hub # via librosa # via torch diff --git a/tests/caching/test__cacher.py b/tests/caching/test__cacher.py index f119c28..9a9f1de 100644 --- a/tests/caching/test__cacher.py +++ b/tests/caching/test__cacher.py @@ -5,8 +5,8 @@ import polars as pl import pytest -from epochalyst.caching.cacher import Cacher -from epochalyst.logging.logger import Logger +from epochlib.caching.cacher import Cacher +from epochlib.logging.logger import Logger from tests.constants import TEMP_DIR diff --git a/tests/data/test_enum_data_format.py b/tests/data/test_enum_data_format.py index 2223f53..556f010 100644 --- a/tests/data/test_enum_data_format.py +++ b/tests/data/test_enum_data_format.py @@ -1,7 +1,7 @@ from unittest import TestCase from dataclasses import dataclass -from epochalyst.data import DataRetrieval, Data +from epochlib.data import DataRetrieval, Data import numpy as np import numpy.typing as npt from typing import Any diff --git a/tests/data/test_pipeline_dataset.py b/tests/data/test_pipeline_dataset.py index 15aebfe..0770151 100644 --- a/tests/data/test_pipeline_dataset.py +++ b/tests/data/test_pipeline_dataset.py @@ -1,8 +1,8 @@ from unittest import TestCase from dataclasses import dataclass -from epochalyst.data import Data, DataRetrieval, PipelineDataset -from epochalyst.training import TrainingBlock +from epochlib.data import Data, DataRetrieval, PipelineDataset +from epochlib.training import TrainingBlock import numpy as np import numpy.typing as npt from typing import Any diff --git a/tests/logging/test_logger.py b/tests/logging/test_logger.py index cfb8ca5..6682c55 100644 --- a/tests/logging/test_logger.py +++ b/tests/logging/test_logger.py @@ -3,7 +3,7 @@ import pytest -from epochalyst.logging.logger import Logger +from epochlib.logging.logger import Logger test_string = "Test" diff --git a/tests/test_ensemble.py b/tests/test_ensemble.py index f3c1d35..049b047 100644 --- a/tests/test_ensemble.py +++ b/tests/test_ensemble.py @@ -3,10 +3,10 @@ import numpy as np import pytest -from epochalyst import EnsemblePipeline -from epochalyst import ModelPipeline -from epochalyst.transformation import TransformationPipeline -from epochalyst.transformation import TransformationBlock +from epochlib import EnsemblePipeline +from epochlib import ModelPipeline +from epochlib.transformation import TransformationPipeline +from epochlib.transformation import TransformationBlock from tests.constants import TEMP_DIR diff --git a/tests/test_model.py b/tests/test_model.py index 8e1cd24..c890850 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -3,9 +3,9 @@ import numpy as np import pytest -from epochalyst import ModelPipeline -from epochalyst.transformation import TransformationPipeline -from epochalyst.transformation import TransformationBlock +from epochlib import ModelPipeline +from epochlib.transformation import TransformationPipeline +from epochlib.transformation import TransformationBlock from tests.constants import TEMP_DIR diff --git a/tests/training/augmentation/test_image_augmentations.py b/tests/training/augmentation/test_image_augmentations.py index f7a53e3..f1499e1 100644 --- a/tests/training/augmentation/test_image_augmentations.py +++ b/tests/training/augmentation/test_image_augmentations.py @@ -1,6 +1,6 @@ import torch -from epochalyst.training.augmentation import image_augmentations +from epochlib.training.augmentation import image_augmentations class TestImageAugmentations: diff --git a/tests/training/augmentation/test_time_series_augmentations.py b/tests/training/augmentation/test_time_series_augmentations.py index 662ea7e..006e558 100644 --- a/tests/training/augmentation/test_time_series_augmentations.py +++ b/tests/training/augmentation/test_time_series_augmentations.py @@ -1,7 +1,7 @@ import numpy as np import torch -from epochalyst.training.augmentation import time_series_augmentations +from epochlib.training.augmentation import time_series_augmentations def set_torch_seed(seed: int = 42) -> None: diff --git a/tests/training/augmentation/test_utils.py b/tests/training/augmentation/test_utils.py index d62ff2f..71cc74d 100644 --- a/tests/training/augmentation/test_utils.py +++ b/tests/training/augmentation/test_utils.py @@ -1,6 +1,6 @@ import torch -from epochalyst.training.augmentation import utils +from epochlib.training.augmentation import utils def set_torch_seed(seed: int = 42) -> None: diff --git a/tests/training/models/test_conv1d_bn_relu.py b/tests/training/models/test_conv1d_bn_relu.py index 749ff61..116c535 100644 --- a/tests/training/models/test_conv1d_bn_relu.py +++ b/tests/training/models/test_conv1d_bn_relu.py @@ -1,7 +1,7 @@ import torch from unittest import TestCase -from epochalyst.training.models import Conv1dBnRelu +from epochlib.training.models import Conv1dBnRelu class TestConv1dBnRelu(TestCase): diff --git a/tests/training/models/test_timm.py b/tests/training/models/test_timm.py index 61caf4d..dc391b9 100644 --- a/tests/training/models/test_timm.py +++ b/tests/training/models/test_timm.py @@ -1,6 +1,6 @@ import torch -from epochalyst.training.models import Timm +from epochlib.training.models import Timm from torch import nn diff --git a/tests/training/test_pretrain_block.py b/tests/training/test_pretrain_block.py index afe0e43..10a2bbc 100644 --- a/tests/training/test_pretrain_block.py +++ b/tests/training/test_pretrain_block.py @@ -1,6 +1,6 @@ import pytest -from epochalyst.training import PretrainBlock +from epochlib.training import PretrainBlock class TestPretrainBlock: diff --git a/tests/training/test_torch_trainer.py b/tests/training/test_torch_trainer.py index 24fd6c9..8bb6245 100644 --- a/tests/training/test_torch_trainer.py +++ b/tests/training/test_torch_trainer.py @@ -4,9 +4,9 @@ import time from dataclasses import dataclass -from epochalyst.training._custom_data_parallel import _CustomDataParallel +from epochlib.training._custom_data_parallel import _CustomDataParallel -from epochalyst.training.torch_trainer import custom_collate +from epochlib.training.torch_trainer import custom_collate from typing import Any from unittest.mock import patch @@ -14,7 +14,7 @@ import pytest import torch -from epochalyst.training.torch_trainer import TorchTrainer +from epochlib.training.torch_trainer import TorchTrainer from tests.constants import TEMP_DIR diff --git a/tests/training/test_training.py b/tests/training/test_training.py index ec495b3..ce6df00 100644 --- a/tests/training/test_training.py +++ b/tests/training/test_training.py @@ -2,8 +2,8 @@ import pytest from agogos.training import Trainer -from epochalyst.training import TrainingPipeline -from epochalyst.training import TrainingBlock +from epochlib.training import TrainingPipeline +from epochlib.training import TrainingBlock from tests.constants import TEMP_DIR diff --git a/tests/training/test_training_block.py b/tests/training/test_training_block.py index accadb0..ecd5c56 100644 --- a/tests/training/test_training_block.py +++ b/tests/training/test_training_block.py @@ -2,7 +2,7 @@ import pytest -from epochalyst.training import TrainingBlock +from epochlib.training import TrainingBlock TEMP_DIR = Path("tests/temp") diff --git a/tests/training/utils/test_get_dependencies.py b/tests/training/utils/test_get_dependencies.py index 2f91c22..1c3099f 100644 --- a/tests/training/utils/test_get_dependencies.py +++ b/tests/training/utils/test_get_dependencies.py @@ -3,7 +3,7 @@ import pytest -from epochalyst.training.utils import _get_openvino, _get_onnxrt +from epochlib.training.utils import _get_openvino, _get_onnxrt class TestGetDependencies: diff --git a/tests/training/utils/test_recursive_repr.py b/tests/training/utils/test_recursive_repr.py index 81bcb75..fc8d706 100644 --- a/tests/training/utils/test_recursive_repr.py +++ b/tests/training/utils/test_recursive_repr.py @@ -1,4 +1,4 @@ -from epochalyst.training.utils.recursive_repr import recursive_repr +from epochlib.training.utils.recursive_repr import recursive_repr class TestRecursiveRepr: diff --git a/tests/training/utils/test_tensor_functions.py b/tests/training/utils/test_tensor_functions.py index a61d1b8..6fbf7bd 100644 --- a/tests/training/utils/test_tensor_functions.py +++ b/tests/training/utils/test_tensor_functions.py @@ -1,5 +1,5 @@ from unittest import TestCase -from epochalyst.training.utils import batch_to_device +from epochlib.training.utils import batch_to_device from torch import Tensor diff --git a/tests/transformation/test_transformation.py b/tests/transformation/test_transformation.py index a8efe6a..df76240 100644 --- a/tests/transformation/test_transformation.py +++ b/tests/transformation/test_transformation.py @@ -4,8 +4,8 @@ import pytest from agogos.transforming import Transformer -from epochalyst.transformation import TransformationPipeline -from epochalyst.transformation import TransformationBlock +from epochlib.transformation import TransformationPipeline +from epochlib.transformation import TransformationBlock from tests.constants import TEMP_DIR diff --git a/tests/transformation/test_transformation_block.py b/tests/transformation/test_transformation_block.py index 710b580..05681a0 100644 --- a/tests/transformation/test_transformation_block.py +++ b/tests/transformation/test_transformation_block.py @@ -6,7 +6,7 @@ import numpy as np import pytest -from epochalyst.transformation import TransformationBlock +from epochlib.transformation import TransformationBlock TEMP_DIR = Path("tests/temp") From 5a7463fbe63af12a74c6fd6af28d809a3c1d70e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:38:41 +0200 Subject: [PATCH 19/19] Bump actions/upload-artifact from 4.3.3 to 4.3.6 (#251) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.3 to 4.3.6. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.3.3...v4.3.6) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jasper van Selm <70692744+schobbejak@users.noreply.github.com> --- .github/workflows/publish-package.yml | 2 +- .github/workflows/version-branch-testing.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index af56331..e149b35 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -13,7 +13,7 @@ jobs: uses: eifinger/setup-rye@v4.2.1 - name: Build the package run: rye build - - uses: actions/upload-artifact@v4.3.3 + - uses: actions/upload-artifact@v4.3.6 with: path: ./dist diff --git a/.github/workflows/version-branch-testing.yml b/.github/workflows/version-branch-testing.yml index c922128..71355d7 100644 --- a/.github/workflows/version-branch-testing.yml +++ b/.github/workflows/version-branch-testing.yml @@ -28,6 +28,6 @@ jobs: uses: eifinger/setup-rye@v4.2.1 - name: Build the package run: rye build - - uses: actions/upload-artifact@v4.3.3 + - uses: actions/upload-artifact@v4.3.6 with: path: ./dist