Skip to content

Instantly share code, notes, and snippets.

@vsergeyev
Created February 10, 2022 09:58
Show Gist options
  • Save vsergeyev/8080b0c9d789e45aec5d04710935cb50 to your computer and use it in GitHub Desktop.
Save vsergeyev/8080b0c9d789e45aec5d04710935cb50 to your computer and use it in GitHub Desktop.
import ray
from ray import workflow
from typing import List
@workflow.step
def read_data(num: int):
return [i for i in range(num)]
@workflow.step
def preprocessing(data: List[float]) -> List[float]:
return [d**2 for d in data]
@workflow.step
def aggregate(data: List[float]) -> float:
return sum(data)
# Initialize workflow storage.
workflow.init()
# Setup the workflow.
data = read_data.step(10)
preprocessed_data = preprocessing.step(data)
output = aggregate.step(preprocessed_data)
# Execute the workflow and print the result.
print(output.run())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment