GSoC’21 — Week 7 and 8 — Setting up the reply functionality

Saransh Chopra
3 min readAug 5, 2021

--

Well, I know I am late, but the last 2 weeks were super hectic because of my University examinations. The examination board suddenly decided to give out grades on the basis of internal examinations and I was burdened with projects, presentations, assignments, and vivas. I did manage to set up a base for the replying functionality. Here are some of the major things I added to the bot -

Refactored random part of the codebase

The codebase was very messy in the parts where random configurations were being generated for the bot and refactoring it solved 2 issues together. One, the code quality improved by a lot, and two, now that the randomness was separated from the functions that created simulations, it became very easy to pass down configurations into these functions which in turn paved the way for integrating the Reply functionality into the existing codebase. The comparison_generator function was also converted to a class named ComparisonGenerator to split up the comparisons into 2 parts — "model comparison" (comparing 2 or more models with an experiment or with a constant discharge) and "parameter comparison" (comparing a single model but varying a specific parameter).

Infinite reply issue

The recent Heroku deployment was working well but the bot was replying to the tweets every time the scheduled workflows ran. The replying feature worked on the following logic —

  1. Read all the tweets in which the bot is mentioned ID > stored ID.
  2. Store the tweet’s ID in a text file.
  3. Iterate over these tweets and reply.
  4. Repeat 1–3

This does create a chicken-egg problem for the bot with the tweet IDs, hence the first tweet ID was manually stored in the text file. All of this was happening on Heroku , i.e. the text file on GitHub was not updated with every new mention.

Now coming to the bug, we had enabled automatic deployment on Heroku which meant that every time theCI passed on the main branch (which happened on every scheduled run), the bot was continuously deployed on Heroku where it was built again with the outdated text file (that had the tweet ID) and the bot started reading and replying to tweets from that old ID.

To tackle this, a new function was added to sync the tweet IDs stored in GitHuband in Heroku .

The CI is failing currently due to some issues, but again, it is very hard to test it on a PR as most of it won’t even run on a PR. It will be fixed probably by tomorrow and the first simulation request will be out by this weekend!

--

--

No responses yet