-
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): Add filters to python client. #6748
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -506,7 +506,8 @@ def list_experiments(self, | |
page_token='', | ||
page_size=10, | ||
sort_by='', | ||
namespace=None): | ||
namespace=None, | ||
filter=None): | ||
"""List experiments. | ||
|
||
Args: | ||
|
@@ -516,6 +517,8 @@ def list_experiments(self, | |
namespace: Kubernetes namespace where the experiment was created. | ||
For single user deployment, leave it as None; | ||
For multi user, input a namespace where the user is authorized. | ||
filter: A url-encoded, JSON-serialized Filter protocol buffer | ||
(see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)). | ||
|
||
Returns: | ||
A response object including a list of experiments and next page token. | ||
|
@@ -527,7 +530,8 @@ def list_experiments(self, | |
sort_by=sort_by, | ||
resource_reference_key_type=kfp_server_api.models.api_resource_type | ||
.ApiResourceType.NAMESPACE, | ||
resource_reference_key_id=namespace) | ||
resource_reference_key_id=namespace, | ||
filter=filter) | ||
return response | ||
|
||
def get_experiment(self, | ||
|
@@ -644,19 +648,24 @@ def _override_caching_options(self, workflow: dict, enable_caching: bool): | |
'pipelines.kubeflow.org/enable_caching'] = str( | ||
enable_caching).lower() | ||
|
||
def list_pipelines(self, page_token='', page_size=10, sort_by=''): | ||
def list_pipelines(self, page_token='', page_size=10, sort_by='', filter=None): | ||
"""List pipelines. | ||
|
||
Args: | ||
page_token: Token for starting of the page. | ||
page_size: Size of the page. | ||
sort_by: one of 'field_name', 'field_name desc'. For example, 'name desc'. | ||
filter: A url-encoded, JSON-serialized Filter protocol buffer | ||
(see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)). | ||
|
||
Returns: | ||
A response object including a list of pipelines and next page token. | ||
""" | ||
return self._pipelines_api.list_pipelines( | ||
page_token=page_token, page_size=page_size, sort_by=sort_by) | ||
page_token=page_token, | ||
page_size=page_size, | ||
sort_by=sort_by, | ||
filter=filter) | ||
|
||
# TODO: provide default namespace, similar to kubectl default namespaces. | ||
def run_pipeline( | ||
|
@@ -1089,7 +1098,8 @@ def list_runs(self, | |
page_size=10, | ||
sort_by='', | ||
experiment_id=None, | ||
namespace=None): | ||
namespace=None, | ||
filter=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: docstring |
||
"""List runs, optionally can be filtered by experiment or namespace. | ||
|
||
Args: | ||
|
@@ -1100,6 +1110,8 @@ def list_runs(self, | |
namespace: Kubernetes namespace to filter upon. | ||
For single user deployment, leave it as None; | ||
For multi user, input a namespace where the user is authorized. | ||
filter: A url-encoded, JSON-serialized Filter protocol buffer | ||
(see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)). | ||
|
||
Returns: | ||
A response object including a list of experiments and next page token. | ||
|
@@ -1112,32 +1124,40 @@ def list_runs(self, | |
sort_by=sort_by, | ||
resource_reference_key_type=kfp_server_api.models | ||
.api_resource_type.ApiResourceType.EXPERIMENT, | ||
resource_reference_key_id=experiment_id) | ||
resource_reference_key_id=experiment_id, | ||
filter=filter) | ||
elif namespace: | ||
response = self._run_api.list_runs( | ||
page_token=page_token, | ||
page_size=page_size, | ||
sort_by=sort_by, | ||
resource_reference_key_type=kfp_server_api.models | ||
.api_resource_type.ApiResourceType.NAMESPACE, | ||
resource_reference_key_id=namespace) | ||
resource_reference_key_id=namespace, | ||
filter=filter) | ||
else: | ||
response = self._run_api.list_runs( | ||
page_token=page_token, page_size=page_size, sort_by=sort_by) | ||
page_token=page_token, | ||
page_size=page_size, | ||
sort_by=sort_by, | ||
filter=filter) | ||
return response | ||
|
||
def list_recurring_runs(self, | ||
page_token='', | ||
page_size=10, | ||
sort_by='', | ||
experiment_id=None): | ||
experiment_id=None, | ||
filter=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
"""List recurring runs. | ||
|
||
Args: | ||
page_token: Token for starting of the page. | ||
page_size: Size of the page. | ||
sort_by: One of 'field_name', 'field_name desc'. For example, 'name desc'. | ||
experiment_id: Experiment id to filter upon. | ||
filter: A url-encoded, JSON-serialized Filter protocol buffer | ||
(see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)). | ||
|
||
Returns: | ||
A response object including a list of recurring_runs and next page token. | ||
|
@@ -1149,10 +1169,14 @@ def list_recurring_runs(self, | |
sort_by=sort_by, | ||
resource_reference_key_type=kfp_server_api.models | ||
.api_resource_type.ApiResourceType.EXPERIMENT, | ||
resource_reference_key_id=experiment_id) | ||
resource_reference_key_id=experiment_id, | ||
filter=filter) | ||
else: | ||
response = self._job_api.list_jobs( | ||
page_token=page_token, page_size=page_size, sort_by=sort_by) | ||
page_token=page_token, | ||
page_size=page_size, | ||
sort_by=sort_by, | ||
filter=filter) | ||
return response | ||
|
||
def get_recurring_run(self, job_id): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you please document this argument below in the function docstring?
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!
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.
The link there is now broken.
https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto