Skip to content

Bug fix/exceptions - #74

Open
codedbyishika wants to merge 25 commits into
refactoring_validationfrom
bug-fix/exceptions
Open

Bug fix/exceptions#74
codedbyishika wants to merge 25 commits into
refactoring_validationfrom
bug-fix/exceptions

Conversation

@codedbyishika

Copy link
Copy Markdown
Contributor

Change generic exceptions to specific exceptions defined in utils.py

@egrace479
egrace479 changed the base branch from main to refactoring_validation July 31, 2026 15:54
@codedbyishika
codedbyishika requested a review from egrace479 July 31, 2026 20:17

@egrace479 egrace479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably have process point exceptions defined instead of trying to anticipate which may be raised. @thompsonmj what do you think?

Comment thread src/cautiousrobot/__main__.py Outdated
Comment thread src/cautiousrobot/__main__.py Outdated
@codedbyishika codedbyishika linked an issue Aug 3, 2026 that may be closed by this pull request
6 tasks
Comment thread tests/test_buddycheck.py
Comment on lines 12 to 38
def setUp(self):
self.buddy_check = BuddyCheck()
self.buddy_check_filename = BuddyCheck(buddy_id='filename')
self.buddy_check_id_col = BuddyCheck(buddy_id = "filename", buddy_col = "sha256")

self.img_source_file = tempfile.NamedTemporaryFile(delete=False, mode='w') # noqa: SIM115
self.checksum_source_file = tempfile.NamedTemporaryFile(delete=False, mode='w') # noqa: SIM115

self.img_source_file.write("""filename,checksum
image1.jpg,abc123
image2.jpg,def456
image3.jpg,ghi789
""")
self.img_source_file.close()

self.checksum_source_file.write("""filename,md5
image1.jpg,abc123
image2.jpg,def456
image3.jpg,ghi789
""")
self.checksum_source_file.close()


def tearDown(self):
self.img_source_file.close()
self.checksum_source_file.close()
os.remove(self.img_source_file.name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
os.remove(self.img_source_file.name)
def setUp(self):
self.buddy_check = BuddyCheck()
self.buddy_check_filename = BuddyCheck(buddy_id='filename')
self.buddy_check_id_col = BuddyCheck(buddy_id="filename", buddy_col="sha256")
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix=".csv") as f:
f.write("""filename,checksum
image1.jpg,abc123
image2.jpg,def456
image3.jpg,ghi789
""")
self.img_source_file = f.name
with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix=".csv") as f:
f.write("""filename,md5
image1.jpg,abc123
image2.jpg,def456
image3.jpg,ghi789
""")
self.checksum_source_file = f.name
def tearDown(self):
os.remove(self.img_source_file)
os.remove(self.checksum_source_file)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented change to remove ruff ignore

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces broad exception handling with targeted exceptions and updates related tests and development tooling.

Changes:

  • Adds domain-specific CSV, checksum, and verification exceptions.
  • Narrows download and image-processing exception handling.
  • Updates tests, Ruff configuration, and CI workflows.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/cautiousrobot/exceptions.py Adds custom exception classes.
src/cautiousrobot/utils.py Uses targeted CSV and Pillow exceptions.
src/cautiousrobot/download.py Handles Requests exceptions specifically.
src/cautiousrobot/__main__.py Revises CLI exception handling.
src/cautiousrobot/__init__.py Adjusts method exposure assignments.
tests/test_roll_call.py Cleans unused tuple values.
tests/test_downsample.py Uses a specific mocked exception.
tests/test_download.py Tests connection failure handling.
tests/test_download_images.py Updates main-flow mocks and exception expectations.
tests/test_buddycheck.py Revises temporary CSV setup.
pyproject.toml Pins Ruff in development dependencies.
.pre-commit-config.yaml Replaces the remote Ruff hook with a local hook.
.gitignore Ignores the uv lockfile.
.github/workflows/run-tests.yml Consolidates linting and test CI.
.github/workflows/run-push-tests.yml Removes the redundant push workflow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/cautiousrobot/__main__.py Outdated
Comment on lines 80 to 82
except ChecksumError as e:
print(e)
return None, None
Comment thread src/cautiousrobot/__main__.py Outdated
Comment on lines +104 to +105
except BuddyCheckError as e:
print(e)
data_df = process_csv(csv_path, expected_cols)
except Exception as missing_cols: # noqa: BLE001
sys.exit(f"{missing_cols} Please adjust inputs and try again.")
data_df = process_csv(csv_path, expected_cols) #Exception handling process_csv
Comment thread src/cautiousrobot/__init__.py Outdated
Comment on lines +9 to +10
_ = buddy_check_instance.validate_download
_ = buddy_check_instance.check_alignment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we actually want to just expose BuddyCheck, since otherwise this is instantiating it with the defaults and those methods would be fixed on what they could validate or check (i.e., only the source values could be set, not the values for the checksum DataFrame).

Comment thread .pre-commit-config.yaml
- id: ruff

name: ruff
entry: uv run --extra dev ruff check --force-exclude

@egrace479 egrace479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to also delete these instantiations

Comment thread src/cautiousrobot/__init__.py Outdated
Comment thread src/cautiousrobot/__init__.py Outdated
codedbyishika and others added 4 commits August 14, 2026 14:33
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handling Ruff Errors and Ignores

4 participants