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
Hi - What Is The Difference Between

Hi - what is the difference between task.mark_stopped() and task.close() ?

  
  
Posted 4 years ago
Votes Newest

Answers 3


TeenyFly97 the TL;DR is:
Task.close() should be called when you previously used Task.init (i.e the code creating the task)
Task.mark_stopped() should be called to stop a remote Task running.
I hope it helps 🙂

  
  
Posted 4 years ago

Hi TeenyFly97 ,

With task.close() the task will do a full shutdown process. This includes repo detection, logs, metrics and artifacts flush, and more. The task will not be the running task anymore and you can start a new task.

With task.mark_stopped() , the task logs will be flushed and the task will mark itself as stopped, but will not perform the full shutdown process, so the current_task will still be this task.

For example:
` from trains import Task

task = Task.init(project_name="example", task_name="task closed")

print(task.current_task().id) # will print first task id
task.close()
print(type(task.current_task())) # will print <class 'NoneType'>

task = Task.init(project_name="example", task_name="Second task")

print(task.current_task().id) # will print second task id This code will create two different tasks, and print(type(task.current_task())) line will print NoneType ` .

` from trains import Task

task = Task.init(project_name="example", task_name="task marked stopped")

print(task.current_task().id) # will print first task id
task.mark_stopped()
print(type(task.current_task())) # will print <class 'trains.task.Task'>
task = Task.init(project_name="example", task_name="Second task") # will raise trains UsageError exception This code will create only one task, and the print(type(task.current_task())) line will print the task object, but in the secondTask.init` call, we will get an exception.

  
  
Posted 4 years ago

Great, thanks!

  
  
Posted 4 years ago
1K Views
3 Answers
4 years ago
one year ago
Tags
Similar posts