Skip to content

Commit 37706a3

Browse files
authored
Merge pull request #207 from cliveseldon/metaflow_aws
Fix metaflow local/remote decision and update to 0.5.1 release
2 parents 7f646cd + 238ad3a commit 37706a3

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

docs/examples/metaflow/README.ipynb

+2-10
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,7 @@
5353
"id": "b2a246ca",
5454
"metadata": {},
5555
"source": [
56-
"## Run Flow locally to deploy to Docker\n",
57-
"\n",
58-
"To run the workflow with a local Docker deployment use the flag:\n",
59-
"\n",
60-
"```\n",
61-
"--tempo-on-docker true\n",
62-
"```\n"
56+
"## Run Flow locally to deploy to Docker"
6357
]
6458
},
6559
{
@@ -105,8 +99,6 @@
10599
"\n",
106100
"### Setup AWS Metaflow Support\n",
107101
"\n",
108-
"Note at present this is required even for a local run as artifacts are stored on S3.\n",
109-
"\n",
110102
"[Install Metaflow with remote AWS support](https://docs.metaflow.org/metaflow-on-aws/metaflow-on-aws).\n",
111103
"\n",
112104
"### Seldon Requirements\n",
@@ -313,7 +305,7 @@
313305
"name": "python",
314306
"nbconvert_exporter": "python",
315307
"pygments_lexer": "ipython3",
316-
"version": "3.7.10"
308+
"version": "3.7.9"
317309
}
318310
},
319311
"nbformat": 4,

docs/examples/metaflow/README.md

-9
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ conda config --add channels conda-forge
3232

3333
## Run Flow locally to deploy to Docker
3434

35-
To run the workflow with a local Docker deployment use the flag:
36-
37-
```
38-
--tempo-on-docker true
39-
```
40-
41-
4235

4336
```python
4437
!python src/irisflow.py --environment=conda run
@@ -61,8 +54,6 @@ We will now run our flow on AWS Batch and will launch Tempo artifacts onto a rem
6154

6255
### Setup AWS Metaflow Support
6356

64-
Note at present this is required even for a local run as artifacts are stored on S3.
65-
6657
[Install Metaflow with remote AWS support](https://docs.metaflow.org/metaflow-on-aws/metaflow-on-aws).
6758

6859
### Seldon Requirements

docs/examples/metaflow/src/irisflow.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,22 @@ def deploy_tempo_remote(self, classifier):
162162
print(self.client_model.predict(np.array([[1, 2, 3, 4]])))
163163

164164
@conda(libraries={"numpy": "1.19.5"})
165-
@pip(libraries={"mlops-tempo": "0.5.0", "conda_env": "2.4.2"})
165+
@pip(libraries={"mlops-tempo": "0.5.1", "conda_env": "2.4.2"})
166166
@step
167167
def tempo(self):
168168
"""
169169
Create Tempo artifacts locally and saved to S3 within the workflow bucket.
170170
Then either deploy locally to Docker or deploy to a remote Kubernetes cluster based on the
171171
--tempo-on-docker parameter
172172
"""
173-
classifier, remote = self.create_tempo_artifacts()
173+
from tempo.metaflow.utils import running_aws_batch
174174

175-
if remote:
175+
classifier, s3_active = self.create_tempo_artifacts()
176+
if s3_active and running_aws_batch(self.tempo):
177+
print("Deploying to remote k8s cluster")
176178
self.deploy_tempo_remote(classifier)
177179
else:
180+
print("Deploying to local Docker")
178181
self.deploy_tempo_local(classifier)
179182

180183
self.next(self.end)

tempo/metaflow/utils.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any
22

3-
from metaflow import S3, FlowSpec, IncludeFile
3+
from metaflow import S3, FlowSpec, IncludeFile, Step
4+
from metaflow.plugins.aws.batch.batch_decorator import BatchDecorator
45

56

67
def save_artifact(model: Any, filename: str):
@@ -178,3 +179,22 @@ def save_pipeline_with_conda(pipeline, folder: str, conda_env: IncludeFile):
178179
with open(conda_env_path, "w") as f:
179180
f.write(conda_env)
180181
save(pipeline)
182+
183+
184+
def running_aws_batch(step: Step) -> bool:
185+
"""
186+
Test if a Step is running on AWS batch
187+
Parameters
188+
----------
189+
step The step to test
190+
191+
Returns
192+
-------
193+
True if flow is running on AWS Batch
194+
195+
"""
196+
running_on_aws_batch = False
197+
for deco in step.decorators: # pylint: disable=maybe-no-member
198+
if isinstance(deco, BatchDecorator):
199+
running_on_aws_batch = True
200+
return running_on_aws_batch

tempo/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.0"
1+
__version__ = "0.5.1"

0 commit comments

Comments
 (0)