Skip to content

Commit

Permalink
feat: Support parallelly running for insights-engine (#3436)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiangce Liu <[email protected]>
(cherry picked from commit bbabfae)
  • Loading branch information
xiangce committed Jun 8, 2022
1 parent e62790a commit 782344d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions insights/core/evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ def preprocess(self):
def run_serial(self, graph=None):
dr.run(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker)

def run_incremental(self, graph=None):
for _ in dr.run_incremental(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker):
pass
def run_incremental(self, graph=None, parallel=False):
components = graph or dr.COMPONENTS[dr.GROUPS.single]
if parallel:
with insights.get_pool(parallel, "insights-engine-pool", {"max_workers": None}) as pool:
dr.run_all(components, self.broker, pool)
else:
dr.run_all(components, self.broker)

def format_response(self, response):
"""
Expand All @@ -70,10 +74,10 @@ def format_result(self, result):
"""
return result

def process(self, graph=None):
def process(self, graph=None, parallel=False):
with self:
if self.incremental:
self.run_incremental(graph)
self.run_incremental(graph, parallel)
else:
self.run_serial(graph)
return self.get_response()
Expand Down

0 comments on commit 782344d

Please sign in to comment.