Skip to content

Commit dac73c6

Browse files
authored
Cleaner jupyter output (#123)
* feat: cleaner ouptut from progress bar in jupyter notebooks * Add type specification to output from start_macro * fix syntax * Update versions * black formatting
1 parent 5dcab67 commit dac73c6

3 files changed

Lines changed: 24 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# AnyPyTools Change Log
2+
## v1.14.0
3+
4+
**Added:**
5+
* Improved formatting of output when running AnyPyTools in Jupyter notebooks.
6+
* Add type anotation to the output of the `start_macro` function.
7+
28

39
## v1.14.0
410
**Added:**

anypytools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"NORMAL_PRIORITY_CLASS",
3737
]
3838

39-
__version__ = "1.14.0"
39+
__version__ = "1.15.0"
4040

4141

4242
def print_versions():

anypytools/abcutils.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def load_results(self, filename):
729729

730730
def start_macro(
731731
self, macrolist=None, folderlist=None, search_subdirs=None, logfile=None
732-
):
732+
) -> AnyPyProcessOutputList:
733733
"""Start a batch processing job.
734734
735735
Runs a list of AnyBody Macro commands in
@@ -838,29 +838,27 @@ def start_macro(
838838
raise ValueError("Nothing to process for " + str(macrolist))
839839

840840
# Start the scheduler
841-
try:
842-
with Progress(
843-
TextColumn("{task.description}"),
844-
BarColumn(),
845-
"{task.completed}/{task.total}",
846-
TimeElapsedColumn(),
847-
TimeRemainingColumn(),
848-
disable=self.silent,
849-
) as progress:
850-
task_progress = progress.add_task(
851-
"Processing tasks", total=len(tasklist)
852-
)
841+
with Progress(
842+
TextColumn("{task.description}"),
843+
BarColumn(),
844+
"{task.completed}/{task.total}",
845+
TimeElapsedColumn(),
846+
TimeRemainingColumn(),
847+
disable=self.silent,
848+
) as progress:
849+
task_progress = progress.add_task("Processing tasks", total=len(tasklist))
850+
try:
853851
for task in self._schedule_processes(tasklist):
854852
if task.has_error() and not self.silent:
855853
progress_print(progress, task_summery(task))
856854
progress.update(task_progress, style="red", refresh=True)
857855
progress.update(task_progress, advance=1, refresh=True)
858-
except KeyboardInterrupt:
859-
print("[red]KeyboardInterrupt: User aborted[/red]")
860-
finally:
861-
_subprocess_container.stop_all()
862-
if not self.silent:
863-
print(tasklist_summery(tasklist))
856+
except KeyboardInterrupt:
857+
progress_print(progress, "[red]KeyboardInterrupt: User aborted[/red]")
858+
finally:
859+
_subprocess_container.stop_all()
860+
if not self.silent:
861+
progress_print(progress, tasklist_summery(tasklist))
864862

865863
self.cleanup_logfiles(tasklist)
866864
# Cache the processed tasklist for restarting later

0 commit comments

Comments
 (0)