Lab 101: Use Open-Meteo API: - Authenticate your C...
# pacc-oct-16-17-2024
j
Lab 101: Use Open-Meteo API: • Authenticate your CLI to Prefect Cloud • Fine to use a personal account or an organization test workspace • Take a function that fetches data and make it a flow • Use .serve() method to deploy your flow • Run your flow from the UI • Create a schedule for your deployment • Shut down your server and restart it • Stretch 1: Run a deployment from the CLI, override the params API docs: open-meteo.com/en/docs Example: wind speed for the last hour: _weather.json()[“hourly”][“windspeed_10m”][0]_
m
I'm able to run a flow, but am getting this exception when I leave the flow running with
.serve()
, it throws this after maybe 10 seconds.
Copy code
+ Exception Group Traceback (most recent call last):
  |   File "/Users/mikthompson/projects/prefect_training/flowtest.py", line 10, in <module>
  |     test_flow.serve()
  |   File "/Users/mikthompson/projects/prefect_training/.venv/lib/python3.11/site-packages/prefect/flows.py", line 932, in serve
  |     asyncio.run(runner.start(webserver=webserver))
  |   File "/Users/mikthompson/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/asyncio/runners.py", line 190, in run
  |     return runner.run(main)
  |            ^^^^^^^^^^^^^^^^
  |   File "/Users/mikthompson/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/asyncio/runners.py", line 118, in run
  |     return self._loop.run_until_complete(task)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/Users/mikthompson/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
  |     return future.result()
  |            ^^^^^^^^^^^^^^^
  |   File "/Users/mikthompson/projects/prefect_training/.venv/lib/python3.11/site-packages/prefect/runner/runner.py", line 402, in start
  |     async with self as runner:
  |   File "/Users/mikthompson/projects/prefect_training/.venv/lib/python3.11/site-packages/prefect/runner/runner.py", line 1289, in __aexit__
  |     await self._exit_stack.__aexit__(*exc_info)
  |   File "/Users/mikthompson/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/contextlib.py", line 745, in __aexit__
  |     raise exc_details[1]
  |   File "/Users/mikthompson/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/python3.11/contextlib.py", line 728, in __aexit__
  |     cb_suppress = await cb(*exc_details)
  |                   ^^^^^^^^^^^^^^^^^^^^^^
  |   File "/Users/mikthompson/projects/prefect_training/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 763, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/Users/mikthompson/projects/prefect_training/.venv/lib/python3.11/site-packages/prefect/utilities/services.py", line 63, in critical_service_loop
    |     await workload()
    |   File "/Users/mikthompson/projects/prefect_training/.venv/lib/python3.11/site-packages/prefect/runner/runner.py", line 741, in _check_for_cancelled_flow_runs
    |     raise RuntimeError(
    | RuntimeError: Runner is not set up. Please make sure you are running this runner as an async context manager.
j
hmm. looking.
m
mentioned in other thread - updating from 3.0.9 to 3.0.10 fixed it
🙏 1
👍 1
🔥 1