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

Implementing Logging Configuration for Notebook Logging #1633

Merged
merged 31 commits into from
Jul 1, 2021

Conversation

DhruvSondhi
Copy link
Contributor

@DhruvSondhi DhruvSondhi commented Jun 7, 2021

This PR aims to implement a configuration for the Notebook logging such that logging can be turned on, off or set to a particular log level for better information.

Description

This implementation of the logging function allows for the following possible state:

  • Log_level, a string value which can be any of the following values: [Notset, Debug, Info, Warning, Error, Critical], allows for logging the output at any of these mention levels
  • Default value has been set to "Critical", thus no logging output is generated.

Implementation via YAML has also been done. New log_state flag is used to control the logging level as well as the state of the logger.
A new Debug section has been created for the JSON Schema. This section caters to all the Debugging parameters that can be set for TARDIS configuration. Debug Packets will also be moved here soon after discussion.

Motivation and context

Allowing for configurable logging levels & state would be a good addition to TARDIS. It would allow for running the simulation without the logs for graphs & other relevant information. Also, gives the opportunity to get only the specified information from the logger for the simulation ie logs of a particular level.

Screenshots

The screenshots here shows some of the different settings & their corresponding output for the logging configuration.

Without specifying any flag:
image
The logger doesn't print any information for the Simulation.

Specifying the log_state flag (functional argument) {setting to "Debug" Level}:
image
The simulation runs for 2 iterations.

Specifying the logging_level: flag (YAML argument) {setting to "Warning" Level}:
image
The simulation runs for 2 iterations.

Specifying the logging_level: as well as log_state flag (functional & YAML argument, both specified) {setting to "Info" Level for functional parameter & "Warning" Level for YAML}:
image
The simulation runs for 2 iterations.
Note: Log_state & log_state {YAML file parameter} both specified & Log_state will be used for Log Level Determination will be printed for the user to notify that both parameters have been given. Later on this will implemented via a logging statement as well.

Documentation Preview : https://dhruvsondhi.github.io/tardis/branch/notebook_logging_config/io/optional/logging_configuration.html

How has this been tested?

  • Testing pipeline.
  • Other.

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

@codecov
Copy link

codecov bot commented Jun 7, 2021

Codecov Report

Merging #1633 (eb3cb7a) into master (c47a3df) will decrease coverage by 0.02%.
The diff coverage is n/a.

❗ Current head eb3cb7a differs from pull request most recent head 37388fc. Consider uploading reports for the commit 37388fc to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1633      +/-   ##
==========================================
- Coverage   61.89%   61.86%   -0.03%     
==========================================
  Files          62       62              
  Lines        5732     5738       +6     
==========================================
+ Hits         3548     3550       +2     
- Misses       2184     2188       +4     
Impacted Files Coverage Δ
tardis/tardis/simulation/base.py 83.33% <0.00%> (-1.84%) ⬇️
tardis/tardis/base.py 59.09% <0.00%> (+4.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c47a3df...37388fc. Read the comment docs.

@DhruvSondhi DhruvSondhi marked this pull request as draft June 8, 2021 04:02
tardis/base.py Show resolved Hide resolved
tardis/io/schemas/base.yml Outdated Show resolved Hide resolved
tardis/io/schemas/debug.yml Outdated Show resolved Hide resolved
tardis/io/schemas/debug.yml Outdated Show resolved Hide resolved
tardis/montecarlo/montecarlo_numba/montecarlo_logger.py Outdated Show resolved Hide resolved
@wkerzendorf
Copy link
Member

wkerzendorf commented Jun 9, 2021

Please add documentation to this.

@DhruvSondhi DhruvSondhi marked this pull request as ready for review June 10, 2021 05:28
@DhruvSondhi
Copy link
Contributor Author

Also, This needs to be moved to a better place in the CodeBase. Need to discuss where a new Logging Submodule can be created 🚀

@DhruvSondhi DhruvSondhi force-pushed the notebook_logging_config branch 2 times, most recently from faa327d to 09cf417 Compare June 14, 2021 15:56
@DhruvSondhi DhruvSondhi force-pushed the notebook_logging_config branch 2 times, most recently from 2c0d0a3 to e69d467 Compare June 17, 2021 16:02
@KevinCawley KevinCawley mentioned this pull request Jun 17, 2021
10 tasks
@DhruvSondhi DhruvSondhi force-pushed the notebook_logging_config branch 2 times, most recently from cafd781 to 1efe8cb Compare June 18, 2021 08:55
tardis/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Rodot- Rodot- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make sure input to this function is validated, or at least don't let it pass silently without warning or error if an invalid value is encountered

tardis/__init__.py Outdated Show resolved Hide resolved
@Rodot- Rodot- self-requested a review June 30, 2021 13:16
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Show resolved Hide resolved
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Show resolved Hide resolved
@DhruvSondhi DhruvSondhi requested a review from Rodot- June 30, 2021 15:54
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Outdated Show resolved Hide resolved
tardis/__init__.py Outdated Show resolved Hide resolved
… arguments

Default value now falls to Debug->Log_state variable
Log_state functional parameter has None as default value
…n YAML & Functional parameters are specified

Updated the Documentation for the newer changes
@Rodot- Rodot- dismissed marxwillia’s stale review July 1, 2021 14:50

I approved the changes

@andrewfullard andrewfullard merged commit 8b7908b into tardis-sn:master Jul 1, 2021
@DhruvSondhi DhruvSondhi deleted the notebook_logging_config branch July 1, 2021 15:28
atharva-2001 pushed a commit to atharva-2001/tardis that referenced this pull request Oct 1, 2021
* Implementing Logging Configuration for Notebook Logging via Function

* Adding Docstring to logging_state()

* Making logging states independent of case of arugment passed

* Adding Debug YAML for Logging & Debugging

* Changing implementation to a single unified flag for logging level

* Moved logging_state() from montecarlo_logger to __init__ for TARDIS

* Adding support for logging messages at specified level

* Moving check for yaml & functional argument to logging_state function

* Added functionality for the Debug section of the YAML to be optional
Implemented check for Logging level & displaying Dataframe appropriately

* Added Tests for logging output configuration via Functional Input & YAML File
Added new YAML test file for testing YAML arguments for logging configuation

* Fixed display() still showing the plasma stratification values table when using specific logging at other logging levels than INFO

* Reworded description of the specific_logging parameter in debug.yml

* Added tests for simulation when both parameters, functional & YAML, are present
Changed debug.yml to be consistent with other test YAML configurations

* Changed the number of iterations & test cases for faster test executions

* Fixed docstring in __init__.py to impart the current implementation of the logging_state func

* Restructuring tests for faster simulation runs

* Added Tutorial Documentation for logging configuration

* Fixed & reworded some explaination in the Tutorial for better understanding

* Changed Quickstart notebook to incorporate new logging config in run_tardis()

* Changed the notebook as request, grammer changes

* Changed the python version to 3.7.10, reran the notebooks

* Fixed some inconsistencies in tutorial grammar

* Fixed with requested changes

* Made logging_level constant value
Changed the TestSimulationLogging class to comply to PEP8 styling

* Fixed metadata for scroll in quickstart notebook

* Renamed logging_level & specific_logging in debug schema to log_state & specific resp

* Added explaination of list_of_filters
Changed some implementation based on requested changes

* Added raising of an expection when invalid log_state parameter value is passed

* Changed implementation for the log_state function as well as the YAML arguments
Default value now falls to Debug->Log_state variable
Log_state functional parameter has None as default value

* Added message for informing the user which parameter will be used when YAML & Functional parameters are specified
Updated the Documentation for the newer changes

* [build docs]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants