Skip to content

Commit

Permalink
feat(sdk): add archive, unarchive, and delete run methods, and tidy d…
Browse files Browse the repository at this point in the history
…ocstrings
  • Loading branch information
droctothorpe committed Apr 14, 2022
1 parent d46fafe commit e10f2a3
Showing 1 changed file with 50 additions and 22 deletions.
72 changes: 50 additions & 22 deletions sdk/python/kfp/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,17 @@ def _get_config_with_default_credentials(self, config):
config.refresh_api_key_hook(config)
return config

def set_user_namespace(self, namespace: str):
def set_user_namespace(self, namespace: str) --> None:
"""Set user namespace into local context setting file.
This function should only be used when Kubeflow Pipelines is in the
multi-user mode.
Args:
namespace: kubernetes namespace the user has access to.
Returns:
None
"""
self._context_setting['namespace'] = namespace
if not os.path.exists(os.path.dirname(Client.LOCAL_KFP_CONTEXT)):
Expand Down Expand Up @@ -585,12 +588,15 @@ def get_experiment(self,
experiment_name))
return result.experiments[0]

def archive_experiment(self, experiment_id: str):
def archive_experiment(self, experiment_id: str) --> None:
"""Archives an experiment.
Args:
experiment_id: id of the experiment.
Returns:
None
Raises:
kfp_server_api.ApiException: If experiment is not found.
"""
Expand All @@ -602,8 +608,6 @@ def delete_experiment(self, experiment_id):
Args:
experiment_id: id of the experiment.
Returns:
If the method is called asynchronously, returns the request thread.
Raises:
kfp_server_api.ApiException: If experiment is not found.
Expand Down Expand Up @@ -760,6 +764,48 @@ def run_pipeline(
IPython.display.display(IPython.display.HTML(html))
return response.run

def archive_run(self, run_id: str) --> None:
"""Archives a run.
Args:
run_id: id of the run.
Returns:
None
Raises:
kfp_server_api.ApiException: If the run is not found.
"""
self._run_api.archive_run(id=run_id)

def unarchive_run(self, run_id: str) --> None:
"""Restores an archived run.
Args:
run_id: id of the run.
Returns:
None
Raises:
kfp_server_api.ApiException: If the run is not found.
"""
self._run_api.unarchive_run(id=run_id)

def delete_run(self, run_id: str) --> None:
"""Deletes a run.
Args:
run_id: id of the run.
Returns:
None
Raises:
kfp_server_api.ApiException: If the run is not found.
"""
self._run_api.delete_run(id=run_id)

def create_recurring_run(
self,
experiment_id: str,
Expand Down Expand Up @@ -1092,10 +1138,6 @@ def delete_job(self, job_id: str):
Args:
job_id: id of the job.
Returns:
Object. If the method is called asynchronously, returns the request
thread.
Raises:
kfp_server_api.ApiException: If the job is not found.
"""
Expand All @@ -1107,9 +1149,6 @@ def disable_job(self, job_id: str):
Args:
job_id: id of the job.
Returns:
Object. If the method is called asynchronously, returns the request
thread.
Raises:
kfp_server_api.ApiException: If the job is not found.
Expand All @@ -1122,10 +1161,6 @@ def enable_job(self, job_id: str):
Args:
job_id: id of the job.
Returns:
Object. If the method is called asynchronously, returns the request
thread.
Raises:
kfp_server_api.ApiException: If the job is not found.
"""
Expand Down Expand Up @@ -1430,9 +1465,6 @@ def delete_pipeline(self, pipeline_id):
Args:
pipeline_id: id of the pipeline.
Returns:
Object. If the method is called asynchronously, returns the request
thread.
Raises:
kfp_server_api.ApiException: If pipeline is not found.
Expand Down Expand Up @@ -1492,10 +1524,6 @@ def delete_pipeline_version(self, version_id: str):
Args:
version_id: id of the pipeline version.
Returns:
Object. If the method is called asynchronously, returns the request
thread.
Raises:
kfp_server_api.ApiException: If pipeline is not found.
"""
Expand Down

0 comments on commit e10f2a3

Please sign in to comment.