Skip to content

Commit

Permalink
Replace boto3 with numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolovison committed Oct 3, 2024
1 parent c41fcd9 commit f48c73c
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 51 deletions.
36 changes: 15 additions & 21 deletions .github/scripts/python_package_upload/package_upload.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
#!/usr/bin/env bash
#!/bin/bash

set -ex

kfp_directory=kfp
boto_directory=boto3
# easy for troubleshooting
tmp_dir=tmp

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"
mkdir -p "$tmp_dir"

# 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-version it will use the one from the computer that may not be the one that the
# pipeline is running
pip download $package -d "$tmp_dir" --only-binary=:all: --python-version $python_version
done
done

# 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
# Copy packages
for entry in "$tmp_dir"/*; 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 @@ -192,6 +192,7 @@ remove_namespace_created_for_rhoai() {
}

setup_kind_requirements() {
upload_python_packages_to_pypi_server
apply_crd
build_image
create_opendatahub_namespace
Expand All @@ -202,7 +203,6 @@ setup_kind_requirements() {
deploy_pypi_server
wait_for_dspo_dependencies
wait_for_dependencies
upload_python_packages_to_pypi_server
create_dspa_namespace
create_namespace_dspa_external_connections
apply_mariadb_minio_secrets_configmaps_external_namespace
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/kind-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ jobs:
go-version: '1.21.x'
id: go

- name: pip version
working-directory: ${{ github.workspace }}/.github/scripts/tests
run: |
pip --version
pip install --upgrade pip
pip --version
- name: Setup and start KinD cluster
uses: ./.github/actions/kind

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Dockerfile.cross
__pycache__/
*.py[cod]
*$py.class
.github/scripts/python_package_upload/
.github/scripts/python_package_upload/tmp
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
22 changes: 12 additions & 10 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,14 @@ 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<\"\
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"
\ 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/\
\ --trusted-host nginx-service.test-pypiserver.svc.cluster.local '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/simple/ --trusted-host\
\ nginx-service.test-pypiserver.svc.cluster.local 'numpy' && \"$0\" \"$@\"\
\n"
- sh
- -ec
- 'program_path=$(mktemp -d)
Expand All @@ -40,8 +41,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 +68,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=['nginx-service.test-pypiserver.svc.cluster.local'])
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'))

0 comments on commit f48c73c

Please sign in to comment.