Wednesday, 17 June 2015

WEEK 2&3 : UNPRODUCTIVITY


Okay that meme was exaggerating. But seriously I have been really busy with my work at Hackerrank which went into production this week. I have been a really bad web developer, much worse at managing my time.

Like I said there is not much work that has been done for GSoC, but I still have to keep posting to push myself to work harder and motivate myself. So this is how it went:

The testing framework that I had mentioned in my previous post took off quite well and my corresponding PR is merged. It has only the tests for basic getters and setters. We just plug in values and try to query them. Not a big deal !

No the agenda thereafter(Week 3) is to extend this testing practice for other functions as well. So an example functions that I could test is:

In the C file

If you see, the problem is that it doesn't return anything for us to test. Now the thing here is we send in a Radiation Packet and its storage model, it make modifications and returns nothing. We'd have to check if the parameters of the Packet changed correctly. Now that is a lot of work, I have opened a PR testing just one such function and lets see where it goes.

Tuesday, 2 June 2015

WEEK 1: ESTABLISHING A TESTING FRAMEWORK !

Okay I accidentally labelled my previous post to be the work of week 1&2 which was supposed to be the community bonding.


SUMMARY(for you lazy fucks out there :P)

  • Zeroed to one testing framework which is super awesome - "ctypes". Smooth and sexy.
  • Way ahead(by 2 weeks) of timeline. Take a look at my proposal.
  • Looking forward to completing the main project in 3 weeks from now and then help with the plasma project and the fitting project.

LONG STORY

As I had mentioned in my previous blogpost I have restructured the C files and the mentor liked it. Early of this week it got merged. Now the task was to test the C files so that the can be called from the root of TARDIS with python setup.py test.

So basically the idea was to be able to call the C functions in python and test them. This isn't a good idea because it involves rewriting all the functions with wrappers in cython or some such glue and then again test. OVERKILL !
OR we could write the tests in C and then write wrappers for them in python. This is okay, because you have a standalone C library for Montecarlo and also callable from python.

But I ended up doing something much better. I found this amazing library in python called ctypes. I knew it earlier but just din't realise how powerful it was until I incorporated it in this amazing way. Checkout my pull request.

What it lets you do is, you can basically use any compiled C library(.so files and etc) as DLLs into python and use their modules. All this with one single line.

from ctypes import CDLL

tests = CDLL(test_path)
tests.test_rpacket_get_nu(double_value)

So this will run the function test_rpacket_get_nu in a C file(library) located at the test path.
The C function look somewhat like this:

bool test_rpacket_get_nu(double value){ rpacket_t * rp = (rpacket_t *) malloc(sizeof(rpacket_t)); rpacket_set_nu(rp, value); if( value != rpacket_get_nu(rp) ){ return false; } return true; }



So I have written the tests for Montecarlo as I would have written for any C library and then called all those functions from python.

In this PR I tested several simple getters and setters using this method. I hope to get my pull request merged in a day or two(if I stop blogging and start coding :P) and then work on with other functions which are not so easy to test(even in pure C) All in all Montecarlo testing should be done in a week and a half or so.

Saturday, 16 May 2015

COMMUNITY BONDING

Its been a long time since I blogged about GSoC. I have been busy with my work at Hackerrank and frankly I haven't done much work for TARDIS and of course my mentor is quite pissed off. So I decided to take some time out for TARDIS.

What has been done

First we had several introductory meetings with all the team members on Google+. I would be working alone for a while on the montecarlo and might have to work with aoife on TARDISatomic later, something related to Helium module(The plasma project probably). It went good and everyone was an astronomer(holds a PhD) except me. After a few days I started to read code and browse through what I had done before(pre-GSoC) since I lost my flow and hardly remember anything I did(has been like a month since I touched TARDIS code).

First I got one of my previous PRs merged - Removing usage of yield in test_utils.py.
I have submitted this one during the pre-GSoC period. The problem with the previous instance of the file is that the yield function wasn't really working and hence the tests passed anyways. It looked something like this :



The problem here was that even if I change it to :



It still works. The reason is that we were using the yield function the wrong way, though I don't know what the right way is. I reported the issue and looked for alternatives until Vytautas figured out that yield was outdated and has been replaced with parametrize. I looked up its documentation and made a quick fix :


All those PRs have been closed and stacked up since long, I was reviewing a few and found out this one, so got it merged by Wolfgang(Don't be afraid, thats my mentor :P)

Then I went about trying to restructure the code, the first thing to figure out is 'HOW' to restructure the C-part. Now this was my idea of making the code more modular and readable, but I had no idea how. What I knew was just that putting all your eggs in one basket is never good - because it looked something like this :

 - montecarlo
   - src
     |
     cmontecarlo.c
     cmontecarlo.h

So basically all the methods for Montecarlo(about 20-25 functions) reside in the same file, each bunch of them serving a different purpose. The first naive approach to making it modular was something like this :


 - montecarlo
   - src
     |
     cmontecarlo.c
     cmontecarlo.h
     rpacket.c
     rpacket.h
     status.h
     storage.h


For more detail, check out my PR on github.

What needs to be done

While this passes all the tests(which means we are not messing up with the imports and compilations) this might not be the best or most optimised one. I would have to talk to my mentors yet and get done with the exact thing. The tentative time to get this merged(in its right state) is by 25th of May. Thats before the coding period.

What I think

While I have not been able to invest much time to this(as much as I did in the pre-GSoC) it still is relatively going good since we are well ahead of the proposed timeline. I am supposed to be understanding radiative processes of black-holes by now, but fuck that lets code !
So probably this pace is acceptable for now but have to get more serious in the coding phase(at-least I hope so ).

Will keep posting....

Wednesday, 29 April 2015

How I got in and what it felt like...

NOTE : THIS IS NOT YOUR "ULTIMATE GUIDE TO ACHIEVING GSoC GLORY" OR "HOW TO GET INTO GSoC FOR DUMMIES". ITS JUST A BLOG STATING MY EXPERIENCES AND CODE THAT WOULD GO IN THROUGHOUT THE SUMMERS SO YOU CAN KNOW WHAT OPEN-SOURCE IS ALL ABOUT.


JAN 2015 - How it started

It wasn't a milestone for me. For many its a glory, lifetime achievement and a definitive goal. I had the same perspective towards GSoC when I was in my 2nd year but then perspectives changed. I gradually started to believe that creating value should be the goal and that process in itself is what gets me high. GSoC/internships/Code-in are merely names/paths to creating great value, they shouldn't be goals themselves !

So why GSoC in particular ? Its because I wanted to be close to my family and work on something which I love and I hate 9-5 jobs, summers are the best time to pursue and explore your passions. Plus you can register it as a Research-Internship for your 3-rd year, and you would also be paid hell a lot. So this was the best summer package.

I fell in love with Sympy - Symbolic python. Its a mathematical software like wolfram. I was interested in abstract mathematics. So I decided to work on "Implementing Group theory module in Sympy".

FEB 2015 - What I wanted to do

I started contributing and made several naive PRs. It was a huge code base and required some time to get familiar with it. Moreover it covered concepts ranging from algebra to quantum mechanics. So it was quite a hard time.

Parallel to that I have been writing my own standalone group theory software which uses basic sympy elements to perform group theoretic functions.

Then I had a conversation with my potential mentor Aaron and also created a decent proposal. They seemed to love the idea and the chances of me getting in were quite good so I continued writing PRs and working on my proposal and the software simultaneously until the 20th when the selected organisations were announced. I realized that our organisation itself has not been selected this year.

This was quite a shock to everyone including the mentors. There was a panic in the mailing list and people bashing each other. Sympy has been a regular at GSoC for the past 3-4 years and under the python umbrella before that, taking about 10 students an year and this time Google bluntly rejected them.

On the other hand for me it was a really big disappointment for three reasons:

  1. Because all the work/code/research I did till then got unnoticed and even if they get a few slots from other organisations somehow, I wouldn't be in because there were much more important improvements to be done than adding a whole new field of mathematics to it. So my project was quite a low priority.
  2. Also because if I'm not in, I'll have no other option except to rot in college during the summers under the name of research internship and I will have to ask my parents money "for working for someone else", there's no real product that I would be creating, just research and I din't feel good about it.
  3. I also can't ask Kishan Patel(who is my dearest friend and was my employer at playpower) to take me as an intern again because even he was struggling a lot with his startup and I din't want to burden him.
Things changed and what GSoC was for me, is not that anymore. I planned correctly, put in effort and did my part but I got fucked and it wasn't my fault this time. At this point I was as desperate as everyone else to make things right for the summer.

FEB 2015 - What I ended up doing

I quickly looked up the organisations involving python and found this organisation called TARDIS - Temperature And Radioactive Diffusion in Supernovae. Its quite a scary name, I know !
I really liked the software and its domain(astronomy). Its still in its initial stages, with cool nerds developing it having PhDs in physics. Seemed exiting to me.

I introduced myself in the mailing list and started getting familiar with the code base. It was relatively easy for me this time, very less code, less research(partly because I took up the testing project).

Since I was quite familiar with python and also the code base I have written a lot of good PRs this time lightning fast until my mentor had to ask me to stop




















So I opened a new PR to resolve the C-tests issue but we were running into issues like this long thread and are still trying to figure things out. Feel free to think about it and comment there if you seem to find a better solution. I also found out that many attempts were made in the past but failed. I feel that the problem is with the setup files that were imported from astropy not playing well with our codebase, will look into that in the near future.

During this time I also wrote a good proposal which Wolfgang(my mentor) liked a lot and helped me out to finish it. After all this I have submitted my proposal on melange and just waited.

MARCH 2015 - What happened next

The mentors have rejected any further contact with the students until the result, None of us had any idea who was going to get selected. As time passed I started to get a feeling that there were other students/projects much more important to them plus its a small organisation so will get very few slots and I have a very less chance to get selected.

And during this period the Hackerrank(applied in december but din't get a call back) guys called me for an interview and I got selected there. This was quite a good turn and I stopped worrying about GSoC because irrespective of me getting selected or not, I can always contribute to TARDIS anytime and I know them well. I just wont get paid for it, and I was okay with it.

APRIL 2015 - Results

Until later when I was writing a mail to my dad and a mail pops in saying "Congratulations: You got selected for GSoC" and quickly opened the melange page. I was shocked and extremely happy at the same time.

Shocked because it was least expected and also realised that I was the only one of the 36 students who applied to get selected. The other two were somehow associated to TARDIS and weren't applicants per se.

MAY 2015(almost) - Now

What will follow now is a series of meetings and some prototyping(may be) until the coding period starts. I have one tomorrow and every Thursday. A typical agenda for a meeting looks like this:








































To be continued...