Adam Lineberry
11/21/2024, 3:23 AMAdam Lineberry
11/21/2024, 3:28 AM@task
and @flow
decorators. I import the flow function in another file and run
from prefect import serve
from my_module import my_flow
serve(
my_flow.to_deployment(name=..., cron=...)
)
I run the prefect server locally with systemd
Let me know if more info is needed.Nate
11/21/2024, 4:07 PMlogging.yaml
file and then set the setting to tell prefect to use itAdam Lineberry
11/22/2024, 2:13 PMhandlers:
# Add Logfire handler
logfire:
level: 0
class: logfire.LogfireLoggingHandler
formatter: standard
loggers:
prefect:
level: "${PREFECT_LOGGING_LEVEL}"
prefect.flow_runs:
level: NOTSET
handlers: [api, logfire] # Added logfire
prefect.task_runs:
level: NOTSET
handlers: [api, logfire] # Added logfire
I set the environment variables:
PREFECT_LOGGING_LEVEL='INFO'
PREFECT_LOGGING_CONFIG_PATH='/home/adam/.prefect/logging.yml'
Added the logfire configure line in the .py file that defines the tasks and flow:
from prefect import flow, task
import logfire
logfire.configure(send_to_logfire=False, config_dir=os.environ['...'])
@task
def ingest_task():
...
@task
def train_model_task():
...
@flow
def nightly_flow():
ingest_task()
train_model_task()
And then serve that flow with another .py file
from prefect import serve
from nightly.pilot_model_nightly import nightly_flow
if __name__ == '__main__':
serve(
nightly_flow.to_deployment(name='pilot_model_nightly', cron='0 9 * * 1-5')
)
Adam Lineberry
11/22/2024, 2:14 PMNate
11/22/2024, 3:51 PMAdam Lineberry
11/26/2024, 9:08 AMlogging.StreamHandler
. The only commonality they have is that they all propagate up to the root logger. It seems to me like I need to somehow hook into the root logger and forward all log records it receives to the prefect logger in order to accomplish what I'm trying to.
How does the solution you proposed accomplish this? I don't understand how adding a new handler to the prefect loggers addresses logging messages from my other loggers and these loggers are disconnected and adding a handler doesn't connect them.
Thanks for your help.