Is it generally safe to run Flyte workflow from co...
# flyte-support
f
Is it generally safe to run Flyte workflow from code directly, e.g. from a FastAPI endpoint? Assuming that my pipeline does not have any side effects, can I just launch it like that?
Copy code
@workflow
def dummy_workflow(n: int) -> int:
    numbers = generate_numbers(n=n)
    squared_numbers = map_task(square)(x=numbers)
    total = sum_squares(squares=squared_numbers)
    return total


class Data(BaseModel):
    n: int = Field(ge=1, le=100)

@app.post("/workflow")
async def root(data: Data):
    result = dummy_workflow(n=data.n)
    return {
        "message": "Workflow executed",
        "result": result,
    }
The reason I'm asking is that I want to have a single pipeline abstraction across our code base
d
you can use flyteremote
f
better to use flyte remote to kick it of
today flyte has an inherent overhead in some cases, we are working on a potential full revamp that makes the entire overhead almost zero
f
But I want to run it locally, should I also use FlyteRemote abstractions then?
d
if you want to run locally
then just do what you are doing now
f
OK, thx!
@damp-lion-88352 Does invoking workflow like:
dummy_workflow(params...)
serialize data passed between tasks?
d
yes