Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
Add more APIs for SDK (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchihe authored and k8s-ci-robot committed Dec 19, 2019
1 parent fec4b00 commit f117363
Show file tree
Hide file tree
Showing 7 changed files with 539 additions and 89 deletions.
6 changes: 5 additions & 1 deletion sdk/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ Class | Method | Description
[PyTorchJobClient](docs/PyTorchJobClient.md) | [get](docs/PyTorchJobClient.md#get) | Get the specified PyTorchJob or all PyTorchJob in the namespace |
[PyTorchJobClient](docs/PyTorchJobClient.md) | [patch](docs/PyTorchJobClient.md#patch) | Patch the specified PyTorchJob|
[PyTorchJobClient](docs/PyTorchJobClient.md) | [delete](docs/PyTorchJobClient.md#delete) | Delete the specified PyTorchJob |

[PyTorchJobClient](docs/PyTorchJobClient.md) | [wait_for_job](docs/PyTorchJobClient.md#wait_for_job) | Wait for the specified job to finish |
[PyTorchJobClient](docs/PyTorchJobClient.md) | [wait_for_condition](docs/PyTorchJobClient.md#wait_for_condition) | Waits until any of the specified conditions occur |
[PyTorchJobClient](docs/PyTorchJobClient.md) | [get_job_status](docs/PyTorchJobClient.md#get_job_status) | Get the PyTorchJob status|
[PyTorchJobClient](docs/PyTorchJobClient.md) | [is_job_running](docs/PyTorchJobClient.md#is_job_running) | Check if the PyTorchJob running |
[PyTorchJobClient](docs/PyTorchJobClient.md) | [is_job_succeeded](docs/PyTorchJobClient.md#is_job_succeeded) | Check if the PyTorchJob Succeeded |

## Documentation For Models

Expand Down
139 changes: 138 additions & 1 deletion sdk/python/docs/PyTorchJobClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ PyTorchJobClient| [create](#create) | Create PyTorchJob|
PyTorchJobClient | [get](#get) | Get the specified PyTorchJob or all PyTorchJob in the namespace |
PyTorchJobClient | [patch](#patch) | Patch the specified PyTorchJob|
PyTorchJobClient | [delete](#delete) | Delete the specified PyTorchJob |

PyTorchJobClient | [wait_for_job](#wait_for_job) | Wait for the specified job to finish |
PyTorchJobClient | [wait_for_condition](#wait_for_condition) | Waits until any of the specified conditions occur |
PyTorchJobClient | [get_job_status](#get_job_status) | Get the PyTorchJob status|
PyTorchJobClient | [is_job_running](#is_job_running) | Check if the PyTorchJob running |
PyTorchJobClient | [is_job_succeeded](#is_job_succeeded) | Check if the PyTorchJob Succeeded |

## create
> create(pytorchjob, namespace=None)
Expand Down Expand Up @@ -173,3 +177,136 @@ namespace | str | The pytorchjob's namespace. Defaults to current or default nam

### Return type
object

## wait_for_job
> wait_for_job(name,
> namespace=None,
> timeout_seconds=600,
> polling_interval=30,
> status_callback=None):
Wait for the specified job to finish.

### Example

```python
from kubeflow.pytorchjob import PyTorchJobClient

pytorchjob_client = PyTorchJobClient()
pytorchjob_client.wait_for_job('mnist', namespace='kubeflow')
```

### Parameters
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
name | str | The PyTorchJob name.| |
namespace | str | The pytorchjob's namespace. Defaults to current or default namespace. | Optional|
timeout_seconds | int | How long to wait for the job, default wait for 600 seconds. | Optional|
polling_interval | int | How often to poll for the status of the job.| Optional|
status_callback | str | Callable. If supplied this callable is invoked after we poll the job. Callable takes a single argument which is the pytorchjob.| Optional|

### Return type
object


## wait_for_condition
> wait_for_condition(name,
> expected_condition,
> namespace=None,
> timeout_seconds=600,
> polling_interval=30,
> status_callback=None):

Waits until any of the specified conditions occur.

### Example

```python
from kubeflow.pytorchjob import PyTorchJobClient

pytorchjob_client = PyTorchJobClient()
pytorchjob_client.wait_for_condition('mnist', expected_condition=["Succeeded", "Failed"], namespace='kubeflow')
```

### Parameters
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
name | str | The PyTorchJob name.| |
expected_condition |List |A list of conditions. Function waits until any of the supplied conditions is reached.| |
namespace | str | The pytorchjob's namespace. Defaults to current or default namespace. | Optional|
timeout_seconds | int | How long to wait for the job, default wait for 600 seconds. | Optional|
polling_interval | int | How often to poll for the status of the job.| Optional|
status_callback | str | Callable. If supplied this callable is invoked after we poll the job. Callable takes a single argument which is the pytorchjob.| Optional|

### Return type
object

## get_job_status
> get_job_status(name, namespace=None)
Returns PyTorchJob status, such as Running, Failed or Succeeded.

### Example

```python
from kubeflow.pytorchjob import PyTorchJobClient

pytorchjob_client = PyTorchJobClient()
pytorchjob_client.get_job_status('mnist', namespace='kubeflow')
```

### Parameters
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
name | str | The PyTorchJob name. | |
namespace | str | The pytorchjob's namespace. Defaults to current or default namespace.| Optional |

### Return type
Str

## is_job_running
> is_job_running(name, namespace=None)
Returns True if the PyTorchJob running; false otherwise.

### Example

```python
from kubeflow.pytorchjob import PyTorchJobClient

pytorchjob_client = PyTorchJobClient()
pytorchjob_client.is_job_running('mnist', namespace='kubeflow')
```

### Parameters
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
name | str | The PyTorchJob name.| |
namespace | str | The pytorchjob's namespace. Defaults to current or default namespace.| Optional |

### Return type
Bool

## is_job_succeeded
> is_job_succeeded(name, namespace=None)
Returns True if the PyTorchJob succeeded; false otherwise.

### Example

```python
from kubeflow.pytorchjob import PyTorchJobClient

pytorchjob_client = PyTorchJobClient()
pytorchjob_client.is_job_succeeded('mnist', namespace='kubeflow')
```

### Parameters
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
name | str | The PyTorchJob name.| |
namespace | str | The pytorchjob's namespace. Defaults to current or default namespace.| Optional |

### Return type
Bool
Loading

0 comments on commit f117363

Please sign in to comment.