Hello all, I have a flow that creates a container,...
# ask-community
m
Hello all, I have a flow that creates a container, starts the container, and grabs the container logs. Unfortunately I cannot seem to output logging infomation to where Prefect Server UI can see them. What am I doing wrong? Code and visualization will be in the thread
container = CreateContainer(
image_name="integration_app:latest",
host_config={"binds": ["/home/mblau/projects/integration/:/app"]},
volumes= "/home/mblau/projects/ispottv-integration/:/app",
environment={f"PREFECT__CONTEXT__SECRETS__{k}": v for k, v in config.context.secrets.items()},
command= "python3 /app/integration.py"
)
start = StartContainer()
logs = GetContainerLogs(trigger=always_run)
status_code = WaitOnContainer()
## set task dependencies via functional API
with Flow("Run a Prefect Flow in Docker") as flow:
start_container = start(container_id=container)
code = status_code(container_id=container, upstream_tasks=[start_container])
collect_logs = logs(container_id=container, upstream_tasks=[code])
## run flow and print logs
#flow_state = flow.run()
print("=" * 30)
print("Container Logs")
print("=" * 30)
from prefect import config
#flow.run_config = LocalRun(env={f"PREFECT__CONTEXT__SECRETS__{k}": v for k, v in config.context.secrets.items()})
#print(flow_state.result[collect_logs].result)
flow.register(project_name= "Test Project")
flow.visualize()
This is my flow visualized
The docker image I am using has prefect as the base image so I can use Local Secrets within the container. I was also hoping to be able to have logs from the image being shown in the UI
https://github.com/PrefectHQ/prefect/commit/abaf4e57950e56383aafe58b7a816438188b1f95 this is the closest thing I have seen on the github, but I am not completely sure how to use?