-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: update #168
Merged
Merged
deps: update #168
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c57cd8a
deps: update
jrcastro2 ed8b8e5
global: move to setup.cfg
kpsherva 75650be
rdm: move migration code from cds-rdm
kpsherva e7eea7a
installation: upgrade invenio-rdm-migrator
kpsherva 6f7c6af
installation: fix setup syntax
kpsherva 3966827
transform: attach JSON logger to visualise the output
kpsherva 4668cda
installation: upgrade cds-dojson
kpsherva b368bf8
CI: add ldap required libs to CI
kpsherva ba23356
chore: fix docstrings
kpsherva a7c6e8d
chore: formatting
kpsherva d6dfefc
chore: add new files to manifest
kpsherva 53f6d8c
global: set up tests
kpsherva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# cds-migrator-kit is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Exceptions.""" | ||
|
||
from dojson.errors import DoJSONException | ||
|
||
################################################################# | ||
# CDS-ILS Migrator Exceptions | ||
################################################################# | ||
|
||
class LossyConversion(DoJSONException): | ||
"""Data lost during migration.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Exception custom initialisation.""" | ||
self.missing = kwargs.pop("missing", None) | ||
self.message = self.description = "Lossy conversion: {0}".format( | ||
self.missing or "" | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class RecordNotDeletable(DoJSONException): | ||
"""Record is not marked as deletable.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Exception custom initialisation.""" | ||
self.message = self.description = "Record is not marked as deletable" | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class ProviderNotAllowedDeletion(DoJSONException): | ||
"""Provider is not allowed to delete records.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Exception custom initialisation.""" | ||
self.provider = kwargs.pop("provider", None) | ||
self.message = self.description = ( | ||
"This provider {0} is not allowed to delete records".format(self.provider) | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
|
||
class CDSImporterException(DoJSONException): | ||
"""CDSDoJSONException class.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Constructor.""" | ||
self.subfield = kwargs.get("subfield", "") | ||
message = kwargs.get("message", None) | ||
if message: | ||
self.message = message | ||
|
||
# because of ILSRestException class attributes | ||
self.description = self.message | ||
|
||
super(CDSImporterException, self).__init__(*args) | ||
|
||
|
||
class RecordModelMissing(CDSImporterException): | ||
"""Missing record model exception.""" | ||
|
||
message = "[Record did not match any available model]" | ||
|
||
|
||
class UnexpectedValue(CDSImporterException): | ||
"""The corresponding value is unexpected.""" | ||
|
||
message = "[UNEXPECTED INPUT VALUE]" | ||
|
||
|
||
class MissingRequiredField(CDSImporterException): | ||
"""The corresponding value is required.""" | ||
|
||
message = "[MISSING REQUIRED FIELD]" | ||
|
||
|
||
class ManualImportRequired(CDSImporterException): | ||
"""The corresponding field should be manually migrated.""" | ||
|
||
message = "[MANUAL IMPORT REQUIRED]" | ||
|
||
|
||
class DocumentImportError(CDSImporterException): | ||
"""Document import exception.""" | ||
|
||
message = "[DOCUMENT IMPORT ERROR]" | ||
|
||
|
||
class SeriesImportError(CDSImporterException): | ||
"""Document import exception.""" | ||
|
||
message = "[SERIES IMPORT ERROR]" | ||
|
||
|
||
class UnknownProvider(CDSImporterException): | ||
"""Unknown provider exception.""" | ||
|
||
message = "Unknown record provider." | ||
|
||
|
||
class InvalidProvider(CDSImporterException): | ||
"""Invalid provider exception.""" | ||
|
||
message = "Invalid record provider." | ||
|
||
|
||
class SimilarityMatchUnavailable(CDSImporterException): | ||
"""Similarity match unavailable exception.""" | ||
|
||
message = ( | ||
"Title similarity matching cannot be performed for " | ||
"this record. Please import it manually." | ||
) | ||
|
||
|
||
############################################################################### | ||
# Migration exceptions | ||
############################################################################### | ||
|
||
|
||
class DumpRevisionException(Exception): | ||
"""Exception for dump revision.""" | ||
|
||
|
||
class JSONConversionException(Exception): | ||
"""JSON Conversion Exception in migration.""" | ||
|
||
|
||
class MigrationException(Exception): | ||
"""Base exception for CDS-ILS migration errors.""" | ||
|
||
|
||
class DocumentMigrationError(MigrationException): | ||
"""Raised for multipart migration errors.""" | ||
|
||
|
||
class SeriesMigrationError(MigrationException): | ||
"""Raised for multipart migration errors.""" | ||
|
||
|
||
class MultipartMigrationError(MigrationException): | ||
"""Raised for multipart migration errors.""" | ||
|
||
|
||
class UserMigrationError(MigrationException): | ||
"""Raised for user migration errors.""" | ||
|
||
|
||
class SerialMigrationError(MigrationException): | ||
"""Raised for serial migration errors.""" | ||
|
||
|
||
class ItemMigrationError(MigrationException): | ||
"""Raised for item migration errors.""" | ||
|
||
|
||
class LoanMigrationError(MigrationException): | ||
"""Raised for loan migration errors.""" | ||
|
||
|
||
class EItemMigrationError(MigrationException): | ||
"""Raised for EItem migration errors.""" | ||
|
||
|
||
class FileMigrationError(MigrationException): | ||
"""Raised for File migration errors.""" | ||
|
||
|
||
class BorrowingRequestError(MigrationException): | ||
"""Raised for borrowing request migration errors.""" | ||
|
||
|
||
class AcqOrderError(MigrationException): | ||
"""Raised for acquisition order migration errors.""" | ||
|
||
|
||
class ProviderError(MigrationException): | ||
"""Raised for provider migration errors.""" | ||
|
||
|
||
class RelationMigrationError(MigrationException): | ||
"""Raised for exceptions when migrating relations.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# cds-migrator-kit is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""CDS Migrator Records logging handler.""" | ||
|
||
import logging | ||
|
||
cli_logger = logging.getLogger("migrator") | ||
documents_logger = logging.getLogger("documents_logger") | ||
items_logger = logging.getLogger("items_logger") | ||
|
||
|
||
def migration_exception_handler(exc, output, key, value, rectype=None, **kwargs): | ||
"""Migration exception handling - log to files. | ||
|
||
:param exc: exception | ||
:param output: generated output version | ||
:param key: MARC field ID | ||
:param value: MARC field value | ||
:return: | ||
""" | ||
logger = logging.getLogger(f"{rectype}s_logger") | ||
cli_logger.error( | ||
"#RECID: #{0} - {1} MARC FIELD: *{2}*, input value: {3}, -> {4}, ".format( | ||
output["legacy_recid"], exc.message, key, value, output | ||
) | ||
) | ||
logger.error( | ||
"MARC: {0}, INPUT VALUE: {1} ERROR: {2}" "".format(key, value, exc.message), | ||
extra=dict(legacy_id=output["legacy_recid"], status="WARNING", new_pid=None), | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment for the future: @jrcastro2 will add structured JSON logging to
invenio-jobs
, and it would be nice to start using it a bit everywhere when we have want to log long running jobs output, so that we have similar fields/structure.