Monday, July 11, 2011

GCI 2011 GCI with New Architecture - W7

Hello all,

This week I started with the Public Task view which first showed all the static fields and then I have created a Form to publish comments for the task and to retrieve the work submissions on that view.In the meanwhile my redirects patch got reviewed and I refactored the GSoC Redirects module but due to my mistake, it broke the existing code, I sincerely apologize for that.I have again written the GCI Redirects module avoiding these mistakes.I then wrote the GCI Timeline Helper class and moved some common code to the core.This got reviewed and will be committing this after the previous patches gets approved.After this I wrote the views to create and edit a GCI Task and have learnt some new things in this process and I sent this one for review too and then as advised by Madhu I moved onto to the task workflow, as the first step I have written a form with a drop down that has the list of actions that are available to the Org Admin, Mentor or Student depending upon the task status.I will be sending this to review now in bit.This week I have spent much more time with my project and in communicating with Madhu which helped me clear many doubts and work better, I feel I have this week's progress is better than the previous ones and I'm happy about it.I will be increasing my time on the project this coming week and will try my best to cover the lag.

GSoC 2011 GUI Overhaul: Push the code and some tasks need to be done

Hi everyone,

Last week I've been working to fix my patches with Daniel. Today I've pushed it into repository. It took a time to convert my commits into chronological patch with Mq. When I sent my patches without Mq, I used the following command to output the patch :

hg export -r started_revision_of_admin_dashboard:tip > patch.diff

Meanwhile the upstream repo changes rapidly with Madhu's changes, so importing the patches that have different tip with my own tip may abort the import. Mq is totally helpful if you're working on many patches while there are rapidly changes in the upstream repo. All you need to do is push your patches into queue and refresh it while receiving feedback from review. And then do hg qfinish to convert the patch into permanent changeset. With the awesomeness of Mq and review/feedback from Daniel and Praveen I just pushed my code a couple hours ago.

The admin dashboard isn't finish yet, there are some functionalities need to be done for PA, such as statistic that Daniel has been working on. I also promised to create MapClusterer to display participant in a single map like the following one:


After finishing the MapClusterer and integrate the statistic module into admin dashboard, I'll working on uploadable org's logo with cropping feature. I've made silly app that prove how Image service from GAE was capable to implement this feature.

Sunday, July 10, 2011

GSoC 2011 Melange Testing Project: CP W7

Hi

The task for this week was to correct my previous tests and finish the remaining tests in soc.logic and soc.modules.gsoc.logic. I have corrected my previous tests and submitted them again for the review. I have tested all the logic functions which are used at least once in the code base. I have not tested the soc.logic.allocations, soc.logic.lists and soc.logic.helper.notifications because these are not in my priority list for now as I need more familiarity with the code base to test them correctly and efficiently. I will come back at some time in future to test them.

       I have started attempting to write the view tests. I have never written any view tests earlier and my experience with Django is 0.1, but sometimes we have to learn the hard way. I studied many of the new tests written by Sverre. Testing a view seems to be a complicated task and I did not understand many things which I had to ask Madhu. Just before writing this post, I had a discussion with Madhu and I asked him what 'Context' is, what tests_utils.StuboutHelper is for, what soc.views.helper.access_checker.Mutator is used for and a load of other topics. At the time of writing this blog post, I was testing the soc.views.helper.access_checker. It will consume more time to test because there are more than 1100 lines of code to test. After testing this, I will test the gsoc.views.helper.access_checker module.

      I have the target of completing all the view tests before the final evaluations. It will require a huge amount of effort which I am pouring in. Lets hope for the best. :)

GSoC 2011 Integration with External APIs: Proposal Sync - W7

Approaching to midterm, i partially finished my first deliverable and sent my patches for review. I'm really For now there is one way sync from GDocs to Melange. We are still discussing to allow students "sync back" their proposals to GDocs.

I was struggled with some problems that i want to mention during this blog post. First when using GData libraries on App Engine infrastructure, exporting documents is not directly possible. The reason is that App Engine uses a distrubuted system and this does not allow to write to filesystem. To export anything, GData restricts its API to save output into a file instead of returning exported content. You need little change on gdata library to make it possible:


diff -r 84a930b76e63 -r e65b82d9ad71 app/gdata/docs/service.py
--- a/app/gdata/docs/service.py Sat Jul 09 03:58:23 2011 +0530
+++ b/app/gdata/docs/service.py Sun Jul 10 11:27:08 2011 +0300
@@ -106,6 +106,11 @@
         server=server, additional_headers=additional_headers, **kwargs)
     self.ssl = True
+    # Variables used to hack-in Export function to use it
+    # with a file handler instead of file path name.
+    self.file_handler = None
+    self.use_file_handler = False
+
   def _MakeKindCategory(self, label):
     if label is None:
       return None
@@ -183,10 +188,17 @@
       raise gdata.service.RequestError, {'status': server_response.status,
                                          'reason': server_response.reason,
                                          'body': response_body}
-    f = open(file_path, 'wb')
-    f.write(response_body)
-    f.flush()
-    f.close()
+
+    def writeResponseToFile(f, close=True):
+      f.write(response_body)
+      f.flush()
+      if close:
+        f.close()
+
+    if self.use_file_handler:
+        writeResponseToFile(self.file_handler, close=False)
+    else:
+        writeResponseToFile(open(file_path, 'wb'))
   def MoveIntoFolder(self, source_entry, folder_entry):
     """Moves a document into a folder in the Document List Feed.
@@ -346,7 +358,7 @@
     self._DownloadFile(url, file_path)
-  def Export(self, entry_or_id_or_url, file_path, gid=None, extra_params=None):
+  def Export(self, entry_or_id_or_url, file_path, gid=None, extra_params=None, file_handler=None):
     """Downloads a document from the Document List in a different format.
     Args:
