class_docstr: A base class for dependency contexts.
  
  Specifies which dependencies should be evaluated in the context for a task
  instance to satisfy the requirements of the context. Also stores state
  related to the context that can be used by dependency classes.
  
  For example there could be a SomeRunContext that subclasses this class which has
  dependencies for:
  
  - Making sure there are slots available on the infrastructure to run the task instance
  - A task-instance's task-specific dependencies are met (e.g. the previous task
    instance completed successfully)
  - ...
  
  :param deps: The context-specific dependencies that need to be evaluated for a
      task instance to run in this execution context.
  :param flag_upstream_failed: This is a hack to generate the upstream_failed state
      creation while checking to see whether the task instance is runnable. It was the
      shortest path to add the feature. This is bad since this class should be pure (no
      side effects).
  :param ignore_all_deps: Whether or not the context should ignore all ignorable
      dependencies. Overrides the other ignore_* parameters
  :param ignore_depends_on_past: Ignore depends_on_past parameter of DAGs (e.g. for
      Backfills)
  :param wait_for_past_depends_before_skipping: Wait for past depends before marking the ti as skipped
  :param ignore_in_retry_period: Ignore the retry period for task instances
  :param ignore_in_reschedule_period: Ignore the reschedule period for task instances
  :param ignore_unmapped_tasks: Ignore errors about mapped tasks not yet being expanded
  :param ignore_task_deps: Ignore task-specific dependencies such as depends_on_past and
      trigger rule
  :param ignore_ti_state: Ignore the task instance's previous failure/success
  :param finished_tis: A list of all the finished task instances of this run
class_docstr_tok: ["A","base","class","for","dependency","contexts",".","Specifies","which","dependencies","should","be","evaluated","in","the","context","for","a","task","instance","to","satisfy","the","requirements","of","the","context",".","Also","stores","state","related","to","the","context","that","can","be","used","by","dependency","classes",".","For","example","there","could","be","a","SomeRunContext","that","subclasses","this","class","which","has","dependencies","for",":","-","Making","sure","there","are","slots","available","on","the","infrastructure","to","run","the","task","instance","-","A","task-instance","'s","task-specific","dependencies","are","met","(","e.g",".","the","previous","task","instance","completed","successfully",")","-","...",":","param","deps",":","The","context-specific","dependencies","that","need","to","be","evaluated","for","a","task","instance","to","run","in","this","execution","context",".",":","param","flag_upstream_failed",":","This","is","a","hack","to","generate","the","upstream_failed","state","creation","while","checking","to","see","whether","the","task","instance","is","runnable",".","It","was","the","shortest","path","to","add","the","feature",".","This","is","bad","since","this","class","should","be","pure","(","no","side","effects",")",".",":","param","ignore_all_deps",":","Whether","or","not","the","context","should","ignore","all","ignorable","dependencies",".","Overrides","the","other","ignore_","*","parameters",":","param","ignore_depends_on_past",":","Ignore","depends_on_past","parameter","of","DAGs","(","e.g",".","for","Backfills",")",":","param","wait_for_past_depends_before_skipping",":","Wait","for","past","depends","before","marking","the","ti","as","skipped",":","param","ignore_in_retry_period",":","Ignore","the","retry","period","for","task","instances",":","param","ignore_in_reschedule_period",":","Ignore","the","reschedule","period","for","task","instances",":","param","ignore_unmapped_tasks",":","Ignore","errors","about","mapped","tasks","not","yet","being","expanded",":","param","ignore_task_deps",":","Ignore","task-specific","dependencies","such","as","depends_on_past","and","trigger","rule",":","param","ignore_ti_state",":","Ignore","the","task","instance","'s","previous","failure\/success",":","param","finished_tis",":","A","list","of","all","the","finished","task","instances","of","this","run"]
docstr: Ensure finished_tis is populated if it's currently None, which allows running tasks without dag_run.
  
   :param dag_run: The DagRun for which to find finished tasks
   :return: A list of all the finished tasks of this DAG and execution_date
docstr_tok: ["Ensure","finished_tis","is","populated","if","it","'s","currently","None",",","which","allows","running","tasks","without","dag_run",".",":","param","dag_run",":","The","DagRun","for","which","to","find","finished","tasks",":","return",":","A","list","of","all","the","finished","tasks","of","this","DAG","and","execution_date"]
code: def ensure_finished_tis(
      self, dag_run: DagRun, session: Session
  ) -> list[TaskInstance]:
      """
      Ensure finished_tis is populated if it's currently None, which allows running tasks without dag_run.
  
       :param dag_run: The DagRun for which to find finished tasks
       :return: A list of all the finished tasks of this DAG and execution_date
      """
      if self.finished_tis is None:
          finished_tis = dag_run.get_task_instances(
              state=State.finished, session=session
          )
          for ti in finished_tis:
              if not hasattr(ti, "task") and dag_run.dag:
                  try:
                      ti.task = dag_run.dag.get_task(ti.task_id)
                  except TaskNotFound:
                      pass
  
          self.finished_tis = finished_tis
      else:
          finished_tis = self.finished_tis
      return finished_tis
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  import attr
  from airflow.exceptions import TaskNotFound
  from airflow.utils.state import State
label_desc: Use image node_id 1 for calling the DepContext obj's underlying member method code with example usage: obj.ensure_finished_tis(dag_run, session) and returns: finished_tis