Lesson: Fixtures are a must
Django gives you this amazing Admin control panel. As soon as you get your models in place and are entering test data, start creating fixtures. For the dash we named them initial_data.json and loaded them into the individual app directories. This meant that every time we blew away the database we got a reload with records in place. Sometimes this means you have to hand-edit JSON (or YAML if you swing that way), but the alternative is to waste time re-entering the same data again and again. Don't forget to change the names of your test fixtures before you launch!
From the command-line how to save a fixture pydanny-style:
./manage.py dumpdata package > apps/packages/fixtures/initial_data.json
One nice thing about fixtures is that when you do have the time/need, you can use them to help you write tests. And it makes development easier for contributors.
Lesson: Research ahead of time
In the days before the contest, we researched to see if our target repos (Github, ;BitBucket, and Google Project Hosting) each had an API and a python library to speak to that API. Github has both an API and python library, Bitbucket has an API but no library. And as far as we can tell, Google Project Hosting lacks both API and library (someone please tell me I'm wrong about Google Project Hosting lacking an API).
This meant that when we commenced coding we knew which code base to work with - we weren't trying to look up this or that random package.
We did the same thing for rendering charts.
Lesson: Get it working then optimize
Looking at some of the code makes us wince a bit. But we got it working. Now we can go back and do some code cleanup, maybe use an XML parser instead of regex to try to scrape content from PyPI, and generally feel better about ourselves.
Lesson: Plan out system architecture in advance
In retrospect it was really amusing, but the night of launch the site was serving via the Django runserver command. We were so dead tired and neither of us are crack system administrators that we did what we had to do to score the contest launch point. The next day Audrey got the site running underApache, and next week we'll be giving someone else system access to increase reliability. Next year for the contest we'll probably use something like this or get continuous integration running in the first hour.
Lesson: Don't be afraid to chat with others after the contest starts
Share your ideas, selected packages and frameworks with your competitors. The break from coding helps clear the mind and they might counter with a better idea/package/framework you can use.
3 comments:
Very nice post with some good detail. I need to get comfy with Fixtures asap, for upgrading my Mingus site... so many little pieces to track,,
Great project! congratulations to both of you.
Lesson: Get it working then optimize
Lesson: Plan out system architecture in advance
Bit of a contradiction, don't you think ;)
@Alex - A little bit. But if we had thought the system work through we might have had a system that didn't go down every 20-30 minutes.
Post a Comment