Have a wrapper over Task to ensure S3 usage, tags, version number etc and project name can be skipped and it picks from the env var
Cool. Notice that when you clone the Task and the agents executes it, the project is already defined, so this env variable is meaningless, no ?
This worked well:
if project_name is None and Task.current_task() is not None: project_name = Task.current_task().get_project_name()
I get other things from the project like the dataset
Is there a good way to get the project of a task?
Looks like Task.current_task() is indeed None in this case. Bit of log below where I print(Task.current_task()) as first step in the script
Environment setup completed successfully Starting Task Execution: None
AgitatedDove14 - the actual replication failed. When we run a task by cloning and enqueueing, there is a current task even if I am yet to do a Task.init right?
yeah i was trying in local and it worked as expected. But in local I was creating a Task first and then seeing if it’s able to get project name from it
if project_name is None and Task.current_task() is not None: project_name = Task.current_task().get_project_name()
This should have fixed it, no?
The first line of it is getting a dataset and it’s failing with no project name
AS in clone the task from the UI and run it
TrickySheep9 , this script would indeed not have a current task - such a task is created using Tasl.init()
- if you didn't call it, it won't be there
As in I am cloning a task and running it and in that takes without doing any Task.init i am trying to get the task that is running
And exact output after the package install and stuff:
Environment setup completed successfully Starting Task Execution: None
It’s essentially this now:
from clearml import Task print(Task.current_task())
Thoughts AgitatedDove14 SuccessfulKoala55 ? Some help would be appreciated.
TrickySheep9 can I see your code? Or at least the relevant part?
But that itself is running in a task right?
SuccessfulKoala55 AgitatedDove14 - this is the example I recreated in demo server - https://demoapp.trains.allegro.ai/projects/ce59885cb4df4cd1afa34aa5b593bb54/experiments/58e02b02d1714f58a590e2335a0f2ab7/execution?columns=selected&columns=type&columns=name&columns=tags&columns=status&columns=project.name&columns=users&columns=started&columns=last_update&columns=last_iteration&columns=parent.name&order=-last_update
Task.init()
will know if you're running locally (and so a new task should be created) or remotely (in case the current task is the one being executed remotely)
Well, the SDK is only aware it's a task if you call Task.init()
. If not, you can fetch tasks using Task.get_task()
, but none of them will be the current.
Essentially - 1. run a task normally. 2. clone 3. edit to have only those two lines.
Question - since this is a task, why is Task.currnet_task() None?
Again, I'm not sure I understand your meaning. You're cloning a task and running it using an agent? That task has task = Task.init()
in it?
It’s a task, it’s running in context of a project, but I don’t have a way to get the project name
(I need this because I refer to datasets in the same project but without specifying the project name)
How can a task running like this know its own project name?