Skip to content

Commit

Permalink
Fix issue Fix styling #670 for indicators, factors, dimensions and an…
Browse files Browse the repository at this point in the history
…alysis
  • Loading branch information
timlinux committed Dec 10, 2024
1 parent 051b75e commit 80a6224
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 255 deletions.
29 changes: 23 additions & 6 deletions geest/core/json_tree_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,38 +500,55 @@ def ensureValidAnalysisMode(self):
self.setAnalysisMode(key)
break

def getDescendantIndicators(self):
def getDescendantIndicators(self, ignore_completed=False, ignore_disabled=True):
"""Return the list of indicators under this item.
Recurses through the tree to find all indicators under this item.
:param ignore_completed: If True, only return indicators that are not completed.
:param ignore_disabled: If True, only return indicators that are not disabled.
"""
indicators = []
if self.isIndicator():
indicators.append(self)
if self.getStatus() != "Completed successfully" or ignore_completed:
if self.getStatus() != "Excluded from analysis" or not ignore_disabled:
indicators.append(self)
for child in self.childItems:
indicators.extend(child.getDescendantIndicators())
return indicators

def getDescendantFactors(self):
def getDescendantFactors(self, ignore_completed=False, ignore_disabled=True):
"""Return the list of factors under this item.
Recurses through the tree to find all factors under this item.
:param ignore_completed: If True, only return factors that are not completed.
:param ignore_disabled: If True, only return factors that are not disabled.
"""
factors = []
if self.isFactor():
factors.append(self)
if self.getStatus() != "Completed successfully" or ignore_completed:
if self.getStatus() != "Excluded from analysis" or not ignore_disabled:
factors.append(self)
for child in self.childItems:
factors.extend(child.getDescendantFactors())
return factors

def getDescendantDimensions(self):
def getDescendantDimensions(self, ignore_completed=False, ignore_disabled=True):
"""Return the list of dimensions under this item.
Recurses through the tree to find all dimensions under this item.
:param ignore_completed: If True, only return dimensions that are not completed.
:param ignore_disabled: If True, only return dimensions that are not disabled.
result_file
"""
dimensions = []
if self.isDimension():
dimensions.append(self)
if self.getStatus() != "Completed successfully" or ignore_completed:
if self.getStatus() != "Excluded from analysis" or not ignore_disabled:
dimensions.append(self)
for child in self.childItems:
dimensions.extend(child.getDescendantDimensions())
return dimensions
Expand Down
34 changes: 11 additions & 23 deletions geest/gui/panels/tree_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,17 +991,13 @@ def queue_workflow_task(self, item, role):
attributes = item.attributes()
if attributes.get("result_file", None) and self.run_only_incomplete:
return
if role == item.role and role == "indicator":
task = self.queue_manager.add_workflow(item, cell_size_m)
if role == item.role and role == "factor":
attributes["analysis_mode"] = "factor_aggregation"
task = self.queue_manager.add_workflow(item, cell_size_m)
if role == item.role and role == "dimension":
attributes["analysis_mode"] = "dimension_aggregation"
task = self.queue_manager.add_workflow(item, cell_size_m)
if role == item.role and role == "analysis":
attributes["analysis_mode"] = "analysis_aggregation"
task = self.queue_manager.add_workflow(item, cell_size_m)
task = self.queue_manager.add_workflow(item, cell_size_m)
if task is None:
return

Expand Down Expand Up @@ -1031,27 +1027,19 @@ def run_item(self, item, shift_pressed):
self.run_only_incomplete = False
else:
self.run_only_incomplete = True
indicators = item.getDescendantIndicators()
factors = item.getDescendantFactors()
dimensions = item.getDescendantDimensions()
indicators = item.getDescendantIndicators(
ignore_completed=self.run_only_incomplete
)
factors = item.getDescendantFactors(ignore_completed=self.run_only_incomplete)
dimensions = item.getDescendantDimensions(
ignore_completed=self.run_only_incomplete
)
for indicator in indicators:
is_complete = indicator.getStatus() == "Workflow Completed"
if not is_complete:
self.queue_workflow_task(indicator, indicator.role)
if is_complete and not self.run_only_incomplete:
self.queue_workflow_task(indicator, indicator.role)
self.queue_workflow_task(indicator, indicator.role)
for factor in factors:
is_complete = factor.getStatus() == "Workflow Completed"
if not is_complete:
self.queue_workflow_task(factor, factor.role)
if is_complete and not self.run_only_incomplete:
self.queue_workflow_task(factor, factor.role)
self.queue_workflow_task(factor, factor.role)
for dimension in dimensions:
is_complete = dimension.getStatus() == "Workflow Completed"
if not is_complete:
self.queue_workflow_task(dimension, dimension.role)
if is_complete and not self.run_only_incomplete:
self.queue_workflow_task(dimension, dimension.role)
self.queue_workflow_task(dimension, dimension.role)
self.queue_workflow_task(item, item.role)
self.items_to_run = len(indicators) + len(factors) + len(dimensions) + 1

Expand Down
Loading

0 comments on commit 80a6224

Please sign in to comment.