-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move integration test into examples (#756)
- moved integration test into examples `folder` - adjust sample implementation to new interface and how a user would do it - added script to execute the pipeline using fondant cli - add execution to ci/cd pipeline For now I've used a bash script for the execution. If we want to add more integration test we should think about a different approach. Fixes #727
- Loading branch information
Showing
16 changed files
with
151 additions
and
114 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
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,13 @@ | ||
# Sample pipeline | ||
|
||
This example is a simple sample pipeline which uses two reusable components | ||
(load_from_parquet, chunk_text), and a custom dummy component. The custom dummy component only | ||
returns the received dataframe. | ||
|
||
The pipeline can be executed with the Fondant cli: | ||
|
||
```bash | ||
fondant run local pipeline.py | ||
``` | ||
|
||
The automated integration test will use the `run.sh` script. |
16 changes: 7 additions & 9 deletions
16
...est/components/dummy_component/Dockerfile → ...ine/components/dummy_component/Dockerfile
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,24 +1,22 @@ | ||
FROM --platform=linux/amd64 python:3.8-slim as base | ||
FROM --platform=linux/amd64 python:3.8-slim | ||
|
||
# System dependencies | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install git -y | ||
|
||
# Install requirements | ||
COPY requirements.txt / | ||
COPY requirements.txt ./ | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
|
||
# Install Fondant | ||
# This is split from other requirements to leverage caching | ||
# Install fondant | ||
ARG FONDANT_VERSION=main | ||
RUN pip3 install fondant[component,aws,azure,gcp]@git+https://github.com/ml6team/fondant@${FONDANT_VERSION} | ||
|
||
# Set the working directory to the component folder | ||
WORKDIR /component | ||
COPY src/ src/ | ||
ENV PYTHONPATH "${PYTHONPATH}:./src" | ||
|
||
FROM base | ||
WORKDIR /component/src | ||
|
||
# Copy over src-files and spec of the component | ||
COPY src/ . | ||
|
||
ENTRYPOINT ["fondant", "execute", "main"] |
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...ts/dummy_component/fondant_component.yaml → ...ts/dummy_component/fondant_component.yaml
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
Empty file.
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
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,37 @@ | ||
# This file contains a sample pipeline. Loading data from a parquet file, | ||
# using the load_from_parquet component, chain a custom dummy component, and use | ||
# the reusable chunking component | ||
import pyarrow as pa | ||
from pathlib import Path | ||
from fondant.pipeline import Pipeline | ||
|
||
BASE_PATH = Path("./.artifacts").resolve() | ||
BASE_PATH.mkdir(parents=True, exist_ok=True) | ||
|
||
# Define pipeline | ||
pipeline = Pipeline(name="dummy-pipeline", base_path=str(BASE_PATH)) | ||
|
||
# Load from hub component | ||
load_component_column_mapping = { | ||
"text": "text_data", | ||
} | ||
|
||
dataset = pipeline.read( | ||
name_or_path="load_from_parquet", | ||
arguments={ | ||
"dataset_uri": "/data/sample.parquet", | ||
"column_name_mapping": load_component_column_mapping, | ||
"n_rows_to_load": 5, | ||
}, | ||
produces={"text_data": pa.string()}, | ||
) | ||
|
||
dataset = dataset.apply( | ||
name_or_path="./components/dummy_component", | ||
) | ||
|
||
dataset.apply( | ||
name_or_path="chunk_text", | ||
arguments={"chunk_size": 10, "chunk_overlap": 2}, | ||
consumes={"text": "text_data"}, | ||
) |
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,32 @@ | ||
#!/bin/bash | ||
# This script executes the sample pipeline in the example folder, checks the correct execution and | ||
# cleans up the directory again | ||
set -e | ||
GIT_HASH=$1 | ||
|
||
|
||
# Setup teardown | ||
cleanup() { | ||
rv=$? | ||
|
||
# Try to remove .artifact folder | ||
artifact_directory="./.artifacts" | ||
|
||
if [ -d "$artifact_directory" ]; then | ||
# Directory exists, remove it | ||
# Can't delete files in cicd pipeline due to missing permissions. Not necessarily needed there, | ||
# but might be useful if you executing the script locally. | ||
rm -rf "$artifact_directory" 2>/dev/null || true | ||
fi | ||
|
||
exit $rv | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
# Bind local data directory to pipeline | ||
data_dir=$(readlink -f "data") | ||
|
||
# Run pipeline | ||
poetry run fondant run local pipeline.py \ | ||
--extra-volumes $data_dir:/data --build-arg FONDANT_VERSION=$GIT_HASH |
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,36 @@ | ||
#!/bin/bash | ||
# This script executes the sample pipeline in the example folder, checks the correct execution and | ||
# cleans up the directory again | ||
GIT_HASH=$1 | ||
|
||
echo "Start integration tests execution ..." | ||
|
||
failed_tests=() | ||
|
||
# Find all run.sh scripts and execute them | ||
for test_script in ./examples/*/run.sh; do | ||
test_name=$(basename "$(dirname "$test_script")") | ||
|
||
echo "Running test: $test_name" | ||
|
||
# Set working dir to the currect integration test | ||
cd $(dirname "$test_script") | ||
|
||
# Execute the run.sh script | ||
bash ./run.sh $GIT_HASH | ||
|
||
# Check the exit status | ||
if [ $? -ne 0 ]; then | ||
echo "Test $test_name failed!" | ||
failed_tests+=("$test_name") | ||
fi | ||
done | ||
|
||
echo "Tests completed" | ||
|
||
if [ ${#failed_tests[@]} -eq 0 ]; then | ||
echo "All tests passed!" | ||
else | ||
echo "Failed tests: ${failed_tests[@]}" | ||
exit 1 # Indicate failure to cicd | ||
fi |
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
1 change: 0 additions & 1 deletion
1
tests/integration_tests/sample_pipeline_test/components/dummy_component/requirements.txt
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...ntegration_tests/sample_pipeline_test/components/load_from_parquet/fondant_component.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.