I tried and it isn’ table to run the task, the cod...
# flyte-support
a
I tried and it isn’ table to run the task, the code is from the doc:
Copy code
# hello.py

# /// script
# requires-python = "==3.13"
# dependencies = [
#    "flyte==0.2.0b23",
# ]
# ///

import flyte

# A TaskEnvironment provides a way of grouping the configuration used by tasks.
env = flyte.TaskEnvironment(name="hello_world", resources=flyte.Resources(memory="250Mi"))

# Use a TaskEnvironment to define tasks, which are regular Python functions.
@env.task
def fn(x: int) -> int: # Type annotations are recommended.
    slope, intercept = 2, 5
    return slope * x + intercept

# Tasks can call other tasks.
# All tasks defined with a given TaskEnvironment will run in their own separate containers,
# but those containers will all be configured identically.
@env.task
def main(x_list: list[int]) -> float:

    x_len = len(x_list)
    if x_len < 10:
        raise ValueError(f"x_list doesn't have a larger enough sample size, found: {x_len}")

    # flyte.map is like Python map, but runs in parallel.
    y_list = list(flyte.map(fn, x_list))
    y_mean = sum(y_list) / len(y_list)
    return y_mean

# Running this script locally will perform a flyte.run, sending your task code to your remote Union/Flyte instance.
if __name__ == "__main__":

    # Establish a remote connection from within your script.
    flyte.init_from_config("config.yaml")
    #flyte.init(project="flytesnacks", domain="development", endpoint="localhost:30080",insecure=True,insecure_skip_verify=False)

    # Run your tasks remotely inline and pass parameter data.
    run = flyte.run(main, x_list=list(range(10)))
    # x= flyte.with_runcontext(mode="local").run(main, x_list=list(range(10)))
    # print(x)

    # Print various attributes of the run.
    print(run.name)
    print(run.url)

    # Stream the logs from the remote run to the terminal.
    run.wait(run)
f
It is not yet
The APIs have changed
This is WIP
But happy to get you onto a union backend
a
I am just testing out. Don’t want to spend dollars. I know you have $30 free sign up
f
Nope that is v1 too
Feel free to use v1
👍 1
r
oh interesting, is there gonna be sandbox available before flyte 2.0 exits beta? and/or helm chart?
f
Sandbox yes
r
👍 👍 in the interim if a user wants to write some Flyte stuffs that is easiest to transfer to Flyte 2.0, is it best to stick with the 1.15 "eager" API?
(and just to be clear: there is no public back-end yet at the
flyteorg/flyte
repo?)
f
Flyte 2.0 will be the future
But today you can write 1.0
a
I agree. Considering Flyte v1 i like Flyte 2. But just my personal opinion. Beauty lies in simplicity !!!
f
That is the entire goal, make it so simple that people can ramp, use and grow on their own
But making things simple is hard