Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eu_fact_force/ingestion/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Create a dedicated file for real pipeline steps.
"""

import hashlib
from pathlib import Path

from eu_fact_force.ingestion.embedding import add_embeddings
Expand All @@ -12,6 +13,13 @@
from .models import DocumentChunk, FileMetadata, SourceFile


def hash_doi(doi: str) -> str:
"""
Hash the DOI to a string of 128 bits.
"""
return hashlib.sha256(doi.encode()).hexdigest()


def fetch_file_and_metadata(doi: str) -> tuple[Path, list[str]]:
"""
Simulate an API call to fetch a PDF and metadata.
Expand Down
9 changes: 9 additions & 0 deletions tests/ingestion/test_services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from eu_fact_force.ingestion.services import hash_doi


def test_hash_doi():
"""Test the hash_doi function."""
assert (
hash_doi("10.1234/example")
== "68b8f7c42b3c20b5b49680c9913c11520ec81f3022f0509564140d4ed3f70d78"
)