Skip to content

Commit

Permalink
Output trusted host as hostname
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Lovison <diegolovison@gmail.com>
  • Loading branch information
diegolovison committed Aug 16, 2024
1 parent 8041ea8 commit 521042d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions sdk/python/kfp/cli/component_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ def test_docker_file_is_created_correctly_with_one_url(self):
WORKDIR /usr/local/src/kfp/components
COPY runtime-requirements.txt runtime-requirements.txt
RUN pip install --index-url https://pypi.org/simple --trusted-host https://pypi.org/simple --no-cache-dir -r runtime-requirements.txt
RUN pip install --index-url https://pypi.org/simple --trusted-host pypi.org --no-cache-dir -r runtime-requirements.txt
RUN pip install --index-url https://pypi.org/simple --trusted-host https://pypi.org/simple --no-cache-dir kfp==1.2.3
RUN pip install --index-url https://pypi.org/simple --trusted-host pypi.org --no-cache-dir kfp==1.2.3
COPY . .
'''))

Expand Down Expand Up @@ -527,9 +527,9 @@ def test_docker_file_is_created_correctly_with_two_urls(self):
WORKDIR /usr/local/src/kfp/components
COPY runtime-requirements.txt runtime-requirements.txt
RUN pip install --index-url https://pypi.org/simple --trusted-host https://pypi.org/simple --extra-index-url https://example.com/pypi/simple --trusted-host https://example.com/pypi/simple --no-cache-dir -r runtime-requirements.txt
RUN pip install --index-url https://pypi.org/simple --trusted-host pypi.org --extra-index-url https://example.com/pypi/simple --trusted-host example.com --no-cache-dir -r runtime-requirements.txt
RUN pip install --index-url https://pypi.org/simple --trusted-host https://pypi.org/simple --extra-index-url https://example.com/pypi/simple --trusted-host https://example.com/pypi/simple --no-cache-dir kfp==1.2.3
RUN pip install --index-url https://pypi.org/simple --trusted-host pypi.org --extra-index-url https://example.com/pypi/simple --trusted-host example.com --no-cache-dir kfp==1.2.3
COPY . .
'''))

Expand Down
5 changes: 3 additions & 2 deletions sdk/python/kfp/dsl/component_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import textwrap
from typing import (Any, Callable, Dict, List, Mapping, Optional, Tuple, Type,
Union)
import urllib
import warnings

import docstring_parser
Expand Down Expand Up @@ -94,9 +95,9 @@ def make_index_url_options(pip_index_urls: Optional[List[str]]) -> str:
index_url = pip_index_urls[0]
extra_index_urls = pip_index_urls[1:]

options = [f'--index-url {index_url} --trusted-host {index_url}']
options = [f'--index-url {index_url} --trusted-host {urllib.parse.urlparse(index_url).hostname}']
options.extend(
f'--extra-index-url {extra_index_url} --trusted-host {extra_index_url}'
f'--extra-index-url {extra_index_url} --trusted-host {urllib.parse.urlparse(extra_index_url).hostname}'
for extra_index_url in extra_index_urls)

return ' '.join(options) + ' '
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/dsl/component_factory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_with_packages_to_install_with_pip_index_url(self):
strip_kfp_version(command),
strip_kfp_version([
'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 --index-url https://myurl.org/simple --trusted-host https://myurl.org/simple \'kfp==2.1.3\' \'--no-deps\' \'typing-extensions>=3.7.4,<5; python_version<"3.9"\' && python3 -m pip install --quiet --no-warn-script-location --index-url https://myurl.org/simple --trusted-host https://myurl.org/simple \'package1\' \'package2\' && "$0" "$@"\n'
'\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 --index-url https://myurl.org/simple --trusted-host myurl.org \'kfp==2.1.3\' \'--no-deps\' \'typing-extensions>=3.7.4,<5; python_version<"3.9"\' && python3 -m pip install --quiet --no-warn-script-location --index-url https://myurl.org/simple --trusted-host myurl.org \'package1\' \'package2\' && "$0" "$@"\n'
]))


Expand Down
1 change: 1 addition & 0 deletions sdk/python/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ types-PyYAML==6.0.5
types-requests==2.27.14
types-tabulate==0.8.6
yapf==0.32.0
uritemplate>=3.0.1,<4
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ deploymentSpec:
- "\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 --index-url https://pypi.org/simple\
\ --trusted-host https://pypi.org/simple 'kfp==2.7.0' '--no-deps' 'typing-extensions>=3.7.4,<5;\
\ --trusted-host pypi.org '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://pypi.org/simple --trusted-host https://pypi.org/simple\
\ --index-url https://pypi.org/simple --trusted-host pypi.org\
\ 'yapf' && \"$0\" \"$@\"\n"
- sh
- -ec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ deploymentSpec:
- "\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 --index-url https://pypi.org/simple\
\ --trusted-host https://pypi.org/simple 'kfp==2.7.0' '--no-deps' 'typing-extensions>=3.7.4,<5;\
\ --trusted-host pypi.org '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://pypi.org/simple --trusted-host https://pypi.org/simple\
\ --index-url https://pypi.org/simple --trusted-host pypi.org\
\ 'yapf' && \"$0\" \"$@\"\n"
- sh
- -ec
Expand Down

0 comments on commit 521042d

Please sign in to comment.