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

Replace boto3 with numpy #713

Merged
merged 1 commit into from
Oct 4, 2024
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: 15 additions & 0 deletions .github/scripts/python_package_upload/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM docker.io/python:3.9
HumairAK marked this conversation as resolved.
Show resolved Hide resolved

# Set working directory
WORKDIR /app

# Copy the script into the container
COPY package_upload.sh /app/package_upload.sh

# Make sure the script is executable
RUN chmod +x /app/package_upload.sh

# Store the files in a folder
VOLUME /app/packages

ENTRYPOINT ["/app/package_upload.sh"]
37 changes: 8 additions & 29 deletions .github/scripts/python_package_upload/package_upload.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
#!/usr/bin/env bash
#!/bin/bash

set -ex

kfp_directory=kfp
boto_directory=boto3

mkdir -p "$kfp_directory"
mkdir -p "$boto_directory"

# Download kfp package
pip download kfp==2.7.0 -d "$kfp_directory"

# Download boto3 package
pip download boto3 -d "$boto_directory"


# Print the pods in the namespace
oc -n test-pypiserver get pods

pod_name=$(oc -n test-pypiserver get pod | grep pypi | awk '{print $1}')

# Copy kfp packages
for kfp_entry in "$kfp_directory"/*; do
echo oc -n test-pypiserver cp "$kfp_entry" $pod_name:/opt/app-root/packages
oc -n test-pypiserver cp "$kfp_entry" $pod_name:/opt/app-root/packages
done

# Copy boto3 packages
for boto_entry in "$boto_directory"/*; do
echo oc -n test-pypiserver cp "$boto_entry" $pod_name:/opt/app-root/packages
oc -n test-pypiserver cp "$boto_entry" $pod_name:/opt/app-root/packages
# Download packages
for python_version in "3.9" "3.10" "3.11" "3.12"; do
for package in "kfp" "numpy"; do
# If we don't set the --python it will use the one from the computer that may not be the one that the
# pipeline is running
pip download $package -d packages --only-binary=:none: --python $python_version
done
done
18 changes: 18 additions & 0 deletions .github/scripts/python_package_upload/package_upload_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -ex

mkdir -p /tmp/packages
docker rm package_upload_run || true
docker build -t package_upload .
docker run --name package_upload_run -v /tmp/packages:/app/packages package_upload

# Print the pods in the namespace
oc -n test-pypiserver get pods

pod_name=$(oc -n test-pypiserver get pod | grep pypi | awk '{print $1}')

# Copy packages
for entry in /tmp/packages/*; do
oc -n test-pypiserver cp "$entry" $pod_name:/opt/app-root/packages
done
2 changes: 1 addition & 1 deletion .github/scripts/tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ upload_python_packages_to_pypi_server() {
echo "---------------------------------"
echo "Upload Python Packages to pypi-server"
echo "---------------------------------"
( cd "${GIT_WORKSPACE}/.github/scripts/python_package_upload" && sh package_upload.sh )
( cd "${GIT_WORKSPACE}/.github/scripts/python_package_upload" && sh package_upload_run.sh )
}

create_dspa_namespace() {
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ Dockerfile.cross
__pycache__/
*.py[cod]
*$py.class
.github/scripts/python_package_upload/
26 changes: 13 additions & 13 deletions tests/resources/test-pipeline-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ deploymentSpec:
exec-say-hello:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- say_hello
- --executor_input
- '{{$}}'
- --function_to_execute
- say_hello
command:
- sh
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
- sh
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.3.0'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
$0\" \"$@\"\n"
- sh
- -ec
- 'program_path=$(mktemp -d)
- sh
- -ec
- 'program_path=$(mktemp -d)


printf "%s" "$0" > "$program_path/ephemeral_component.py"

_KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"

'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef say_hello(name: str) -> str:\n hello_text = f'Hello, {name}!'\n\
\ print(hello_text)\n return hello_text\n\n"
image: quay.io/opendatahub/ds-pipelines-ci-executor-image:v1.1
Expand Down Expand Up @@ -77,4 +77,4 @@ root:
Output:
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.3.0
sdkVersion: kfp-2.9.0
18 changes: 9 additions & 9 deletions tests/resources/test-pipeline-with-custom-pip-server-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ deploymentSpec:
- sh
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n
\ PIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location --index-url https://nginx-service.test-pypiserver.svc.cluster.local:443/simple/\
\ 'kfp==2.7.0' '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location --index-url https://nginx-service.test-pypiserver.svc.cluster.local/simple/\
\ 'kfp==2.9.0' '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"\
3.9\"' && python3 -m pip install --quiet --no-warn-script-location --index-url\
\ https://nginx-service.test-pypiserver.svc.cluster.local:443/simple/ 'boto3' && \"\
$0\" \"$@\"\n"
\ https://nginx-service.test-pypiserver.svc.cluster.local/simple/ 'numpy'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
- 'program_path=$(mktemp -d)
Expand All @@ -40,8 +39,9 @@ deploymentSpec:

'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef say_hello() -> str:\n hello_text = f'Hello!'\n print(hello_text)\n\
\ return hello_text\n\n"
\ *\n\ndef say_hello() -> str:\n import numpy as np\n hello_text =\
\ f'Numpy version: {np.__version__}'\n print(hello_text)\n return\
\ hello_text\n\n"
image: quay.io/opendatahub/ds-pipelines-ci-executor-image:v1.0
pipelineInfo:
name: hello-pipeline
Expand All @@ -66,4 +66,4 @@ root:
Output:
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.7.0
sdkVersion: kfp-2.9.0
10 changes: 6 additions & 4 deletions tests/resources/test-pipeline-with-custom-pip-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# Edited the compiled version manually, to remove the --trusted-host flag
# this is so we can test for tls certs validations when launcher installs packages
@dsl.component(base_image="quay.io/opendatahub/ds-pipelines-ci-executor-image:v1.0",
packages_to_install=['boto3'],
pip_index_urls=['https://nginx-service.test-pypiserver.svc.cluster.local:443/simple/'])
packages_to_install=['numpy'],
pip_index_urls=['https://nginx-service.test-pypiserver.svc.cluster.local/simple/'],
pip_trusted_hosts=[])
def say_hello() -> str:
hello_text = 'Hello!'
import numpy as np
hello_text = f'Numpy version: {np.__version__}'
print(hello_text)
return hello_text

Expand All @@ -18,4 +20,4 @@ def hello_pipeline() -> str:


if __name__ == '__main__':
compiler.Compiler().compile(hello_pipeline, __file__ + '.yaml')
compiler.Compiler().compile(hello_pipeline, __file__.replace('.py', '-run.yaml'))
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def hello_pipeline(recipient: str) -> str:


if __name__ == '__main__':
compiler.Compiler().compile(hello_pipeline, __file__ + '.yaml')
compiler.Compiler().compile(hello_pipeline, __file__.replace('.py', '-run.yaml'))
Loading