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
I Wonder What Is The Best Practice Today To Fetch A Model From Another Task By Models Name Or Id ? Currently, I See This Can Be Done As

I wonder what is the best practice today to fetch a model from another task by models name or id ?
Currently, I see this can be done as
` from clearml import Task

training_task_id = "xyz"
model_name = "exp_name: model_name"

training_task = Task.get_task(training_task_id)
model = None

for m in training_task.get_models()["output"]:
if m.name == model_name:
model = m

assert model is not None
model.name, model.get_local_copy() `However, it is a bit too verbose...

  
  
Posted 3 years ago
Votes Newest

Answers 3


well, if you know your model id you can simplify things a little bit.
mdl = clearml.Model(model_id)
m_output = mdl.get_local_copy()

  
  
Posted 3 years ago

Thanks UptightCoyote42 !

  
  
Posted 3 years ago

Well, it's a little verbose, I agree 🙂
I'm sure you know, but for the community's sake I'll just say it's possible to use a more pythonic syntax instead of the for loop:
model = next(m for m in Task.get_task(training_task_id).get_models()["output"] if m.name == model_name)This will raise StopIteration error if no such model is found, or alternatively:
model = next((m for m in Task.get_task(training_task_id).get_models()["output"] if m.name == model_name), None)Which will return None is not model is found

  
  
Posted 3 years ago
945 Views
3 Answers
3 years ago
one year ago
Tags