miniature-traffic-86643
07/03/2024, 2:03 PMimport pandas as pd
from sklearn.datasets import load_wine
from flytekit import task, workflow
from flytekit.configuration import ImageConfig, Config, SerializationSettings
from flytekit.types.pickle import FlytePickle
from flytekit.remote import FlyteRemote
# 🧱 @task decorators define the building blocks of your pipeline
@task
def get_data_new(x:int) -> pd.DataFrame:
"""Get the wine dataset."""
print('hi')
return load_wine(as_frame=True).frame
if __name__ == "__main__":
# FlyteRemote object is the main entrypoint to API
remote = FlyteRemote(
config=Config.auto(),
default_project="flytesnacks",
default_domain="development",
)
remote.register_task(
get_data_new,
serialization_settings=SerializationSettings(image_config=ImageConfig.auto(img_name="<http://ghcr.io/flyteorg/flytekit:py3.9-1.2.3|ghcr.io/flyteorg/flytekit:py3.9-1.2.3>")),
version="v2")
task = remote.fetch_task(name="get_data_new", version="v2")
remote.execute(
task,
inputs={'x':0}
)
ancient-wolf-19325
07/03/2024, 2:03 PM@task
decorator should be used correctly, and the remote.register_task
method should be called with the appropriate parameters. Additionally, the FlyteRemote
configuration and task execution should be properly set up.
Here's a corrected version of the code:
import pandas as pd
from sklearn.datasets import load_wine
from flytekit import task, workflow
from flytekit.configuration import ImageConfig, Config, SerializationSettings
from flytekit.types.pickle import FlytePickle
from flytekit.remote import FlyteRemote
# 🧱 @task decorators define the building blocks of your pipeline
@task
def get_data_new(x: int) -> pd.DataFrame:
"""Get the wine dataset."""
print('hi')
return load_wine(as_frame=True).frame
if __name__ == "__main__":
# FlyteRemote object is the main entrypoint to API
remote = FlyteRemote(
config=Config.auto(),
default_project="flytesnacks",
default_domain="development",
)
# Register the task
remote.register_task(
entity=get_data_new,
serialization_settings=SerializationSettings(image_config=ImageConfig.auto(img_name="ghcr.io/flyteorg/flytekit:py3.9-1.2.3")),
version="v2"
)
# Fetch the registered task
task = remote.fetch_task(name="get_data_new", version="v2")
# Execute the task
remote.execute(
task,
inputs={'x': 0},
wait=True
)
Key Changes:
1. Corrected Syntax: Changed ->
to ->
in the @task
decorator.
2. Image Configuration: Corrected the img_name
parameter in ImageConfig.auto
.
3. Register Task: Used the entity
parameter to register the task.
4. Execution: Added wait=True
to the remote.execute
method to wait for the task execution to complete.
For more details, refer to the FlyteRemote documentation.
Would you like more details on any specific part of the process?
Sources:
- FlyteRemote documentation
- FlyteRemote API Reference 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.freezing-airport-6809
freezing-airport-6809
miniature-traffic-86643
07/03/2024, 2:29 PMminiature-traffic-86643
07/03/2024, 2:30 PMfreezing-airport-6809
miniature-traffic-86643
07/03/2024, 2:33 PM