This commit is contained in:
Benoît Sierro
2021-05-31 14:56:00 +02:00
parent f0b20b90c7
commit e40dc3ce2c
4 changed files with 12 additions and 7 deletions

View File

@@ -246,6 +246,7 @@ valid_variable = dict(
) )
ENVIRON_KEY_BASE = "SCGENERATOR_" ENVIRON_KEY_BASE = "SCGENERATOR_"
HUSH_PROGRESS = ENVIRON_KEY_BASE + "HUSH_PROGRESS"
TMP_FOLDER_KEY_BASE = ENVIRON_KEY_BASE + "SC_TMP_" TMP_FOLDER_KEY_BASE = ENVIRON_KEY_BASE + "SC_TMP_"
PREFIX_KEY_BASE = ENVIRON_KEY_BASE + "PREFIX_" PREFIX_KEY_BASE = ENVIRON_KEY_BASE + "PREFIX_"
PARAM_SEPARATOR = " " PARAM_SEPARATOR = " "

View File

@@ -50,5 +50,6 @@ done
############################################################################################## ##############################################################################################
#### call your code below #### call your code below
export SCGENERATOR_HUSH_PROGRESS=""
scgenerator {command} {configs_list} scgenerator {command} {configs_list}
exit exit

View File

@@ -2,10 +2,9 @@ import multiprocessing
import os import os
import sys import sys
from datetime import datetime from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Tuple, Type from typing import Any, Dict, List, Tuple, Type
import numpy as np import numpy as np
from numba import jit
from tqdm import tqdm from tqdm import tqdm
from .. import initialize, io, utils, const from .. import initialize, io, utils, const

View File

@@ -10,10 +10,11 @@ import datetime as dt
import itertools import itertools
import logging import logging
import multiprocessing import multiprocessing
import re
import socket import socket
from typing import Any, Callable, Dict, Iterator, List, Mapping, Tuple, Union import os
from typing import Any, Dict, Iterator, List, Mapping, Tuple, Union
from asyncio import Event from asyncio import Event
from io import StringIO
import numpy as np import numpy as np
import ray import ray
@@ -21,7 +22,7 @@ from copy import deepcopy
from tqdm import tqdm from tqdm import tqdm
from .const import PARAM_SEPARATOR, PREFIX_KEY_BASE, valid_variable, pbar_format from .const import PARAM_SEPARATOR, PREFIX_KEY_BASE, valid_variable, pbar_format, HUSH_PROGRESS
from .logger import get_logger from .logger import get_logger
from .math import * from .math import *
@@ -175,8 +176,11 @@ def progress_worker(num_steps: int, progress_queue: multiprocessing.Queue):
Literal[0] : stop the worker and close the progress bars Literal[0] : stop the worker and close the progress bars
Tuple[int, float] : worker id and relative progress between 0 and 1 Tuple[int, float] : worker id and relative progress between 0 and 1
""" """
kwargs = {}
if os.getenv(HUSH_PROGRESS) is not None:
kwargs = dict(file=StringIO())
pbars: Dict[int, tqdm] = {} pbars: Dict[int, tqdm] = {}
with tqdm(total=num_steps, desc="Simulating", unit="step", position=0) as tq: with tqdm(total=num_steps, desc="Simulating", unit="step", position=0, **kwargs) as tq:
while True: while True:
raw = progress_queue.get() raw = progress_queue.get()
if raw == 0: if raw == 0:
@@ -185,7 +189,7 @@ def progress_worker(num_steps: int, progress_queue: multiprocessing.Queue):
return return
i, rel_pos = raw i, rel_pos = raw
if i not in pbars: if i not in pbars:
pbars[i] = tqdm(**pbar_format(i)) pbars[i] = tqdm(**pbar_format(i), **kwargs)
pbars[i].update(rel_pos - pbars[i].n) pbars[i].update(rel_pos - pbars[i].n)
tq.update() tq.update()