Skip to content

Commit

Permalink
updates messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
pveigadecamargo committed Aug 12, 2024
1 parent 2654b93 commit ea95cc4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
23 changes: 17 additions & 6 deletions aequilibrae/utils/python_signal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.util as iutil
import os
import warnings
from random import choice

Expand All @@ -13,8 +14,7 @@

qgis = iutil.find_spec("qgis") is not None

if missing_tqdm and not qgis:
warnings.warn("No progress bars will be shown. Please install tqdm to see them")
show_status = os.environ.get("AEQ_SHOW_PROGRESS", "FALSE") == "TRUE"


class PythonSignal: # type: ignore
Expand All @@ -28,23 +28,26 @@ class PythonSignal: # type: ignore
['action', 'bar hierarchy', 'value', 'text', 'master']
'action': 'start', 'update', or 'finished_*_processing' (the last one applies in QGIS)
'bar hierarchy': 'master' or 'secondary'
'position': Position (0 for top, 1 for bottom)
'value': Numerical value for the action (total or current)
'text': Whatever label to be updated
'master': The corresponding master bar for this task
"""

deactivate = missing_tqdm # by default don't use progress bars in tests
deactivate = not show_status # by default don't use progress bars in tests

def __init__(self, object):
self.color = choice(["green", "magenta", "cyan", "blue", "red", "yellow"])
self.pbar = None # type: tqdm
self.keydata = {}
self.pos = 0
self.position = 0

def emit(self, val):
if self.deactivate:
return
if val[0] == "set_position":
self.position = val[1]

if val[0] == "finished":
if self.pbar is not None:
self.pbar.close()
Expand All @@ -61,14 +64,22 @@ def emit(self, val):
self.keydata[val[1]] = val[2]

elif val[0] == "start":
if missing_tqdm and not qgis:
self.deactivate = True
warnings.warn("No progress bars will be shown. Please install tqdm to see them")
if self.pbar is not None:
self.pbar.close()
desc = str(val[2]).rjust(50)
self.pbar = tqdm(total=val[1], colour=self.color, leave=False, desc=desc, position=self.pos)
self.pbar = tqdm(total=val[1], colour=self.color, leave=False, desc=desc, position=self.position)

elif val[0] == "update":
self.pbar.update(val[1] - self.pbar.n)
if len(val) > 2:
desc = str(val[2]).rjust(50)
if self.pbar.desc != desc:
self.pbar.set_description(desc, refresh=True)

elif val[0] == "set_text":
desc = str(val[1]).rjust(50)
if self.pbar.desc != desc:
self.pbar.set_description(desc, refresh=True)
3 changes: 1 addition & 2 deletions docs/website/check_documentation_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
sys.path.append(npth)
print(npth)

with open(npth / "__version__.py") as f:
exec(f.read())
from setup import release_version

# We check if the reference to all existing versions were added by checking
# that the current version is referenced
Expand Down

0 comments on commit ea95cc4

Please sign in to comment.