Skip to content

Refactor Validation and Create RollCall module#56

Open
codedbyishika wants to merge 19 commits into
mainfrom
refactoring_validation
Open

Refactor Validation and Create RollCall module#56
codedbyishika wants to merge 19 commits into
mainfrom
refactoring_validation

Conversation

@codedbyishika

@codedbyishika codedbyishika commented Jun 3, 2026

Copy link
Copy Markdown

Move following functions from main.py to Validation.py + Change AGENTS.md:
validate_csv_extension
validate_output_directory This function was removed, as it should have been in #43.
validate_filename_uniqueness
handle_missing_filenames
setup_expected_columns

RollCall Module

Added above functionalities and check_existing_images to the rollcall module which prechecks all the conditions before downloading.

Non Interactive Missing File Handling

  • Implemented missing file check as non interactive error handing

Duplicate Checksums

  • Implemented checks for checking duplicates

Summary

  • Implemented summary of where images & downsized images will be downloaded

  • Changed main according to new csv handle
  • Updated tests to the new features

Move following functions:
validate_csv_extension
validate_output_directory
validate_filename_uniqueness
handle_missing_filenames
setup_expected_columns
@codedbyishika codedbyishika requested a review from egrace479 June 4, 2026 17:04

@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.

Found a holdover from prior implementation method.

Comment thread src/cautiousrobot/validation.py Outdated
@egrace479 egrace479 changed the title Refractor Validation.py Refactor Validation.py Jun 4, 2026
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>

This comment was marked as outdated.

Comment thread src/cautiousrobot/validation.py Outdated

This comment was marked as outdated.

This comment was marked as outdated.

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/cautiousrobot/validation.py Outdated
Comment thread src/cautiousrobot/validation.py Outdated
@egrace479 egrace479 mentioned this pull request Jun 8, 2026
2 tasks
- Change tests
- Include check_existing_images
This reverts commit ff930b0.
@codedbyishika codedbyishika linked an issue Jun 17, 2026 that may be closed by this pull request
@codedbyishika codedbyishika changed the title Refactor Validation.py Refactor RollCall.py Jun 17, 2026
Comment thread src/cautiousrobot/roll_call.py Outdated
@codedbyishika codedbyishika requested a review from egrace479 June 19, 2026 19:07
@codedbyishika codedbyishika changed the title Refactor RollCall.py Refactor Validation and Create RollCall module Jun 22, 2026

@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 haven't had a chance to check the test changes, but some efficiency can be added and I have some questions in implementation of new features that rely on consideration of the motivation. Mainly the new duplicate check that should have an option to ignore for the purposes of still downloading, but then what is the intended response to duplicates; if the ignore flag is passed, should it be skipped or at least provide the duplicates in a usable format so the user can do something with the information?

roll_call.check_duplicate_checksums(
data_df=source_df,
hash_col=args.verifier_col.lower(),
ignore_duplicates=getattr(args, "ignore_duplicates", False)

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.

Where is this defined?

Comment on lines 139 to +141
# Validate and handle existing output directory
img_dir = args.output_dir
source_df, filtered_df = check_existing_images(csv_path, img_dir, source_df, filename_col, subfolders)
source_df, filtered_df = roll_call.check_existing_images(csv_path, img_dir, source_df, filename_col, subfolders)

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.

Is the idea of checking for duplicate hashes in the source DataFrame first to alert the user to their existence even if they have most images already?

Comment on lines 159 to 160
if isinstance(args.side_length, int):
downsample_dest_path = img_dir + "_downsized"

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.

Suggested change
if downsample_dir:

Since this is already defined above, no need to do extra checks and redefine. Unfortunately, this will be a couple comments since the formatting isn't holding for a block comment on these unedited lines. (it should be replacing the if instance... and downsample_dest_path = ...

error_log_filepath=error_log_filepath,
filename=filename_col,
subfolders=subfolders,
downsample_path=downsample_dest_path,

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.

Suggested change
downsample_path=downsample_dir,

file_url=url_col,
wait=args.wait_time,
retry=args.max_retries)
print(f"Images downloaded from {csv_path} to {img_dir}, with downsampled images in {downsample_dest_path}.")

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.

Suggested change
print(f"Images downloaded from {csv_path} to {img_dir}, with downsampled images in {downsample_dir}.")

url_col (str): Name of the column containing image URLs.

Returns:
pd.DataFrame | None: Rows with missing filenames when present; otherwise None.

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.

Suggested change
pd.DataFrame | None: Rows with missing filenames when present; otherwise None.
missing (pd.DataFrame) | None: DataFrame of entries with URLs but missing filenames or None.

args (argparse.Namespace): Parsed command-line arguments.

Returns:
tuple[dict, str | None]: Column mapping to use for filename, URL, and optional subfolder handling.

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.

Suggested change
tuple[dict, str | None]: Column mapping to use for filename, URL, and optional subfolder handling.
(expected_cols, subfolders) tuple[dict, str | None]: Column mapping to use for filename, URL, and optional subfolder handling.

# If duplicates exist, preview or save
self._preview_or_save("duplicate_checksums", dupes)

if ignore_duplicates:

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.

If this is going to run regardless of the ignore, it seems like it would make sense to print or save duplicates so the user is aware and can do something with that information.

Comment thread AGENTS.md

### Core Modules
- `__main__.py` - Main entry point with CLI argument parsing and workflow orchestration
- `roll_call.py` - CSV validation and input handling functions

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.

Suggested change
- `roll_call.py` - CSV validation and input handling functions
- `roll_call.py` - Pre-download checks and processing.

Not sure that processing is exactly the right term, but staging doesn't quite fit the bill either.

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.

Add dry-run functionality Extract the pre-download verification elements into roll_call module.

3 participants