Skip to content

Commit

Permalink
add code example in README
Browse files Browse the repository at this point in the history
Signed-off-by: Yubo Wang <[email protected]>
  • Loading branch information
Yubo Wang committed May 15, 2023
1 parent b864d30 commit 79ab42b
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions plugins/flytekit-kf-tensorflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,42 @@ To install the plugin, run the following command:
pip install flytekitplugins-kftensorflow
```

## Upgrade TensorFlow Plugin
## Code Example
To build a TFJob with:
10 workers with restart policy as failed and 2 CPU and 2Gi Memory
1 ps replica with resources the same as task defined resources
1 chief replica with resources the same as task defined resources and restart policy as always
run policy as clean up all pods after job is finished.

You code:
```python
from flytekitplugins.kftensorflow import PS, Chief, CleanPodPolicy, RestartPolicy, RunPolicy, TfJob, Worker

@task(
task_config=TfJob(
worker=Worker(
replicas=5,
requests=Resources(cpu="2", mem="2Gi"),
limits=Resources(cpu="2", mem="2Gi"),
restart_policy=RestartPolicy.FAILURE,
),
ps=PS(replicas=1),
chief=Chief(replicas=1, restart_policy=RestartPolicy.ALWAYS),
run_policy=RunPolicy(clean_pod_policy=CleanPodPolicy.RUNNING),
),
image="test_image",
resources=Resources(cpu="1", mem="1Gi"),
)
def tf_job():
...
```


## Upgrade TensorFlow Plugin from to V1
Tensorflow plugin is now updated from v0 to v1 to enable more configuration options.
To migrate from v0 to v1, change the following:
1. Update flytepropeller to v
2. Update flytekit version to v
1. Update flytepropeller to v1.6.0
2. Update flytekit version to v1.6.1
3. Update your code from:
```
task_config=TfJob(num_workers=10, num_ps_replicas=1, num_chief_replicas=1),
Expand Down

0 comments on commit 79ab42b

Please sign in to comment.