Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove abstract component test #510

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions components/caption_images/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
FROM --platform=linux/amd64 pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime as base

# System dependencies
RUN apt-get update && \
Expand All @@ -15,9 +15,16 @@ ARG FONDANT_VERSION=main
RUN pip3 install fondant[aws,azure,gcp]@git+https://github.com/ml6team/fondant@${FONDANT_VERSION}

# Set the working directory to the component folder
WORKDIR /component/src
WORKDIR /component
COPY src/ src/
ENV PYTHONPATH "${PYTHONPATH}:./src"

# Copy over src-files
COPY src/ .
FROM base as test
COPY test_requirements.txt .
RUN pip3 install --no-cache-dir -r test_requirements.txt
COPY tests/ tests/
RUN python -m pytest tests

FROM base
WORKDIR /component/src
ENTRYPOINT ["fondant", "execute", "main"]
1 change: 1 addition & 0 deletions components/caption_images/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==7.4.2
38 changes: 21 additions & 17 deletions components/caption_images/tests/test_caption_images.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import pandas as pd
import requests
from caption_images.src.main import CaptionImagesComponent
from fondant.abstract_component_test import AbstractComponentTest

from src.main import CaptionImagesComponent

class TestCaptionImagesComponent(AbstractComponentTest):
def create_component(self):
return CaptionImagesComponent(

def test_image_caption_component():
image_urls = [
"https://cdn.pixabay.com/photo/2023/06/29/09/52/angkor-thom-8096092_1280.jpg",
"https://cdn.pixabay.com/photo/2023/07/19/18/56/japanese-beetle-8137606_1280.png",
]
input_dataframe = pd.DataFrame(
{"images": {"data": [requests.get(url).content for url in image_urls]}})

expected_output_dataframe = pd.DataFrame(
data={("captions", "text"): {0: "a motorcycle", 1: "a beetle"}},
)

component = CaptionImagesComponent(
model_id="Salesforce/blip-image-captioning-base",
batch_size=4,
max_new_tokens=2,
)

def create_input_data(self):
image_urls = [
"https://cdn.pixabay.com/photo/2023/06/29/09/52/angkor-thom-8096092_1280.jpg",
"https://cdn.pixabay.com/photo/2023/07/19/18/56/japanese-beetle-8137606_1280.png",
]
return pd.DataFrame(
{"images": {"data": [requests.get(url).content for url in image_urls]}},
)
output_dataframe = component.transform(input_dataframe)

def create_output_data(self):
return pd.DataFrame(
data={("captions", "text"): {0: "a motorcycle", 1: "a beetle"}},
)
pd.testing.assert_frame_equal(
left=expected_output_dataframe,
right=output_dataframe,
check_dtype=False,
)
47 changes: 0 additions & 47 deletions src/fondant/abstract_component_test.py

This file was deleted.