Skip to content

Commit

Permalink
defer dagbag load until first list call
Browse files Browse the repository at this point in the history
  • Loading branch information
ms32035 committed Aug 29, 2019
1 parent 72fa82c commit 4c861de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dag-dependencies-plugin/dag_dependencies_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class DAGDependenciesView(BaseView):
dagbag = models.DagBag(settings.DAGS_FOLDER)
dagbag = None
plugins_folder = conf.get("core", "plugins_folder")
template_folder = os.path.join(plugins_folder, "dag-dependencies-plugin")
route_base = "/"
Expand All @@ -34,8 +34,11 @@ def render(self, template, **context):
def list(self):
title = "DAG Dependencies"

if DAGDependenciesView.dagbag is None:
DAGDependenciesView.dagbag = models.DagBag(settings.DAGS_FOLDER)

if datetime.utcnow() > self.last_refresh + timedelta(
seconds=self.refresh_interval
seconds=self.refresh_interval
):
DAGDependenciesView.dagbag.collect_dags()
self.nodes, self.edges = self._generate_graph()
Expand Down

0 comments on commit 4c861de

Please sign in to comment.