Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verbosity flag for MPB #1302

Merged
merged 21 commits into from
Jul 31, 2020
Merged

Add verbosity flag for MPB #1302

merged 21 commits into from
Jul 31, 2020

Conversation

RobinD42
Copy link
Contributor

See NanoComp/mpb#116 and NanoComp/mpb#119

  • Adds a verbosity flag for the mpb code.
  • All prints, whether in C++ or Python are now conditional with a verbosity check
  • Adds a Python verbosity manager class to make setting and checking the verbosity from Python more pythonic, it is used for both Meep and MPB.

Currently all verbosity checks are checking for >=2 so more fine-tuning will be needed to adjust the levels tested for the specific messages.

@RobinD42
Copy link
Contributor Author

RobinD42 commented Jul 27, 2020

In addition...

  • There are a few print statements in libctl that are still showing up, so similar verbosity checking will probably be needed there.

  • Does it make sense to have to set multiple verbosity flags from Python? It would not be hard to adjust the Verbosity class to be able to manage more than one of the C/C++ verbosity flags, and then set them all to the same value with one statement. The Verbosity object could also be adjusted to be used as a Singleton, improving its usability a little more.

@RobinD42
Copy link
Contributor Author

I think the remaining test failures are all due to using a libmpb that does not have a mpb_verbosity symbol yet. It's added in NanoComp/mpb#119

@stevengj
Copy link
Collaborator

When running interactively from Python, e.g. in Jupyter notebooks, we probably want to set verbosity to 1 by default.

@stevengj stevengj merged commit e416477 into NanoComp:master Jul 31, 2020
@RobinD42 RobinD42 deleted the mpb-verbosity branch July 31, 2020 20:32
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
* Return the prior verbosity level setting. Change the parameter name to `level`

* Add verbosity level global variable, and a Python function for setting it

* Switch the verbosity value and related code to a class

* switch parameter name to `level`, prep for reuse with other cvars

* Move verbosity module to meep

* Rename module to avoid name conflicts with names of instances

* Restore returning the former level from set()

* Use the Verbosity class in meep

* Add ability to set the initial level

* Make sure we use mpb's verbosity flag, and not colliding with meep's

* Move the creation of the verbosity obj so it's available when submodules are imported

* Add explicit rules for the meep.mpb .py files so they will be copied into place with a simple `make`

* Add verbosity checks in solver.py

* Add verbosity checks in libpympb/pympb.cpp

* Revert a Makefile change

* Handle the case where a cvar object does not yet have a verbosity attribute.
This will help with transitioning while the feature rolls out.

* Python2 doesn't have f-strings

* empty commit to trigger build

* Support building with an older MPB which doesn't have the mpb_verbosity global

* Set the verbosity default to 1

* match MPB

Co-authored-by: Steven G. Johnson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants