Daryl
01/28/2024, 6:17 AMsubmit_as_runner
feature in 2.4.17
I was super happy to see this feature make it into the latest release but am trying to figure out how to make it work for a simple use case.
https://github.com/PrefectHQ/prefect/releases/tag/2.14.17
I have a simple list of files I want to submit to a subflow (which must process sycronously, not async) and want to have the web server parallel run those to so some scientific processing.
Based on the example in releaase notes (which were, um... complex for this simpel case), I am figuring I should be able to do the following:
@flow(log_prints=True)
def ingest():
path = "/data/staging/obj"
files = file_checker(path) # file_checker is a task
submit_to_runner(
sci_processing, [{"file": file} for file in files]
)
wait_for_submitted_runs()
And see the runners spin up multiple runs of the sci_processing.through the subflow sci_processing
.
(I'm having a bit of trouble with spinning up the webserver runners at the mo, cause I'm not sure prefect config set ...
is working as advertised, but before going down this bunny hole, does anyone see a problem with the above as an approach?Nate
01/28/2024, 2:47 PMPREFECT_EXPERIMENTAL_ENABLE_EXTRA_RUNNER_ENDPOINTS=true
PREFECT_RUNNER_SERVER_ENABLE=true
what issues are you encountering? your example makes sense to me as shown aboveDaryl
01/28/2024, 4:53 PMprefect config set
command.
I'm getting a
ERROR: [Errno 99] error while attempting to bind on address ('::1', 8080, 0, 0): cannot assign requested address
when spinning it up on docker compose with two docker containers (server and
cli) from PrefectHQ/prefect
even with the ports 8080 exposed in the
docker compose ports directive.
Any ideas as to what may be wrong here?
(do I need a separate docker container in the compose for the Runner?)Nate
01/28/2024, 4:55 PMNate
01/28/2024, 4:56 PMDaryl
01/30/2024, 2:35 PMdocker exec
and shell into the cli version - this is how I usually submit my flows, I get the
ERROR: [Errno 99] error while attempting to bind on address ('::1', 8080, 0, 0): cannot assign requested address
which happends when I run the python -i atlas_ingest.py
, it deploys (when I get the error, but normally I'd do this and then run the atlas_ingest()
function.
I've checked in the docker compose and I do have port 8080 open on the docker server, so imagine it's some other issue here though a bit stumped.
The docker-compose.yml is below for reference.
version: "3.9"
services:
### Prefect Server API and UI
server:
image: prefecthq/prefect:2.14.17-python3.11
restart: always
volumes:
- prefect:/root/.prefect
- ./data/staging:/data/staging
# - /data/staging:/data/staging
entrypoint: ["/opt/prefect/entrypoint.sh", "prefect", "server", "start"]
environment:
- PREFECT_UI_URL=<http://127.0.0.1:4200/api>
- PREFECT_API_URL=<http://127.0.0.1:4200/api>
# If you want to access Prefect Server UI from anywhere other than the Docker host machine, you will need to change
# PREFECT_UI_URL and PREFECT_API_URL to match the external hostname/IP of the host machine. For example:
#- PREFECT_UI_URL=<http://external-ip:4200/api>
#- PREFECT_API_URL=<http://external-ip:4200/api>
- PREFECT_SERVER_API_HOST=0.0.0.0
# - PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://postgres:postgres@database:5432/prefect>
- PREFECT_API_DATABASE_CONNECTION_URL=sqlite+aiosqlite:////root/.prefect/prefect.db
# Uncomment the following line if you want to use the 'S3 Bucket' storage block instead of the older 'S3' storage
- EXTRA_PIP_PACKAGES=astropy prefect-sqlalchemy psycopg2-binary datetime httpx
ports:
- 4200:4200
- 8080:8080
### Prefect CLI
cli:
image: prefecthq/prefect:2.14.17-python3.11
working_dir: /root/flows
volumes:
- ./flows:/root/flows
- ./data/staging:/data/staging
# - /data/staging:/data/staging
environment:
- PREFECT_API_URL=<http://server:4200/api>
# Use PREFECT_API_KEY to use the CLI to interact with Prefect Cloud
# - PREFECT_API_KEY=YOUR_API_KEY
- EXTRA_PIP_PACKAGES=astropy prefect-sqlalchemy psycopg2-binary datetime httpx
# profiles: ["cli"]
command: tail -f /dev/null
volumes:
prefect:
db:
# minio:
networks:
default:
name: prefect-network
Nate
01/30/2024, 2:38 PMmain
and seeing if that fixes your problem? we may have introduced a slight bug in the default settings around this that we reverted yesterday but have not yet releasedDaryl
01/30/2024, 2:40 PMDaryl
01/30/2024, 2:41 PMDaryl
01/30/2024, 2:42 PMNate
01/30/2024, 2:42 PMDaryl
01/30/2024, 2:43 PMDaryl
01/30/2024, 2:48 PMDaryl
01/31/2024, 12:54 AMNate
01/31/2024, 1:14 AMDaryl
01/31/2024, 4:16 AMprefect config set PREFECT_EXPERIMENTAL_ENABLE_EXTRA_RUNNER_ENDPOINTS=True
and the
prefect config set PREFECT_RUNNER_SERVER_ENABLE=True
I can see them set that way in my settings.
I've also set the docker ports for the wwebserver container to expose 8080:8080.
However, when I run my deployment< i am getting the following error on the run:
File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 355, in _run_async
result = await coro
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/prefect/runner/submit.py", line 135, in submit_to_runner
raise ValueError(
ValueError: The `submit_to_runner` utility requires the `Runner` webserver to be running and built with extra endpoints enabl
ed. To enable this, set the `PREFECT_EXPERIMENTAL_ENABLE_EXTRA_RUNNER_ENDPOINTS` setting to `True`.
03:34:38.685 | ERROR | Flow run 'practical-cockatoo' - Finished in state Failed('Flow run encountered an exception. ValueEr
ror: The `submit_to_runner` utility requires the `Runner` webserver to be running and built with extra endpoints enabled. To
enable this, set the `PREFECT_EXPERIMENTAL_ENABLE_EXTRA_RUNNER_ENDPOINTS` setting to `True`.')
03:34:39.037 | INFO | prefect.flow_runs.runner - Process for flow run 'practical-cockatoo' exited cleanly.
For whatever reason, even with the cofigs set, it still seems to not believe that runner is set (to be sure, I set it on both the server and the cli container.Nate
01/31/2024, 4:18 AMDaryl
01/31/2024, 4:27 AMdocker compose up -d
to get both to stand up, then doccker exec
into the shell of the cli container and run the python file.
II also just switched over the serve satement to be precisely like yours which still throws the ERR so for some reason Runner is either blocked in starting or not starting at all.Daryl
01/31/2024, 4:29 AM@flow(log_prints=True)
def atlas_ingest():
atlas_path = "/data/staging/atlas/obj"
files = file_checker(atlas_path)
submit_to_runner(
sci_backend_processing, [{"file": file} for file in files]
)
wait_for_submitted_runs()
and this handy bit Icopied from your test file:
if __name__ == "__main__":
serve(atlas_ingest.to_deployment(__file__), limit=10, webserver=True)
Daryl
01/31/2024, 4:30 AMNate
01/31/2024, 4:37 AMDaryl
01/31/2024, 4:47 AMDaryl
01/31/2024, 4:48 AMDaryl
01/31/2024, 5:04 AMNate
01/31/2024, 5:06 AMDaryl
01/31/2024, 2:34 PMDaryl
02/02/2024, 3:02 AMNate
02/02/2024, 5:22 AMDaryl
02/02/2024, 5:29 AMDaryl
02/02/2024, 5:32 AMDaryl
02/02/2024, 5:32 AMDaryl
02/02/2024, 12:51 PMdocker compose
. I managed to run the simulated work tasks from the deployment (so, yey!!!), but on the docker compose up
I got the following errors. However, running the flow from the deployment UI interface worked fine.
I'm going to try to adapt what you did to my ingest pipeline and see what happens. Will update you later, but just thought you'd want to know about the solid progress. Def looks like the simulated work is runing in parallel
Error log from the cli spin up of docker compose after it pulled 2.14.20.
Pretty sure it was related to your flow code though as it went away when Itried using my code.Daryl
02/03/2024, 2:19 AMNate
02/03/2024, 2:21 AMNate
02/03/2024, 2:22 AMDaryl
02/03/2024, 2:33 AMSarah Krasnik
02/07/2024, 12:03 AM