Unanswered
Hi, Guys
Can I Run A Task In Task?
I Have Task, If That Ended, It Will Start To Run Another Task Remotely.
Thanks In Advance!
Thanks for response.
from clearml import Task
from clearml.automation import TaskScheduler
from datetime import timedelta, datetime
def my_task():
task = Task.init(...)
# do somthinge
print("do something")
# sleep 10
condition = True
if condition:
# i want to trigger run another task by
# set some config in task, but execute tomorrow/sometime
# not directly run at the time.
# here i use
task_id = task.id
task.close()
task_clone:Task = Task.get_task(task_id=task_id)
# schedule running a task for tomorrow
now = datetime.utcnow()
schedule_time = now + timedelta(days=1, minutes=30)
hour = schedule_time.hour
minute = schedule_time.minute
scheduler = TaskScheduler(
sync_frequency_minutes=60,
force_create_task_name='Scheduler Task',
force_create_task_project='Automation/Controller',
)
# here i run my task
scheduler.add_task(
target_project=task_clone.project,
queue='cpu-nomad-preprod',
name=task_clone.name,
schedule_task_id=task_clone.id,
minute=minute,
hour=hour,
day=1,
recurring=False,
task_parameters ={
"params/limit_per_day": params["limit_per_day"], # limit perday, before 15k
"params/csv_url": params["csv_url"],
"params/zoom_level": params["zoom_level"],
"params/pond_type": params["pond_type"],
},
single_instance=True
)
pass
print("task end")
i tried do that, but it seems cannot do. do you have another solutions?
100 Views
0
Answers
9 months ago
9 months ago