My code runs, But is it clean?

My code runs. But I didn’t ever think to care about whether it is clean or not. You might be wondering that why suddenly I have decided to write on this topic. Let me explain you the story.

I was going through badges of fedora and logged in to my account. And when I tried to view my profile as RDF it raised an Internal Server error. So I pinged Pingou on #fedora-apps about the issue and he told that the issue has already been reported. Since it was an internal server error I decided to run tahrir from my local host to know the reason behind the error(Though Ralph Bean has already commented the traceback on the issue later). And I followed README of tahrir to install tahrir for development purpose. There also I found some bugs, thus I sent a PR which was later merged. While initializing tahrir

$ initialize_tahrir_db tahrir.ini

I started getting traceback from dependencies. There was around 15 dependencies which threw traceback and I was like tahrir would not be working on my local machine 😛 . I finally installed all the dependencies with

$ pip install

and ended up with running tahrir from my localhost:8000 . I decided to send a PR to tahrir to avoid traceback from dependencies. Thus I did

$ pip freeze > requirements.txt

and sent a PR and asked Pingou & Threebean to review it. Pingou told me that requirements.txt contains all the dependencies those were installed on my virtualenv during setting up tahrir. It is not like tahrir requires all the dependencies listed in the requirements.txt to be installed on your virtualenv rather it needs only few of them. Well it can be explained like this

” If tahrir requires dependency A and installing A requires dependency B , then you do not need to include B as requirement. It will be dragged automatically while installing the dependency what you actually depend on which is A” — Pingou

Awesome lesson learnt! Hence I only needed to add requests and set an upper bound to rdflib. Thus I closed my PR and sent another PR to fix traceback. Though we were still getting traceback from twisted. As discussed with Pingou and Threebean on irc we realized it was an moksha.wsgi issue which was later fixed by  Threebean. And now we won’t be getting any traceback when hacking tahrir.

And I learned that we really don’t need to include unnecessary things in code that makes it look bad. Not only running our code successfully but we should also care about keeping it clean and good. Thanks to Pingou and Ralph Bean for giving me such a wonderful lesson. You people really made my day 🙂 . My day ended with earning a developer badge from fedora. Now I am trying to work on the issue and reading the codebase of rdflib. Because for the version of rdflib<4.x there was no internal server error. Only for rdflib>4.x there comes an internal server error. So there must be some change in rdflib source code which is raising the Assertion error in tahrir . Wish me good luck friends 😉

Anyway enough of talking. I should stop writing now 😛 See ya!

Advertisements