Algorithm
Algorithm Documentation sub-package for MaRDMO.
Provides everything needed to document algorithms within RDMO:
- :mod:
~MaRDMO.algorithm.models— Dataclasses representing Algorithm, Problem, Software, and Benchmark entities retrieved from MaRDI Portal or Wikidata. - :mod:
~MaRDMO.algorithm.handlers— Signal handlers that populate the questionnaire when an external ID is saved. - :mod:
~MaRDMO.algorithm.providers— RDMO optionset providers for searching algorithms, problems, software, and benchmarks in external knowledge graphs. - :mod:
~MaRDMO.algorithm.worker— Background worker for generating algorithm previews and exporting algorithm entries to the MaRDI Portal. - :mod:
~MaRDMO.algorithm.constants— Relation mappings, section maps, and URI-prefix configurations specific to the algorithm catalog.
Handlers
Module containing Handlers for the Algorithm Documentation.
Information inherits _entry, _collect_existing_ids, _hydrate_relatants, and _fill from BaseInformation (MaRDMO/handler_base.py).
All batch methods accept catalog='' (unused but required by the shared _fill and _hydrate_relatants signatures).
Information
Bases: BaseInformation
Handlers for the Algorithm Documentation questionnaire.
Source code in MaRDMO/algorithm/handlers.py
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 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 | |
__init__()
Load algorithm and publication questions, MathAlgoDB registry, and base URI.
Source code in MaRDMO/algorithm/handlers.py
37 38 39 40 41 | |
algorithm(instance)
Handle Algorithm ID save: hydrate basics and cascade to Problem and Software.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
RDMO :class: |
required |
Source code in MaRDMO/algorithm/handlers.py
71 72 73 74 75 76 77 | |
benchmark(instance)
Handle Benchmark ID save: hydrate basics and SPARQL data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
RDMO :class: |
required |
Source code in MaRDMO/algorithm/handlers.py
47 48 49 50 51 52 53 | |
problem(instance)
Handle Algorithmic Problem ID save: hydrate basics and cascade to Benchmark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
RDMO :class: |
required |
Source code in MaRDMO/algorithm/handlers.py
63 64 65 66 67 68 69 | |
software(instance)
Handle Software ID save: hydrate basics and cascade to Benchmark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
RDMO :class: |
required |
Source code in MaRDMO/algorithm/handlers.py
55 56 57 58 59 60 61 | |
Models
Dataclasses that represent entities in the Algorithm documentation catalog.
Each class maps to one entity type collected from MaRDI Portal and Wikidata during algorithm documentation. Instances are populated from SPARQL query results and carry the fields needed to render questionnaire answers and export entries.
Provides:
- :class:
Benchmark— benchmark problem associated with an algorithm - :class:
Software— software implementation of an algorithm - :class:
Problem— algorithmic problem solved by an algorithm - :class:
Algorithm— central entity representing the documented algorithm
Algorithm
dataclass
Data Class for Algorithm Item
Source code in MaRDMO/algorithm/models.py
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 | |
from_query(raw_data)
classmethod
Generate Class Item From Query (single-item, backward-compatible).
Source code in MaRDMO/algorithm/models.py
180 181 182 183 | |
from_query_batch(raw_data)
classmethod
Parse a batch SPARQL result into {external_id: instance} dict.
Source code in MaRDMO/algorithm/models.py
185 186 187 188 189 190 191 192 | |
from_query_single(data)
classmethod
Parse one SPARQL result row into an Algorithm instance.
Source code in MaRDMO/algorithm/models.py
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 | |
Benchmark
dataclass
Data Class For Benchmark Item
Source code in MaRDMO/algorithm/models.py
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 | |
from_query(raw_data)
classmethod
Generate Class Item From Query (single-item, backward-compatible).
Source code in MaRDMO/algorithm/models.py
29 30 31 32 | |
from_query_batch(raw_data)
classmethod
Parse a batch SPARQL result into {external_id: instance} dict.
Source code in MaRDMO/algorithm/models.py
34 35 36 37 38 39 40 41 | |
from_query_single(data)
classmethod
Parse one SPARQL result row into a Benchmark instance.
Source code in MaRDMO/algorithm/models.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
Problem
dataclass
Data Class for Problem Item
Source code in MaRDMO/algorithm/models.py
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 | |
from_query(raw_data)
classmethod
Generate Class Item From Query (single-item, backward-compatible).
Source code in MaRDMO/algorithm/models.py
125 126 127 128 | |
from_query_batch(raw_data)
classmethod
Parse a batch SPARQL result into {external_id: instance} dict.
Source code in MaRDMO/algorithm/models.py
130 131 132 133 134 135 136 137 | |
from_query_single(data)
classmethod
Parse one SPARQL result row into a Problem instance.
Source code in MaRDMO/algorithm/models.py
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 | |
Software
dataclass
Data Class for Software Item
Source code in MaRDMO/algorithm/models.py
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 | |
from_query(raw_data)
classmethod
Generate Class Item From Query (single-item, backward-compatible).
Source code in MaRDMO/algorithm/models.py
74 75 76 77 | |
from_query_batch(raw_data)
classmethod
Parse a batch SPARQL result into {external_id: instance} dict.
Source code in MaRDMO/algorithm/models.py
79 80 81 82 83 84 85 86 | |
from_query_single(data)
classmethod
Parse one SPARQL result row into a Software instance.
Source code in MaRDMO/algorithm/models.py
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 | |
Providers
RDMO optionset providers for the Algorithm documentation catalog.
Each provider class implements get_options and is referenced from the
algorithm catalog configuration. Providers query MaRDI Portal and Wikidata
for entity suggestions and optionally allow to create new
entries or restrict suggestions to previously documented entities.
Provides:
- :class:
Algorithm— searches external sources for algorithms; refresh on select - :class:
RelatedAlgorithmWithoutCreation— algorithm lookup without user creation - :class:
AlgorithmicProblem— searches for algorithmic problems; refresh on select - :class:
RelatedAlgorithmicProblemWithCreation— problem lookup with user creation - :class:
RelatedAlgorithmicProblemWithoutCreation— problem lookup, no creation - :class:
Benchmark— searches for benchmarks; refresh on select - :class:
RelatedBenchmarkWithCreation— benchmark lookup with user creation - :class:
RelatedBenchmarkOrSoftwareWithoutCreation— benchmark/software lookup, no creation
Algorithm
Bases: Provider
Algorithm Provider (MaRDI Portal / Wikidata), No User Creation, Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
AlgorithmicProblem
Bases: Provider
Algorithmic Problem Provider (MaRDI Portal / Wikidata), No User Creation, Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
Benchmark
Bases: Provider
Benchmark Provider (MaRDI Portal / Wikidata), No User Creation, Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
RelatedAlgorithmWithoutCreation
Bases: Provider
Algorithm Provider (MaRDI Portal), No User Creation, No Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
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 | |
RelatedAlgorithmicProblemWithCreation
Bases: Provider
Algorithmic Problem Provider (MaRDI Portal / Wikidata), User Creation, No Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.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 154 155 156 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
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 | |
RelatedAlgorithmicProblemWithoutCreation
Bases: Provider
Algorithmic Problem Provider (MaRDI Portal), No User Creation, No Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
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 | |
RelatedBenchmarkOrSoftwareWithoutCreation
Bases: Provider
Benchmark, Software Provider (MaRDI Portal), No User Creation, No Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
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 | |
RelatedBenchmarkWithCreation
Bases: Provider
Benchmark Provider (MaRDI Portal / Wikidata), User Creation, No Refresh Upon Selection
Source code in MaRDMO/algorithm/providers.py
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 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/algorithm/providers.py
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 | |
Workers
Background worker for the Algorithm documentation catalog.
Implements the task that collects algorithm metadata from User, MaRDI Portal, and Wikidata, renders a preview document, and exports the result to the MaRDI Portal.
Provides:
- :class:
PrepareAlgorithm— orchestrates data collection, preview rendering, and portal export for a single algorithm documentation project
PrepareAlgorithm
Bases: PublicationExport
Prepare Algorithm documentation answers for preview rendering and MaRDI Portal export.
Inherits publication export helpers from
:class:~MaRDMO.publication.worker.PublicationExport and extends them
with algorithm-specific relation mapping and Wikibase payload generation.
Source code in MaRDMO/algorithm/worker.py
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 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 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 336 337 338 339 340 341 342 343 344 345 346 | |
__init__()
Initialise with Wikibase vocabulary and the MathAlgoDB ontology registry.
Source code in MaRDMO/algorithm/worker.py
32 33 34 35 | |
export(data, url)
Assemble and return the complete Wikibase payload for an Algorithm documentation export.
Creates a :class:~MaRDMO.payload.GeneratePayload instance, processes
all unique items, then delegates each entity section (algorithms, problems,
software, benchmarks, publications) to dedicated helper methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Top-level answers dict produced by |
required | |
url
|
Target Wikibase API URL for the upload. |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple |
|
|
meth: |
Source code in MaRDMO/algorithm/worker.py
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 | |
preview(answers)
Resolve entity cross-references for the Algorithm documentation preview page.
Applies algorithm-specific relation mappings so that the preview template receives a fully-resolved answers dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
answers
|
Top-level answers dict (mutated in place). |
required |
Returns:
| Type | Description |
|---|---|
|
The mutated answers dict. |
Source code in MaRDMO/algorithm/worker.py
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 | |
Constants
Compile-time constants and configuration builders for the Algorithm catalog.
Centralises the property URIs, relation definitions, and question/item
mappings that the algorithm documentation sub-package needs at runtime.
Values are loaded once from the RDMO database via the
getters helpers and then referenced by handlers, providers, and workers.
Provides:
get_relations()— returns the full relation-definition dict for algorithmsget_uri_prefix_map()— returns the{prefix: URI}map used to expand compact IDs- Module-level constants built from the above (
RELATIONS,URI_PREFIX_MAP, etc.)
get_relations()
Build the relation mapping for the Algorithm Documentation.
Maps each MathAlgoDB relation URL to the corresponding Wikibase property (and optional qualifier item or direction string) used when writing statements to the MaRDI Portal.
Returns:
| Type | Description |
|---|---|
|
Dict mapping MathAlgoDB relation URL strings to |
|
|
lists; qualifier is either a Wikibase item ID or |
Source code in MaRDMO/algorithm/constants.py
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 | |
get_uri_prefix_map()
Build the attribute-URI → section config mapping for the Algorithm Documentation.
Maps each relation attribute URI to the corresponding questionnaire section metadata needed to add or hydrate the related entity.
Returns:
| Type | Description |
|---|---|
|
Dict mapping full RDMO attribute URI strings to dicts with keys |
|
|
|
Source code in MaRDMO/algorithm/constants.py
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 | |