Miksus / rocketry

Modern scheduling library for Python
https://rocketry.readthedocs.io
MIT License
3.28k stars 108 forks source link

Warning error #206

Open LecoOliveira opened 1 year ago

LecoOliveira commented 1 year ago

Very nice project man!! It's a pleasure to use it im my own project. But i have a little problem. When I run the tasks shows that message on the console:

UserWarning: Logger rocketry.task cannot be read. Logging is set to memory. To supress this warning, please set a handler that can be read (redbird.logging.RepoHandler)
  warnings.warn(
/home/alex/Documentos/Estudos/Palmeiras_News/.venv/lib/python3.10/site-packages/rocketry/session.py:364: UserWarning: Logger rocketry.task has too low level (WARNING). Level is set to INFO to make sure the task logs get logged.

My code:

repo = CSVFileRepo(filename='app/task.csv', model=MinimalRecord)

task_logger = logging.getLogger('rocketry.task')
handler = RepoHandler(repo=repo)
task_logger.addHandler(handler)

I already added the 'repo', am I doing something wrong?

OS: Linux Ubuntu 22.04 LTS Python version 3.10 Additional context

rocketry 2.5.1

oppenheimertoy commented 1 year ago

Hello, @LecoOliveira! Facing same issue with rocketry version 2.5.1. Killed about an hour to understand what i'm doing wrong. Here my code snippet

@app.setup()
def set_repo(logger=TaskLogger()):
    repo = SQLRepo(engine=create_engine(config.SQLALCHEMY_DATABASE_URI), 
                   table="tasks_logs", model=MinimalRecord, 
                   id_field="created",
                   if_missing="create")
    handler = RepoHandler(repo=repo)
    handler.setLevel(logging.DEBUG)
    logger = logging.getLogger("rocketry.task")
    logger.addHandler(handler)

I am using rocketry alongside with FastAPI application factory and my repo has been configured under @app.setup decorator.