parameters: (task_name)
docstring: See if we can find the config.txt assuming the task name is an
      absolute/relative path
docstring_summary: See if we can find the config.txt assuming the task name is an
      absolute/relative path
docstring_tokens: See if we can find the config . txt assuming the task name is an absolute / relative path
function: def find_task_config_file(task_name):
      """
      See if we can find the config.txt assuming the task name is an
      absolute/relative path
      """
  
      base_dirs = []
      if PurePath(task_name).is_absolute():
          # Only check the root path since the path is aboslute
          base_dirs.append("/")
      else:
          # Not absolute path, so check from the current directory first
          base_dirs.append(".")
  
          vtr_flow_tasks_dir = str(paths.vtr_flow_path / "tasks")
  
          # Then the VTR tasks directory
          base_dirs.append(vtr_flow_tasks_dir)
  
      # Generate potential config files (from most to least specific)
      potential_config_file_paths = []
      for base_dir in base_dirs:
          # Assume points directly to a config.txt
          assume_config_path = str(PurePath(base_dir) / task_name)
          potential_config_file_paths.append(assume_config_path)
  
          # Assume points to a config dir (containing config.txt)
          assume_config_dir_path = str(PurePath(base_dir) / task_name / "config.txt")
          potential_config_file_paths.append(assume_config_dir_path)
  
          # Assume points to a task dir (containing config/config.txt)
          assume_task_dir_path = str(PurePath(base_dir) / task_name / "config" / "config.txt")
          potential_config_file_paths.append(assume_task_dir_path)
  
      # Find the first potential file that is valid
      for config_file in potential_config_file_paths:
          config_path = Path(config_file)
          is_file = config_path.is_file()
          is_named_config = config_path.name == "config.txt"
          is_in_config_dir = config_path.parent.name == "config"
  
          if is_file and is_named_config and is_in_config_dir:
              return config_path.resolve()
  
      raise VtrError("Could not find config/config.txt for task {name}".format(name=task_name))
function_tokens: def find_task_config_file ( task_name ) : base_dirs = [ ] if PurePath ( task_name ) . is_absolute ( ) : # Only check the root path since the path is aboslute base_dirs . append ( "/" ) else : # Not absolute path, so check from the current directory first base_dirs . append ( "." ) vtr_flow_tasks_dir = str ( paths . vtr_flow_path / "tasks" ) # Then the VTR tasks directory base_dirs . append ( vtr_flow_tasks_dir ) # Generate potential config files (from most to least specific) potential_config_file_paths = [ ] for base_dir in base_dirs : # Assume points directly to a config.txt assume_config_path = str ( PurePath ( base_dir ) / task_name ) potential_config_file_paths . append ( assume_config_path ) # Assume points to a config dir (containing config.txt) assume_config_dir_path = str ( PurePath ( base_dir ) / task_name / "config.txt" ) potential_config_file_paths . append ( assume_config_dir_path ) # Assume points to a task dir (containing config/config.txt) assume_task_dir_path = str ( PurePath ( base_dir ) / task_name / "config" / "config.txt" ) potential_config_file_paths . append ( assume_task_dir_path ) # Find the first potential file that is valid for config_file in potential_config_file_paths : config_path = Path ( config_file ) is_file = config_path . is_file ( ) is_named_config = config_path . name == "config.txt" is_in_config_dir = config_path . parent . name == "config" if is_file and is_named_config and is_in_config_dir : return config_path . resolve ( ) raise VtrError ( "Could not find config/config.txt for task {name}" . format ( name = task_name ) )