Adrien Boutreau
05/10/2020, 3:52 PMMay 10th 2020 at 4:48:48pm | prefect.CloudTaskRunner
INFO
Task 'GetContainerLogs': finished task run for task with final state: 'Success'
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 ?Jenny
05/10/2020, 5:58 PMfrom prefect import task, Flow
@task(log_stdout=True)
def my_task():
print("This will be logged!")
flow = Flow("log-stdout", tasks=[my_task])
You can see more about logging in the docs here: https://docs.prefect.io/core/idioms/logging.html#logging-configuration-and-usageAdrien Boutreau
05/11/2020, 5:34 AMcontainer = 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()
josh
05/11/2020, 12:57 PMGetContainerLogs
task in the task library returns a result that looks like this:
api_result = client.logs(container=container_id).decode()
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.