DEV Community

Cover image for GSoC Week 12
Chiemezuo
Chiemezuo

Posted on

GSoC Week 12

This was my penultimate week (going by the timeline for the final submission), so there was less new code being added, and more thorough testing of the code I'd already written.

Weekly Check-in

We had no meeting because Storm was on holiday and Saptak had a clashing meeting. There wasn't much to discuss, so we opted to catch up on Slack. The Slack discussions circled around making decisions on some of the questions that Thibaud raised when reviewing my pull requests.

Challenges

I probably unlocked superpowers because I didn't quite hit many stumbling blocks. I suppose that's one of the perks of working on a codebase for several weeks.
What I did find a bit challenging, however, was fixing up the bulk_to_python method in my ImageBlock. The implementation I'd had up to that point defeated the purpose of the bulk method because in the case where the received data previously belonged to an ImageChooserBlock, it ran a database query for each individual ID contained in the list elements. Fixing this required my going through the methods in the parent classes to get a sense of how things ran so that I could take advantage of the parent class' method. Afterwards, I would have to convert the format to something the ImageBlock could work with. It was simple, but it sure wasn't easy.

What I learned

I kept hitting some errors that made progress more difficult for me. I ended up running to Chat-GPT for some answers, and I made a nice finding. The following two code blocks might look the same but are very different.

for value in values:
            if isinstance(value, int):
Enter fullscreen mode Exit fullscreen mode
if all(isinstance(value, int) for value in values):
Enter fullscreen mode Exit fullscreen mode

I was stuck trying to get the latter to work because it looked "fancier" and more concise than the former, and this was because it was inherently wrong, although seemingly correct.

The first block of code goes through a list and checks each item in the list for a condition. The second block might look like it does the same thing, but I realized that the part after the if was a "generator expression" (as explained by ChatGPT). This meant that it would always evaluate to True because it was interpreted as "if there's a generator expression" rather than "if the output of this generator expression is true". Switching to the former solved the problems I had, however, it took a lot of debugging for me to find out that the error was actually from the if statement. I spent so much time logging every layer of the ImageBlock, the values for the methods, and the values in the parent class methods before making my findings.

After fixing the error though, I tested as thoroughly as I could and pushed my changes. All that was left were a few more comments that I thought I would resolve in my weekly meetings with Thibaud. However, he was unable to attend the meetings, so I pushed the final touches for the following week. I also asked my mentor to look into a CI error I was getting all of a sudden. We weren't able to get to the bottom of it and decided we'd face it squarely in the last week. This week, more than ever, I was so confident about finishing my Summer of Code program on a high note.

Thank you for reading this far, and kudos to you if you actually somehow followed up on this series.

Till next time.
Cheers. 🥂

Top comments (0)