Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Is It Possible To Set An Environment Variable For A Task?

Is it possible to set an environment variable for a task?

  
  
Posted 3 years ago
Votes Newest

Answers 30


Will debug a bit more and see what’s up

  
  
Posted 3 years ago

It’s a task, it’s running in context of a project, but I don’t have a way to get the project name

  
  
Posted 3 years ago

(I need this because I refer to datasets in the same project but without specifying the project name)

  
  
Posted 3 years ago

It’s essentially this now:

from clearml import Task print(Task.current_task())

  
  
Posted 3 years ago

TrickySheep9 can I see your code? Or at least the relevant part?

  
  
Posted 3 years ago

task.get_project_name()

  
  
Posted 3 years ago

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?

  
  
Posted 3 years ago

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?

  
  
Posted 3 years ago

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?

  
  
Posted 3 years ago

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

  
  
Posted 3 years ago

And exact output after the package install and stuff:

Environment setup completed successfully Starting Task Execution: None

  
  
Posted 3 years ago

How can a task running like this know its own project name?

  
  
Posted 3 years ago

But that itself is running in a task right?

  
  
Posted 3 years ago

The first line of it is getting a dataset and it’s failing with no project name

  
  
Posted 3 years ago

This worked well:

if project_name is None and Task.current_task() is not None: project_name = Task.current_task().get_project_name()

  
  
Posted 3 years ago

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

  
  
Posted 3 years ago

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)

  
  
Posted 3 years ago

Thoughts AgitatedDove14 SuccessfulKoala55 ? Some help would be appreciated.

  
  
Posted 3 years ago

AS in clone the task from the UI and run it

  
  
Posted 3 years ago

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.

  
  
Posted 3 years ago

Sure:
task.get_project_name()

  
  
Posted 3 years ago

Is there a good way to get the project of a task?

  
  
Posted 3 years ago

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

  
  
Posted 3 years ago

Am I missing something?

  
  
Posted 3 years ago

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 ?

  
  
Posted 3 years ago

I get other things from the project like the dataset

  
  
Posted 3 years ago

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?

  
  
Posted 3 years ago

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

  
  
Posted 3 years ago

You mean Task.clone() API call failed ?

  
  
Posted 3 years ago