omnigraph API Documentation
blazegraph
Blazegraph
Bases: SparqlServer
Dockerized Blazegraph SPARQL server
Source code in omnigraph/blazegraph.py
27 28 29 30 31 32 33 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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
__init__(config, env)
Initialize the Blazegraph manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
ServerConfig
|
Server configuration |
required |
env |
ServerEnv
|
Server environment (includes log, shell, debug, verbose) |
required |
Source code in omnigraph/blazegraph.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
load_dump_files(file_pattern='dump_*.ttl', use_bulk=True)
Load all dump files matching pattern.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_pattern |
str
|
Glob pattern for dump files |
'dump_*.ttl'
|
use_bulk |
bool
|
Use bulk loader if True, individual files if False |
True
|
Returns:
Type | Description |
---|---|
int
|
Number of files loaded successfully |
Source code in omnigraph/blazegraph.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
load_file(filepath)
Load a single RDF file into Blazegraph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path to RDF file |
required |
Returns:
Type | Description |
---|---|
bool
|
True if loaded successfully |
Source code in omnigraph/blazegraph.py
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 |
|
load_files_bulk(file_list)
Load multiple files using Blazegraph's bulk loader REST API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_list |
list
|
List of file paths to load |
required |
Returns:
Type | Description |
---|---|
bool
|
True if loaded successfully |
Source code in omnigraph/blazegraph.py
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 |
|
status()
Get Blazegraph status information.
Returns:
Type | Description |
---|---|
dict
|
Dictionary with status information, empty dict if error |
Source code in omnigraph/blazegraph.py
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 |
|
test_geosparql()
Test if GeoSPARQL functions work.
Returns:
Type | Description |
---|---|
bool
|
True if GeoSPARQL is available |
Source code in omnigraph/blazegraph.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
BlazegraphConfig
dataclass
Bases: ServerConfig
Blazegraph configuration
Source code in omnigraph/blazegraph.py
12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
jena
Created on 2025-05-28
Apache Jena SPARQL support
@author: wf
Jena
Bases: SparqlServer
Dockerized Apache Jena Fuseki SPARQL server
Source code in omnigraph/jena.py
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 |
|
__init__(config, log=None, shell=None, debug=False)
Initialize the Jena Fuseki manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
ServerConfig
|
Jena server configuration |
required |
log |
Log
|
Log instance for logging |
None
|
shell |
Shell
|
Shell instance for Docker commands |
None
|
debug |
bool
|
Enable debug output |
False
|
Source code in omnigraph/jena.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
status()
Get Jena Fuseki status information.
Returns:
Type | Description |
---|---|
dict
|
Dictionary with status information, empty dict if error |
Source code in omnigraph/jena.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
JenaConfig
dataclass
Bases: ServerConfig
Jena Fuseki configuration
Source code in omnigraph/jena.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
__init__(self, config, log=None, shell=None, debug=False)
Initialize the Jena Fuseki manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
ServerConfig
|
Jena server configuration |
required |
log |
Log
|
Log instance for logging |
None
|
shell |
Shell
|
Shell instance for Docker commands |
None
|
debug |
bool
|
Enable debug output |
False
|
Source code in omnigraph/jena.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
ominigraph_paths
Created on 27.05.2025
@author: wf
OmnigraphPaths
Omnigraph Default Paths
Source code in omnigraph/ominigraph_paths.py
10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
__init__()
constructor
Source code in omnigraph/ominigraph_paths.py
15 16 17 18 19 20 21 22 |
|
omnigraph_cmd
Created on 2025-05-28
@author: wf
OmnigraphCmd
Command line interface for omnigraph.
Source code in omnigraph/omnigraph_cmd.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
__init__()
Initialize command line interface.
Source code in omnigraph/omnigraph_cmd.py
55 56 57 58 59 60 61 62 63 |
|
getArgParser(description=None, version_msg=None)
Setup command line argument parser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description(str) |
the description |
required | |
version_msg(str) |
the version message |
required |
Returns:
Name | Type | Description |
---|---|---|
ArgumentParser |
ArgumentParser
|
the argument parser |
Source code in omnigraph/omnigraph_cmd.py
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 |
|
getServers()
Get the servers to work with.
Returns:
Type | Description |
---|---|
Dict[str, SparqlServer]
|
Dictionary of active servers |
Source code in omnigraph/omnigraph_cmd.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
handle_args(args)
Handle command line arguments.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if arguments were handled, False otherwise |
args |
bool
|
Namespace |
Source code in omnigraph/omnigraph_cmd.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
run_cmds(server, cmds)
Run commands on a server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server |
SparqlServer
|
Server instance |
required |
cmds |
List[str]
|
List of commands to execute |
required |
Returns:
Type | Description |
---|---|
bool
|
True if any commands were handled |
Source code in omnigraph/omnigraph_cmd.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
ServerCmd
dataclass
Command wrapper for server operations.
Source code in omnigraph/omnigraph_cmd.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
__init__(title, func)
Initialize server command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
Description of the command |
required |
func |
Callable
|
Function to execute |
required |
Source code in omnigraph/omnigraph_cmd.py
24 25 26 27 28 29 30 31 32 33 |
|
run(verbose=True)
Execute the server command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose |
bool
|
Whether to print result |
True
|
Returns:
Type | Description |
---|---|
any
|
Result from function execution |
Source code in omnigraph/omnigraph_cmd.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
main()
Main entry point for command line interface.
Source code in omnigraph/omnigraph_cmd.py
210 211 212 213 214 215 216 |
|
omniserver
Created on 2025-05-28
@author: wf
OmniServer
Factory class for creating and managing SPARQL server instances.
Source code in omnigraph/omniserver.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 |
|
__init__(env)
constructor
Source code in omnigraph/omniserver.py
22 23 24 25 26 |
|
server4Config(config)
Create a SparqlServer instance based on server type in config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
ServerConfig
|
ServerConfig with server type and settings |
required |
Returns:
Type | Description |
---|---|
SparqlServer
|
SparqlServer instance of appropriate type |
Source code in omnigraph/omniserver.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
servers(yaml_path)
Load active servers from YAML configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_path |
Path
|
Path to YAML configuration file |
required |
Returns:
Type | Description |
---|---|
Dict[str, SparqlServer]
|
Dictionary mapping server names to SparqlServer instances |
Source code in omnigraph/omniserver.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
persistent_log
This is redundant copy to avoid dependeny hell the original is at https://github.com/WolfgangFahl/nicegui_widgets/blob/main/ngwidgets/persistent_log.py
Created on 2024-10-04
@author: wf
Log
Wrapper for persistent logging.
Source code in omnigraph/persistent_log.py
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 |
|
__post_init__()
Initializes the log with level mappings and updates the level counts.
Source code in omnigraph/persistent_log.py
56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
clear()
Clears all log entries.
Source code in omnigraph/persistent_log.py
70 71 72 73 74 75 |
|
color_msg(color, msg)
Display a colored message
Source code in omnigraph/persistent_log.py
52 53 54 |
|
get_counter(level)
Returns the counter for the specified log level.
Source code in omnigraph/persistent_log.py
87 88 89 90 91 |
|
get_level_summary(level, limit=7)
Get a summary of the most common counts for the specified log level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level |
str
|
The log level name ('error', 'warn', 'info'). |
required |
limit |
int
|
The maximum number of most common entries to include in the summary (default is 7). |
7
|
Returns:
Type | Description |
---|---|
Tuple[int, str]
|
Tuple[int, str]: A tuple containing the count of log entries and a summary message. |
Source code in omnigraph/persistent_log.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
log(icon, kind, msg)
Log a message with the specified icon and kind.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
icon |
str
|
The icon representing the log level ('❌', '⚠️', '✅'). |
required |
kind |
str
|
The category or type of the log message. |
required |
msg |
str
|
The log message to record. |
required |
Source code in omnigraph/persistent_log.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
update_level_counts()
Updates the counts for each log level based on the existing entries.
Source code in omnigraph/persistent_log.py
77 78 79 80 81 82 83 84 85 |
|
LogEntry
Represents a log entry with a message, kind, and log level name.
Source code in omnigraph/persistent_log.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
qlever
Created on 2025-05-28
@author: wf
QLever
Bases: SparqlServer
Dockerized QLever SPARQL server
Source code in omnigraph/qlever.py
26 27 28 29 30 31 32 33 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 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
__init__(container_name='qlever', image='adfreiburg/qlever', data_dir=None, dataset='olympics', port=7001, log=None, shell=None, debug=False)
Initialize the QLever manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container_name |
str
|
Docker container name |
'qlever'
|
image |
str
|
Docker image to use |
'adfreiburg/qlever'
|
port |
int
|
Port for QLever web interface |
7001
|
data_dir |
str
|
where to keep the data |
None
|
dataset(str) |
a default dataset to be loaded |
required | |
log |
Log
|
Log instance for logging |
None
|
shell |
Shell
|
Shell instance for Docker commands |
None
|
debug |
bool
|
Enable debug output |
False
|
Source code in omnigraph/qlever.py
31 32 33 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 |
|
load_dump_files(file_pattern='dump_*.ttl', use_bulk=True)
Load all dump files matching pattern.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_pattern |
str
|
Glob pattern for dump files |
'dump_*.ttl'
|
use_bulk |
bool
|
Use bulk loader if True, individual files if False |
True
|
Returns:
Type | Description |
---|---|
int
|
Number of files loaded successfully |
Source code in omnigraph/qlever.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
load_file(filepath)
Load a single RDF file into QLever.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
Path to RDF file |
required |
Returns:
Type | Description |
---|---|
bool
|
True if loaded successfully |
Source code in omnigraph/qlever.py
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 |
|
start(show_progress=True)
Start QLever using proper workflow.
Source code in omnigraph/qlever.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
status()
Get QLever status information.
Returns:
Type | Description |
---|---|
dict
|
Dictionary with status information, empty dict if error |
Source code in omnigraph/qlever.py
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 |
|
shell
This is redundant copy to avoid dependeny hell the original is at https://github.com/WolfgangFahl/nicegui_widgets/blob/main/ngwidgets/shell.py
Created on 2025-05-14
@author: wf
Shell
Runs commands with environment from profile
Source code in omnigraph/shell.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
__init__(profile=None, shell_path=None)
Initialize shell with optional profile
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profile |
Path to profile file to source e.g. ~/.zprofile |
None
|
|
shell_path |
str
|
the shell_path e.g. /bin/zsh |
None
|
Source code in omnigraph/shell.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
find_profile()
Find the appropriate profile file for the current shell
Searches for the profile file corresponding to the shell_name in the user's home directory.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to the profile file or None if not found |
Source code in omnigraph/shell.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
ofArgs(args)
classmethod
Create Shell from command line args
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Arguments with optional profile |
required |
Returns:
Name | Type | Description |
---|---|---|
Shell |
Configured Shell |
Source code in omnigraph/shell.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
proc_stats(title, procs, ignores=[])
Show process statistics with checkmark/crossmark and success/failure summary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
A short title to label the output section. |
required |
procs |
Dict[Path, CompletedProcess]
|
Mapping of input files to their process results. |
required |
ignores |
List[str]
|
List of substrings. If any is found in stderr, the error is ignored. |
[]
|
Source code in omnigraph/shell.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
run(cmd, text=True, debug=False, tee=False)
Run command with profile, always capturing output and optionally teeing it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd |
Command to run |
required | |
text |
Text mode for subprocess I/O |
True
|
|
debug |
Print the command to be run |
False
|
|
tee |
If True, also print output live while capturing |
False
|
Returns:
Type | Description |
---|---|
CompletedProcess
|
subprocess.CompletedProcess |
Source code in omnigraph/shell.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
StdTee
Manages teeing for both stdout and stderr using StreamTee instances. Captures output in instance variables.
Source code in omnigraph/shell.py
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 |
|
run(process, tee=True)
classmethod
Run teeing and capture for the given process. Returns a StdTee instance with stdout/stderr captured.
Source code in omnigraph/shell.py
93 94 95 96 97 98 99 100 101 102 |
|
StreamTee
Tees a single input stream to both a mirror and a capture buffer.
Source code in omnigraph/shell.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
SysTee
Tee sys.stdout and sys.stderr to a logfile while preserving original output.
Source code in omnigraph/shell.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
sparql_server
Created on 2025-05-27
@author: wf
ServerConfigs
Collection of server configurations loaded from YAML.
Source code in omnigraph/sparql_server.py
67 68 69 70 71 72 73 74 75 76 77 |
|
ofYaml(yaml_path)
classmethod
Load server configurations from YAML file.
Source code in omnigraph/sparql_server.py
73 74 75 76 77 |
|
ServerEnv
Server environment configuration.
Source code in omnigraph/sparql_server.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
__init__(log=None, shell=None, debug=False, verbose=False)
Initialize server environment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log |
Log
|
Log instance for logging |
None
|
shell |
Shell
|
Shell instance for command execution |
None
|
debug |
bool
|
Enable debug mode |
False
|
verbose |
bool
|
Enable verbose output |
False
|
Source code in omnigraph/sparql_server.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
SparqlServer
Base class for dockerized SPARQL servers
Source code in omnigraph/sparql_server.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
__init__(config, env)
Initialize the SPARQL server manager.
Source code in omnigraph/sparql_server.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
count_triples()
Count total triples in the SPARQL server.
Returns:
Type | Description |
---|---|
int
|
Number of triples |
Source code in omnigraph/sparql_server.py
227 228 229 230 231 232 233 234 235 236 237 |
|
exists()
Check if container exists (running or stopped).
Returns:
Type | Description |
---|---|
bool
|
True if container exists |
Source code in omnigraph/sparql_server.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
is_running()
Check if container is currently running.
Returns:
Type | Description |
---|---|
bool
|
True if container is running |
Source code in omnigraph/sparql_server.py
294 295 296 297 298 299 300 301 302 303 304 |
|
run_shell_command(command, success_msg=None, error_msg=None)
Helper function for running shell commands with consistent error handling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command |
str
|
Shell command to run |
required |
success_msg |
str
|
Message to log on success |
None
|
error_msg |
str
|
Message to log on error |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if command succeeded (returncode 0) |
Source code in omnigraph/sparql_server.py
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 165 |
|
start(show_progress=True)
Start SPARQL server in Docker container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
show_progress |
bool
|
Show progress bar while waiting |
True
|
Returns:
Type | Description |
---|---|
bool
|
True if started successfully |
Source code in omnigraph/sparql_server.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
stop()
Stop the server container.
Returns:
Type | Description |
---|---|
bool
|
True if stopped successfully |
Source code in omnigraph/sparql_server.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
wait_until_ready(timeout=30, show_progress=False)
Wait for server to be ready.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
int
|
Maximum seconds to wait |
30
|
show_progress |
bool
|
Show progress bar while waiting |
False
|
Returns:
Type | Description |
---|---|
bool
|
True if ready within timeout |
Source code in omnigraph/sparql_server.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
version
Created on 2025-05-28
@author: wf
Version
Version handling for nicegui widgets
Source code in omnigraph/version.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
yamlable
This is redundant copy to avoid dependeny hell the original is at https://github.com/WolfgangFahl/nicegui_widgets/blob/main/ngwidgets/yamlable.py
Created on 2023-12-08, Extended on 2023-16-12 and 2024-01-25
@author: wf, ChatGPT
Prompts for the development and extension of the 'YamlAble' class within the 'yamable' module:
- Develop 'YamlAble' class in 'yamable' module. It should convert dataclass instances to/from YAML.
- Implement methods for YAML block scalar style and exclude None values in 'YamlAble' class.
- Add functionality to remove None values from dataclass instances before YAML conversion.
- Ensure 'YamlAble' processes only dataclass instances, with error handling for non-dataclass objects.
- Extend 'YamlAble' for JSON serialization and deserialization.
- Add methods for saving/loading dataclass instances to/from YAML and JSON files in 'YamlAble'.
- Implement loading of dataclass instances from URLs for both YAML and JSON in 'YamlAble'.
- Write tests for 'YamlAble' within the pyLodStorage context. Use 'samples 2' example from pyLoDStorage https://github.com/WolfgangFahl/pyLoDStorage/blob/master/lodstorage/sample2.py as a reference.
- Ensure tests cover YAML/JSON serialization, deserialization, and file I/O operations, using the sample-based approach..
- Use Google-style docstrings, comments, and type hints in 'YamlAble' class and tests.
- Adhere to instructions and seek clarification for any uncertainties.
- Add @lod_storable annotation support that will automatically YamlAble support and add @dataclass and @dataclass_json prerequisite behavior to a class
DateConvert
date converter
Source code in omnigraph/yamlable.py
80 81 82 83 84 85 86 87 88 |
|
YamlAble
Bases: Generic[T]
An extended YAML handler class for converting dataclass objects to and from YAML format, and handling loading from and saving to files and URLs.
Source code in omnigraph/yamlable.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
from_dict2(data)
classmethod
Creates an instance of a dataclass from a dictionary, typically used in deserialization.
Source code in omnigraph/yamlable.py
310 311 312 313 314 315 316 317 318 |
|
from_yaml(yaml_str)
classmethod
Deserializes a YAML string to a dataclass instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_str |
str
|
A string containing YAML formatted data. |
required |
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
An instance of the dataclass. |
Source code in omnigraph/yamlable.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
load_from_json_file(filename)
classmethod
Loads a dataclass instance from a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path to the JSON file. |
required |
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
An instance of the dataclass. |
Source code in omnigraph/yamlable.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
load_from_json_url(url)
classmethod
Loads a dataclass instance from a JSON string obtained from a URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL pointing to the JSON data. |
required |
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
An instance of the dataclass. |
Source code in omnigraph/yamlable.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
load_from_yaml_file(filename)
classmethod
Loads a dataclass instance from a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path to the YAML file. |
required |
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
An instance of the dataclass. |
Source code in omnigraph/yamlable.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
load_from_yaml_url(url)
classmethod
Loads a dataclass instance from a YAML string obtained from a URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL pointing to the YAML data. |
required |
Returns:
Name | Type | Description |
---|---|---|
T |
T
|
An instance of the dataclass. |
Source code in omnigraph/yamlable.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
read_from_url(url)
classmethod
Helper method to fetch content from a URL.
Source code in omnigraph/yamlable.py
255 256 257 258 259 260 261 262 263 264 |
|
remove_ignored_values(value, ignore_none=True, ignore_underscore=False, ignore_empty=True)
classmethod
Recursively removes specified types of values from a dictionary or list. By default, it removes keys with None values. Optionally, it can also remove keys starting with an underscore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
Any
|
The value to process (dictionary, list, or other). |
required |
ignore_none |
bool
|
Flag to indicate whether None values should be removed. |
True
|
ignore_underscore |
bool
|
Flag to indicate whether keys starting with an underscore should be removed. |
False
|
ignore_empty |
bool
|
Flag to indicate whether empty collections should be removed. |
True
|
Source code in omnigraph/yamlable.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
represent_literal(dumper, data)
Custom representer for block scalar style for strings.
Source code in omnigraph/yamlable.py
115 116 117 118 119 120 121 |
|
represent_none(_, __)
Custom representer for ignoring None values in the YAML output.
Source code in omnigraph/yamlable.py
109 110 111 112 113 |
|
save_to_json_file(filename, **kwargs)
Saves the current dataclass instance to a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path where the JSON file will be saved. |
required |
**kwargs |
Additional keyword arguments for the |
{}
|
Source code in omnigraph/yamlable.py
243 244 245 246 247 248 249 250 251 252 253 |
|
save_to_yaml_file(filename)
Saves the current dataclass instance to a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path where the YAML file will be saved. |
required |
Source code in omnigraph/yamlable.py
201 202 203 204 205 206 207 208 209 210 |
|
to_yaml(ignore_none=True, ignore_underscore=True, allow_unicode=True, sort_keys=False)
Converts this dataclass object to a YAML string, with options to omit None values and/or underscore-prefixed variables, and using block scalar style for strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ignore_none |
bool
|
Flag to indicate whether None values should be removed from the YAML output. |
True
|
ignore_underscore |
bool
|
Flag to indicate whether attributes starting with an underscore should be excluded from the YAML output. |
True
|
allow_unicode |
bool
|
Flag to indicate whether to allow unicode characters in the output. |
True
|
sort_keys |
bool
|
Flag to indicate whether to sort the dictionary keys in the output. |
False
|
Returns:
Type | Description |
---|---|
str
|
A string representation of the dataclass object in YAML format. |
Source code in omnigraph/yamlable.py
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 |
|
lod_storable(cls)
Decorator to make a class LoDStorable by inheriting from YamlAble. This decorator also ensures the class is a dataclass and has JSON serialization/deserialization capabilities.
Source code in omnigraph/yamlable.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|