So this is not actually an issue with module itself but I guess I'm just too new with it.
My use case:
I have a Python script that allows me to run a bunch of pipelines at the same time so I dont have to go and click each one of them manually. While running, the script displays a table (I'm using tabulate) with information for all the pipelines being run, like the status, the result, name and URL. This table is updated in "real time" (I'm using print("\n\033[H\033[J") to clear the screen). Now I wanted to add a progress bar to show me how many the pipelines are completed... so enter alive-progress. I got it to work exactly like I wanted but there's one visual issue that I don't like. Every time the table is refreshed it also shows on {item_number}: pushing the table to the right. I tried using bar.text but that only prints the header of the table.
My question is: Is there a way to disable the on {item_number}: when I print something from within the alive_bar context manager?
The relevant code:
class PipelineRun
...
@staticmethod
async def wait_pipelines(pipeline_runs: list["PipelineRun"]):
group = asyncio.gather(
*[pipeline_run.wait() for pipeline_run in pipeline_runs if pipeline_run.state != "FAILED_TO_START"]
)
with alive_bar(len(pipeline_runs), manual=True, unit=" pipelines", receipt=False) as bar:
while True:
if not group.done():
await asyncio.sleep(1)
PipelineRun.print_results_table(pipeline_runs, bar)
else:
break
@staticmethod
def print_results_table(pipeline_runs: list["PipelineRun"], bar: Optional[Callable] = None):
table = []
table_headers = ["Repository", "Pipeline", "Branch", "Build #", "Status", "Result", "URL"]
for pipeline_run in pipeline_runs:
table.append([
pipeline_run.repo,
pipeline_run.pipeline,
pipeline_run.branch,
pipeline_run.build_number,
pipeline_run.state,
pipeline_run.result,
pipeline_run.ui_url
])
total_pipelines = len(pipeline_runs)
completed_pipelines = len([pipeline_run for pipeline_run in pipeline_runs if pipeline_run.state == "COMPLETED"])
failed_to_start = len([pipeline_run for pipeline_run in pipeline_runs if pipeline_run.state == "FAILED_TO_START"])
print("\033[H\033[J") # clear screen
print("\nWaiting for pipelines to complete...\n")
print(tabulate(table, headers=table_headers))
print("\n")
if bar is not None:
bar((completed_pipelines+failed_to_start)/total_pipelines)
So this is not actually an issue with module itself but I guess I'm just too new with it.
My use case: I have a Python script that allows me to run a bunch of pipelines at the same time so I dont have to go and click each one of them manually. While running, the script displays a table (I'm using
tabulate
) with information for all the pipelines being run, like the status, the result, name and URL. This table is updated in "real time" (I'm usingprint("\n\033[H\033[J")
to clear the screen). Now I wanted to add a progress bar to show me how many the pipelines are completed... so enteralive-progress
. I got it to work exactly like I wanted but there's one visual issue that I don't like. Every time the table is refreshed it also showson {item_number}:
pushing the table to the right. I tried usingbar.text
but that only prints the header of the table.My question is: Is there a way to disable the
on {item_number}:
when I print something from within thealive_bar
context manager?The relevant code:
Sample output: