Skip to content

Commit

Permalink
Update workflow & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HonzaCuhel committed Jan 10, 2024
1 parent 0d56988 commit 5285f65
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: Tests

on:
push:
branches: [ master, main ]
paths:
- 'src/datadreamer/**/**.py'
- 'tests/**/**.py'
- .github/workflows/tests.yaml
pull_request:
branches: [ dev, main, add-tests ]
branches: [ dev, main ]
paths:
- 'src/datadreamer/**/**.py'
- 'tests/**/**.py'
Expand Down Expand Up @@ -36,14 +42,19 @@ jobs:
sudo apt update
sudo apt install -y pandoc
pip install -e .[dev]
pip install pytest coverage-badge
- name: Install dependencies [Windows]
if: matrix.os == 'windows-latest'
run: pip install -e .[dev]
run: |
pip install -e .[dev]
pip install pytest coverage-badge
- name: Install dependencies [macOS]
if: matrix.os == 'macOS-latest'
run: pip install -e .[dev]
run: |
pip install -e .[dev]
pip install pytest coverage-badge
- name: Run tests with coverage [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
Expand Down
3 changes: 2 additions & 1 deletion tests/unittests/test_annotators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

def test_owlv2_annotator():
device = "cuda" if torch.cuda.is_available() else "cpu"
pass
assert device in ["cuda", "cpu"]



if __name__ == "__main__":
Expand Down
11 changes: 8 additions & 3 deletions tests/unittests/test_image_generation.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import pytest
import torch
from PIL import Image
from datadreamer.image_generation.sdxl_image_generator import StableDiffusionImageGenerator
from datadreamer.image_generation.sdxl_turbo_image_generator import StableDiffusionTurboImageGenerator
from datadreamer.image_generation.clip_image_tester import ClipImageTester


def test_clip_image_tester():
device = "cuda" if torch.cuda.is_available() else "cpu"
pass
assert device in ["cuda", "cpu"]


def test_sdxl_image_generator():
device = "cuda" if torch.cuda.is_available() else "cpu"
# image_generator = StableDiffusionImageGenerator(device=device)
image_generator = StableDiffusionImageGenerator()
generated_image = image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]])
for generated_image in image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]]):
assert generated_image is not None
assert isinstance(generated_image, Image.Image)
image_generator.release(empty_cuda_cache=True if device != 'cpu' else False)


def test_sdxl_turbo_image_generator():
device = "cuda" if torch.cuda.is_available() else "cpu"
# image_generator = StableDiffusionTurboImageGenerator(device=device)
image_generator = StableDiffusionTurboImageGenerator()
generated_image = image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]])
for generated_image in image_generator.generate_images(["A photo of a cat, dog"], [["cat", "dog"]]):
assert generated_image is not None
assert isinstance(generated_image, Image.Image)
image_generator.release(empty_cuda_cache=True if device != 'cpu' else False)


Expand Down

0 comments on commit 5285f65

Please sign in to comment.