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=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:
logging.info("Starting Flyte task with input: %d", x)
result = x + 1
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)