-
I have a list of tasks for a worker.py like this: from rocketry import Rocketry
from rocketry.args import Return
from app.stuff.folks import list_folks, save_new_folks
app = Rocketry()
app.task("daily between 22:00 and 23:00", func=list_folks,
execution="async", name="list_all_folks_from_external_system")
app.task("after task 'list_all_folks_from_external_system' succeeded",
func=save_new_folks, execution="async",
parameters={
"current_folks": Return("list_all_folks"),
},
name="create_new_company_folks")
app.task...
app.task..
app.task...
And so on...
if __name__ == '__main__':
app.run() How would you recommend importing those I was searching for some |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is actually something I'm creating at the very moment. Though I thought maybe But the short answer for current state of the framework is probably to make an But back to the groups, so I was thinking of implementing it like this: In a module that contains tasks (let's call it from rocketry import Grouper
from rocketry.conds import time_of_day
group = Grouper(
prefix="mytasks.", # Tasks will be named like "mytasks.task_name"
start_cond=time_of_day.between("08:00", "18:00"), # All tasks in this group must fulfill this condition as well to be allowed to start
execution="thread",
)
@group.task(...)
def my_task():
... Then in the main file: from rocketry import Rocketry
from module import group
app = Rocketry()
app.include_group(group) However, custom conditions and arguments might require some thinking. I'm also open to suggestions. Do you find |
Beta Was this translation helpful? Give feedback.
-
Glad to hear! I was thinking to make the groups even more functional (which was the reason I added the It kind of surprises me the possible use cases this feels to fit well. I have been thinking of creating a demo of talking bots (that communicate with each other), a simulation or a personal assistant at some point. The groundwork of the library is quite enormous but it's nice to see how well it paid off.
And this made my day :) |
Beta Was this translation helpful? Give feedback.
This is actually something I'm creating at the very moment. Though I thought maybe
Grouper
would be Rocketry's equivalent forRouter
from FastAPI and then there would be a method.include_group
. I think I'll do a simple implementation at first in which the group cannot be interacted after including them to an app but it would nice if we could disable a whole group at once or set all tasks in a group running at once. There also could be some conditions related to these like all tasks of a group has finished etc.But the short answer for current state of the framework is p…