LeoCumpli21's Blog

Fourth-week blog post for GSoC 2021

Published: 06/28/2021

Once again, I'm writing this as part of my Google Summer of Code (GSoC) for Python Software Foundation (PSF). The third week has ended, and along with it I finished my first milestone... Or at least that's what I thought. Last post I told you I was ready to tackle my second milestone, however, I forgot some lectures need to be checked as well. So, I did start my second milestone, but I had to pause it. Let the questions begin.

What am I working on

I worked on 2 different things. First, regarding my second milestone, I worked on two tickets. Before ellaborating on them, let me introduce you to what this milestone is about: It consists of refactoring Facebook's API lesson. The expected outcome is to have created new exercises with other APIs, public ones so that no special requirements are asked for.

  • The 1st ticket was a piece of cake. I just had to debug a block of code that involved using Reddit API.
  • The 2nd one wasn't as easy. Here's why: I had to create 3 exercises from scratch involving TestDive API. Here's one of them:
            import requests
            import json
            api_url = "https://tastedive.com/api/similar"
            proxy = "https://cors.bridged.cc/"
            parametros = {"q": "Coco", "limit": 5, "info": 1}
            solicitud = requests.get(proxy + api_url, params=parametros)
            datos = json.loads(solicitud.text)
            resultados = len(datos["Similar"]["Results"])
            print(f"resultados: {resultados}")
            peliculas_similares = []
            for peli in datos["Similar"]["Results"]:
            print(f"Pelis: {peliculas_similares} len: {len(peliculas_similares)}")
            pixar = 0
            for peli in datos["Similar"]["Results"]:
                for pal in peli["wTeaser"].split():
                    if pal == "Pixar":
                        pixar += 1
            print(f"Pixar: {pixar}")
I also added unittest for automatic grading to it. Apart from that, I made a web test with playwright for this same exercise. I learned about page.keyboard from Playwright.
Keyboard provides an api for managing a virtual keyboard. The high level api is keyboard.type(text, **kwargs), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
Before this, to press a key or type something I used:
            page.press("text=def remplazar_primer_caracter(s):", "Tab")
                "text=def remplazar_primer_caracter(s):",
                "return s[0] + s[1:].replace(s[0], '*')",
Notice the first argument, which is the "selector", an element to tell playwright where to apply an event. Now, I just have to place the cursor where I want to start typing and, with the keyboard class, tell it what to do. For example:
            page.click("#ac_l45_5 >> text=parametros = {}")
            # Clear all code
            # Type something
            page.keyboard.type("Hello world")
The second thing I worked on was fixing 2 lectures.

What have I struggled with this week?

Once again, git gave me trouble. I don't know why, but git push and all its variants decided to not work anymore. Regarding python, my major problem was when I wanted to clear all code with playwright using the ctrl+A & backspace keys.

What solutions have I found?

For the git problem, I had to install GitHub Desktop to push my local commits to my remote repo. For playwright doubts, I checked its documentation and found the keyboard class.
This is all for now :)

View Blog Post

Third-week check-in for GSoC 2021

Published: 06/23/2021

Hi! Today June 21 I begin my third week for GSoC 2021. I am loving this experience so far. Now, I'm going to answer 3 questions regarding my work last week, what I struggled with, and what I will focus on this week.

What did I do this week?

In my last post, I mentioned I was working on fixing the existing quizzes of the project. I kept doing that, and I finished. I started fixing some lectures. By fixing I mean:

  • Formatting all python code with black.
  • Changing static snippets to activecode.
  • Creating some exercises with automating grading using unit test
  • Creating some web tests (where needed), with playwright
I've already finished fixing 4 lectures. This week I made 8 PRs, some of which were proposing simple changes.

Did I get stuck anywhere?

