def __GetEnvVarsForTask(cls, task): """Returns the env vars for the task. Args: task: string: The task for which the envvar should be prepared. Returns: dict {string, string}: The dictionary of IDS to values. """ rel_path = PipelineUtils.GetTaskOutputRelativeDir(task) vars = {} for k, v in PipelineConfig.Instance().GetAllSubDirsForPath(rel_path).items(): vars[k] = v prev_dir = FileUtils.GetPreviousDatedDir(v) if not prev_dir: prev_dir = v vars[k + '_PREV'] = prev_dir vars.update(PipelineConfig.Instance().GetAllENVVars()) # Check if the task is critical or not. task_options = cls.__GetTaskOptions(task) if task_options[Runner.TASK_OPTIONS['ABORT_FAIL']]: vars['PIPELINE_TASK_ABORT_FAIL'] = '1' if task_options[Runner.TASK_OPTIONS['ALLOW_FAIL']]: vars['PIPELINE_TASK_ALLOW_FAIL'] = '1' return vars
def GetPrevDatedDirCotainingPattern(cls, path, pattern): """Returns the previous dated sibling directory containing the request file. Args: path: string: The dir whose sibling is to be returned. pattern: string: The pattern (glob.glob) that is expected to be present in the sibling directory. Returns: string: the out dir base for the pipeline. None if there is no out dir. """ while path: prev_dir = FileUtils.GetPreviousDatedDir(path) if prev_dir and glob.glob(os.path.join(prev_dir, pattern)): return prev_dir path = prev_dir return None