From 4c861de4769aecff122a88cba57d9d20a62bc5b7 Mon Sep 17 00:00:00 2001 From: Marcin Szymanski Date: Thu, 29 Aug 2019 23:17:59 +0200 Subject: [PATCH] defer dagbag load until first list call --- dag-dependencies-plugin/dag_dependencies_plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dag-dependencies-plugin/dag_dependencies_plugin.py b/dag-dependencies-plugin/dag_dependencies_plugin.py index c72bf21..5852e31 100644 --- a/dag-dependencies-plugin/dag_dependencies_plugin.py +++ b/dag-dependencies-plugin/dag_dependencies_plugin.py @@ -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 = "/" @@ -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()