Yes I did. As I've mentioned over the past posts, we use pytest-playwright as our web tester. I've been coding easy tests for the quizzes, and I thought that was enough. Until I got to program a test for a lecture that involved writing into a prompt box. I got stuck in there beacause I didn't know playwright had a special way to deal with dialog prompts. So I had to search in their documentation for an answer, and I got one.
Here's the piece of code I was looking for:

                def test_TWP18_ac_5(page):
                    # Deal with prompt box
                    def handle_dialog(dialog):
                        dialog.accept("una palabra")

                    # Code to go to TWP18 page, do the exercise and run it.

                    # Fill prompt box
                    page.on("dialog", handle_dialog)

What is coming up next?

Last Saturday (June 19), the team got together in a videocall to discuss what we've done so far and what is coming up. So, now that I've finished with the quizzes and the easy lectures, some of which are awaiting review, I will begin my second milestone. It consists on refactoring a lecture that involves accesing some APIs. My idea is to fix one existing exercise that uses Reddit API, and to create two exercises using two different public and easy to manipulate API's. Meanwhile, I'll continue searching for ways to make the SQL lecture work.

View Blog Post

Second-week blog post for GSoC 2021

Published: 06/14/2021

Hi everyone! This is my second post for Google Summer of Code (GSoC) 2021. The coding period has started and so far my experience has been most enjoyable. As I stated in my first post, this week I began working on my first milestone, and I can say I've done wonderfully.

What am I working on?

This week, a fellow collaborator (Ybrahin) and I worked on fixing the existing python quizzes of the project Python para Zombis. We divided the number of quizzes each one would fix; I get to fix 7. From those, I've completed 5. So far, I've done 5 PR's, 4 of which have been merged into the master branch, and 1 awaiting review. Completing a quiz fix also involves making a web test with pytest-playwright for an exercise in that quiz. Moreover, this weekend I did some research about Runestone supporting SQL language. This is relevant to us because there is a lesson in the project that is currently in standby due to the sqlite3 python module used in there. To be clear, Runestone doesn't support that module, and that's why this lesson isn't working.
Do you remember I talked about flake8 in my first post? Well, Ybrahin introduced me to another tool to automate code formatting, named Black.

Black is the uncompromising Python code formatter.
Black makes code review faster by producing the smallest diffs possible.

What have I struggled with this week?

I had no bigger problems than trouble understanding git commands. I am still getting used to working with GitHub, and sometimes I don't know the exact sintax, nor the correct time to execute them. Regarding python, I haven't struggled.

What solutions have I found?

If any doubts come to me while programming I tend to do one of two things:

  • Ask my workmates and mentors.
  • Try to find an answer from Google.

View Blog Post

First-week check-in for GSoC 2021

Published: 06/07/2021

On May 17th I received the great news: Python Argentina, the organization I applied to, under the umbrella of Python Software Foundation (PSF), accepted me to contribute to their project titled PyZombis. Since then, all accepted students entered the community bonding period. For three weeks, I've been in touch with my mentors and with two other students.
PyZombis is intended to be a MOOC to teach Python to Spanish speakers.
This article is my first check-in of the journey I'm beginning. I'll answer 3 simple questions. Hope you enjoy.

What did I do this week?

So far, I've done solid progress. I got to know my working team and discussed everything around the project. We decided the techniques of how we'll be working this GSoC, and most importantly, we have separated our initial proposals into milestones and issues in GitHub. Also, as I'm new to GitHub, I had to learn its basics. I learned about PEP8, the Style Guide for Python Code, and about a tool that checks whether my code follows those rules, named flake8. I learned about Playwright as well, a tool to automate tests for web apps. Now, I feel ready to start the coding period.

What is coming up next?

Today, June 7th, the coding period starts. I'll be working for 2 months on this open source software project. These first two weeks, I'll focus on completing my first milestone: fixing existing code, adding python quizzes with unit test and adding minimal Playwright tests.

Did I get stuck anywhere?

Indeed. My second milestone involves using Brython and the Twitter API. My mentor recomended trying to combine both by integrating twitter-scraper library in Brython. Unfortunately, everything I have tried so far hasn't worked.
View Blog Post