Skip to content

Commit

Permalink
Remove unwanted output from console
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusJungemann committed Jan 23, 2025
1 parent ff9b051 commit 454c1aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/finn/builder/build_dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(self, logger, level, originalstream):
def write(self, buf):
for line in buf.rstrip().splitlines():
self.logger.log(self.level, line.rstrip())
timestamp = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
self.console.write(f"[{timestamp}] " + buf)
timestamp = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
self.console.write(f"[{timestamp}] " + line.rstrip())

def flush(self):
self.console.flush()
Expand Down
9 changes: 6 additions & 3 deletions src/finn/util/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import logging
import os
import subprocess
import sys
import tempfile
from qonnx.util.basic import roundup_to_integer_multiple

Expand Down Expand Up @@ -197,6 +197,9 @@ def build(self, code_gen_dir):
process_compile.communicate()


log = logging.getLogger("launch_process_helper")


def launch_process_helper(args, proc_env=None, cwd=None, print_stdout=True):
"""Helper function to launch a process in a way that facilitates logging
stdout/stderr with Python loggers.
Expand All @@ -209,10 +212,10 @@ def launch_process_helper(args, proc_env=None, cwd=None, print_stdout=True):
(cmd_out, cmd_err) = proc.communicate()
if cmd_out is not None and print_stdout is True:
cmd_out = cmd_out.decode("utf-8")
sys.stdout.write(cmd_out)
log.info(cmd_out)
if cmd_err is not None:
cmd_err = cmd_err.decode("utf-8")
sys.stderr.write(cmd_err)
log.critical(cmd_err)
return (cmd_out, cmd_err)


Expand Down

0 comments on commit 454c1aa

Please sign in to comment.