Adrien Boutreau05/10/2020, 3:52 PM
May 10th 2020 at 4:48:48pm | prefect.CloudTaskRunner
which is cool 🙂 but I don't have any print done by my job itself - now if I check log file (in folder .prefect/results) in console I can see all prints done by my job - Do you know how I can have it in UI ?
Task 'GetContainerLogs': finished task run for task with final state: 'Success'
Jenny05/10/2020, 5:58 PM
You can see more about logging in the docs here: https://docs.prefect.io/core/idioms/logging.html#logging-configuration-and-usage
from prefect import task, Flow @task(log_stdout=True) def my_task(): print("This will be logged!") flow = Flow("log-stdout", tasks=[my_task])
Adrien Boutreau05/11/2020, 5:34 AM
container = CreateContainer( image_name="img:latest", command='''python myjob.py''', ) start = StartContainer() logs = GetContainerLogs(trigger=always_run) status_code = WaitOnContainer() schedule = IntervalSchedule(interval=timedelta(hours=1)) #schedule = Schedule(clocks=[CronClock("0 7 * * *")]) with Flow("flow", schedule) 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.register()
josh05/11/2020, 12:57 PM
task in the task library returns a result that looks like this:
Since the logs are retrieved you should add a downstream task that does something with the result of that task where you can filter, save, output, etc.
api_result = client.logs(container=container_id).decode()