little-printer-49833
04/10/2025, 2:22 PMcareful-australia-19356
04/15/2025, 5:29 PMlogging
library to dump logs to the terminal
An example
import logging
from flytekit import task, workflow
# Configure the logger
logging.basicConfig(
level=<http://logging.INFO|logging.INFO>, # Set the log level
format='%(asctime)s - %(levelname)s - %(message)s', # Set the log format
handlers=[
logging.StreamHandler(), # Output logs to the console
logging.FileHandler('flyte_local_execution.log') # Output logs to a file
]
)
# Define a Flyte task with logging
@task
def my_flyte_task(x: int) -> int:
<http://logging.info|logging.info>("Starting Flyte task with input: %d", x)
result = x + 1
<http://logging.info|logging.info>("Completed Flyte task with result: %d", result)
return result
# Define a Flyte workflow
@workflow
def my_flyte_workflow(x: int) -> int:
return my_flyte_task(x=x)