Hi Team, I'm evaluating Prefect as data flow pipel...
# ask-community
g
Hi Team, I'm evaluating Prefect as data flow pipeline and started learning and trying out. My setup is Prefect Server, LocalAgent running inside a docker and creating task from jupyter Notebook and registering flow using S3 storage. I could all but when I run getting error "Failed to load and execute Flow's environment: AttributeError("'NoneType' object has no attribute 'setup'")"I know making some simple mistake, any help would be appreciated. Flow is simple hello world. Since my prefect server running remote, I couldn't find option to pass API url to flow, hence created client and used to register, registration works. here is my code for that. import prefect from prefect import task, Flow, client from prefect.storage import Local from prefect.storage import S3 clientP = client.Client(api_server="API URL") storage = S3(bucket="bucket",client_options={"aws_access_key_id" : "awsaccesskeyidXXX", "aws_secret_access_key" : "awssecretaccesskey"}) @task def say_hello():     logger = prefect.context.get("logger")     logger.info("Hello, Cloud!") with Flow("hello-flow",storage=storage) as flow:     say_hello() # Register the flow under the "tutorial" project clientP.register(flow,"learning")
m
Hello Gopinath! I believe you are looking for something similar to this:
Copy code
import prefect
from prefect import task, Flow

from prefect.storage import S3


storage = S3(bucket="bucket",client_options={"aws_access_key_id" : "awsaccesskeyidXXX", "aws_secret_access_key" : "awssecretaccesskey"})

@task
def say_hello():
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("Hello, Cloud!")

with Flow("hello-flow",storage=storage) as flow:
    say_hello()

flow.register(project_name="learning")
g
Hi Mariia, Thanks. Yes but When I tried to register to Prefect Server running in different remote server above failed.. Hence I used Client and set api url and then register.
m
I see. Did you make any changes to config.toml file? It’s located in
~/.prefect/config.toml
?
Copy code
[server]
  host = "<ip_API>"
  port = "4200"
  endpoint = "${server.host}:${server.port}"
Run
prefect backend server
too.
g
Thanks Mariia. That worked.
m
Awesome, glad to hear 🙂
g
@Mariia Kerimova One help. i'm trying to use aws.s3.s3download task, any examples would really help.
m
Copy code
from prefect.tasks.aws.s3 import S3Download
from prefect import task, Flow

result = S3Download(bucket="<bucket_name>")

@task(log_stdout=True)
def print_result(content):
    print(content)

with Flow("S3Download") as flow:
    content = result(key="index.html")
    print_result(content)

flow.run()
g
Thanks it worked. Unfortunately my use case didn't allow this flow. My usecase require Apache Arrow feather or Apache Arrow to be passed between task. How can I implement this extension and can give pull request
j
Hi Gopinath, Prefect is data format agnostic, if you're passing data between tasks you can use whatever object types you want. If you're writing data to disk (as e.g. a feather file) you can use whatever python libraries you'd want to access them in downstream tasks. What features are you expecting from prefect here for interacting with feather/arrow?
g
Thanks Jim, Let me tried out and come back of any issues.