Skip to content

Commit

Permalink
Fix progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaveMyYard committed Jul 25, 2023
1 parent b21f252 commit f4bb888
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion robusta_krr/core/integrations/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
V2HorizontalPodAutoscalerList,
)

from robusta_krr.core.models.objects import HPAData, K8sObjectData, PodData
from robusta_krr.core.models.objects import HPAData, K8sObjectData
from robusta_krr.core.models.result import ResourceAllocations
from robusta_krr.utils.configurable import Configurable

Expand Down
16 changes: 8 additions & 8 deletions robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ async def _calculate_object_recommendations(self, object: K8sObjectData) -> RunR
step=self._strategy.settings.timeframe_timedelta,
)

# self.__progressbar.progress()

self.debug(f"Calculating recommendations for {object} with {len(metrics)} metrics")

# NOTE: We run this in a threadpool as the strategy calculation might be CPU intensive
Expand All @@ -133,6 +131,8 @@ async def _calculate_object_recommendations(self, object: K8sObjectData) -> RunR
async def _gather_object_allocations(self, k8s_object: K8sObjectData) -> ResourceScan:
recommendation = await self._calculate_object_recommendations(k8s_object)

self.__progressbar.progress()

return ResourceScan.calculate(
k8s_object,
ResourceAllocations(
Expand All @@ -153,13 +153,13 @@ async def _collect_result(self) -> Result:

self.info(f'Using clusters: {clusters if clusters is not None else "inner cluster"}')

# with ProgressBar(self.config, total=len(objects), title="Calculating Recommendation") as self.__progressbar:
scans_tasks = [
asyncio.create_task(self._gather_object_allocations(k8s_object))
async for k8s_object in self._k8s_loader.list_scannable_objects(clusters)
]
with ProgressBar(self.config, title="Calculating Recommendation") as self.__progressbar:
scans_tasks = [
asyncio.create_task(self._gather_object_allocations(k8s_object))
async for k8s_object in self._k8s_loader.list_scannable_objects(clusters)
]

scans = await asyncio.gather(*scans_tasks)
scans = await asyncio.gather(*scans_tasks)

if len(scans) == 0:
self.warning("Current filters resulted in no objects available to scan.")
Expand Down
2 changes: 1 addition & 1 deletion robusta_krr/utils/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ProgressBar(Configurable):

def __init__(self, config: Config, **kwargs) -> None:
super().__init__(config)
self.show_bar = self.echo_active and False
self.show_bar = self.echo_active
if self.show_bar:
self.alive_bar = alive_bar(**kwargs)

Expand Down

0 comments on commit f4bb888

Please sign in to comment.