class_docstr: Trigger Task execution if an event happens in the system.
  
  Examples:
  
  - New model is published/tagged,
  - New Dataset is created,
  - General Task failed,
  - Task metric below/above threshold, alert every X minutes
class_docstr_tok: ["Trigger","Task","execution","if","an","event","happens","in","the","system",".","Examples",":","-","New","model","is","published\/tagged",",","-","New","Dataset","is","created",",","-","General","Task","failed",",","-","Task","metric","below\/above","threshold",",","alert","every","X","minutes"]
docstr: Create a cron job alike scheduling for a pre existing Task or function.
  Trigger the Task/function execution on changes in the Task
  Notice it is recommended to give the trigger a descriptive unique name, if not provided a task ID is used.
  
  Notice `task_overrides` can except reference to the trigger model ID:
  example: task_overrides={'Args/task_id': '${task.id}'}
  Notice if schedule_function is passed, use the following function interface:
  
  .. code-block:: py
  
     def schedule_function(task_id):
         pass
  
  :param schedule_task_id: Task/task ID to be cloned and scheduled for execution
  :param schedule_queue: Queue name or ID to put the Task into (i.e. schedule)
  :param schedule_function: Optional, instead of providing Task ID to be scheduled,
      provide a function to be called. Notice the function is called from the scheduler context
      (i.e. running on the same machine as the scheduler)
  :param name: Name or description for the cron Task (should be unique if provided otherwise randomly generated)
  :param trigger_project: Only monitor tasks from this specific project (not recursive)
  :param trigger_name: Trigger only on tasks with name matching (regexp)
  :param trigger_on_tags: Trigger when all tags in the list are present
  :param trigger_required_tags: Trigger only on tasks with the following additional tags (must include all tags)
  :param trigger_on_status: Trigger on Task status change. Expect list of status strings, e.g. ['failed', 'published'].
      TaskStatusEnum: ["created", "in_progress", "stopped", "closed", "failed", "completed", "queued", "published",
      "publishing", "unknown"]
  :param trigger_exclude_dev_tasks: If True only trigger on Tasks executed by clearml-agent (and not manually)
  :param trigger_on_metric: Trigger on metric/variant above/under threshold (metric=title, variant=series)
  :param trigger_on_variant: Trigger on metric/variant above/under threshold (metric=title, variant=series)
  :param trigger_on_threshold: Trigger on metric/variant above/under threshold (float number)
  :param trigger_on_sign: possible values "max"/"maximum" or "min"/"minimum",
      trigger Task if metric below "min" or "above" maximum. Default: "minimum"
  :param target_project: Specify target project to put the cloned scheduled Task in.
  :param add_tag: Add tag to the executed Task. Provide specific tag (str) or
      pass True (default) to use the trigger name as tag
  :param single_instance: If True, do not launch the Task job if the previous instance is still running
      (skip until the next scheduled time period). Default False.
  :param reuse_task: If True, re-enqueue the same Task (i.e. do not clone it) every time, default False.
  :param task_parameters: Configuration parameters to the executed Task.
      for example: {'Args/batch': '12'} Notice: not available when reuse_task=True/
  :param task_overrides: Change task definition.
      for example {'script.version_num': None, 'script.branch': 'main'} Notice: not available when reuse_task=True
  :return: True if job is successfully added to the scheduling list
