Skip to content

Commit

Permalink
#75 Savepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Oct 3, 2024
1 parent 80c12c6 commit bc0b692
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
37 changes: 35 additions & 2 deletions src/senzing_abstract/szengine_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ class SzEngineAbstract(ABC):
4030: PREFIX + "search_by_attributes({0}) failed. Return code: {1}",
4031: PREFIX + "why_entities({0}, {1}) failed. Return code: {2}",
4032: PREFIX + "why_records({0}, {1}, {2}, {3}, {4}) failed. Return code: {5}",
4033: PREFIX + "why_record_in_entity{0}, {1}, {2}) failed. Return code: {3}",
4033: PREFIX + "why_record_in_entity({0}, {1}, {2}) failed. Return code: {3}",
4034: (
PREFIX
+ "SzEngine({0}, {1}) failed. instance_name and settings must both be set or"
" both be empty"
),
4035: PREFIX + "preprocess_record({0}, {1}) failed. Return code: {2}",
}
""" :meta private: """

Expand All @@ -114,7 +115,7 @@ def add_record(
Args:
data_source_code (str): Identifies the provenance of the data.
record_id (str): The unique identifier within the records of the same data source.
record_definition (str | Dict): A JSON document containing the record to be added to the Senzing repository.
record_definition (str): A JSON document containing the record to be added to the Senzing repository.
flags (int, optional): Flags used to control information returned. Defaults to 0.
Returns:
Expand Down Expand Up @@ -754,6 +755,38 @@ def how_entity_by_entity_id(
:language: json
"""

@abstractmethod
def preprocess_record(
self,
record_definition: str,
flags: int = 0,
**kwargs: Any,
) -> str:
"""
The `preprocess_record` method tests adding a record into the Senzing datastore.
Args:
record_definition (str): A JSON document containing the record to be added to the Senzing repository.
flags (int, optional): Flags used to control information returned. Defaults to 0.
Returns:
str: A JSON document containing metadata as specified by the flags.
Raises:
.. collapse:: Example:
.. literalinclude:: ../../examples/szengine/preprocess_record.py
:linenos:
:language: python
**Output:**
.. literalinclude:: ../../examples/szengine/preprocess_record.txt
:linenos:
:language: json
"""

@abstractmethod
def prime_engine(self, **kwargs: Any) -> None:
"""
Expand Down
15 changes: 14 additions & 1 deletion tests/szengine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ def test_how_entity_by_entity_id(sz_engine: SzEngineAbstract) -> None:
# sz_engine.initialize("", "")


def test_preprocess_record(sz_engine: SzEngineAbstract) -> None:
"""Test SzEngine().preprocess_record()."""
sz_engine.preprocess_record("", 0)


def test_prime_engine(sz_engine: SzEngineAbstract) -> None:
"""Test SzEngine().prime_engine()."""
sz_engine.prime_engine()
Expand Down Expand Up @@ -202,7 +207,7 @@ def add_record(
self,
data_source_code: str,
record_id: str,
record_definition: Union[str, Dict[Any, Any]],
record_definition: str,
flags: int = 0,
**kwargs: Any,
) -> str:
Expand Down Expand Up @@ -361,6 +366,14 @@ def initialize(
) -> None:
"""None"""

def preprocess_record(
self,
record_definition: str,
flags: int = 0,
**kwargs: Any,
) -> str:
return ""

def prime_engine(self, **kwargs: Any) -> None:
"""None"""

Expand Down

0 comments on commit bc0b692

Please sign in to comment.