Slackbot
04/09/2024, 2:47 PMNate
04/09/2024, 2:49 PMPREFECT_DEFAULT_RESULT_STORAGE_BLOCK=gcs/my-gcs-block
Marvin
04/09/2024, 2:49 PMAndy Irvine
04/09/2024, 2:49 PMNate
04/09/2024, 2:50 PMAndy Irvine
04/09/2024, 2:51 PMNate
04/09/2024, 2:52 PMreturn
values for flow runs, independent of any work poolNate
04/09/2024, 2:53 PMpip install prefect-gcp
and make a GcsBucket
- perhaps @Marvin can find an example of thatMarvin
04/09/2024, 2:54 PMprefect-gcp
using pip (pip install prefect-gcp
) and then create a GcsBucket
. However, the example I found doesn't specifically utilize GcsBucket
, but it does demonstrate a basic Prefect flow structure. For a GcsBucket
example, I would need to run another search or check the Prefect GCP integration repository or documentation.
Nonetheless, the example code here is a simple Prefect deployment that uses serve.py
and looks like it's meant to provide an illustration of a Python script serving a Prefect flow and mapping tasks:
python
import time
from prefect import flow, task
from pydantic import BaseModel, Field
class Data(BaseModel):
key: str
value: dict = Field(default_factory=dict)
@task
def fetch_data_for_key(key: str) -> Data:
"""A task that simulates fetching data from some source"""
return Data(key=key, value={"data": "some data"})
@task
def process_data(data: Data) -> Data:
"""A task that simulates processing data"""
print(f"Processing {data!r} (I swear)")
time.sleep(3)
return data
@flow
def work_i_need_to_do_sometimes(keys: list[str]):
"""Work you might need to do ever so often"""
raw_data_futures = fetch_data_for_key.map(keys)
process_data.map(raw_data_futures)
if __name__ == "__main__":
work_i_need_to_do_sometimes.serve(
name="sporradic-deployment",
parameters={"keys": ["foo", "bar", "baz"]},
)
The original code doesn't include a GcsBucket
. If you need to see how to work with GcsBucket
specifically, I'd suggest searching for more examples related to GcsBucket
in GCP integrations. The example provided can be found in this GitHub repository.Nate
04/09/2024, 2:54 PMNate
04/09/2024, 2:55 PMAndy Irvine
04/09/2024, 2:56 PM