class_docstr: ArgoEvent is a small event, a message, that can be published to Argo Workflows. The
  event will eventually start all flows which have been previously deployed with `@trigger`
  to wait for this particular named event.
  
  Parameters
  ----------
  name : str,
      Name of the event
  url : str, optional
      Override the event endpoint from `ARGO_EVENTS_WEBHOOK_URL`.
  payload : Dict, optional
      A set of key-value pairs delivered in this event. Used to set parameters of triggered flows.
class_docstr_tok: ["ArgoEvent","is","a","small","event",",","a","message",",","that","can","be","published","to","Argo","Workflows",".","The","event","will","eventually","start","all","flows","which","have","been","previously","deployed","with","`","@","trigger","`","to","wait","for","this","particular","named","event",".","Parameters","--","--","--","--","--","name",":","str",",","Name","of","the","event","url",":","str",",","optional","Override","the","event","endpoint","from","`","ARGO_EVENTS_WEBHOOK_URL","`",".","payload",":","Dict",",","optional","A","set","of","key-value","pairs","delivered","in","this","event",".","Used","to","set","parameters","of","triggered","flows","."]
docstr: Publishes an event.
  
  Note that the function returns immediately after the event has been sent. It
  does not wait for flows to start, nor it guarantees that any flows will start.
  
  Parameters
  ----------
  payload : dict
      Additional key-value pairs to add to the payload.
  ignore_errors : bool, default: True
      If True, events are created on a best effort basis - errors are silently ignored.
docstr_tok: ["Publishes","an","event",".","Note","that","the","function","returns","immediately","after","the","event","has","been","sent",".","It","does","not","wait","for","flows","to","start",",","nor","it","guarantees","that","any","flows","will","start",".","Parameters","--","--","--","--","--","payload",":","dict","Additional","key-value","pairs","to","add","to","the","payload",".","ignore_errors",":","bool",",","default",":","True","If","True",",","events","are","created","on","a","best","effort","basis","-","errors","are","silently","ignored","."]
code: def publish(self, payload=None, force=True, ignore_errors=True):
      """
      Publishes an event.
  
      Note that the function returns immediately after the event has been sent. It
      does not wait for flows to start, nor it guarantees that any flows will start.
  
      Parameters
      ----------
      payload : dict
          Additional key-value pairs to add to the payload.
      ignore_errors : bool, default: True
          If True, events are created on a best effort basis - errors are silently ignored.
      """
  
      if payload == None:
          payload = {}
      # Publish event iff forced or running on Argo Workflows
      if force or os.environ.get("ARGO_WORKFLOW_TEMPLATE"):
          try:
              headers = {}
              if self._access_token:
                  # TODO: Test with bearer tokens
                  headers = {
                      "Authorization": "Bearer {}".format(
                          self._access_token
                      )
                  }
              if ARGO_EVENTS_WEBHOOK_AUTH == "service":
                  headers.update(SERVICE_HEADERS)
              # TODO: do we need to worry about certs?
  
              # Use urllib to avoid introducing any dependency in Metaflow
              data = {
                  "name": self._name,
                  "payload": {
                      # Add default fields here...
                      "name": self._name,
                      "id": str(uuid.uuid4()),
                      "timestamp": int(time.time()),
                      "utc_date": datetime.utcnow().strftime("%Y%m%d"),
                      "generated-by-metaflow": True,
                      **self._payload,
                      **payload,
                  },
              }
              request = urllib.request.Request(
                  self._url,
                  method="POST",
                  headers={
                      "Content-Type": "application/json",
                      **headers,
                  },
                  data=json.dumps(data).encode("utf-8"),
              )
              retries = 3
              backoff_factor = 2
  
              for i in range(retries):
                  try:
                      urllib.request.urlopen(request, timeout=10.0)
                      print(
                          "Argo Event (%s) published." % self._name,
                          file=sys.stderr,
                      )
                      return data["payload"]["id"]
                  except urllib.error.HTTPError as e:
                      # TODO: Retry retryable HTTP error codes
                      raise e
                  except urllib.error.URLError as e:
                      if i == retries - 1:
                          raise e
                      else:
                          time.sleep(backoff_factor**i)
          except Exception as e:
              msg = "Unable to publish Argo Event (%s): %s" % (
                  self._name,
                  e,
              )
              if ignore_errors:
                  print(msg, file=sys.stderr)
              else:
                  raise ArgoEventException(msg)
      else:
          msg = (
              "Argo Event (%s) was not published. Use "
              + "ArgoEvent(...).publish(...) "
              + "to force publish."
          ) % self._name
  
          if ignore_errors:
              print(msg, file=sys.stderr)
          else:
              raise ArgoEventException(msg)
  
file_path: metaflow/metaflow/plugins/argo/argo_events.py
imports: import json
  import os
  import sys
  import time
  import urllib
  import uuid
  from datetime import datetime
  from metaflow.exception import MetaflowException
  from metaflow.metaflow_config import ARGO_EVENTS_WEBHOOK_AUTH, ARGO_EVENTS_WEBHOOK_URL, SERVICE_HEADERS
label_desc: Use image node_id 4 for calling the ArgoEvent obj's underlying member method code with example usage: obj.publish(payload, force, ignore_errors) and returns: data