Skip to content
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

add docs about from_deployment #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions docs/metaflow/managing-flows/deployer.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@
```python
triggered_run = deployed_flow.trigger()
```

:::tip
The `deployed_flow` object which is needed, so as to create a `triggered_run` object via the `trigger()` method

Check warning on line 50 in docs/metaflow/managing-flows/deployer.md

View workflow job for this annotation

GitHub Actions / Run linters

Line length: Expected: 100; Actual: 111
can also be fetched using the `from_deployment` method. This is useful if we want to reference a flow which has

Check warning on line 51 in docs/metaflow/managing-flows/deployer.md

View workflow job for this annotation

GitHub Actions / Run linters

Line length: Expected: 100; Actual: 111
been deployed previously. Thus, we need not call `create()` again to create a fresh new deployed flow.

An `identifier` is needed so as to reference the previously deployed flow. An optional `metadata` can also be used.

Check warning on line 54 in docs/metaflow/managing-flows/deployer.md

View workflow job for this annotation

GitHub Actions / Run linters

Line length: Expected: 100; Actual: 115

```py
from metaflow import Deployer

deployer = Deployer('helloflow.py')
deployed_flow = deployer.argo_workflows().create()

# save this for later use...
identifier = deployed_flow.name
metadata = deployed_flow.metadata
```

Assuming the `identifier` was saved when the flow was deployed, we can now use the `from_deployment` method as follows:

Check warning on line 67 in docs/metaflow/managing-flows/deployer.md

View workflow job for this annotation

GitHub Actions / Run linters

Line length: Expected: 100; Actual: 119

```py
from metaflow import DeployedFlow

# use the identifier and metadata saved above..
deployed_flow = DeployedFlow.from_deployment(identifier=identifier, metadata=metadata)
triggered_run = deployed_flow.trigger()
```
:::

:::note
The `from_deployment` method is only available for argo-workflows.
:::

You can specify any [`Parameters`](/metaflow/basics#how-to-define-parameters-for-flows)
in `trigger`, e.g.
```python
Expand All @@ -57,11 +91,9 @@
cloud instance needs to start to execute the task:

```python
import time
while triggered_run.run is None:
print(f'Waiting for the run to start')
time.sleep(1)
print('Run started', triggered_run.run)
# wait for the run object to be available, timeout None means wait forever
run_obj = triggered_run.wait_for_run(timeout=None)
print('Run started', run_obj)
```

### Terminating a triggered run
Expand Down
Loading