Miksus / rocketry

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

BUG #221

Open evanraalte opened 1 year ago

evanraalte commented 1 year ago

Describe the bug I'm trying to run the example described here.

It seems that the do_things function is not executed, when running the example

The expected behaviour is

To Reproduce I modified the example a bit, so that files are touched and hence I can verify that the function do_things is run correctly.

main.py:

from rocketry import Rocketry
from pathlib import Path
app = Rocketry()

@app.task()
def do_things():
    Path("getting_here").touch()
if __name__ == "__main__":
    Path("getting_here_too").touch()
    app.session.run(do_things)

pyproject.toml:

[tool.poetry]
name = "rocketry_playground"
version = "0.1.0"
description = ""
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
rocketry = "^2.5.1"
pydantic = "^1.10"
sqlalchemy = "1.4.41"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Run:

poetry install
poetry run python main.py

Expected behavior I expect there to be two files added after the script runs:

Actual behavior

image

(note that the getting_here file is not generated.

evanraalte commented 1 year ago

Just fixed it by checking out the run method from app.session. It should be:

from rocketry import Rocketry
app = Rocketry()

@app.task()
def do_things():
    print("Getting here")

if __name__ == "__main__":
    app.session.run("do_things",)

Could you confirm that this is indeed the correct way to call it? If so, I can make a PR to update the docs.