class_docstr: EnvironmentController inherits from BaseController and manages business logic related to the
  environment.
  
  Methods
  -------
  create(dictionary)
      Create an environment within the project
  build(id)
      Build the environment for use within the project
  list()
      List all environments within the project
  delete(id)
      Delete the specified environment from the project
class_docstr_tok: ["EnvironmentController","inherits","from","BaseController","and","manages","business","logic","related","to","the","environment",".","Methods","--","--","--","-","create","(","dictionary",")","Create","an","environment","within","the","project","build","(","id",")","Build","the","environment","for","use","within","the","project","list","(",")","List","all","environments","within","the","project","delete","(","id",")","Delete","the","specified","environment","from","the","project"]
docstr: Checkout to specific environment id
  
  Parameters
  ----------
  environment_id : str
      environment id to checkout to
  
  Returns
  -------
  bool
      True if success
  
  Raises
  ------
  EnvironmentNotInitialized
      error if not initialized (must initialize first)
  PathDoesNotExist
      if environment id does not exist
  UnstagedChanges
      error if not there exists unstaged changes in environment
docstr_tok: ["Checkout","to","specific","environment","id","Parameters","--","--","--","--","--","environment_id",":","str","environment","id","to","checkout","to","Returns","--","--","--","-","bool","True","if","success","Raises","--","--","--","EnvironmentNotInitialized","error","if","not","initialized","(","must","initialize","first",")","PathDoesNotExist","if","environment","id","does","not","exist","UnstagedChanges","error","if","not","there","exists","unstaged","changes","in","environment"]
code: def checkout(self, environment_id):
      """Checkout to specific environment id
  
      Parameters
      ----------
      environment_id : str
          environment id to checkout to
  
      Returns
      -------
      bool
          True if success
  
      Raises
      ------
      EnvironmentNotInitialized
          error if not initialized (must initialize first)
      PathDoesNotExist
          if environment id does not exist
      UnstagedChanges
          error if not there exists unstaged changes in environment
  
      """
      if not self.is_initialized:
          raise EnvironmentNotInitialized()
      if not self.exists(environment_id):
          raise EnvironmentDoesNotExist(
              __(
                  "error",
                  "controller.environment.checkout_env",
                  environment_id,
              )
          )
      # Check if unstaged changes exist
      if self._has_unstaged_changes():
          raise UnstagedChanges()
      # Check if environment has is same as current
      results = self.dal.environment.query({"id": environment_id})
      environment_obj = results[0]
      environment_hash = environment_obj.unique_hash
  
      if self._calculate_project_environment_hash() == environment_hash:
          return True
      # Remove all content from project environment directory
      for file in os.listdir(
          self.environment_driver.environment_directory_path
      ):
          file_path = os.path.join(
              self.environment_driver.environment_directory_path, file
          )
          try:
              if os.path.isfile(file_path):
                  os.remove(file_path)
              elif os.path.isdir(file_path):
                  shutil.rmtree(file_path)
          except Exception as e:
              print(e)
      # Add in files for that environment id
      file_collection_obj = self.dal.file_collection.get_by_id(
          environment_obj.file_collection_id
      )
      environment_definition_path = os.path.join(
          self.home, file_collection_obj.path
      )
      # Copy to temp folder and remove files that are datmo specific
      _temp_env_dir = get_datmo_temp_path(self.home)
      self.file_driver.copytree(
          environment_definition_path, _temp_env_dir
      )
      for (
          filename
      ) in self.environment_driver.get_datmo_definition_filenames():
          os.remove(os.path.join(_temp_env_dir, filename))
      # Copy from temp folder to project environment directory
      self.file_driver.copytree(
          _temp_env_dir,
          self.environment_driver.environment_directory_path,
      )
      shutil.rmtree(_temp_env_dir)
      return True
  
imports: import os
  import shutil
  from datmo.core.controller.base import BaseController
  from datmo.core.controller.file.file_collection import FileCollectionController
  from datmo.core.entity.environment import Environment
  from datmo.core.util.i18n import get
  from datmo.core.util.validation import validate
  from datmo.core.util.spinner import Spinner
  from datmo.core.util.json_store import JSONStore
  from datmo.core.util.misc_functions import get_datmo_temp_path, list_all_filepaths
  from datmo.core.util.exceptions import PathDoesNotExist, RequiredArgumentMissing, TooManyArgumentsFound, EnvironmentNotInitialized, UnstagedChanges, ArgumentError, EnvironmentDoesNotExist, ProjectNotInitialized
label_desc: Use image node_id 17 for calling the EnvironmentController obj's underlying member method code with example usage: obj.checkout(environment_id) and returns: True, True