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

Logger Widget Panel #2872

Open
wants to merge 62 commits into
base: master
Choose a base branch
from

Conversation

atharva-2001
Copy link
Member

📝 Description

Type: 🪲 bugfix | 🚀 feature | ☣️ breaking change | 🚦 testing | 📝 documentation | 🎢 infrastructure

Write a complete description of your changes, including the necessary context or any piece of information required to understand your work.

Also, link issues affected by this pull request by using the keywords: close, closes, closed, fix, fixes, fixed, resolve, resolves or resolved.

📌 Resources

Examples, notebooks, and links to useful references.

🚦 Testing

How did you test these changes?

  • Testing pipeline
  • Other method (describe)
  • My changes can't be tested (explain why)

☑️ Checklist

  • I requested two reviewers for this pull request
  • I updated the documentation according to my changes
  • I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@tardis-bot
Copy link
Contributor

tardis-bot commented Nov 11, 2024

*beep* *bop*
Hi human,
I ran ruff on the latest commit (7d28b93).
Here are the outputs produced.
Results can also be downloaded as artifacts here.
Summarised output:

8	G004   	[ ] Logging statement uses f-string
5	F405   	[ ] `exclude_patterns` may be undefined, or defined from star imports
4	E999   	[ ] SyntaxError: Expected an expression
4	W292   	[*] No newline at end of file
3	W293   	[*] Blank line contains whitespace
3	UP015  	[*] Unnecessary open mode parameters
2	I001   	[*] Import block is un-sorted or un-formatted
2	E402   	[ ] Module level import not at top of file
2	F401   	[*] `IPython.display.display` imported but unused
2	TRY300 	[ ] Consider moving this statement to an `else` block
1	B018   	[ ] Found useless expression. Either assign it to a variable or remove it.
1	RET505 	[ ] Unnecessary `else` after `return` statement
1	RET506 	[ ] Unnecessary `else` after `raise` statement
1	E712   	[*] Avoid equality comparisons to `True`; use `if toml_config_tool_dict["tardis"]['edit_on_github']:` for truth checks
1	E722   	[ ] Do not use bare `except`
1	E902   	[ ] No such file or directory (os error 2)
1	W291   	[*] Trailing whitespace
1	D204   	[*] 1 blank line required after class docstring
1	PGH004 	[ ] Use specific rule codes when using `noqa`
1	PLW0127	[ ] Self-assignment of variable `atom_data`
1	UP009  	[*] UTF-8 encoding declaration is unnecessary
1	UP030  	[*] Use implicit references for positional format fields
1	UP032  	[*] Use f-string instead of `format` call

Complete output(might be large):

