Hello there. Did any of you had the same issue on ...
# pacc-oct-1-2-2024
n
Hello there. Did any of you had the same issue on using .serve(): AttributeError: 'Flow' object has no attribute 'serve'. The prefect version used is as below (for those of you that had it working, which version of prefect is used?)
m
What's the full code that's executing here?
n
Copy code
import httpx
from prefect import flow


@flow()
def fetch_weather(lat: float = 38.9, lon: float = -77.0):
    base_url = "<https://api.open-meteo.com/v1/forecast/>"
    temps = httpx.get(
        base_url,
        params=dict(latitude=lat, longitude=lon, hourly="temperature_2m"),
    )
    forecasted_temp = float(temps.json()["hourly"]["temperature_2m"][0])
    print(f"Forecasted temp C: {forecasted_temp} degrees")
    return forecasted_temp


if __name__ == "__main__":
    fetch_weather.serve(name="deploy-1")
as in 101\weather1-serve.py
j
This could happen if an old version of Prefect is being used. What does
prefect version
show?
n
It shows
j
Let’s troubleshoot in the first lab.