Refactor Validation and Create RollCall module#56
Conversation
Move following functions: validate_csv_extension validate_output_directory validate_filename_uniqueness handle_missing_filenames setup_expected_columns
egrace479
left a comment
There was a problem hiding this comment.
Found a holdover from prior implementation method.
Co-authored-by: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com>
- Change tests - Include check_existing_images
This reverts commit ff930b0.
egrace479
left a comment
There was a problem hiding this comment.
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) |
| # 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) |
There was a problem hiding this comment.
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?
| if isinstance(args.side_length, int): | ||
| downsample_dest_path = img_dir + "_downsized" |
There was a problem hiding this comment.
| 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, |
There was a problem hiding this comment.
| 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}.") |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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: |
There was a problem hiding this comment.
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.
|
|
||
| ### Core Modules | ||
| - `__main__.py` - Main entry point with CLI argument parsing and workflow orchestration | ||
| - `roll_call.py` - CSV validation and input handling functions |
There was a problem hiding this comment.
| - `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.
Move following functions from main.py to Validation.py + Change AGENTS.md:
validate_csv_extension
validate_output_directoryThis 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
Duplicate Checksums
Summary