@@ -361,6 +373,13 @@
     Raises:
       RequestError if the service does not respond with success
     """
+
+    if file_handler:
+      self.file_handler = file_handler
+      self.use_file_handler = True
+    else:
+      self.use_file_handler = False
+
     ext = None
     match = self.__FILE_EXT_PATTERN.match(file_path)
     if match:


With this you can use a memory file (StringIO) with Export function to write content to file handler directly instead of giving a file name to function for opening.

Second problem was about OAuth authentication page. We were willing to put OAuth page inside a frame in a jQuery dialog instead of a popup window. For strange reasons, page did not show up in the frame. I started an issue to learn the reason behind that: http://code.google.com/p/gdata-issues/issues/detail?id=2651

You can see demo of proposal sync from here with username:testmelange@gmail.com , password:melange2011 and type to find "Test Document 1" that is in GDocs account of testmelange user.

Monday, July 4, 2011

GCI 2011 GCI with New Architecture

Hello all,

Apologies for the late blog post.This week I have started off with the url patterns for GCI and Lennard suggested that I move the common functions to the core and leave the GCI related constants in that module and I have done that.I then went onto the GCITask view but before that I had to add another method to the access_checker to check if the task is published or not but looks like, I still need to modify this method a bit to include other cases too.I still have to retrieve work submissions for the Task view and form to edit the task and to subscribe the task.And me and Madhu had a small discussion about the templates and we decided to use the gsoc templates for now and make modifications where needed and use gsoc's css and JS till we get the designs.Meanwhile my other patches have been reviewed.First I had to refactor the gsoc redirects module, as many of the redirects are moved to the core and some methods have to be overridden to set the _url_name.And I was asked to make a little change to the gsoc access_checker as it's DeveloperAccessChecker should also inherit from AccessChecker, and the same was done to the gci access_checker too.Made required changes to the other patches as mentioned.I haven't spent enough time last week, as I had to help a Professor with his coursework and I really could not avoid it, I discussed with him today and took permission till the end of August, So I will cover up this week and will spend extra time on my project.

GSoC 2011 Melange Testing Project: CP W6

Hi,
In the last conference call, I reported my problems to Sverre that most of my time is spent on reading the code itself and that I had problems in deciding about the use cases when writing tests. My productivity has been very low till now and I have written atmost two tests per week. This week I worked hard and I have written tests for all the modules in gsoc.logic and soc.logic except three modules. Though the tests are under review and they need drastic improvements, I have now become comfortable in deciding about the use cases and writing tests. I had a discussion with Leo and he told that I was unnecessarily using DjangoTestCase. I can use seeder_logic and inherit my test classes from unittest.TestCase and this will improve the performance and speed. I was using DjangoTestCase to avoid instantiating the GSoCOrganization, GSoCTimeline and other entities which I could use directly when inherited from DjangoTestCase. But seeder_logic is more useful and its also used in DjangoTestCase. So, I corrected the test for soc.logic.host and used seeder_logic to seed the entities and it was working fine.
     
I tested a total of 8 modules in this week and the coverage has increased by 4%. The present coverage of the tests in my local copy is 70%. The coverage will increase more when I write tests for the soc.views. 

My work for this week is to correct the previous tests, test the remaining three modules in gsoc.logic and soc.logic and then start the view tests.I hope to finish all the logic tests before the mid-term evaluations.

PS: Mercurial queues are AWESOME. Salute and gratitude to the guy who wrote that extension. :)

Sunday, July 3, 2011

GSoC 2011 GUI Overhaul: Typical PA Workflow and Admin Dashboard Usage

Hi everyone,

A week ago I asked Madhu about the typical workflow for PA (Program Admin). Madhu was so kind to explain the workflow for PA. I'll summarize the workflow and usage of admin dashboard by the PA. The followings are ordered things that should be done by PA to organize the GSoC program:
  1. Initialize the program settings such as program name, document page, or timeline of the program. These settings already provided by site.py and timeline.py views.
  2. Invite organizations to participate.
  3. Create the organization application survey. I believe this is related to what Madhu's did for survey with form builder. I can easily add the url inside the new admin dashboard to refer to the form builder.
  4. PA and her team discuss the organization selection internally.
  5. Accepted organization announced. I don't know yet if there's a view or task to accept organization.
  6. Student signup period. Students begin submitting proposals to organizations.
  7. PA can assign slot in this time or before the accepted projects announced. There's a view for slot assignment.
  8. PA can check the duplicate proposal. There's a view to trigger the duplicate proposals' task queue. This queue will iterate each proposals and filter the proposals by the same student that would be accepted by two or more organizations. The resolution was done manually by gathering a meeting.
  9. PA can check slot transfer by organization and accept/ignore the request of transfer by org admin. There's a view for this.
  10. After all organizations solve the duplication status and agree with the given slots. PA can trigger the accept_proposals' task queue. There's a view to trigger accept_proposals queue.
  11. PA creates survey for mentors and students. There's a survey builder committed by Madhu.
  12. PA freeze the program after the final term.
I don't know yet what the task needed by the PA after creating the survey. But the typical workflow should be like the list I mentioned above.