This content originally appeared on DEV Community and was authored by Harshil Patel
Introduction
This week in our open-source course at Seneca, we were tasked to learn a complete open-source pull request flow and submit a pull request to some other student repo. I partnered with my friend (Aryan)[https://github.com/AryanK1511] to work on his project (github-echo)[https://github.com/AryanK1511/github-echo]. A CLI tool that helps to assist in obtaining in-depth information about GitHub repositories.
I was working on adding a new feature that prints Token usage info when --token-usage
flag is passed as an argument to the CLI tool. When working with LLMs it is important to understand how many tokens are used and it's crucial to stay within a given token limit. Therefore, adding a feature for printing Token information is beneficial for users.
The Issue
Firstly, I was required to open an issue to Aryan's repo describing what feature I wanted to add to his repo. I submitted an issue mentioning feature details and how I am planning to implement this feature.
Implementing the Feature
First, I forked Aryan's repo, and here is the forked version. Next, I cloned this forked repo to my local machine and created a new branch for working on the feature, here is the branch.
Finally, I started working on the code and the first thing I did was to try and run Aryan's code on my local machine. For running his code, I was required to get the Gemini API key and GitHub API Token. After gathering all the required information and setting up those as environment variables, I tested the code on the local machine and it was working as expected with no errors. Then, I reviewed the file structure to understand how the tool is working and what files I need to make changes to add this feature.
Since Aryan is using the Gemini API, I spent some time reading API documentation and started understanding how API works and comparing it with the code. This knowledge is required for implementing the new feature. I reviewed the API reference and this is what a response from Gemini looks like, so my task was to extract this information and print it to stderr.
Updating codebase
With a clear understanding of what to do, I started by adding an option for accepting --usage-token
using typer
library. Then, I programmed the feature for printing token usage to stderr
along with regular output.
After implementing the feature, I thoroughly tested the tool and ensured it worked as expected. Following this, I updated the repo documentation to include how to use the tool.
Submitting a PR
I made all of these changes on my own branch in a forked copy of Aryan's repository. Since write access to open-source repositories is typically restricted to admins or maintainers, I submitted a pull request after resolving the issue.
Aryan appreciated my work and promptly merged the PR. After the merge, I closed the issue I had previously opened.
PR to my Repo
Aryan made a similar contribution to my GitHub repository, (Resume-enhancer)[https://github.com/hpatel292-seneca/ResumeEnhancer], a CLI taken for tailoring resumes based on job descriptions. He implemented the token usage features with an improvement for printing output to stdout
, which significantly improves the tool's functionality.
You can review the pull request to my repo: (PR)[https://github.com/hpatel292-seneca/ResumeEnhancer/pull/17]
Integrating Aryan's changes was seamless due to our strong friendship. I tested the updates by fetching his pull request into a separate branch and thoroughly evaluated the new feature. Everything worked perfectly, so I left positive feedback on his PR, acknowledging his great work, and then closed the request.
This experience of working on a classmate's repo was both enjoyable and a learning opportunity. I am excited to contribute to more complex projects in the future.
This content originally appeared on DEV Community and was authored by Harshil Patel
Harshil Patel | Sciencx (2024-09-20T14:16:54+00:00) My First Open Source Pull Request. Retrieved from https://www.scien.cx/2024/09/20/my-first-open-source-pull-request/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.