All posts by Tarannum Khan

Outreachy: The learning phase

We are happy that Open Humans will have four Outreachy interns this summer. Our interns are working on their own Open Humans related projects and will regularly blog about their internship experience. Read Tarannum’s post about working on creating packages  for the Open Humans API:

The Open Humans API provides command line tools to interact with Open Humans. From where, I started working with Open Humans API to where it is now, the transformation has been just magical.

With the help of Open Humans organisation mentors,  lot of features were added like messaging and uploading large files with the help of AWS. From learning the proper way to name the functions to testing the functions, documenting the API using Sphinx, adding more command line tools, every smaller piece of learning added to create an avalanche of wisdom.

For legacy code, test is a necessity. The code is full of logic, it’s alive and it’s core to any application. We need to keep going back to the code to update it, so tests are crucial.

I mocked the API test using VCR.py . It’s just like Thor’s stormbreaker (Marvel fan will understand) in the field of unit testing. It’s apt for those applications which make http calls to external services(in my case Open Humans).

Why VCR.py

The external service should not be tightly coupled with the application. If the external services fail, the application should still run correctly. One absolute novice testing way is to hard code error prone request and code the necessary error handling routines. But, this is highly not recommended because once you update even a few line of code, you have to manually test it again. So, we hop on to the more sophisticated way of testing: Unittesting.

Running tests which call the external service every time will be very slow. Apart from it, the tests won’t work offline and sending too many requests to the external service can be a problem too. So, here steps the protagonist, VCR.py. 🙂

You just need to run the test online once when the cassette file which stores all the important information related to the requests response has not been created. Once, it is done, the response of requests will just be compared with the cassette file and yes , it’s done 🙂 . You have became successful in making your application more sturdy.

How to use VCR.py

For each function serving a particular feature, a class for testing is created. For testing different lines of code of a particular feature, different tests(functions with assertion) is created in the test class. Tests for valid response, invalid responses are written.

For the first time, when the test is run, the request really hits the external service and a cassette file is formed. Once the cassette is formed which contain status codes, status, etc, the response of tests is just compared with the cassette file when the tests are run again. It really speeds up the testing process and saves us from sending requests to the external service again and again. Whether you are offline at your home or 40,000 feet above the ground anytime you can test your code, once the cassettes are formed.

Want to try a hand on this cool stuff?  You can follow this https://github.com/OpenHumans/open-humans-api/blob/master/ohapi/tests/test_api.py. The link contains a lot of examples to write tests using vcr.py. You can see the bigger picture by observing any function in the https://github.com/OpenHumans/open-humans-api/blob/master/ohapi/api.py and how for each functions tests and cassettes are formed.

I would like to thank Mad Price Ball for mentoring me in the best way possible. The meetings with them are fun where I learn a lot of new stuff and a new way to see things, to tackle an issue with a fresh perspective.

Apart from this, I also worked on testing the public functions of Open Humans API. Presently, I am working on creating a reusable django app for Open Humans. A lot of brainstorming goes while you are in the process of designing an application, it’s use cases, what kind of audience it will cater.

Reusable application are the application which will be used by other applications. After all, reusability is the way of life in Python. I will cover the reusable app topic in my next blog. Till then, stay tuned. 🙂

The road to Outreachy

We are happy that Open Humans will have four Outreachy interns this summer. Our interns are working on their own Open Humans related projects and will regularly blog about their internship experience. Read Tarannum Khan’s first post about how they came to join Open Humans as an Outreachy intern:

Four months ago, my amazing journey with Outreachy started. Ever since I see a tremendous growth in me regarding not only the open source development field but also a great boost in my will to continue and succeed, interact with a new bunch of people easily and learn from them.

Just clearing the fog, Outreachy is a great program for the people out there traditionally underrepresented in tech who are interested in open source development and don’t know where to start or try hands in this area. This is the right place to get started. Outreachy community provide an immense support for beginner like you and me and nurture our development skills by providing a superb platform to work in a collaborative environment with the mentors and other Outreachy participants.

I am working with the Open Humans organization and my project is on “Writing an Python module for the Open Humans API & a self-contained, modular Django app”. Open Humans community have been very supportive throughout. I would like to thank Mad Price Ball(mentor), Bastian Greshake Tzovaras and Mike Esclante for being always there to clear my doubts. And the best thing about them is that they has been a major support in this process of learning by sharing their development knowledge which is pretty cool.

I got to know about Outreachy through my friends of my institute and took my first big step in this area.

START(very important)

Organisation and project selection

Select the perfect organisation with the perfect project and the perfect language to work on(But life is not so perfect). So let’s go practical. On the outreachy website, once the projects get floated, look for each and every project of every organisation. Take a look at the repository provided by them. For the beginners, do check on the issue tagged with beginners or good first issue. If it looks understandable after having a look at the repository, you are good to go and start contributing to it.

Initially you can contribute to two or three repositories but with time you would know which one to really pick and focus on. Every mentor has a different interaction style which is mentioned in the outreachy website from which you will get an idea, how to reach the mentors. I suggest that your decision to choose a project should majorly depend on the project repository, it’s issue and then on the language. Don’t hesitate to pick a language in which you are not much comfortable but you should know the basics at the least, rest assured learning with this amazing community.

Bug fixing

Once the project is selected, take an issue, if you think you can do it, get it assigned and start working. If you are having any trouble feel free to either raise your doubts in the organisation forum or you can contact mentors. Someone will be always there to git pull you ahead from where you were stuck. You would love the feeling when your first pull request will be merged. 🙂

Patience is the key

Sometimes things might get a little tough as you are a new player in this field. Just keep up with patience, keep reading documentations, keep discussing with your mentors, keep coding and you will solve the issue(BA-AM). After solving each issue from beginner friendly to moderate to hard level, your self-confidence will be boosted immensely. In this great learning curve, you will learn a lot of new and interesting development stuff and your stamina to read documentations will increase drastically. (Life of a developer: Birth, find bug, read documentation, code, death)

Outreachy proposal

Now it’s time for the big show: PROPOSAL. Think clearly and meticulously about the project, the problem it’s trying to solve and make a clear plan of how you will solve the problem with the proper timeline and technical details. You can see a link to my proposal here. Start at least two weeks before the deadline to write the proposal.

Done and dusted. After the outreachy application period, keep on contributing. Whether you get selected or not, but the road to Outreachy is totally amazing. Your knowledge and confidence will boost immensely. And maybe not immediately but definitely, you will get a project to work with the Outreachy community as Outreachy programme is held in winters as well as in summers, so just keep on coding. I was lucky enough to get selected in my first attempt and work with Open Humans. Just be ready to give your time and energy to Outreachy and keep on working. 😀

Some pre-internship suggestions will be to learn git. It really helps and will save a lot of your time. The earlier you start contributing, the better your chances will be to spend your summer or winter non-vacation.

Feel free to contact me at tkhaniitr@gmail.com. I will be there to clear the doubts and even interact with you, given that I am not that boring 😀.

Keep your enthusiasm up and keep coding.