code: def test_create_from_task(self):
      self.__setup()
      # 0) Test if fails with TaskNotComplete error
      # 1) Test if success with empty task files, results
      # 2) Test if success with task files, results, and message
      # 3) Test if success with message, label, config and stats
      # 4) Test if success with updated stats from after_snapshot_id and task_results
  
      # Create task in the project
      task_obj = self.task_controller.create()
  
      # 0) Test option 0
      failed = False
      try:
          _ = self.snapshot_controller.create_from_task(
              message="my test snapshot", task_id=task_obj.id
          )
      except TaskNotComplete:
          failed = True
      assert failed
  
      # 1) Test option 1
  
      # Create task_dict
      task_command = ["sh", "-c", "echo test"]
      task_dict = {"command_list": task_command}
  
      # Create environment definition
      env_def_path = os.path.join(
          self.project_controller.home, "Dockerfile"
      )
      with open(env_def_path, "wb") as f:
          f.write(to_bytes("FROM python:3.5-alpine"))
  
      updated_task_obj = self.task_controller.run(
          task_obj.id, task_dict=task_dict
      )
      after_snapshot_obj = self.task_controller.dal.snapshot.get_by_id(
          updated_task_obj.after_snapshot_id
      )
      environment_obj = self.task_controller.dal.environment.get_by_id(
          after_snapshot_obj.environment_id
      )
      self.environment_ids.append(environment_obj.id)
  
      snapshot_obj = self.snapshot_controller.create_from_task(
          message="my test snapshot", task_id=updated_task_obj.id
      )
  
      assert isinstance(snapshot_obj, Snapshot)
      assert snapshot_obj.id == updated_task_obj.after_snapshot_id
      assert snapshot_obj.message == "my test snapshot"
      assert snapshot_obj.stats == updated_task_obj.results
      assert snapshot_obj.visible == True
  
      # Create new task and corresponding dict
      task_obj = self.task_controller.create()
      task_command = ["sh", "-c", "echo accuracy:0.45"]
      task_dict = {"command_list": task_command}
  
      # Create environment definition
      env_def_path = os.path.join(
          self.project_controller.home, "Dockerfile"
      )
      with open(env_def_path, "wb") as f:
          f.write(to_bytes("FROM python:3.5-alpine"))
  
      # Test the default values
      updated_task_obj = self.task_controller.run(
          task_obj.id, task_dict=task_dict
      )
      after_snapshot_obj = self.task_controller.dal.snapshot.get_by_id(
          updated_task_obj.after_snapshot_id
      )
      environment_obj = self.task_controller.dal.environment.get_by_id(
          after_snapshot_obj.environment_id
      )
      self.environment_ids.append(environment_obj.id)
  
      # 2) Test option 2
      snapshot_obj = self.snapshot_controller.create_from_task(
          message="my test snapshot", task_id=updated_task_obj.id
      )
  
      assert isinstance(snapshot_obj, Snapshot)
      assert snapshot_obj.id == updated_task_obj.after_snapshot_id
      assert snapshot_obj.message == "my test snapshot"
      assert snapshot_obj.stats == updated_task_obj.results
      assert snapshot_obj.visible == True
  
      # 3) Test option 3
      test_config = {"algo": "regression"}
      test_stats = {"accuracy": 0.9}
      snapshot_obj = self.snapshot_controller.create_from_task(
          message="my test snapshot",
          task_id=updated_task_obj.id,
          label="best",
          config=test_config,
          stats=test_stats,
      )
  
      assert isinstance(snapshot_obj, Snapshot)
      assert snapshot_obj.id == updated_task_obj.after_snapshot_id
      assert snapshot_obj.message == "my test snapshot"
      assert snapshot_obj.label == "best"
      assert snapshot_obj.config == test_config
      assert snapshot_obj.stats == test_stats
      assert snapshot_obj.visible == True
  
      # 4) Test option 4
      test_config = {"algo": "regression"}
      test_stats = {"new_key": 0.9}
      task_obj_2 = self.task_controller.create()
      updated_task_obj_2 = self.task_controller.run(
          task_obj_2.id,
          task_dict=task_dict,
          snapshot_dict={"config": test_config, "stats": test_stats},
      )
      after_snapshot_obj = self.task_controller.dal.snapshot.get_by_id(
          updated_task_obj_2.after_snapshot_id
      )
      environment_obj = self.task_controller.dal.environment.get_by_id(
          after_snapshot_obj.environment_id
      )
      self.environment_ids.append(environment_obj.id)
  
      snapshot_obj = self.snapshot_controller.create_from_task(
          message="my test snapshot",
          task_id=updated_task_obj_2.id,
          label="best",
      )
      updated_stats_dict = {}
      updated_stats_dict.update(test_stats)
      updated_stats_dict.update(updated_task_obj.results)
  
      assert isinstance(snapshot_obj, Snapshot)
      assert snapshot_obj.id == updated_task_obj_2.after_snapshot_id
      assert snapshot_obj.message == "my test snapshot"
      assert snapshot_obj.label == "best"
      assert snapshot_obj.stats == updated_stats_dict
      assert snapshot_obj.visible == True
  
imports: import os
  import tempfile
  import platform
  from io import open, TextIOWrapper
  from datmo.config import Config
  from datmo.core.controller.project import ProjectController
  from datmo.core.controller.environment.environment import EnvironmentController
  from datmo.core.controller.task import TaskController
  from datmo.core.controller.snapshot import SnapshotController
  from datmo.core.entity.snapshot import Snapshot
  from datmo.core.util.exceptions import EntityNotFound, RequiredArgumentMissing, TaskNotComplete, InvalidArgumentType, ProjectNotInitialized, InvalidProjectPath, DoesNotExist, UnstagedChanges
  from datmo.core.util.misc_functions import check_docker_inactive, pytest_docker_environment_failed_instantiation
label_desc: Use image node_id 20 for calling the TestSnapshotController obj's underlying member method code with example usage: obj.test_create_from_task() without return types