docstr: Create a new Task from an existing code base.
  If the code does not already contain a call to Task.init, pass add_task_init_call=True,
  and the code will be patched in remote execution (i.e. when executed by `clearml-agent`
  
  :param project_name: Set the project name for the task. Required if base_task_id is None.
  :param task_name: Set the name of the remote task. Required if base_task_id is None.
  :param task_type: Optional, The task type to be created. Supported values: 'training', 'testing', 'inference',
      'data_processing', 'application', 'monitor', 'controller', 'optimizer', 'service', 'qc', 'custom'
  :param repo: Remote URL for the repository to use, OR path to local copy of the git repository
      Example: 'https://github.com/allegroai/clearml.git' or '~/project/repo'
  :param branch: Select specific repository branch/tag (implies the latest commit from the branch)
  :param commit: Select specific commit id to use (default: latest commit,
      or when used with local repository matching the local commit id)
  :param script: Specify the entry point script for the remote execution. When used in tandem with
      remote git repository the script should be a relative path inside the repository,
      for example: './source/train.py' . When used with local repository path it supports a
      direct path to a file inside the local repository itself, for example: '~/project/source/train.py'
  :param working_directory: Working directory to launch the script from. Default: repository root folder.
      Relative to repo root or local folder.
  :param packages: Manually specify a list of required packages. Example: ["tqdm>=2.1", "scikit-learn"]
      or `True` to automatically create requirements
      based on locally installed packages (repository must be local).
  :param requirements_file: Specify requirements.txt file to install when setting the session.
      If not provided, the requirements.txt from the repository will be used.
  :param docker: Select the docker image to be executed in by the remote session
  :param docker_args: Add docker arguments, pass a single string
  :param docker_bash_setup_script: Add bash script to be executed
      inside the docker before setting up the Task's environment
  :param output_uri: Optional, set the Tasks's output_uri (Storage destination).
      examples: 's3://bucket/folder', 'https://server/' , 'gs://bucket/folder', 'azure://bucket', '/folder/'
  :param base_task_id: Use a pre-existing task in the system, instead of a local repo/script.
      Essentially clones an existing task and overrides arguments/requirements.
  :param add_task_init_call: If True, a 'Task.init()' call is added to the script entry point in remote execution.
  :param force_single_script_file: If True, do not auto-detect local repository
  :param raise_on_missing_entries: If True, raise ValueError on missing entries when populating
  :param verbose: If True, print verbose logging
docstr_tok: ["Create","a","new","Task","from","an","existing","code","base",".","If","the","code","does","not","already","contain","a","call","to","Task.init",",","pass","add_task_init_call=True",",","and","the","code","will","be","patched","in","remote","execution","(","i.e",".","when","executed","by","`","clearml-agent","`",":","param","project_name",":","Set","the","project","name","for","the","task",".","Required","if","base_task_id","is","None",".",":","param","task_name",":","Set","the","name","of","the","remote","task",".","Required","if","base_task_id","is","None",".",":","param","task_type",":","Optional",",","The","task","type","to","be","created",".","Supported","values",":","'training","'",",","'testing","'",",","'inference","'",",","'data_processing","'",",","'application","'",",","'monitor","'",",","'controller","'",",","'optimizer","'",",","'service","'",",","'qc","'",",","'custom'",":","param","repo",":","Remote","URL","for","the","repository","to","use",",","OR","path","to","local","copy","of","the","git","repository","Example",":","'https",":","\/\/github.com\/allegroai\/clearml.git","'","or","'~\/project\/repo'",":","param","branch",":","Select","specific","repository","branch\/tag","(","implies","the","latest","commit","from","the","branch",")",":","param","commit",":","Select","specific","commit","id","to","use","(","default",":","latest","commit",",","or","when","used","with","local","repository","matching","the","local","commit","id",")",":","param","script",":","Specify","the","entry","point","script","for","the","remote","execution",".","When","used","in","tandem","with","remote","git","repository","the","script","should","be","a","relative","path","inside","the","repository",",","for","example",":","'.\/source\/train.py","'",".","When","used","with","local","repository","path","it","supports","a","direct","path","to","a","file","inside","the","local","repository","itself",",","for","example",":","'~\/project\/source\/train.py'",":","param","working_directory",":","Working","directory","to","launch","the","script","from",".","Default",":","repository","root","folder",".","Relative","to","repo","root","or","local","folder",".",":","param","packages",":","Manually","specify","a","list","of","required","packages",".","Example",":","[","``","tqdm",">","=2.1","''",",","``","scikit-learn","''","]","or","`","True","`","to","automatically","create","requirements","based","on","locally","installed","packages","(","repository","must","be","local",")",".",":","param","requirements_file",":","Specify","requirements.txt","file","to","install","when","setting","the","session",".","If","not","provided",",","the","requirements.txt","from","the","repository","will","be","used",".",":","param","docker",":","Select","the","docker","image","to","be","executed","in","by","the","remote","session",":","param","docker_args",":","Add","docker","arguments",",","pass","a","single","string",":","param","docker_bash_setup_script",":","Add","bash","script","to","be","executed","inside","the","docker","before","setting","up","the","Task","'s","environment",":","param","output_uri",":","Optional",",","set","the","Tasks","'s","output_uri","(","Storage","destination",")",".","examples",":","'s3",":","\/\/bucket\/folder","'",",","'https",":","\/\/server\/","'",",","'gs",":","\/\/bucket\/folder","'",",","'azure",":","\/\/bucket","'",",","'\/folder\/'",":","param","base_task_id",":","Use","a","pre-existing","task","in","the","system",",","instead","of","a","local","repo\/script",".","Essentially","clones","an","existing","task","and","overrides","arguments\/requirements",".",":","param","add_task_init_call",":","If","True",",","a","'Task.init","(",")","'","call","is","added","to","the","script","entry","point","in","remote","execution",".",":","param","force_single_script_file",":","If","True",",","do","not","auto-detect","local","repository",":","param","raise_on_missing_entries",":","If","True",",","raise","ValueError","on","missing","entries","when","populating",":","param","verbose",":","If","True",",","print","verbose","logging"]
code: def __init__(
      self,
      project_name=None,  # type: Optional[str]
      task_name=None,  # type: Optional[str]
      task_type=None,  # type: Optional[str]
      repo=None,  # type: Optional[str]
      branch=None,  # type: Optional[str]
      commit=None,  # type: Optional[str]
      script=None,  # type: Optional[str]
      working_directory=None,  # type: Optional[str]
      packages=None,  # type: Optional[Union[bool, Sequence[str]]]
      requirements_file=None,  # type: Optional[Union[str, Path]]
      docker=None,  # type: Optional[str]
      docker_args=None,  # type: Optional[str]
      docker_bash_setup_script=None,  # type: Optional[str]
      output_uri=None,  # type: Optional[str]
      base_task_id=None,  # type: Optional[str]
      add_task_init_call=True,  # type: bool
      force_single_script_file=False,  # type: bool
      raise_on_missing_entries=False,  # type: bool
      verbose=False,  # type: bool
  ):
      # type: (...) -> None
      """
      Create a new Task from an existing code base.
      If the code does not already contain a call to Task.init, pass add_task_init_call=True,
      and the code will be patched in remote execution (i.e. when executed by `clearml-agent`
  
      :param project_name: Set the project name for the task. Required if base_task_id is None.
      :param task_name: Set the name of the remote task. Required if base_task_id is None.
      :param task_type: Optional, The task type to be created. Supported values: 'training', 'testing', 'inference',
          'data_processing', 'application', 'monitor', 'controller', 'optimizer', 'service', 'qc', 'custom'
      :param repo: Remote URL for the repository to use, OR path to local copy of the git repository
          Example: 'https://github.com/allegroai/clearml.git' or '~/project/repo'
      :param branch: Select specific repository branch/tag (implies the latest commit from the branch)
      :param commit: Select specific commit id to use (default: latest commit,
          or when used with local repository matching the local commit id)
      :param script: Specify the entry point script for the remote execution. When used in tandem with
          remote git repository the script should be a relative path inside the repository,
          for example: './source/train.py' . When used with local repository path it supports a
          direct path to a file inside the local repository itself, for example: '~/project/source/train.py'
      :param working_directory: Working directory to launch the script from. Default: repository root folder.
          Relative to repo root or local folder.
      :param packages: Manually specify a list of required packages. Example: ["tqdm>=2.1", "scikit-learn"]
          or `True` to automatically create requirements
          based on locally installed packages (repository must be local).
      :param requirements_file: Specify requirements.txt file to install when setting the session.
          If not provided, the requirements.txt from the repository will be used.
      :param docker: Select the docker image to be executed in by the remote session
      :param docker_args: Add docker arguments, pass a single string
      :param docker_bash_setup_script: Add bash script to be executed
          inside the docker before setting up the Task's environment
      :param output_uri: Optional, set the Tasks's output_uri (Storage destination).
          examples: 's3://bucket/folder', 'https://server/' , 'gs://bucket/folder', 'azure://bucket', '/folder/'
      :param base_task_id: Use a pre-existing task in the system, instead of a local repo/script.
          Essentially clones an existing task and overrides arguments/requirements.
      :param add_task_init_call: If True, a 'Task.init()' call is added to the script entry point in remote execution.
      :param force_single_script_file: If True, do not auto-detect local repository
      :param raise_on_missing_entries: If True, raise ValueError on missing entries when populating
      :param verbose: If True, print verbose logging
      """
      if (
          repo
          and len(urlparse(repo).scheme) <= 1
          and not re.compile(self._VCS_SSH_REGEX).match(repo)
      ):
          folder = repo
          repo = None
      else:
          folder = None
  
      if raise_on_missing_entries and not base_task_id:
          if not script:
              raise ValueError("Entry point script not provided")
          if not repo and not folder and not Path(script).is_file():
              raise ValueError(
                  "Script file '{}' could not be found".format(script)
              )
      if raise_on_missing_entries and commit and branch:
          raise ValueError(
              "Specify either a branch/tag or specific commit id, not both (either --commit or --branch)"
          )
      if (
          raise_on_missing_entries
          and not folder
          and working_directory
          and working_directory.startswith("/")
      ):
          raise ValueError(
              "working directory '{}', must be relative to repository root"
          )
  
      if requirements_file and not Path(requirements_file).is_file():
          raise ValueError("requirements file could not be found '{}'")
  
      self.folder = folder
      self.commit = commit
      self.branch = branch
      self.repo = repo
      self.script = script
      self.cwd = working_directory
      assert not packages or isinstance(packages, (tuple, list, bool))
      self.packages = (
          list(packages)
          if packages is not None and not isinstance(packages, bool)
          else (packages or None)
      )
      self.requirements_file = (
          Path(requirements_file) if requirements_file else None
      )
      self.base_task_id = base_task_id
      self.docker = dict(
          image=docker,
          args=docker_args,
          bash_script=docker_bash_setup_script,
      )
      self.add_task_init_call = add_task_init_call
      self.project_name = project_name
      self.task_name = task_name
      self.task_type = task_type
      self.output_uri = output_uri
      self.task = None
      self.force_single_script_file = bool(force_single_script_file)
      self.raise_on_missing_entries = raise_on_missing_entries
      self.verbose = verbose
  
imports: import inspect
  import json
  import os
  import re
  import tempfile
  from sys import platform
  from functools import reduce
  from logging import getLogger
  from typing import Optional, Sequence, Union, Tuple, List, Callable, Dict, Any
  from pathlib2 import Path
  from six.moves.urllib.parse import urlparse
  from .args import _Arguments
  from .repo import ScriptInfo
  from ...task import Task
label_desc: Use image node_id 1 to create a new CreateAndPopulate object from inherited base classes: object with example: obj = CreateAndPopulate(project_name, task_name, task_type, repo, branch, commit, script, working_directory, packages, requirements_file, docker, docker_args, docker_bash_setup_script, output_uri, base_task_id, add_task_init_call, force_single_script_file, raise_on_missing_entries, verbose)