API Reference
This page contains the automatically generated API documentation for the Semantic Backup Explorer.
semantic_backup_explorer.core.backup_operations
Core business logic for backup operations.
Classes
BackupComparisonResult
dataclass
Result of comparing a local folder with its backup.
Source code in semantic_backup_explorer/core/backup_operations.py
BackupOperations
High-level operations for backup management.
Source code in semantic_backup_explorer/core/backup_operations.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
Functions
__init__(index_path, rag_pipeline=None)
Initialize BackupOperations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_path
|
Path
|
Path to the backup index file. |
required |
rag_pipeline
|
Optional[RAGPipeline]
|
Optional RAG pipeline for semantic folder matching. |
None
|
Source code in semantic_backup_explorer/core/backup_operations.py
find_and_compare(local_path)
Finds the matching backup folder and compares contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_path
|
Path
|
The local folder to compare. |
required |
Returns:
| Type | Description |
|---|---|
BackupComparisonResult
|
A BackupComparisonResult object. |
Source code in semantic_backup_explorer/core/backup_operations.py
verify_backup_drive()
Verifies if the currently connected drive matches the one in the index.
Returns:
| Type | Description |
|---|---|
tuple[bool, Optional[str]]
|
A tuple of (is_correct, error_message). |
Source code in semantic_backup_explorer/core/backup_operations.py
Functions
semantic_backup_explorer.indexer.scan_backup
Module for scanning backup directories and creating a markdown index.
Functions
scan_backup(root_path, output_file='data/backup_index.md', callback=None)
Recursively scans the root_path and writes every file and folder with its full path into a structured markdown file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_path
|
str | Path
|
Path to the backup directory to scan. |
required |
output_file
|
str | Path
|
Path to the output markdown file. |
'data/backup_index.md'
|
callback
|
Optional[Callable[[int, str], None]]
|
Optional callback function called with (count, current_root). |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If root_path does not exist. |
NotADirectoryError
|
If root_path is not a directory. |
PermissionError
|
If output_file cannot be written. |
Source code in semantic_backup_explorer/indexer/scan_backup.py
semantic_backup_explorer.rag.rag_pipeline
Module for the RAG (Retrieval-Augmented Generation) pipeline.
Classes
RAGPipeline
Orchestrates the retrieval and generation process to answer questions about backups.
Source code in semantic_backup_explorer/rag/rag_pipeline.py
Functions
__init__()
Initialize the RAG pipeline with embedder, retriever, and LLM client.
Raises:
| Type | Description |
|---|---|
ImportError
|
If any semantic dependencies are missing. |
Source code in semantic_backup_explorer/rag/rag_pipeline.py
answer_question(question)
Answers a question using retrieved context from the backup index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
question
|
str
|
The user's question. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
A tuple of (answer_text, context_text). |
Source code in semantic_backup_explorer/rag/rag_pipeline.py
semantic_backup_explorer.compare.folder_diff
Module for comparing local folders with backup contents.
Classes
FolderDiffResult
Functions
compare_folders(local_path, backup_files)
Compares local folder content with backup files.
Files with newer local modification times are included in 'only_local' to trigger sync.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_path
|
str | Path
|
Path to the local folder. |
required |
backup_files
|
Union[list[str], dict[str, float]]
|
Either a list of relative paths or a dictionary mapping relative paths to modification timestamps. |
required |
Returns:
| Type | Description |
|---|---|
FolderDiffResult
|
A TypedDict containing lists of files 'only_local', 'only_backup', and 'in_both'. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If local_path does not exist. |
NotADirectoryError
|
If local_path is not a directory. |
Source code in semantic_backup_explorer/compare/folder_diff.py
get_folder_content(folder_path)
Returns a dictionary of relative file paths and their modification times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_path
|
str | Path
|
Path to the folder to scan. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary mapping relative file paths to their modification timestamps. |
Source code in semantic_backup_explorer/compare/folder_diff.py
semantic_backup_explorer.sync.sync_missing
Module for synchronizing files between local and backup directories.
Classes
SyncProgressCallback
Bases: Protocol
Protocol for sync progress callbacks.
Source code in semantic_backup_explorer/sync/sync_missing.py
Functions
__call__(current, total, filename, error=None)
Called for each file processed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
int
|
Current file number (1-indexed). |
required |
total
|
int
|
Total number of files. |
required |
filename
|
str
|
Relative path of current file. |
required |
error
|
Optional[str]
|
Error message if sync failed, None if successful. |
None
|
Source code in semantic_backup_explorer/sync/sync_missing.py
Functions
sync_files(files_to_sync, source_root, target_root, callback=None)
Copies files from source_root to target_root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files_to_sync
|
list[str]
|
List of relative file paths to copy. |
required |
source_root
|
str | Path
|
Source directory. |
required |
target_root
|
str | Path
|
Target directory. |
required |
callback
|
Optional[SyncProgressCallback]
|
Optional progress callback. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[tuple[str, str]]]
|
Tuple of (synced_files, errors) where errors is a list of (filename, error_msg). |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If source_root does not exist. |
Source code in semantic_backup_explorer/sync/sync_missing.py
semantic_backup_explorer.utils.config
Centralized configuration for backup operations.
Classes
BackupConfig
Bases: BaseSettings
Central configuration for backup operations.
Loads values from environment variables or a .env file.
Source code in semantic_backup_explorer/utils/config.py
Functions
validate_backup_drive()
Validate that backup drive exists and is accessible.
Raises:
| Type | Description |
|---|---|
ValueError
|
If backup drive does not exist. |