-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
732a52a
commit 3781af8
Showing
22 changed files
with
288 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Default | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9, 3.11, 3.12] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Set up the dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipreqs pip-tools | ||
chmod +x requirements.sh | ||
sh ./requirements.sh | ||
- name: Install dependencies | ||
run: | | ||
pip install pytest black | ||
pip install -r requirements.txt | ||
- name: Run black | ||
id: black | ||
run: | | ||
black . | ||
git config --global user.name 'Jorgedavyd' | ||
git config --global user.email 'jorged.encyso@gmail.com' | ||
git diff --exit-code || (git add . && git commit -m "Automatically formatted with black" && git push) | ||
- name: Run tests | ||
run: | | ||
pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: To PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*.*.*' # Trigger on all tag pushes | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and publish Python 🐍 distributions 📦 to PyPI | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install wheel setuptools | ||
- name: Extract tag name | ||
id: extract_tag | ||
run: echo "TAG_NAME=$(echo $GITHUB_REF | cut -d/ -f3)" >> $GITHUB_ENV | ||
|
||
- name: Update version in setup.py and lightorch/_version.py | ||
run: | | ||
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ env.TAG_NAME }}/g" setup.py | ||
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ env.TAG_NAME }}/g" lightorch/_version.py | ||
- name: Build the package | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@v1.8.14 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
- name: Clean up | ||
run: rm -rf build dist *.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# 0.0.1 | ||
First Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
__version_info__ = ("0", "0", "1") | ||
__version__ = ".".join(__version_info__) | ||
__version__ = '{{VERSION_PLACEHOLDER}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
from .adversarial import * | ||
from .supervised import * | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
rm requirements.txt | ||
pipreqs lightorch/ --savepath=requirements.in | ||
pip-compile | ||
rm requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Tests | ||
1. Unit Tests: | ||
- All functions/methods covered. | ||
- Edge cases considered. | ||
2. Integration Tests: | ||
- Interactions with other modules tested. | ||
- API calls verified. |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from ..lightorch.nn.criterions import * | ||
from torch import Tensor, nn | ||
from .utils import * | ||
import random | ||
|
||
## Test automation for criterions | ||
|
||
# Unit tests | ||
input: Tensor = create_inputs(1, 3, 256, 256) | ||
target: Tensor = create_inputs(1, 3, 256, 256) | ||
|
||
mu: Tensor = create_inputs(1, 32) | ||
logvar: Tensor = create_inputs(1, 32) | ||
|
||
model: nn.Module = Model(32) | ||
randint: int = random.randint(-100, 100) | ||
|
||
|
||
def test_tv() -> None: | ||
loss = TV(randint) | ||
loss(input = input) | ||
|
||
|
||
def test_style() -> None: | ||
loss = StyleLoss(model, input, randint) | ||
loss(input = input, target = target, feature_extractor = False) | ||
|
||
|
||
def test_perc() -> None: | ||
loss = PerceptualLoss(model, input, randint) | ||
loss(input = input, target = target, feature_extractor = False) | ||
|
||
def test_psnr() -> None: | ||
loss = PeakNoiseSignalRatio(1, randint) | ||
loss(input = input, target = target) | ||
|
||
# Integration tests | ||
def test_lagrange() -> None: | ||
loss = LagrangianFunctional( | ||
nn.MSELoss(), nn.MSELoss(), nn.MSELoss(), lambd = Tensor([randint for _ in range(2)]) | ||
) | ||
loss(input=input, target=target) | ||
|
||
def test_loss() -> None: | ||
loss = Loss( | ||
TV(randint), PeakNoiseSignalRatio(1, randint) | ||
) | ||
loss(input = input, target = target) | ||
|
||
def test_elbo() -> None: | ||
loss = ELBO( | ||
randint, PeakNoiseSignalRatio(1, randint) | ||
) | ||
loss(input = input, target = target, mu = mu, logvar = logvar) | ||
|
||
def test_fourier() -> None: | ||
input: Tensor = create_inputs(1, 3, 256, 256) | ||
|
||
def test_partial() -> None: | ||
raise NotImplementedError | ||
|
||
def test_kan() -> None: | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from ..lightorch.training.supervised import Module | ||
from ..lightorch.nn.criterions import PeakNoiseSignalRatio | ||
from ..lightorch.htuning.optuna import htuning | ||
from .utils import Model, create_inputs, DataModule | ||
|
||
import random | ||
from torch import Tensor, nn | ||
in_size: int = 32 | ||
input: Tensor = create_inputs(1, in_size) | ||
randint: int = random.randint(-100, 100) | ||
#Integrated test | ||
|
||
class SupModel(Module): | ||
def __init__(self, **hparams) -> None: | ||
super().__init__(**hparams) | ||
self.criterion = PeakNoiseSignalRatio(1, randint) | ||
self.model = Model(in_size) | ||
|
||
def forward(self, input: Tensor) -> Tensor: | ||
return self.model(input) | ||
|
||
def objective(): | ||
pass | ||
|
||
def test_supervised() -> None: | ||
htuning( | ||
model_class = SupModel, | ||
hparam_objective=objective, | ||
datamodule = DataModule, | ||
valid_metrics = 'MSE', | ||
datamodule_kwargs= dict( | ||
pin_memory = False, | ||
num_workers = 1, | ||
batch_size = 1 | ||
), | ||
directions = 'minimize', | ||
precision = 'high', | ||
n_trials = 10, | ||
trianer_kwargs = dict(fast_dev_run = True) | ||
) |
Empty file.
Oops, something went wrong.