lava icon indicating copy to clipboard operation
lava copied to clipboard

Add logging and remove print statements

Open mgkwill opened this issue 3 years ago • 1 comments

Objective of issue: Add logging logger to lava to organize and enhance logging and remove print statements

Lava version:

  • [x] 0.3.0 (feature release)

I'm submitting a ...

  • [x] feature request

Current behavior:

  • Lava logging is done with print, which is minimally functional and doesn't allow for fine grained control of logging including debug logging

Expected behavior:

  • Use logging module for logging and log messages at the appropriate level of log-level

mgkwill avatar Feb 09 '22 20:02 mgkwill

This change enables unit test output to be:

.....................................................................s.................sss.............................................................................
----------------------------------------------------------------------
Ran 167 tests in 39.853s

OK (skipped=4)

Currently running unit tests outputs the following bloated and unneeded text:

Runtime not started yet.
Exception happened
Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line [39](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:39), in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line [50](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:50), in run_spk
    raise AssertionError("All the error info")
AssertionError: All the error info

Exception happened
Exception happened
Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line [54](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:54), in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 50, in run_spk
    raise AssertionError("All the error info")
AssertionError: All the error info

Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line [63](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:63), in run_spk
    raise TypeError("All the error info")
TypeError: All the error info

Exception happened
Exception happened
Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x[64](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:64)/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 63, in run_spk
    raise TypeError("All the error info")
TypeError: All the error info

Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 50, in run_spk
    raise AssertionError("All the error info")
AssertionError: All the error info

[Loihi1SimCfg]: Using the first PyProcessModel PyLifModelFloat available for Process Process_2[67](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:67)::LIF.
[Loihi1SimCfg]: Using the first PyProcessModel PyLifModelFloat available for Process Process_270::LIF.
[Loihi1SimCfg]: Using the first PyProcessModel PyLifModelFloat available for Process Process_273::LIF.
[INFO]  Executed 167 unit tests
[INFO]  All unit tests passed.
[INFO]  Executing flake8 on project sources.
[INFO]  Building distribution in /home/runner/work/lava/lava/target/dist/lava-nc-0.2.0
[INFO]  Copying scripts to /home/runner/work/lava/lava/target/dist/lava-nc-0.2.0/scripts
[INFO]  Writing setup.py as /home/runner/work/lava/lava/target/dist/lava-nc-0.2.0/setup.py
[INFO]  Collecting coverage information for 'pybuilder.plugins.python.unittest_plugin:run_unit_tests'
[WARN]  ut_coverage_branch_threshold_warn is 0 and branch coverage will not be checked
[WARN]  ut_coverage_branch_partial_threshold_warn is 0 and partial branch coverage will not be checked
[INFO]  Running unit tests
[INFO]  Executing unit tests from Python modules in /home/runner/work/lava/lava/tests/lava
Runtime not started yet.
Exception happened
Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 1[69](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:69), in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 50, in run_spk
    raise AssertionError("All the error info")
AssertionError: All the error info

Exception happened
Exception happened
Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 63, in run_spk
    raise TypeError("All the error info")
TypeError: All the error info

Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 50, in run_spk
    raise AssertionError("All the error info")
AssertionError: All the error info

Exception happened
Exception happened
Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 50, in run_spk
    raise AssertionError("All the error info")
AssertionError: All the error info

Traceback (most recent call last):
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/message_infrastructure/multiprocessing.py", line 30, in run
    mp.Process.run(self)
  File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/runtime/runtime.py", line 39, in target_fn
    actor.start(*args, **kwargs)
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 54, in start
    self.run()
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 169, in run
    raise inst
  File "/home/runner/work/lava/lava/src/lava/magma/core/model/py/model.py", line 123, in run
    self.run_spk()
  File "/home/runner/work/lava/lava/tests/lava/magma/runtime/test_exception_handling.py", line 63, in run_spk
    raise TypeError("All the error info")
TypeError: All the error info

[Loihi1SimCfg]: Using the first PyProcessModel PyLifModelFloat available for Process Process_267::LIF.
[Loihi1SimCfg]: Using the first PyProcessModel PyLifModelFloat available for Process Process_2[70](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:70)::LIF.
[Loihi1SimCfg]: Using the first PyProcessModel PyLifModelFloat available for Process Process_2[73](https://github.com/lava-nc/lava/runs/5129361365?check_suite_focus=true#step:5:73)::LIF.
.....................................................................s.................sss.............................................................................
----------------------------------------------------------------------
Ran 167 tests in 41.018s

OK (skipped=4)

mgkwill avatar Feb 09 '22 21:02 mgkwill