class_docstr: Wrapper class for the basic BlueFog API.
class_docstr_tok: ["Wrapper","class","for","the","basic","BlueFog","API","."]
docstr: A python interface to call the timeline for StartActivity.
  If you want to use this function, please make sure to turn on the timeline first by
  setting the ENV variable BLUEFOG_TIMELINE = {file_name}, or use
  bfrun --timeline-filename {file_name} ...
  
  Args:
      tensor_name (str): The activity associated tensor name.
      activity_name (str): The activity type.
  
  Returns:
      A boolean value that whether timeline is executed correctly or not.
  
  Example:
      >>> import bluefog.torch as bf
      >>> from bluefog.common.util import env
      >>> with env(BLUEFOG_TIMELINE="./timeline_file"):
      >>>     bf.init()
      >>> bf.timeline_start_activity(tensor_name, activity_name)
      >>> ...
      >>> bf.timeline_end_activity(tensor_name)
docstr_tok: ["A","python","interface","to","call","the","timeline","for","StartActivity",".","If","you","want","to","use","this","function",",","please","make","sure","to","turn","on","the","timeline","first","by","setting","the","ENV","variable","BLUEFOG_TIMELINE","=","{","file_name","}",",","or","use","bfrun","--","timeline-filename","{","file_name","}","...","Args",":","tensor_name","(","str",")",":","The","activity","associated","tensor","name",".","activity_name","(","str",")",":","The","activity","type",".","Returns",":","A","boolean","value","that","whether","timeline","is","executed","correctly","or","not",".","Example",":",">",">",">","import","bluefog.torch","as","bf",">",">",">","from","bluefog.common.util","import","env",">",">",">","with","env","(","BLUEFOG_TIMELINE=","''",".\/timeline_file","''",")",":",">",">",">","bf.init","(",")",">",">",">","bf.timeline_start_activity","(","tensor_name",",","activity_name",")",">",">",">","...",">",">",">","bf.timeline_end_activity","(","tensor_name",")"]
code: def timeline_start_activity(
      self, tensor_name: str, activity_name: str
  ) -> bool:
      """A python interface to call the timeline for StartActivity.
      If you want to use this function, please make sure to turn on the timeline first by
      setting the ENV variable BLUEFOG_TIMELINE = {file_name}, or use
      bfrun --timeline-filename {file_name} ...
  
      Args:
          tensor_name (str): The activity associated tensor name.
          activity_name (str): The activity type.
  
      Returns:
          A boolean value that whether timeline is executed correctly or not.
  
      Example:
          >>> import bluefog.torch as bf
          >>> from bluefog.common.util import env
          >>> with env(BLUEFOG_TIMELINE="./timeline_file"):
          >>>     bf.init()
          >>> bf.timeline_start_activity(tensor_name, activity_name)
          >>> ...
          >>> bf.timeline_end_activity(tensor_name)
      """
      if self.warn_timeline:
          # We know timeline didn't turn on. No need to repeat it.
          return False
      self._MPI_LIB_CTYPES.bluefog_timeline.argtypes = [
          ctypes.c_bool,
          ctypes.c_char_p,
          ctypes.c_char_p,
      ]
      ret = self._MPI_LIB_CTYPES.bluefog_timeline(
          True,
          tensor_name.encode("utf-8"),
          activity_name.encode("utf-8"),
      )
      if ret != 1 and not self.warn_timeline:
          logger.error(
              "Cannot start activity in the timeline. "
              "Most common reason is you didn't turn on the timeline function. "
              "Use bfrun --timeline-filename file_name ... or "
              "setting the ENV variable BLUEFOG_TIMELINE = file_name"
          )
          self.warn_timeline = True
          return False
      return True
  
imports: from typing import List, Callable, Optional
  import atexit
  import contextlib
  import ctypes
  import logging
  import networkx
  import bluefog.common.util
  import bluefog.common.topology_util
label_desc: Use image node_id 26 for calling the BlueFogBasics obj's underlying member method code with example usage: obj.timeline_start_activity(tensor_name, activity_name) and returns: True, False, False