Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
philippmwirth committed Sep 14, 2023
1 parent 2d10d76 commit 88c723a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
15 changes: 1 addition & 14 deletions tests/api_workflow/test_api_workflow_upload_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import numpy as np

from lightly.utils import io as io_utils
from lightly.utils.io import INVALID_FILENAME_CHARACTERS
from tests.api_workflow.mocked_api_workflow_client import (
N_FILES_ON_SERVER,
MockedApiWorkflowSetup,
)
from tests.api_workflow.mocked_api_workflow_client import MockedApiWorkflowSetup


class TestApiWorkflowUploadEmbeddings(MockedApiWorkflowSetup):
Expand Down Expand Up @@ -80,15 +76,6 @@ def test_upload_wrong_filenames(self):
with self.assertRaises(ValueError):
self.t_ester_upload_embedding(n_data=n_data, special_name_first_sample=True)

def test_upload_comma_filenames(self):
n_data = len(self.api_workflow_client._mappings_api.sample_names)
for invalid_char in INVALID_FILENAME_CHARACTERS:
with self.subTest(msg=f"invalid_char: {invalid_char}"):
with self.assertRaises(ValueError):
self.t_ester_upload_embedding(
n_data=n_data, special_char_in_first_filename=invalid_char
)

def test_set_embedding_id_default(self):
self.api_workflow_client.set_embedding_id_to_latest()
embeddings = (
Expand Down
25 changes: 1 addition & 24 deletions tests/data/test_LightlyDataset.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import os
import random
import re
import shutil
import tempfile
import unittest
import warnings
from typing import List, Tuple

import numpy as np
import torch
import torchvision
from PIL.Image import Image

from lightly.data import LightlyDataset
from lightly.data._utils import check_images
from lightly.utils.io import INVALID_FILENAME_CHARACTERS

try:
import av
import av as _
import cv2

from lightly.data._video import VideoDataset
Expand Down Expand Up @@ -137,24 +132,6 @@ def test_create_lightly_dataset_from_folder_nosubdir(self):
for i in range(n_tot):
sample, target, fname = dataset[i]

def test_create_lightly_dataset_with_invalid_char_in_filename(self):
# create a dataset
n_tot = 100
dataset = torchvision.datasets.FakeData(size=n_tot, image_size=(3, 32, 32))

for invalid_char in INVALID_FILENAME_CHARACTERS:
with self.subTest(msg=f"invalid_char: {invalid_char}"):
tmp_dir = tempfile.mkdtemp()
sample_names = [f"img_,_{i}.jpg" for i in range(n_tot)]
for sample_idx in range(n_tot):
data = dataset[sample_idx]
path = os.path.join(tmp_dir, sample_names[sample_idx])
data[0].save(path)

# create lightly dataset
with self.assertRaises(ValueError):
dataset = LightlyDataset(input_dir=tmp_dir)

def test_check_images(self):
# create a dataset
tmp_dir = tempfile.mkdtemp()
Expand Down

0 comments on commit 88c723a

Please sign in to comment.