lf1-io / padl

Functional deep learning
Apache License 2.0
106 stars 4 forks source link

Simplify get segment #428

Closed wuhu closed 2 years ago

wuhu commented 2 years ago

This PR simplifies inspector.get_segment_from_frame, function responsible for extracting code segments from a frame object. Previously, for run-time reasons, this would first try to get the block of code surrounding the statement before extracting it. This proved to be the cause of many bugs, therefore I remove it here. This makes loading code slower. To mitigate, I added a cached version of ast.parse. Tests run a bit (factor of ~1.5) slower, but in practice this shouldn't be a problem.

codecov-commenter commented 2 years ago

Codecov Report

Merging #428 (f1e0a96) into main (f258e5d) will decrease coverage by 0.04%. The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main     #428      +/-   ##
==========================================
- Coverage   89.08%   89.04%   -0.05%     
==========================================
  Files          15       15              
  Lines        3006     3004       -2     
==========================================
- Hits         2678     2675       -3     
- Misses        328      329       +1     
Impacted Files Coverage Δ
padl/dumptools/inspector.py 92.73% <66.66%> (-0.67%) :arrow_down:
padl/dumptools/ast_utils.py 59.57% <100.00%> (+3.76%) :arrow_up:
padl/dumptools/var2mod.py 94.79% <100.00%> (-0.05%) :arrow_down:

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 bf1f0e8...f1e0a96. Read the comment docs.

wuhu commented 2 years ago

@jasonkhadka thanks for the review, I've changed accordingly.