Skip to content

Commit c2d4752

Browse files
authored
Merge pull request #640 from malariagen/GH597_hide_progress_via_env_var
Use optional env var for show_progress in Ag3, Af1
2 parents 791dc1c + af3aff6 commit c2d4752

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

malariagen_data/af1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Af1(AnophelesDataResource):
4040
debug : bool, optional
4141
Set to True to enable debug level logging.
4242
show_progress : bool, optional
43-
If True, show a progress bar during longer-running computations.
43+
If True, show a progress bar during longer-running computations. The default can be overridden using an environmental variable named MGEN_SHOW_PROGRESS.
4444
check_location : bool, optional
4545
If True, use ipinfo to check the location of the client system.
4646
**kwargs
@@ -82,7 +82,7 @@ def __init__(
8282
results_cache=None,
8383
log=sys.stdout,
8484
debug=False,
85-
show_progress=True,
85+
show_progress=None,
8686
check_location=True,
8787
cohorts_analysis=None,
8888
site_filters_analysis=None,

malariagen_data/ag3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class Ag3(AnophelesDataResource):
112112
debug : bool, optional
113113
Set to True to enable debug level logging.
114114
show_progress : bool, optional
115-
If True, show a progress bar during longer-running computations.
115+
If True, show a progress bar during longer-running computations. The default can be overridden using an environmental variable named MGEN_SHOW_PROGRESS.
116116
check_location : bool, optional
117117
If True, use ipinfo to check the location of the client system.
118118
**kwargs
@@ -154,7 +154,7 @@ def __init__(
154154
results_cache=None,
155155
log=sys.stdout,
156156
debug=False,
157-
show_progress=True,
157+
show_progress=None,
158158
check_location=True,
159159
cohorts_analysis=None,
160160
aim_analysis=None,

malariagen_data/anoph/base.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import json
24
from contextlib import nullcontext
35
from datetime import date
@@ -54,12 +56,24 @@ def __init__(
5456
bokeh_output_notebook: bool = False,
5557
log: Optional[Union[str, IO]] = None,
5658
debug: bool = False,
57-
show_progress: bool = False,
59+
show_progress: Optional[bool] = None,
5860
check_location: bool = False,
5961
storage_options: Optional[Mapping] = None,
6062
results_cache: Optional[str] = None,
6163
tqdm_class=None,
6264
):
65+
# If show_progress has not been specified, then determine the default.
66+
if show_progress is None:
67+
# Get the env var, if it exists.
68+
show_progress_env = os.getenv("MGEN_SHOW_PROGRESS")
69+
70+
# If the env var does not exist, then use the class default.
71+
# Otherwise, convert the env var value to a boolean and use that.
72+
if show_progress_env is None:
73+
show_progress = True
74+
else:
75+
show_progress = show_progress_env.lower() in ("true", "1", "yes", "on")
76+
6377
self._config_path = config_path
6478
self._pre = pre
6579
self._gcs_default_url = gcs_default_url

0 commit comments

Comments
 (0)