docstr_tok: ["Create","a","cron","job","alike","scheduling","for","a","pre","existing","Task","or","function",".","Trigger","the","Task\/function","execution","on","changes","in","the","Task","Notice","it","is","recommended","to","give","the","trigger","a","descriptive","unique","name",",","if","not","provided","a","task","ID","is","used",".","Notice","`","task_overrides","`","can","except","reference","to","the","trigger","model","ID",":","example",":","task_overrides=","{","'Args\/task_id","'",":","'","$","{","task.id","}","'","}","Notice","if","schedule_function","is","passed",",","use","the","following","function","interface",":","..","code-block",":",":","py","def","schedule_function","(","task_id",")",":","pass",":","param","schedule_task_id",":","Task\/task","ID","to","be","cloned","and","scheduled","for","execution",":","param","schedule_queue",":","Queue","name","or","ID","to","put","the","Task","into","(","i.e",".","schedule",")",":","param","schedule_function",":","Optional",",","instead","of","providing","Task","ID","to","be","scheduled",",","provide","a","function","to","be","called",".","Notice","the","function","is","called","from","the","scheduler","context","(","i.e",".","running","on","the","same","machine","as","the","scheduler",")",":","param","name",":","Name","or","description","for","the","cron","Task","(","should","be","unique","if","provided","otherwise","randomly","generated",")",":","param","trigger_project",":","Only","monitor","tasks","from","this","specific","project","(","not","recursive",")",":","param","trigger_name",":","Trigger","only","on","tasks","with","name","matching","(","regexp",")",":","param","trigger_on_tags",":","Trigger","when","all","tags","in","the","list","are","present",":","param","trigger_required_tags",":","Trigger","only","on","tasks","with","the","following","additional","tags","(","must","include","all","tags",")",":","param","trigger_on_status",":","Trigger","on","Task","status","change",".","Expect","list","of","status","strings",",","e.g",".","[","'failed","'",",","'published","'","]",".","TaskStatusEnum",":","[","``","created","''",",","``","in_progress","''",",","``","stopped","''",",","``","closed","''",",","``","failed","''",",","``","completed","''",",","``","queued","''",",","``","published","''",",","``","publishing","''",",","``","unknown","''","]",":","param","trigger_exclude_dev_tasks",":","If","True","only","trigger","on","Tasks","executed","by","clearml-agent","(","and","not","manually",")",":","param","trigger_on_metric",":","Trigger","on","metric\/variant","above\/under","threshold","(","metric=title",",","variant=series",")",":","param","trigger_on_variant",":","Trigger","on","metric\/variant","above\/under","threshold","(","metric=title",",","variant=series",")",":","param","trigger_on_threshold",":","Trigger","on","metric\/variant","above\/under","threshold","(","float","number",")",":","param","trigger_on_sign",":","possible","values","``","max","''","\/","''","maximum","''","or","``","min","''","\/","''","minimum","''",",","trigger","Task","if","metric","below","``","min","''","or","``","above","''","maximum",".","Default",":","``","minimum","''",":","param","target_project",":","Specify","target","project","to","put","the","cloned","scheduled","Task","in",".",":","param","add_tag",":","Add","tag","to","the","executed","Task",".","Provide","specific","tag","(","str",")","or","pass","True","(","default",")","to","use","the","trigger","name","as","tag",":","param","single_instance",":","If","True",",","do","not","launch","the","Task","job","if","the","previous","instance","is","still","running","(","skip","until","the","next","scheduled","time","period",")",".","Default","False",".",":","param","reuse_task",":","If","True",",","re-enqueue","the","same","Task","(","i.e",".","do","not","clone","it",")","every","time",",","default","False",".",":","param","task_parameters",":","Configuration","parameters","to","the","executed","Task",".","for","example",":","{","'Args\/batch","'",":","'12","'","}","Notice",":","not","available","when","reuse_task=True\/",":","param","task_overrides",":","Change","task","definition",".","for","example","{","'script.version_num","'",":","None",",","'script.branch","'",":","'main","'","}","Notice",":","not","available","when","reuse_task=True",":","return",":","True","if","job","is","successfully","added","to","the","scheduling","list"]
code: def add_task_trigger(
      self,
      schedule_task_id=None,  # type: Union[str, Task]
      schedule_queue=None,  # type: str
      schedule_function=None,  # type: Callable[[str], None]
      trigger_project=None,  # type: str
      trigger_name=None,  # type: Optional[str]
      trigger_on_tags=None,  # type: Optional[List[str]]
      trigger_on_status=None,  # type: Optional[List[str]]
      trigger_exclude_dev_tasks=None,  # type: Optional[bool]
      trigger_on_metric=None,  # type: Optional[str]
      trigger_on_variant=None,  # type: Optional[str]
      trigger_on_threshold=None,  # type: Optional[float]
      trigger_on_sign=None,  # type: Optional[str]
      trigger_required_tags=None,  # type: Optional[List[str]]
      name=None,  # type: Optional[str]
      target_project=None,  # type: Optional[str]
      add_tag=True,  # type: Union[bool, str]
      single_instance=False,  # type: bool
      reuse_task=False,  # type: bool
      task_parameters=None,  # type: Optional[dict]
      task_overrides=None,  # type: Optional[dict]
  ):
      # type: (...) -> None
      """
      Create a cron job alike scheduling for a pre existing Task or function.
      Trigger the Task/function execution on changes in the Task
      Notice it is recommended to give the trigger a descriptive unique name, if not provided a task ID is used.
  
      Notice `task_overrides` can except reference to the trigger model ID:
      example: task_overrides={'Args/task_id': '${task.id}'}
      Notice if schedule_function is passed, use the following function interface:
  
      .. code-block:: py
  
         def schedule_function(task_id):
             pass
  
      :param schedule_task_id: Task/task ID to be cloned and scheduled for execution
      :param schedule_queue: Queue name or ID to put the Task into (i.e. schedule)
      :param schedule_function: Optional, instead of providing Task ID to be scheduled,
          provide a function to be called. Notice the function is called from the scheduler context
          (i.e. running on the same machine as the scheduler)
      :param name: Name or description for the cron Task (should be unique if provided otherwise randomly generated)
      :param trigger_project: Only monitor tasks from this specific project (not recursive)
      :param trigger_name: Trigger only on tasks with name matching (regexp)
      :param trigger_on_tags: Trigger when all tags in the list are present
      :param trigger_required_tags: Trigger only on tasks with the following additional tags (must include all tags)
      :param trigger_on_status: Trigger on Task status change. Expect list of status strings, e.g. ['failed', 'published'].
          TaskStatusEnum: ["created", "in_progress", "stopped", "closed", "failed", "completed", "queued", "published",
          "publishing", "unknown"]
      :param trigger_exclude_dev_tasks: If True only trigger on Tasks executed by clearml-agent (and not manually)
      :param trigger_on_metric: Trigger on metric/variant above/under threshold (metric=title, variant=series)
      :param trigger_on_variant: Trigger on metric/variant above/under threshold (metric=title, variant=series)
      :param trigger_on_threshold: Trigger on metric/variant above/under threshold (float number)
      :param trigger_on_sign: possible values "max"/"maximum" or "min"/"minimum",
          trigger Task if metric below "min" or "above" maximum. Default: "minimum"
      :param target_project: Specify target project to put the cloned scheduled Task in.
      :param add_tag: Add tag to the executed Task. Provide specific tag (str) or
          pass True (default) to use the trigger name as tag
      :param single_instance: If True, do not launch the Task job if the previous instance is still running
          (skip until the next scheduled time period). Default False.
      :param reuse_task: If True, re-enqueue the same Task (i.e. do not clone it) every time, default False.
      :param task_parameters: Configuration parameters to the executed Task.
          for example: {'Args/batch': '12'} Notice: not available when reuse_task=True/
      :param task_overrides: Change task definition.
          for example {'script.version_num': None, 'script.branch': 'main'} Notice: not available when reuse_task=True
      :return: True if job is successfully added to the scheduling list
      """
      trigger = TaskTrigger(
          base_task_id=schedule_task_id,
          base_function=schedule_function,
          queue=schedule_queue,
          name=name,
          target_project=target_project,
          single_instance=single_instance,
          task_parameters=task_parameters,
          task_overrides=task_overrides,
          add_tag=(
              add_tag
              if isinstance(add_tag, str)
              else (name or schedule_task_id)
          )
          if add_tag
          else None,
          clone_task=not bool(reuse_task),
          match_name=trigger_name,
          project=Task.get_project_id(trigger_project)
          if trigger_project
          else None,
          tags=trigger_on_tags,
          required_tags=trigger_required_tags,
          on_status=trigger_on_status,
          exclude_dev=trigger_exclude_dev_tasks,
          metrics=trigger_on_metric,
          variant=trigger_on_variant,
          threshold=trigger_on_threshold,
          value_sign=trigger_on_sign,
      )
      trigger.verify()
      self._task_triggers.append(trigger)
  
imports: import json
  import logging
  from datetime import datetime
  from threading import enumerate
  from typing import List, Optional, Dict, Union, Callable
  from attr import attrs, attrib
  from .job import ClearmlJob
  from .scheduler import BaseScheduleJob, BaseScheduler, ExecutedJob
  from ..task import Task
  from ..backend_api.session.client import APIClient
  from ..backend_interface.util import datetime_to_isoformat, datetime_from_isoformat
label_desc: Use image node_id 4 for calling the TriggerScheduler obj's underlying member method code with example usage: obj.add_task_trigger(schedule_task_id, schedule_queue, schedule_function, trigger_project, trigger_name, trigger_on_tags, trigger_on_status, trigger_exclude_dev_tasks, trigger_on_metric, trigger_on_variant, trigger_on_threshold, trigger_on_sign, trigger_required_tags, name, target_project, add_tag, single_instance, reuse_task, task_parameters, task_overrides) without return types