asv.conf.json:1:1: B018 Found useless expression. Either assign it to a variable or remove it.
asv.conf.json:32:2: W292 [*] No newline at end of file
conda-linux-64.lock:5:1: E999 SyntaxError: Expected class, function definition or async function definition after decorator
conda-lock.yml:14:10: E999 SyntaxError: Expected an expression
conda-osx-arm64.lock:5:1: E999 SyntaxError: Expected class, function definition or async function definition after decorator
docs/conf.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
docs/conf.py:27:1: I001 [*] Import block is un-sorted or un-formatted
docs/conf.py:27:10: W291 [*] Trailing whitespace
docs/conf.py:30:8: F401 [*] `tardis` imported but unused
docs/conf.py:36:43: PGH004 Use specific rule codes when using `noqa`
docs/conf.py:46:6: UP015 [*] Unnecessary open mode parameters
docs/conf.py:67:1: F405 `exclude_patterns` may be undefined, or defined from star imports
docs/conf.py:68:1: F405 `exclude_patterns` may be undefined, or defined from star imports
docs/conf.py:69:1: F405 `exclude_patterns` may be undefined, or defined from star imports
docs/conf.py:70:1: F405 `exclude_patterns` may be undefined, or defined from star imports
docs/conf.py:71:1: F405 `exclude_patterns` may be undefined, or defined from star imports
docs/conf.py:140:1: W293 Blank line contains whitespace
docs/conf.py:175:1: W293 Blank line contains whitespace
docs/conf.py:194:13: UP030 Use implicit references for positional format fields
docs/conf.py:194:13: UP032 [*] Use f-string instead of `format` call
docs/conf.py:221:1: E402 Module level import not at top of file
docs/conf.py:294:4: E712 Avoid equality comparisons to `True`; use `if toml_config_tool_dict["tardis"]['edit_on_github']:` for truth checks
docs/conf.py:361:1: E402 Module level import not at top of file
docs/conf.py:376:10: UP015 [*] Unnecessary open mode parameters, use ""w""
docs/conf.py:391:10: UP015 [*] Unnecessary open mode parameters, use ""w""
tardis/base.py:104:13: PLW0127 Self-assignment of variable `atom_data`
tardis/io/logger/__init__.py:3:4: W292 [*] No newline at end of file
tardis/io/logger/colored_logger.py:1:1: E902 No such file or directory (os error 2)
tardis/io/logger/logger.py:1:1: I001 [*] Import block is un-sorted or un-formatted
tardis/io/logger/logger.py:29:9: TRY300 Consider moving this statement to an `else` block
tardis/io/logger/logger.py:30:5: E722 Do not use bare `except`
tardis/io/logger/logger.py:174:21: G004 Logging statement uses f-string
tardis/io/logger/logger.py:247:5: D204 [*] 1 blank line required after class docstring
tardis/io/logger/logger.py:265:1: W293 [*] Blank line contains whitespace
tardis/io/logger/logger.py:265:2: W292 [*] No newline at end of file
tardis/simulation/base.py:8:29: F401 [*] `IPython.display.display` imported but unused
tardis/simulation/base.py:197:13: RET506 Unnecessary `else` after `raise` statement
tardis/simulation/base.py:261:17: G004 Logging statement uses f-string
tardis/simulation/base.py:268:9: RET505 Unnecessary `else` after `return` statement
tardis/simulation/base.py:445:13: G004 Logging statement uses f-string
tardis/simulation/base.py:543:13: G004 Logging statement uses f-string
tardis/simulation/base.py:632:21: G004 Logging statement uses f-string
tardis/simulation/base.py:635:13: G004 Logging statement uses f-string
tardis/simulation/base.py:640:13: G004 Logging statement uses f-string
tardis/simulation/base.py:691:13: TRY300 Consider moving this statement to an `else` block
tardis/simulation/base.py:693:26: G004 Logging statement uses f-string
tardis_env3.yml:3:10: E999 SyntaxError: Expected an expression
tardis_env3.yml:80:14: W292 [*] No newline at end of file
Found 48 errors.
[*] 16 fixable with the `--fix` option (4 hidden fixes can be enabled with the `--unsafe-fixes` option).

@atharva-2001 atharva-2001 marked this pull request as ready for review November 15, 2024 08:16
@tardis-bot
Copy link
Contributor

tardis-bot commented Nov 25, 2024

*beep* *bop*

Hi, human.

The docs workflow has succeeded ✔️

Click here to see your results.

self.futures = []

# Single event loop and thread for all environments
self.loop = asyncio.new_event_loop()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this to be created for environments outside of a notebook? e.g. what happens if you run TARDIS in the command line?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm afraid it creates a new loop there too. Do we want to show the logs in the terminal or do we want to show it as a Panel widget in the browser(it would be deployed on some port)? If it is the first case then I will change it so that this mechanism only works with VSCode and Jupyter Notebooks(since those are the places where we would be seeing the widget). Does that sound alright to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please make the logs just print to terminal for CLI use of TARDIS.

Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewfullard
Copy link
Contributor

I really don't like pinning notebook to an earlier version. There were major improvements in 7.x.

@atharva-2001 atharva-2001 force-pushed the logger_widget_panel branch 3 times, most recently from 72de203 to 5738a20 Compare December 16, 2024 10:30
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 69.38776% with 45 lines in your changes missing coverage. Please review.

Project coverage is 69.61%. Comparing base (a51af90) to head (7d28b93).

Files with missing lines Patch % Lines
tardis/io/logger/logger.py 67.85% 45 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2872      +/-   ##
==========================================
- Coverage   70.01%   69.61%   -0.40%     
==========================================
  Files         228      227       -1     
  Lines       16549    16587      +38     
==========================================
- Hits        11586    11547      -39     
- Misses       4963     5040      +77     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -182,6 +183,8 @@
else:
nbsphinx_execute = "auto"

# nbsphinx_kernel_name = 'python3'
# nbsphinx_allow_errors = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something to keep?

@tardis-bot
Copy link
Contributor

