original_docstring: parses the task file and return an context and step instances
docstring: parses the task file and return an context and step instances
docstring_tokens: parses the task file and return an context and step instances
code: def parse_task(self, task_id, inputs=None):
          """parses the task file and return an context and step instances"""
          LOG.info("Parsing task config: %s", self.path)
          kw = inputs
          try:
              with utils.load_resource(self.path) as f:
                  try:
                      input_task = f.read()
                      rendered_task = TaskTemplate.render(input_task, **kw)
                  except Exception as e:
                      LOG.exception('Failed to render template:\n%s\n', input_task)
                      raise e
                  LOG.debug("Input task is:\n%s\n", rendered_task)
  
                  cfg = yaml_load(rendered_task)
          except IOError as ioerror:
              sys.exit(ioerror)
  
          self._check_schema(cfg["schema"], "task")
          meet_precondition = self._check_precondition(cfg)
  
          if "context" in cfg:
              context_cfgs = [cfg["context"]]
          elif "contexts" in cfg:
              context_cfgs = cfg["contexts"]
          else:
              context_cfgs = [{"type": "Dummy", "name": "Dummy"}]
  
          _contexts = []
          for cfg_attrs in context_cfgs:
              cfg_attrs['task_id'] = task_id
              context_type = cfg_attrs.get("type")
              context = Context.get(context_type)
              context.init(cfg_attrs)
              _contexts.append(context)
  
          run_in_parallel = cfg.get("run_in_parallel", False)
  
          # add tc and task id for influxdb extended tags
          for step in cfg["steps"]:
              task_name = os.path.splitext(os.path.basename(self.path))[0]
              step["tc"] = task_name
              step["task_id"] = task_id
              # embed task path into step so we can load other files
              # relative to task path
              step["task_path"] = os.path.dirname(self.path)
  
          # TODO we need something better here, a class that represent the file
          return cfg["steps"], run_in_parallel, meet_precondition, _contexts
code_tokens: def parse_task ( self , task_id , inputs = None ) : LOG . info ( "Parsing task config: %s" , self . path ) kw = inputs try : with utils . load_resource ( self . path ) as f : try : input_task = f . read ( ) rendered_task = TaskTemplate . render ( input_task , ** kw ) except Exception as e : LOG . exception ( 'Failed to render template:\n%s\n' , input_task ) raise e LOG . debug ( "Input task is:\n%s\n" , rendered_task ) cfg = yaml_load ( rendered_task ) except IOError as ioerror : sys . exit ( ioerror ) self . _check_schema ( cfg [ "schema" ] , "task" ) meet_precondition = self . _check_precondition ( cfg ) if "context" in cfg : context_cfgs = [ cfg [ "context" ] ] elif "contexts" in cfg : context_cfgs = cfg [ "contexts" ] else : context_cfgs = [ { "type" : "Dummy" , "name" : "Dummy" } ] _contexts = [ ] for cfg_attrs in context_cfgs : cfg_attrs [ 'task_id' ] = task_id context_type = cfg_attrs . get ( "type" ) context = Context . get ( context_type ) context . init ( cfg_attrs ) _contexts . append ( context ) run_in_parallel = cfg . get ( "run_in_parallel" , False ) for step in cfg [ "steps" ] : task_name = os . path . splitext ( os . path . basename ( self . path ) ) [ 0 ] step [ "tc" ] = task_name step [ "task_id" ] = task_id step [ "task_path" ] = os . path . dirname ( self . path ) return cfg [ "steps" ] , run_in_parallel , meet_precondition , _contexts
short_docstring: parses the task file and return an context and step instances
short_docstring_tokens: parses the task file and return an context and step instances
comment: """parses the task file and return an context and step instances"""$SEP$# add tc and task id for influxdb extended tags$SEP$# embed task path into step so we can load other files$SEP$# relative to task path$SEP$# TODO we need something better here, a class that represent the file