Logs
Automatic logging
The client can be interegrated with the logging package to stream the logs into the lab. The documentation below explains how to easily track your logs.
Add an observer
If you are already using logging
in your workflow, the integration will be very simple. Instead of creating the logger with logging.getLogger()
, use run.add_log_stream()
. It attaches a stream handler to your logger and returns the logger
object that you may use to directly write on this stream. Note that if you lose reference to the logger
object, you may reload it using the logging.getLogger()
, or call again run.add_log_stream()
.
from pyhectiqlab import Run
run = Run(name="Logging example", project="lab/demo")
logger = run.add_log_stream()
logger.info("Hello world")
Remove an observer
If you want to stop streaming the logs, use run.remove_log_stream()
. You can restore the stream by executing run.add_log_stream
back.
# Stop logging the stream
run.remove_log_stream()
# Start again
run.add_log_stream()
Error handling
When a run is used within a script (instead of a jupyter notebook), the error traceback will automatically be pushed to the lab and assigned the run a failed
status. If the exception is a KeyboardInterupt
, the status will be changed to stopped
.
# main.py
if __name__ == "__main__":
run = Run(name="With traceback", project="lab/demo")
assert False, "This error is automatically sent to the server."
python main.py
Methods
pyhectiqlab.Run
Parameters
Property | Type | Default | Description |
---|---|---|---|
logger_name | str | None | If specified, the name of the log stream that will be observed. If not specified, the root logging is be observed. |
format | str | '%(asctime)s - %(levelname)s - %(message)s' | Optional log format. |
level | int | 30 | Minimum logging level. See logging levels. |
Parameters
Property | Type | Default | Description |
---|---|---|---|
logger_name | str | None | If specified, the name of the log stream that will be observed. If not specified, the root stream will be remove. |
Parameters
Property | Type | Default | Description |
---|