I can not cancel a running task

Hello, I am running a task using Ray but I am unable to cancel it. Attached is my code in Python. Any clue why is that and would you please provide the reason and the solution for that? Thank you

Currently, you need to cancel the task from the task submitter process.

Thank you for getting back @RayAdmin. Would you please provide hint or documentation how to achieve it?

ray.cancel doesn’t accept task id. you need to pass object ref created from run_ray_train_job.

ref = run_ray_train_job.remote()
ray.cancel(ref)