MONTHLY LEARNINGS IN GOOGLE SUMMER OF CODE 2020
Mapping my Journey through GSoC’20 — Landing.
My Final Month as a GSoC 2020 Student Developer!
(I am Aryan Gupta, developing the MSS Software under Python Software Foundation through Google Summer of Code, 2020.
The Third Month of GSoC is fast paced. There’s writing tests, fixing bugs, catching up on backlogs, new features, documentation. Only when you are finished with the project do you get a breather.
Finally, the Last day of GSoC has arrived ;))
There’s not much of story writing here. Its basically wrapping up the project. Read on to see what I worked on in the last month and my learnings :))
Front-End Development
The UI is as minimal as it is. However, I still had to change button functionalities for better user experience.
My two cents : Perspective plays an important role.
In Marketing, users are considered gods. Their word is our command. They can never be wrong.
In Development, users are considered dumb. Who need to be guided at every stage. Software should be intuitive, not make them guess what to do.
Back-End Development
Fastkml Support
Fastkml implementation can parse all files. However, it won’t read the feature for which we have not added functionality. it will simply skip it. This helps prevent crashes when it encounters a foreign KML tag.
Here’s a table for important KML Features.
Some KML Features, at this point are not relevant for MSS. This includes those which connect to the Internet. Its considered unsafe for flight planning. Other things that are not necessary include adding an extra terrestrial layer or show pictures of places like in Google Earth. Its not needed in MSS.
The green parts are what I have added, in summary :
So, I am pretty confident all legal KML Files can be run, parsed, displayed on the map with the correct geometry and style :))
Attention to Detail— When you can’t see whats right in front of you.
A new feature that the mentors suggested was the flexibility to restore files in their last used state the next time KML Overlay is opened.
Sounded easy. I could save the last states of the files in a dictionary through the destructor, save settings to disk and then call those files the next time KML Overlay is opened. I wrote the required code and ran it.
File "/home/aryan/anaconda3/envs/mssdev/lib/python3.7/site-packages/matplotlib/figure.py", line 1909, in __getstate__
if getattr(self.canvas, 'manager', None) \
RuntimeError: wrapped C/C++ object of type MplTopViewCanvas has been deleted
Funny thing : I have been working strictly with Python. Why did I get a C/C++ error? And some object was apparently deleted… And I have been working with storing stuff in disk memory..really gave me anxiety.
Obscure errors like these make programming take more time than scheduled.
I tried, but couldn’t figure out the cause of the error. Joern pointed out my mistake —
I had a dictionary containing info of the file — its name, linewidth, colour and the patch object which was drawn on the map. I was attempting to save that dictionary, hitherto store an object in disk, that object got deleted when the program stopped running, hence the memory corruption.
Me : I feel silly. The answer was right in front of me.
Joern : You always do afterwards. Hindsight is so easy :)
Bug Fixing & Fixing Crashes
When you make changes quite fast, you forget to test out everything, and this gives rise to bugs. I faced a lot of them in the last 2 weeks. It was kinda embarrassing, when all the mentors were messaging “ Aryan, another bug”.
I am happy that the mentors found those errors early on , so I could fix them.
Then there were the crashes.
I am very confident about my Fastkml implementation. It was a shock when Reimar sent a KML File which crashed the software. The file threw up parsing errors, it got stuck and was difficult to remove from the ListWidget.
I went through the file. There was simply no fault anywhere in the KML Syntax. Even my Except statement to catch Syntax errors had not caught this. I did the trial and error method; removed some parts, tested which part was working and which was not.
The problem turned out to be a comma.
3D coordinates of LineStrings are separated by commas, and different points are separated by a whitespace. For example
1,2,0.0 3,4,0.0
represents coordinates (1,2,0.0) and (3,4,0.0). The KML File didn’t have the space between the points, but a comma. Thus it was being parsed as a 6 Dimensional coordinate than a 3 dimensional one!
You can have no idea what kind of things can cause error. You can just minimize it.
This put in a new doubt; Any badly written KML File can crash the software. Even a file having “Hello World” with a KML extension, and the software crashes. So, I set up better measures to catch and resolve such issues.
Writing Tests, Logging and Exceptions
Test Writing is tough. I learnt that Mocking is an important concept of tests, and damn useful!
I wrote tests for Automating Mouse Clicks for PyQt Elements, and for parsing KML Files and testing what patches were being plotted on the map.
Tests show vulnerabilities in the system. To fix these vulnerabilities, the easiest way is to catch the error in an Exception. However, I got into a bad habit of writing open Exceptions i.e.
except Exception as e:
This is not at all useful. It catches all the errors, so if somewhere the software fails, you will not be able to debug where the error occurred, since you are giving the error a free pass into the system.
Writing specific Exceptions, (and then logging the error) is the way to go!
Here are some awesome links to check out :
Final Product — Documentation & Demonstration
You can find an overview of my GSoC Project right here.
Its better to see those features in action. Here’s my Demo Video!
(Enhancing KML Support Demo Video — Mission Support System — GSoC 2020 by Aryan Gupta is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License).
Stats & Learnings
These might not be for all, but a good source of help for me, when I face anxiety while coding.
- Its just a problem. Its not everything. It will take time. But it will be solved.
- Take a break after a burnout. Fresh mind generates new ideas. ( I found it helpful to sleep on a problem and wake up with the solution next morning).
- Don’t sit in front of the screen all day. Do monotonous chores, physical exertion helps and the mind solves the problem on its own.
- Coding really just involves Objects and for loop and try except statements, the works. If you know the basics, you can accomplish a lot. Don’t put yourself down based on your present skill level. Just get started and Hustle!
- Programming is like 2 gears moving, and in between you keep adding more gears. You have to keep them all moving together.
- Its not about the number of lines, number of PRs. Its not about comparison with anyone. Its about learning for your own good.
- Writing down stuff helps. I finished up 1.5 notebooks working on my project.
- You can ask for help without feeling guilty if you have tried it on your own. Googling helps.
Acknowledgements
I’m thankful to my mentors Jörn Ungermann, Reimar Bauer and Christian Rolf who provided immense support and motivation to persevere through all my difficulties. They sympathised with my problems and gave me ideas on how to face the challenges head on. Without their guidance, I would have been lost. I would also like to thank my GSoC mate Tanish who helped me out with my small doubts from time to time :))
I’m also grateful to MSS, PSF & the GSoC Community. This program has made me more confident about my abilities, and has strengthened my belief in the fact that passion, perseverance and patience can help you achieve wonders!
Finally, to the Open Source Community : Thank you for being so welcoming. I started from scratch and three months later, its still hard for me to believe that I developed a feature of a software :)) Thank you for giving me this opportunity, and I’ll personally continue forward the Open Source spirit with my future contributions.
Signing out,
Aryan