Skip to content

FinishingFieldsUpdates#78

Merged
Linked-Liszt merged 13 commits into
mainfrom
FinishingFieldsUpdates
Dec 4, 2025
Merged

FinishingFieldsUpdates#78
Linked-Liszt merged 13 commits into
mainfrom
FinishingFieldsUpdates

Conversation

@matthewrdiamond

Copy link
Copy Markdown
Collaborator

Complete Synopsis of Changes in the FinishingFieldsUpdates Branch

I've successfully reviewed the git commits in your current branch. Here's a comprehensive synopsis of all the changes, organized by functional area:

1. File Name Pattern Handling & UI Improvements

  • Latest refactoring (ba15997): Complete overhaul of the "find file names" button functionality
    • Removed _generate_dropdown_for_position() in favor of mode-specific dropdown generation
    • Mode 1 now displays field options independently for each position
    • Mode 2 handles single positions with special styling for mismatched positions
    • New _generate_pattern_label() helper applies patterns across all positions
    • Both modes use _merge_field_values for finalizing options

2. Validation System Enhancements

  • Validation refactoring (eb042dc): Streamlined validation process
    • Created wrapper function for validate_for_input to eliminate redundancy
    • Expanded optional parameters in wire reconstruction and peak indexing pages
    • Standardized semicolon delimiters throughout the application
    • Fixed comma-delimiter issues in filenamePrefix values

3. ID Number Management

  • IDnumber implementation (07daa3e): Added comprehensive ID handling

    • Added IDnumber support to wire reconstruction
    • Centralized shared functions (get_num_inputs_from_fields(), make_IDnumber(), parse_IDnumber()) in db_utils.py
    • Updated submit_parameters to use ctx.states instead of hard-coded values
  • Deduplication fix (a935ac6): Fixed parse_IDnumber() to ensure ID-type lists match parent ID counts with proper None padding

4. Path and Data Handling Fixes

  • Auto-population corrections (921c1e1): Fixed wire reconstruction auto-population to use original input data paths instead of output paths
  • Field merging (6399093, 1f15285): Created _merge_field_values() helper to properly handle comma-separated values during page loads
  • Index population (6f7ed67): Fixed single-entry issue, now properly uses semicolon delimiters per path

5. Output Folder Management

  • Template building (fb8a642): Successfully implemented output folder path template building for both wire reconstruction and peak indexing
  • Submit improvements (4cb4c43):
    • Reorganized validation order with ID validations first
    • Added root_path to submit_parameters
    • Clean handling of existing IDs for output folder creation
    • Commented out unused parameters like "detectorCropX1"

6. Bug Fixes

  • Fixed "Save Changes to Catalog" button error on scan.py (88c78a8)
  • Resolved href id alignment issues
  • Removed unnecessary wirerecon_id storage code (9be9ac8)
  • Updated remaining trigger->signal references

7. Code Organization

  • Moved shared utility functions to centralized locations (db_utils.py)
  • Standardized delimiter usage across the application
  • Improved code maintainability through helper function consolidation

Impact Summary

These changes represent a significant improvement in:

  • User Experience: Better file pattern handling and clearer UI feedback
  • Data Integrity: Consistent delimiter usage and proper ID management
  • Code Quality: Reduced redundancy and better organization
  • Bug Resolution: Multiple critical fixes for data handling and UI interactions

The branch appears ready for integration, with comprehensive improvements to form handling, validation, and data processing workflows.

…form.py to handle “SN, WR, MR, PI” id labels.

- Made format_filename_with_indices() function in create_peakindexing.py to modularize and improve how the indices get added to the filename string.

- Made _extract_indices_from_files() function in callback_registrars.py to modularize index recognition, including allowing for a dynamic number of indices.

- Updated ‘*’ wildcard generation to retain %d components in callback_registrars.py.

- Created get_data_from_id() function in db.utils.py to read data_path and filenamePrefix from either reconstructed or original data.

- Redefined number of pooled jobs from number of provided paths to longest sequence of semicolon-separated entries with the added get_num_inputs_from_fields() function in validation_helpers.py.

- Added depthRange parsing to create_peakindexing.py validation

- Removal of Threshold and Threshold Ratio from  in create_peakindexing.py.

- Renamed “param” to “field” for objects in validation_helpers.py and create_.py pages.

- Added hdf file extensions to config.yaml.template and _filter_files_by_extension() function to callback_registrars.py to filter by them.
- Moved shared get_num_inputs_from_fields(), make_IDnumber(), and parse_IDnumber() functions to db_utils.py.
- Changed both create_ files’ submit_parameters’s all_submit_params dict to use ctx.states rather than hard-coded items.
…nt scanNumber validation in create_peakindexing.py and create_wire_reconstruction.py

- Added root_path to submit_parameters() callback in create_peakindexing.py and create_wire_reconstruction.py
- create_peakindexing.py and create_wire_reconstruction.py’s submit_parameters() functions now cleanly handle any existing ids to make the output folder
- create_peakindexing.py’s validate_peakindexing_inputs()function now uses get_data_from_id() function to get data_path
- Unused parameters like “detectorCropX1” commented out in submit_parameters()  and validate_inputs() callbacks
…roach for both wire reconstruction and peak indexing pages:

## Changes Made:

### 1. **Created Helper Functions** (in both files)
- `build_output_folder_template()` in `create_wire_reconstruction.py`
- `build_output_folder_template()` in `create_peakindexing.py`

These functions build output folder templates based on available IDs from the database chain, with only the final action ID remaining as `%d`.

### 2. **Updated Page Load Callbacks**
- Modified `load_scan_data_from_url()` in both files to use the helper functions
- Templates are now built when the page loads with URL parameters
- All known IDs (scanNumber, wirerecon_id, recon_id) are filled in at load time

### 3. **Simplified Submit Functions**
- Replaced complex conditional logic (~25 lines) with simple `%` replacement
- Submit functions now just replace the final `%d` placeholder with the next action ID
- Reduced from multiple nested conditionals to a single try/except block

### 4. **Enhanced Shared Callback**
- Updated `register_update_path_fields_callback()` in `callback_registrars.py` to accept:
  - `output_folder_id` parameter (optional)
  - `build_template_func` parameter (optional)
- When both are provided, the callback now also updates the output folder field using the template function

### 5. **Updated Callback Registrations**
- Both `create_wire_reconstruction.py` and `create_peakindexing.py` now pass:
  - `output_folder_id='outputFolder'`
  - `build_template_func=build_output_folder_template`

## Benefits:

1. **Cleaner Code**: Reduced complexity in submit functions
2. **Better UX**: Output folder template is built immediately when page loads
3. **Consistency**: Same approach used in both wire reconstruction and peak indexing
4. **Maintainability**: Template building logic centralized in helper functions
5. **Flexibility**: "Update Path Fields" button now also updates output folder

## Path Template Examples:

**Wire Reconstruction:**
- With scanNumber: `analysis/scan_276994/rec_%d/data`
- Without scanNumber: `analysis/data_path/rec_%d/data`

**Peak Indexing:**
- With scanNumber only: `analysis/scan_276994/index_%d`
- With scanNumber + wirerecon_id: `analysis/scan_276994/rec_5/index_%d`
- With scanNumber + recon_id: `analysis/scan_276994/rec_3/index_%d`
- Without scanNumber: `analysis/data_path/index_%d`

All implementations follow the principle: build the template on page load with all known IDs, then simply replace the final `%d` with the next action ID on submit.
…ters by creating the _merge_field_values() helper function in callback_registrars.py, which is used in callback_registrars.py’s update_path_fields_from_id() callback and the load_scan_data_from_url() callback on both create_pages. Incidentally, this function can be used more generally for any field with comma-separated values.

- Applied wildcard sorting to filename templates dropdown and applied auto-selection to choose the first in the list

- Updated Filename dropdown options to show results for all data paths as delimiter-joined strings and be updated when valid results are entered between the delimiter (; default). Created _generate_dropdown_for_position() helper function to assist.

The helper function `_generate_dropdown_for_position()` (lines 155-216):
- Takes base pattern parts and a position to vary
- Generates dropdown options with informative labels showing file counts/ranges
- Only shows the informative label for the pattern being varied at that position
- Other positions show plain patterns
…ters by creating the _merge_field_values() helper function in callback_registrars.py, which is used in callback_registrars.py’s update_path_fields_from_id() callback and the load_scan_data_from_url() callback on both create_pages. Incidentally, this function can be used more generally for any field with comma-separated values.

- Applied wildcard sorting to filename templates dropdown and applied auto-selection to choose the first in the list

- Updated Filename dropdown options to show results for all data paths as delimiter-joined strings and be updated when valid results are entered between the delimiter (; default). Created _generate_dropdown_for_position() helper function to assist.

- Updated create_wire_reconstruction.py to parse IDnumbers like create_peakindexing, so that it can use WR values
…g the output path of WRs (like it would do for create_peakindexing) instead of the original input data path by providing "context" parameter to get_data_from_id() function in db_utils.py.
…unction so that that the lengths of all ID-type lists in the returned dict match the number of parent IDs (padded with Nones)
- Removed a bit of unnecessary code in create_wire_reconstruction.py for storing wirerecon_id.
…for_input to avoid repeated inputs, as well as adding/expanding optional_params lists (create_wire_reconstruction.py and create_peakindexing.py).

- Standardized semicolon delimiter usage.
- Fixed an issue with comma-delimiting filenamePrefix values by adding that step to wire_recon_form and peakindex_form.
- Fixed an href id alignment issue in scan.py.
- Removed _generate_dropdown_for_position() helper function in favor of custom dropdown_options generation for Modes 1 (generates for all positions) and 2 (uses single position).
-- Mode 1 now displays options for each field independently.
-- Added styling for labels in Mode 2 (when working with mismatched position).
- New _generate_pattern_label() helper function that applies pattern and range information to all positions.
- Use _merge_field_values in both Modes for finalizing generated field options.

@matthewrdiamond matthewrdiamond left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Resolves Issues #65-67

@Linked-Liszt Linked-Liszt merged commit 185277e into main Dec 4, 2025
1 check passed
@Linked-Liszt Linked-Liszt deleted the FinishingFieldsUpdates branch December 16, 2025 00:14
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.

2 participants