Jeff S
07/29/2024, 6:56 PMtry:
logger = get_run_logger()
logger.setLevel(logging.INFO)
except MissingContextError:
# If there's no active Prefect context, use a standard Python logger
logger = logging.getLogger()
def run_single_pipeline(account_id: str, resource: str) -> Dict:
"""Run a single pipeline for a given account and resource"""
logger.info(f"Starting pipeline for account {account_id}, resource {resource}")
#...pipeline code
logger.info(f"Pipeline run successful for {account_id} - {resource}")
@task(persist_result=True)
def process_ads(account_id: str) -> Dict:
try:
result = run_single_pipeline(account_id, "ads")
logger.info(f"Pipeline result for table ads: {result}")
return result
except PrefectException as e:
logger.error(f"Pipeline error for table ads: {str(e)}")
raise # Re-raise the exception to mark the flow run as failed
Nate
07/29/2024, 7:18 PMtry:
logger = get_run_logger()
logger.setLevel(<http://logging.INFO|logging.INFO>)
except MissingContextError:
# If there's no active Prefect context, use a standard Python logger
logger = logging.getLogger()
if not, it seems you'd always end up with a standard logger (not a run logger) and so any records emitted by that logger would not get sent up to the APIJeff S
07/29/2024, 7:19 PMNate
07/29/2024, 7:20 PMlogger = get_run_logger()
inside the flow and then you shouldnt need the try/except
Jeff S
07/29/2024, 7:21 PMNate
07/29/2024, 7:21 PMJeff S
07/29/2024, 8:29 PM