class_docstr: TaskController inherits from BaseController and manages business logic associated with tasks
  within the project.
  
  Attributes
  ----------
  environment : datmo.core.controller.environment.environment.EnvironmentController
      used to create environment if new definition file
  snapshot : datmo.core.controller.snapshot.SnapshotController
      used to create snapshots before and after tasks
  
  Methods
  -------
  create(dictionary)
      creates a Task object with the permanent parameters
  _run_helper(environment_id, log_filepath, options)
      helper for run to start environment and run with the appropriate parameters
  run(self, id, dictionary=None)
      runs the task and tracks the run, logs, inputs and outputs
  list(sort_key=None, sort_order=None)
      lists all tasks within the project given filters
  delete(id)
      deletes the specified task from the project
docstr: Stop and remove run for the task and update task object statuses
  
  Parameters
  ----------
  task_id : str, optional
      id for the task you would like to stop
  all : bool, optional
      if specified, will stop all tasks within project
  
  Returns
  -------
  return_code : bool
      system return code of the stop
  
  Raises
  ------
  RequiredArgumentMissing
  TooManyArgumentsFound
docstr_tok: ["Stop","and","remove","run","for","the","task","and","update","task","object","statuses","Parameters","--","--","--","--","--","task_id",":","str",",","optional","id","for","the","task","you","would","like","to","stop","all",":","bool",",","optional","if","specified",",","will","stop","all","tasks","within","project","Returns","--","--","--","-","return_code",":","bool","system","return","code","of","the","stop","Raises","--","--","--","RequiredArgumentMissing","TooManyArgumentsFound"]
code: def stop(self, task_id=None, all=False, status="STOPPED"):
      """Stop and remove run for the task and update task object statuses
  
      Parameters
      ----------
      task_id : str, optional
          id for the task you would like to stop
      all : bool, optional
          if specified, will stop all tasks within project
  
      Returns
      -------
      return_code : bool
          system return code of the stop
  
      Raises
      ------
      RequiredArgumentMissing
      TooManyArgumentsFound
      """
      if task_id is None and all is False:
          raise RequiredArgumentMissing(
              __("error", "controller.task.stop.arg.missing", "id")
          )
      if task_id and all:
          raise TooManyArgumentsFound()
      if task_id:
          try:
              task_obj = self.get(task_id)
          except DoesNotExist:
              time.sleep(1)
              task_obj = self.get(task_id)
          task_match_string = (
              "datmo-task-" + self.model.id + "-" + task_id
          )
          # Get the environment id associated with the task
          kwargs = {"match_string": task_match_string}
          # Get the environment from the task
          before_snapshot_id = task_obj.before_snapshot_id
          after_snapshot_id = task_obj.after_snapshot_id
          if not before_snapshot_id and not after_snapshot_id:
              # TODO: remove...for now database may not be in sync. no task that has run can have NO before_snapshot_id
              time.sleep(1)
              task_obj = self.get(task_id)
          # TODO: fix stop function to handle stopping containers run from specific environment_ids
          # if after_snapshot_id:
          #     after_snapshot_obj = self.snapshot.get(after_snapshot_id)
          #     kwargs['environment_id'] = after_snapshot_obj.environment_id
          # if not after_snapshot_id and before_snapshot_id:
          #     before_snapshot_obj = self.snapshot.get(before_snapshot_id)
          #     kwargs['environment_id'] = before_snapshot_obj.environment_id
          return_code = self.environment.stop(**kwargs)
      if all:
          return_code = self.environment.stop(all=True)
      # Set stopped task statuses to STOPPED if return success
      if return_code:
          if task_id:
              self.dal.task.update({"id": task_id, "status": status})
          if all:
              task_objs = self.dal.task.query({})
              for task_obj in task_objs:
                  self.dal.task.update(
                      {"id": task_obj.id, "status": status}
                  )
  
      return return_code
  
imports: import os
  import time
  import shlex
  import threading
  import webbrowser
  from datetime import datetime
  from datmo.core.controller.base import BaseController
  from datmo.core.controller.snapshot import SnapshotController
  from datmo.core.controller.environment.environment import EnvironmentController
  from datmo.core.entity.task import Task
  from datmo.core.util.validation import validate
  from datmo.core.util.spinner import Spinner
  from datmo.core.util.i18n import get
  from datmo.core.util.exceptions import TaskRunError, RequiredArgumentMissing, ProjectNotInitialized, PathDoesNotExist, TaskInteractiveDetachError, TooManyArgumentsFound, EntityNotFound, DoesNotExist, TaskNoCommandGiven
label_desc: Use image node_id 13 for calling the TaskController obj's underlying member method code with example usage: obj.stop(task_id, all, status) and returns: return_code