*beep* *bop*
Hi human,
I ran benchmarks as you asked comparing master (a51af90) and the latest commit (7d28b93).
Here are the logs produced by ASV.
Results can also be downloaded as artifacts here.

Significantly changed benchmarks:

All benchmarks:

Benchmarks that have stayed the same:

| Change   | Before [a51af908] <master>   | After [7d28b932]    | Ratio   | Benchmark (Parameter)                                                                                                               |
|----------|------------------------------|---------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------|
|          | 2.77±0ms                     | 3.21±0.04ms         | ~1.16   | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('scatter')                                     |
|          | 1.87±1μs                     | 2.18±1μs            | ~1.16   | transport_montecarlo_estimators_radfield_estimator_calcs.BenchmarkMontecarloMontecarloNumbaPacket.time_update_line_estimators       |
|          | 441±200ns                    | 491±100ns           | ~1.11   | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_pair_creation_opacity_calculation                                |
|          | 52.3±30μs                    | 57.6±30μs           | ~1.10   | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_scatter                                          |
|          | 22.7±5μs                     | 25.0±6μs            | ~1.10   | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_last_interaction_tracker_list |
|          | 2.96±0.4μs                   | 3.24±0.4μs          | 1.09    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_bad_vpacket                                       |
|          | 661±0.7ns                    | 704±0.9ns           | 1.07    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_thomson_scatter                                       |
|          | 2.33±0ms                     | 2.47±0.01ms         | 1.06    | transport_montecarlo_main_loop.BenchmarkTransportMontecarloMontecarloMainLoop.time_montecarlo_main_loop                             |
|          | 531±300ns                    | 541±100ns           | 1.02    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_compton_opacity_calculation                                      |
|          | 190±0.1ns                    | 193±0.2ns           | 1.02    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_intensity_black_body                                       |
|          | 1.19±0μs                     | 1.21±0μs            | 1.02    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_boundary                |
|          | 1.42±0.4μs                   | 1.45±0.4μs          | 1.02    | transport_geometry_calculate_distances.BenchmarkTransportGeometryCalculateDistances.time_calculate_distance_line                    |
|          | 60.9±0.09ms                  | 61.8±0.07ms         | 1.01    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_rpacket_trackers_to_dataframe                  |
|          | 3.91±0ms                     | 3.90±0.04ms         | 1.00    | opacities_opacity_state.BenchmarkOpacitiesOpacityState.time_opacity_state_initialize('macroatom')                                   |
|          | 1.05±0.01m                   | 1.05±0m             | 1.00    | run_tardis.BenchmarkRunTardis.time_run_tardis_rpacket_tracking                                                                      |
|          | 2.10±0m                      | 2.11±0m             | 1.00    | spectrum_formal_integral.BenchmarkTransportMontecarloFormalIntegral.time_FormalIntegrator_functions                                 |
|          | 39.5±0.03s                   | 39.3±0.4s           | 0.99    | run_tardis.BenchmarkRunTardis.time_run_tardis                                                                                       |
|          | 6.88±2μs                     | 6.80±3μs            | 0.99    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_volley                                    |
|          | 3.31±0.4μs                   | 3.26±0.4μs          | 0.98    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket_within_shell                              |
|          | 6.15±1μs                     | 5.98±0.8μs          | 0.97    | transport_montecarlo_vpacket.BenchmarkMontecarloMontecarloNumbaVpacket.time_trace_vpacket                                           |
|          | 45.4±20μs                    | 43.6±20μs           | 0.96    | transport_montecarlo_interaction.BenchmarkTransportMontecarloInteraction.time_line_emission                                         |
|          | 38.2±0.2μs                   | 36.6±0.04μs         | 0.96    | transport_montecarlo_packet_trackers.BenchmarkTransportMontecarloPacketTrackers.time_generate_rpacket_tracker_list                  |
|          | 571±100ns                    | 541±200ns           | 0.95    | opacities_opacity.BenchmarkMontecarloMontecarloNumbaOpacities.time_photoabsorption_opacity_calculation                              |
|          | 2.97±0.4ms                   | 2.77±0.6ms          | 0.93    | transport_montecarlo_single_packet_loop.BenchmarkTransportMontecarloSinglePacketLoop.time_single_packet_loop                        |

If you want to see the graph of the results, you can check it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

5 participants