-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(sdk): client to support KFP v2 API. #7411
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Chen!
Just a few very small questions and potential changes -- curious what you think.
sdk/python/kfp/__init__.py
Outdated
|
||
TYPE_CHECK = True | ||
|
||
from kfp.client import Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a pylint ignore comment so that is passes a linting check?
from kfp.client import Client | |
from kfp.client import Client # pylint: disable=wrong-import-position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks for the suggestion!
@@ -16,9 +16,13 @@ | |||
# https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages | |||
__path__ = __import__("pkgutil").extend_path(__path__, __name__) | |||
|
|||
__version__ = '2.0.0b0' | |||
__version__ = '2.0.0-alpha.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not this line of code
Should Copyright on this file be 2022 because we are presently modifying it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
credentials[client_id]['other_client_id'], | ||
credentials[client_id]['other_client_secret'], | ||
credentials[client_id]['refresh_token'], client_id) | ||
if other_client_id is None or other_client_secret is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit / not your code:
This could be refactored to make it a little bit clearer what is returned if the predicate if other_client_id is None or other_client_secret is None
is met:
if other_client_id is None or other_client_secret is None:
# fetch IAP auth token: service accounts
return get_auth_token_from_sa(client_id)
# fetch IAP auth token: user account
# Obtain the ID token for provided Client ID with user accounts.
# Flow: get authorization code -> exchange for refresh token -> obtain
# and return ID token
refresh_token = get_refresh_token_from_client_id(
other_client_id, other_client_secret)
credentials = {}
if os.path.exists(LOCAL_KFP_CREDENTIAL):
with open(LOCAL_KFP_CREDENTIAL, 'r') as f:
credentials = json.load(f)
credentials[client_id] = {}
credentials[client_id]['other_client_id'] = other_client_id
credentials[client_id]['other_client_secret'] = other_client_secret
credentials[client_id]['refresh_token'] = refresh_token
# TODO: handle the case when the refresh_token expires, which only
# happens if the refresh_token is not used once for six months.
if not os.path.exists(os.path.dirname(LOCAL_KFP_CREDENTIAL)):
os.makedirs(os.path.dirname(LOCAL_KFP_CREDENTIAL))
with open(LOCAL_KFP_CREDENTIAL, 'w') as f:
json.dump(credentials, f)
return id_token_from_refresh_token(other_client_id,
other_client_secret, refresh_token,
client_id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file and client.py as well may have many refactoring opportunities, let alone the pylint errors.
Will leave those for later PRs-- feel empowered to propose refactoring PRs as well :)
|
||
token = None | ||
|
||
# "existing_token" is designed to accept token generated outside of SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about removing this commented out code? I don't know much about its origin, but we're not using it here nor in deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not knowing much about the origin either, but existing_token
seems to me it's still used as an optional parameter.
Maybe this chunk of comments should really be moved into the docstring instead.
sdk/python/setup.py
Outdated
@@ -138,6 +139,6 @@ def find_version(*file_path_parts): | |||
'console_scripts': [ | |||
'dsl-compile = kfp.deprecated.compiler.main:main', | |||
'dsl-compile-v2 = kfp.compiler.main:main', | |||
'kfp=kfp.__main__:main' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not this line of code
Copyright 2022 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/test kubeflow-pipelines-samples-v2 |
/retest |
…7400) * chore(sdk): clean, dedup, reconcile, organize requirements * apply yapf formatting * correct copyright
* chore(sdk): fix test missing tempdir cleanup * fix test path * fix test path * clean up setUp method * change string placeholder from s to test_dir
/retest |
@chensun: The following tests failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Chen!
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: connor-mccarthy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
* copy _client.py and _auth.py from deprecated folder * Make kfp.Client support v2 API (IR). * fix test golden * address comments * copyright year * chore(backend): clean up pipelinespec.Value usage (kubeflow#7407) * chore(sdk): clean, dedup, reconcile, organize requirements (kubeflow#7400) * chore(sdk): clean, dedup, reconcile, organize requirements * apply yapf formatting * correct copyright * chore(sdk): fix test missing tempdir cleanup (kubeflow#7403) * chore(sdk): fix test missing tempdir cleanup * fix test path * fix test path * clean up setUp method * change string placeholder from s to test_dir * release note Co-authored-by: Connor McCarthy <mccarthy.connor.james@gmail.com>
Description of your changes:
pipeline_manifest
andruntime_config
inApiPipelineSpec
.Checklist: