Feature/use-call-number-type-fallback#991
Conversation
…mMapper; add tests for new functionality
…ences in the index
- Replaced direct logging calls with a logger instance in multiple migration task files. - Updated logging setup to utilize a centralized logging configuration for consistency. - Ensured that all logging messages are routed through the new logger for better management and formatting. - Improved error handling and logging in various methods to enhance traceability during migration processes.
…ager for FolioClient
…when both dates are missing
…ain consistency in datetime assignments
…t third-party libraries
There was a problem hiding this comment.
Pull request overview
This PR addresses three related migration-tool behaviors: (1) applying a configured default call number type when call number parts are present but no type was mapped, (2) fixing InventoryBatchPoster upsert failures by removing an unnecessary async with self.folio_client, and (3) refactoring logging to centralized Rich-based configuration that cooperates with folio_data_import progress output.
Changes:
- Add default call number type fallback logic to holdings/items mapping when no explicit call number type is mapped.
- Introduce centralized logging configuration (
logging_config.py) and convert many modules to module-level loggers. - Adjust
InventoryBatchPosterasync lifecycle and update docs/tests accordingly.
Reviewed changes
Copilot reviewed 58 out of 58 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_migration_report.py | Updates log capture strategy to work with module-level loggers/propagation. |
| tests/test_logging_config.py | Adds tests for the new centralized logging setup and filters. |
| tests/test_legacy_loan.py | Updates expectations around legacy loan date parsing fallbacks. |
| tests/test_items_mapper.py | Adds tests for item default call number type fallback behavior. |
| tests/test_holdings_mapper.py | Adds tests for holdings default call number type fallback behavior. |
| src/folio_migration_tools/transaction_migration/legacy_request.py | Switches to module-level logger usage. |
| src/folio_migration_tools/transaction_migration/legacy_loan.py | Uses module-level logger; adjusts parse-error date defaults to start/end of day. |
| src/folio_migration_tools/task_configuration.py | Minor import consolidation. |
| src/folio_migration_tools/migration_tasks/user_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/user_importer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/reserves_migrator.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/requests_migrator.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/organization_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/orders_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/migration_task_base.py | Routes task logging setup through centralized logging_config. |
| src/folio_migration_tools/migration_tasks/marc_import.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/manual_fee_fines_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/loans_migrator.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/items_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/inventory_batch_poster.py | Removes async with self.folio_client to fix upsert flow; switches to module-level logger. |
| src/folio_migration_tools/migration_tasks/holdings_marc_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/holdings_csv_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/courses_migrator.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/bibs_transformer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/migration_tasks/batch_poster.py | Switches from root logging calls to module-level logger (unicode error handling path touched). |
| src/folio_migration_tools/migration_tasks/init.py | Minor import ordering cleanup. |
| src/folio_migration_tools/migration_report.py | Uses module-level logger for report logging. |
| src/folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/rules_mapper_base.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/marc_reader_wrapper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/marc_file_processor.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/hrid_handler.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/holdings_statementsparser.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/marc_rules_transformation/conditions.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/user_mapper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/ref_data_mapping.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/organization_mapper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/order_mapper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/notes_mapper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/mapping_file_mapper_base.py | Adds call-number helpers (has_call_number_parts, get_call_number_type_id_by_name) and logging refactor. |
| src/folio_migration_tools/mapping_file_transformation/manual_fee_fines_mapper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/mapping_file_transformation/item_mapper.py | Implements default call number type fallback for items. |
| src/folio_migration_tools/mapping_file_transformation/holdings_mapper.py | Implements default call number type fallback for holdings. |
| src/folio_migration_tools/mapping_file_transformation/courses_mapper.py | Minor import cleanup. |
| src/folio_migration_tools/mapper_base.py | Switches some error logging to module-level logger. |
| src/folio_migration_tools/logging_config.py | New centralized Rich-based logging configuration module. |
| src/folio_migration_tools/holdings_helper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/folder_structure.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/extradata_writer.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/custom_exceptions.py | Minor import formatting change. |
| src/folio_migration_tools/circulation_helper.py | Switches from root logging calls to module-level logger. |
| src/folio_migration_tools/main.py | Initializes centralized logging early and switches exception logging to module-level logger. |
| noxfile.py | Removes unused import. |
| docs/source/reference_data_mapping.md | Removes now-deleted circulation mapping doc link. |
| docs/source/mapping_files_circulation.md | Deletes obsolete/empty circulation mapping doc stub. |
| docs/source/logging.md | Adds documentation for new logging behavior and file outputs. |
| docs/source/index.md | Adds new logging doc to the docs index and removes circulation doc entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #991 +/- ##
==========================================
+ Coverage 78.37% 80.04% +1.66%
==========================================
Files 113 116 +3
Lines 15381 16136 +755
Branches 1819 1876 +57
==========================================
+ Hits 12055 12916 +861
+ Misses 2982 2871 -111
- Partials 344 349 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…lication in ItemMapper
… to correct parameter names and remove unused fields
|



Purpose
Fixes #988
Fixes #989
Fixes #990
Changes Made in this PR
defaultCallNumberTypeNameparameter of their task configurations if call number types are not explicitly mapped and a call number part value is not emptyasync withcontext manager invocation forself.folio_clientonInventoryBatchPosterfolio_data_importtasksCode Review Specifics
docs/sourceTask Checklist
nox -rs safety.pre-commit run --all-filesnox -rs testscd src; poetry run python3 -m folio_migration_tools -hWarning Checklist
How to Verify
Open Questions
Learn Anything Cool?