'Suppressing debug messages from neptune library

Is there a way to suppress the DEBUG messages outputted by the NEPTUNE library? https://github.com/neptune-ai/neptune-client

This is what I am doing currently:

tracker = neptune.init(project=f'WORKSPACE/PROJECT_NAME',
                       capture_hardware_metrics=False,
                       source_files=[],
                       capture_stdout=False,
                       capture_stderr=False)

These are the DEBUG messages I get:

2022-05-03  11:31:58 DEBUG https://app.neptune.ai:443 "POST /api/leaderboard/v1/attributes/ping?experimentId=aaa HTTP/1.1" 200 0
2022-05-03  11:32:08 DEBUG ping({'experimentId': 'aaa', '_request_options': {'timeout': 10, 'connect_timeout': 10}})


Solution 1:[1]

You can completely disable stdout. Use the following functions:

import sys, os

# Disable
def disable_stdout():
    sys.stdout = open(os.devnull, 'w')

# Restore
def enable_stdout():
    sys.stdout = sys.__stdout__

Example:

disable_stdout()

<Code to Run without logging/printing>

enable_stdout()

WARNING:
This is a quite dangerous approach, as it will probably hide other important/usefull messages.
Use it as a last resort

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Giorgos Skourtsidis