|
| 1 | +--- |
| 2 | +layout: report |
| 3 | +report_year: '2018' |
| 4 | +permalink: /GSoC/2018/StatusReport/VaibhavRai |
| 5 | +student: Vaibhav Kumar Rai |
| 6 | +organisation: coala |
| 7 | +organisation_link : https://coala.io |
| 8 | +project: Debug and Profile Bears |
| 9 | +project_link: https://summerofcode.withgoogle.com/projects/#6109762077327360 |
| 10 | +tarball: https://rawgit.com/RaiVaibhav/GSoC-Report/master/project.tar |
| 11 | +mentors: > |
| 12 | + [Mischa Krüger](https://github.com/Makman2), |
| 13 | + [Fabian Neuschmidt](https://github.com/fneu), |
| 14 | + [Arjun Singh Yadav](https://github.com/arjunsinghy96) |
| 15 | +phase: |
| 16 | + - Bonding : https://gitlab.com/coala/GSoC/GSoC-2018/milestones/18 |
| 17 | + - Phase 1 : https://gitlab.com/coala/GSoC/GSoC-2018/milestones/52 |
| 18 | + - Phase 2 : https://gitlab.com/coala/GSoC/GSoC-2018/milestones/53 |
| 19 | + - Phase 3 : https://gitlab.com/coala/GSoC/GSoC-2018/milestones/54 |
| 20 | +bio: > |
| 21 | + I am third year student of B.Tech Computer Science Engineering at Shri Mata |
| 22 | + Vaishno Devi Uiversity, Katra, Jammu and Kashmir. I participated in GSoC and |
| 23 | + worked with [coala](https://coala.io) to create a better quality Bears by |
| 24 | + creating a tool which will have the ability to jump directly into Bear code |
| 25 | + and move through it using a debugger interface such as pdb and make debugging |
| 26 | + of Bears as easy as writing the Bear. |
| 27 | + A Debugger should also the ability to investigate the settings passed to the |
| 28 | + Bear. |
| 29 | + I also implemented a Profiler Interface which provides abilities to profile |
| 30 | + Bear code to optimize its performance. |
| 31 | +social: |
| 32 | + - GitHub: |
| 33 | + - username: RaiVaibhav |
| 34 | + - link: https://github.com/RaiVaibhav |
| 35 | + - GitLab: |
| 36 | + - username: RaiVaibhav |
| 37 | + - link: https://gitlab.com/RaiVaibhav |
| 38 | + - Gitter: |
| 39 | + - username: RaiVaibhav |
| 40 | + - link: https://gitter.im/RaiVaibhav |
| 41 | + - Openhub: RaiVaibhav |
| 42 | + - link: https://www.openhub.net/accounts/RaiVaibhav |
| 43 | + |
| 44 | +blog: https://raivaibhav.github.io |
| 45 | +activity: |
| 46 | + - 0: |
| 47 | + - repo: cEPs |
| 48 | + - link: https://github.com/coala/cEPs/commit/d7de1896ed3e9370a431987a210a82751e211066 |
| 49 | + - details: > |
| 50 | + cEP-0021.md: Proposed implementation of `Profiling Interface`. |
| 51 | + - 1: |
| 52 | + - repo: coala |
| 53 | + - link: https://github.com/coala/coala/commit/d6186cd1bc3f4e049acac21c657b5a21c55393de |
| 54 | + - details: > |
| 55 | + Removed the `filter_raising_callables` function and inline it, to decrease |
| 56 | + the complexity of code for future modification in Debugger<br>Interface pull |
| 57 | + request. |
| 58 | + - 2: |
| 59 | + - repo: coala |
| 60 | + - link: https://github.com/coala/coala/commit/c1184ca58a9cca30afc144e7ad7a1bf7c5fe5f55 |
| 61 | + - details: > |
| 62 | + Added Debugger Interface with `--debug-bears` argument and debug bears |
| 63 | + process so that pdb work in single process environment and<br>bear developer |
| 64 | + can debug specified bear. |
| 65 | + - 3: |
| 66 | + - repo: coala |
| 67 | + - link: https://github.com/coala/coala/commit/4cb1a6c5bb85bc42a315d118a2f66123465ab4ed |
| 68 | + - details: > |
| 69 | + Debug_Bears.rst: Added Debugger Interface document with demo. |
| 70 | + - 4: |
| 71 | + - repo: coala |
| 72 | + - link: https://github.com/coala/coala/commit/89833995c1380b813f30bf2048e3f63d495dd71a |
| 73 | + - details: > |
| 74 | + Prevent bear test from failing, replaced httpstat with Google teapot |
| 75 | + because of SSL certification error. |
| 76 | + - 5: |
| 77 | + - repo: coala-bears |
| 78 | + - link: https://github.com/coala/coala-bears/commit/8faa08ef573105a75cf31c57298d6b6ba9201d8e |
| 79 | + - details: > |
| 80 | + Debugged PySafetyBear to get the cause of upstream problem and failure of |
| 81 | + appveyor CI, updated PySafetyBear to support lastest version<br>of safety. |
| 82 | + - 6: |
| 83 | + - repo: coala |
| 84 | + - link: https://github.com/coala/coala/commit/e9e7e3770791b6df41b414a01c5a956c2b8b356f |
| 85 | + - details: > |
| 86 | + Added Settings inspection toolset through which user can access the |
| 87 | + settings of a Bear in Debug environment. |
| 88 | + - 7: |
| 89 | + - repo: coala |
| 90 | + - link: https://github.com/coala/coala/commit/80f8bc955bf4db2892d52262396d824f3050fb71 |
| 91 | + - details: > |
| 92 | + Debug_bears.rst: Added Settings inspection toolset document with demo. |
| 93 | + - 8: |
| 94 | + - repo: coala |
| 95 | + - link: https://github.com/coala/coala/commit/3cb58246351ecbabd9768151cb6b9fe28c3790fc |
| 96 | + - details: > |
| 97 | + Removed `debugger` flag from `init` of bear Base class because of the API |
| 98 | + breakage issue for the existing users. |
| 99 | + - 9: |
| 100 | + - repo: coala-utils |
| 101 | + - link: https://gitlab.com/coala/coala-utils/commit/ba2e0789d0f1c405af93e313e692087077b45954 |
| 102 | + - details: > |
| 103 | + Enhance TRUE and FALSE STRINGS in coala-utils `constants` so that |
| 104 | + settings like debugger and profiler can be enable and disable with<br>the |
| 105 | + value like `ok`, `positive`, `none`, `negative` etc. |
| 106 | + - 10: |
| 107 | + - repo: coala |
| 108 | + - link: https://github.com/coala/coala/commit/fea6e01bd0b5300b0f46c3528981c1e6558e1867 |
| 109 | + - details: > |
| 110 | + Added Profiler Interface on coala with `--profile` argument to profile |
| 111 | + execution of bear. |
| 112 | + - 11: |
| 113 | + - repo: mobans |
| 114 | + - link: https://gitlab.com/coala/mobans/commit/b2d62db0e7bd8879843879974f2168cc3600bfa2 |
| 115 | + - details: > |
| 116 | + Add `prof/` to `coala.gitignore` template. Ignored profiled data directory |
| 117 | + created by `pytest-profiling`. |
| 118 | + - 12: |
| 119 | + - repo: coala |
| 120 | + - link: https://github.com/coala/coala/commit/0e075217ea1bc5732d9deac57355431db00ef4ee |
| 121 | + - details: > |
| 122 | + Profile_Bears.rst: Add Profiling Interface document with demo. |
| 123 | +--- |
| 124 | + |
| 125 | +### Debug and Profile Bears |
| 126 | + |
| 127 | +#### Work Done |
| 128 | + |
| 129 | +1. Debugger Interface added in coala. |
| 130 | + 1. Step into the `run()` method of a bear move through it using a debugger |
| 131 | + interface such as `pdb` and exits as soon as `run()` is left. |
| 132 | + 2. Pdb's quit-command (`q`) remapped so coala continues its normal execution |
| 133 | + without aborting. So, `quit` or `q` will first clear all breakpoints and |
| 134 | + then continue execution. |
| 135 | + 3. Users can specify the bear they want to debug using `--debug-bears`. |
| 136 | + 4. Users can specify to debug bears using a `.coafile`. |
| 137 | + |
| 138 | +2. A new command `settings` is included in coala's Debugging Interface to |
| 139 | + inspect Bear settings in the debugging environment. It displays all passed |
| 140 | + settings of a Bear and their values so bear developer can quickly inspect |
| 141 | + them. |
| 142 | + |
| 143 | +3. Profiler Interface added in coala. |
| 144 | + 1. The profiler will start by profiling the `run()` method of bears because |
| 145 | + this is the part where bear writers will spend time on, as rest of the |
| 146 | + part like loading the files, collecting the settings, etc. are done by |
| 147 | + coala itself. |
| 148 | + 2. `--profile-bears` or `profile_bears` (using .coafile) is the main argument |
| 149 | + to enable profiling. |
| 150 | + 3. Accept an additional parameter `directory_path` through which bear |
| 151 | + developers can specify where to store the profiled data files. |
| 152 | + |
| 153 | +#### Challenges |
| 154 | + |
| 155 | +I had difficulties with testing of Debugger interface. With the help of `Mock`, |
| 156 | +test for debugger interface was created, though code coverage was 100% but |
| 157 | +`mock` test was not the ideal test, so after hours of discussion with Mischa we |
| 158 | +decided to capture the `pdb stdout` and assert the the output with the real |
| 159 | +output but problem arised, the ideal tests passes but somehow it didn't showed |
| 160 | +the code coverage to 100% not only that it also removed the coverage of the |
| 161 | +previous tests, at first I thought created test have some problem but seems |
| 162 | +like `pytest-cov` had a problem, so to confirm that I created a |
| 163 | +[test repo](https://github.com/RaiVaibhav/test_repo) and enable the |
| 164 | +[CI](https://travis-ci.org/RaiVaibhav/test_repo) on that repo to check the |
| 165 | +coverage report, it also showed same failure. So, I created a issue on |
| 166 | +`pytest-cov` repo but actual problem was, both coverage and debugger use the |
| 167 | +same trace feature, so it was not possible to run coverage and debugger in |
| 168 | +parallel or say it is not possible to chain the trace functions, so Mischa gave |
| 169 | +a idea to restore the trace callbacks and then run test, it worked finally so I |
| 170 | +included both ideal and `Mock` test so that the coverage remain 100, but in all |
| 171 | +of these I lagged around 3 week from my schedule. So I couldn't implement one of |
| 172 | +the proposed feature. |
| 173 | + |
| 174 | +#### Work to be done |
| 175 | + |
| 176 | +A tool which will provide the ability to inspect result instances like |
| 177 | +`origin`, `diffs`, `file`, `severity`, `message`, `aspects` and several other |
| 178 | +attributes in debugging environment or in a seperate python console where all |
| 179 | +where user can easily access there values. Information about result will help |
| 180 | +bear developer in creating a better performant Bears. |
| 181 | + |
| 182 | +Result inspection tool will not only help in debugging the bear results but |
| 183 | +also help in testing the bear by asserting the various attributes of expected |
| 184 | +result with actual result. |
0 commit comments