name: Good First Issue
about: A beginner-friendly task perfect for first-time contributors
title: '[GOOD FIRST ISSUE] Add pre-check for empty links in LinkPredictor'
labels: 'good first issue'
assignees: ''
Welcome! 👋
This is a beginner-friendly issue perfect for first-time contributors to the Intugle project. We've designed this task to help you get familiar with our codebase while making a meaningful contribution.
Task Description
The LinkPredictor.predict method calls save_yaml without first checking if any links were actually found. If self.links is empty, save_yaml will raise a NoLinksFoundError, which is currently handled after the call. The check for empty links should be moved before the call to save_yaml to prevent unnecessary error handling and improve logic flow.
Why This Matters
By performing the check before calling save_yaml, we make the code more robust and prevent an unnecessary exception from being raised. This improves the clarity of the code and makes error handling more efficient, as the save_yaml method will only be called when there are actual links to save.
What You'll Learn
- How to improve error handling and control flow in Python.
- Understanding the
LinkPredictor class and its interaction with save_yaml.
- Best practices for defensive programming.
Step-by-Step Guide
Prerequisites
Setup Instructions
-
Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/data-tools.git
cd data-tools
-
Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
-
Create a new branch
git checkout -b fix/issue-NUMBER-pre-check-empty-links
Implementation Steps
- Locate the
predict method: Open src/intugle/link_predictor/predictor.py and find the predict method.
- Identify the
save_yaml call: Find the line self.save_yaml(file_path=filename).
- Add a conditional check: Before this line, add an
if statement to check if len(self.links) == 0. If it is, print a warning message (similar to the existing one) and return self to exit the method early.
- Remove redundant check: Remove the existing
if len(self.links) == 0: block that is currently after the save_yaml call.
Files to Modify
- File:
src/intugle/link_predictor/predictor.py
- Change: Add a pre-check for empty
self.links before calling save_yaml in the predict method.
- Line(s): Around lines 150-160.
Testing Your Changes
# Run tests
pytest tests/
# You might need to create a simple test case that simulates a scenario where no links are found
# to verify the new logic. For example, by providing datasets that have no common columns.
Submitting Your Work
-
Commit your changes
git add .
git commit -m "Fix: Add pre-check for empty links before saving in LinkPredictor"
-
Push to your fork
git push origin fix/issue-NUMBER-pre-check-empty-links
-
Create a Pull Request
- Go to the original repository
- Click "Pull Requests" → "New Pull Request"
- Select your branch
- Fill out the PR template
- Reference this issue with "Fixes #ISSUE_NUMBER"
Expected Outcome
The predict method will gracefully handle cases where no links are found by printing a warning and returning early, without attempting to save an empty relationships file.
Definition of Done
Resources
Need Help?
Don't hesitate to ask questions! We're here to help you succeed.
Skills You'll Use
Thank you for contributing to Intugle!
Tips for Success:
- Take your time and read through everything carefully
- Don't be afraid to ask questions
- Test your changes before submitting
- Have fun! 🎉
name: Good First Issue
about: A beginner-friendly task perfect for first-time contributors
title: '[GOOD FIRST ISSUE] Add pre-check for empty links in LinkPredictor'
labels: 'good first issue'
assignees: ''
Welcome! 👋
This is a beginner-friendly issue perfect for first-time contributors to the Intugle project. We've designed this task to help you get familiar with our codebase while making a meaningful contribution.
Task Description
The
LinkPredictor.predictmethod callssave_yamlwithout first checking if any links were actually found. Ifself.linksis empty,save_yamlwill raise aNoLinksFoundError, which is currently handled after the call. The check for empty links should be moved before the call tosave_yamlto prevent unnecessary error handling and improve logic flow.Why This Matters
By performing the check before calling
save_yaml, we make the code more robust and prevent an unnecessary exception from being raised. This improves the clarity of the code and makes error handling more efficient, as thesave_yamlmethod will only be called when there are actual links to save.What You'll Learn
LinkPredictorclass and its interaction withsave_yaml.Step-by-Step Guide
Prerequisites
Setup Instructions
Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/data-tools.git cd data-toolsCreate a virtual environment
Install dependencies
pip install -e ".[dev]"Create a new branch
Implementation Steps
predictmethod: Opensrc/intugle/link_predictor/predictor.pyand find thepredictmethod.save_yamlcall: Find the lineself.save_yaml(file_path=filename).ifstatement to check iflen(self.links) == 0. If it is, print a warning message (similar to the existing one) andreturn selfto exit the method early.if len(self.links) == 0:block that is currently after thesave_yamlcall.Files to Modify
src/intugle/link_predictor/predictor.pyself.linksbefore callingsave_yamlin thepredictmethod.Testing Your Changes
Submitting Your Work
Commit your changes
Push to your fork
Create a Pull Request
Expected Outcome
The
predictmethod will gracefully handle cases where no links are found by printing a warning and returning early, without attempting to save an empty relationships file.Definition of Done
Resources
Need Help?
Don't hesitate to ask questions! We're here to help you succeed.
Skills You'll Use
Thank you for contributing to Intugle!
Tips for Success: