pyMogwai API Documentation
core
hd_index
Created on 2024-11-07
@author: wf
base on A. Harth and S. Decker, "Optimized index structures for querying RDF from the Web," Third Latin American Web Congress (LA-WEB'2005), Buenos Aires, Argentina, 2005, pp. 10 pp.-, doi: 10.1109/LAWEB.2005.25. keywords: {Resource description framework;Data models;Semantic Web;Indexes;Java;Vocabulary;Database systems;Memory;Indexing;Information retrieval},
Index
A Single index in the SPOG matrix as explained in identified by from/to positions
Source code in mogwai/core/hd_index.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 |
|
name: str
property
Full quad index name based on Harth/Decker SPOG ordering
__init__(from_pos, to_pos)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_pos |
str
|
First position (S,P,O,G) |
required |
to_pos |
str
|
Second position (S,P,O,G) |
required |
Source code in mogwai/core/hd_index.py
78 79 80 81 82 83 84 85 86 |
|
add_quad(quad)
Add a quad to this index's lookup using quad positions
Source code in mogwai/core/hd_index.py
94 95 96 97 98 99 100 101 102 103 |
|
IndexConfig
dataclass
Configuration of which SPOG indices to use
Source code in mogwai/core/hd_index.py
16 17 18 19 20 |
|
IndexConfigs
Bases: Enum
Standard index configurations
Source code in mogwai/core/hd_index.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 |
|
get_config()
Get the index configuration for this enum value
Source code in mogwai/core/hd_index.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 58 59 60 61 |
|
Quad
dataclass
A quad of hashable values (Subject-Predicate-Object-Graph)
Source code in mogwai/core/hd_index.py
64 65 66 67 68 69 70 71 |
|
SPOGIndex
all 16 possible indices based on SPOG matrix
see http://harth.org/andreas/ YARS and the paper
Source code in mogwai/core/hd_index.py
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 |
|
add_quad(quad)
Add quad only to configured active indices
Source code in mogwai/core/hd_index.py
139 140 141 142 |
|
get_lookup(from_pos, to_pos)
Get lookup dict for from->to positions if active
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_pos |
str
|
From position (S,P,O,G) |
required |
to_pos |
str
|
To position (S,P,O,G) |
required |
Returns: Lookup dict if index active in current config, None otherwise
Source code in mogwai/core/hd_index.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
mogwaigraph
MogwaiGraph
Bases: DiGraph
networkx based directed graph see https://networkx.org/documentation/stable/reference/classes/digraph.html
Source code in mogwai/core/mogwaigraph.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 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 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
__init__(incoming_graph_data=None, config=None, **attr)
Initialize a MogwaiGraph with optional data and configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
incoming_graph_data |
Graph data in NetworkX compatible format |
None
|
|
config |
MogwaiGraphConfig
|
Configuration for field names and defaults |
None
|
**attr |
Graph attributes as key=value pairs |
{}
|
Source code in mogwai/core/mogwaigraph.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
add_edge(*args, **kwargs)
Add an edge with default or explicit label
Source code in mogwai/core/mogwaigraph.py
186 187 188 189 190 191 192 |
|
add_labeled_edge(srcId, destId, edgeLabel, properties=None, **kwargs)
add a labeled edge
Source code in mogwai/core/mogwaigraph.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 171 172 173 |
|
add_labeled_node(label, name, properties=None, node_id=None, **kwargs)
Add a labeled node to the graph.
we can only insert a node by hashable value and as names and ids might occur multiple times we use incremented node ids if no node_id is provided
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str
|
The label for the node. |
required |
name |
str
|
The name of the node. |
required |
properties |
dict
|
Additional properties for the node. Defaults to None. |
None
|
node_id |
Optional[int]
|
The ID for the node. If not provided, a new ID will be generated. Defaults to None. |
None
|
kwargs |
further property values |
{}
|
Returns: Any: The ID of the newly added node - will be an integer if node_id was kept as default None
Raises:
Type | Description |
---|---|
MogwaiGraphError
|
If a node with the provided ID already exists in the graph. |
Source code in mogwai/core/mogwaigraph.py
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 |
|
add_node(*args, **kwargs)
Add a node with default or explicit labels
Source code in mogwai/core/mogwaigraph.py
175 176 177 178 179 180 181 182 183 184 |
|
add_to_index(element_type, subject_id, label, name, properties)
Add labels, name, and properties to the SPOG index for a given subject and element_type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_type |
str
|
(str): node or edge |
required |
subject_id |
Hashable
|
The ID of the subject (node or edge). |
required |
label |
str
|
the label for the subject. |
required |
name |
str
|
Name of the subject. |
required |
properties |
dict
|
Dictionary of additional properties to index. |
required |
Source code in mogwai/core/mogwaigraph.py
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 |
|
crew()
classmethod
create the TheCrew example graph see TinkerFactory.createTheCrew() in https://tinkerpop.apache.org/docs/current/reference/
Source code in mogwai/core/mogwaigraph.py
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 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
draw(outputfile, title='MogwaiGraph', **kwargs)
Draw the graph using graphviz Parameters
outputfile : str
the file to save the graph to
title : str, default 'MogwaiGraph'
the title of the graph
kwargs : dict
additional parameters used to configure the drawing style.
For more details see MogwaiGraphDrawer
Source code in mogwai/core/mogwaigraph.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
get_next_node_id()
get the next node_id
Source code in mogwai/core/mogwaigraph.py
49 50 51 52 53 54 55 56 |
|
get_nodes(label, name)
@FIXME - this is ugly code
Source code in mogwai/core/mogwaigraph.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
join(from_label, to_label, join_field, target_key, edge_label)
Joins two node types by field values and creates edges between them.
Source code in mogwai/core/mogwaigraph.py
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 |
|
modern(index_config='off')
classmethod
create the modern graph see https://tinkerpop.apache.org/docs/current/tutorials/getting-started/
Source code in mogwai/core/mogwaigraph.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
MogwaiGraphConfig
dataclass
configuration of a MogwaiGraph
Source code in mogwai/core/mogwaigraph.py
11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
MogwaiGraphDrawer
helper class to draw MogwaiGraphs
Source code in mogwai/core/mogwaigraph.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
__init__(g, title, **kwargs)
Parameters
g : MogwaiGraph
the graph to draw
title : str
the title of the graph
kwargs : dict
additional parameters used to configure the drawing style
* fontname : str, default 'arial'
the font to use
* fillcolor : str, default '#ADE1FE'
the fill color of the vertices
* edge_line_width : int, default 3
the width of the edges
* dash_width : int, default 5
number of dashess in the head/properties delimiter
* v_limit : int, default 10
the maximum number of vertices to show
* e_limit : int, default 10
the maximum number of edges to show
* vertex_properties : list, default None
the properties to display for vertices, if None
all properties are shown
* edge_properties : list, default None
the properties to display for edges, if None
all properties are shown
* prog : str, default 'dot'
the layout program to use
Source code in mogwai/core/mogwaigraph.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
draw(outputfile)
draw the given graphviz markup from the given output file using the graphviz "dot" software
Source code in mogwai/core/mogwaigraph.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
steps
base_steps
branch_steps
filter_steps
HasWithin
Bases: FilterStep
Similar to Has
, but with multiple options for the value
Source code in mogwai/core/steps/filter_steps.py
80 81 82 83 84 85 86 87 88 89 |
|
flatmap_steps
io_step
map_steps
Fold
Bases: MapStep
Source code in mogwai/core/steps/map_steps.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
__init__(traversal, seed=None, foldfunc=None)
Combine all traversers into a single Value containing a list of all traversers.
If seed
and foldfunc
are provided, the traversers will be reduced into a single value using the provided function.
For example, g.V().values('age').fold(0, lambda x,y: x+y).next()
will result in the sum of all ages.
Parameters
seed: Any, optional The initial value to start the fold with. foldfunc: Callable[[Any,Any], Any], optional The bi-function to use to reduce the traversers into a single value.
Source code in mogwai/core/steps/map_steps.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
modulation_steps
start_steps
statics
add_camel_case_aliases(module_globals)
Add camelCase aliases for all snake_case callables in the module's globals.
Source code in mogwai/core/steps/statics.py
13 14 15 16 17 18 19 20 21 22 23 24 |
|
terminal_steps
traversal
AnonymousTraversal
Bases: Traversal
This class implements Anonymous traversals. These are traversals that are not directly bound to a source. They are used as subqueries in other traversals, and are not meant to be run on their own. As input, they receive a set of traversers from the parent traversal, and they return a set of traversers to the parent traversal.
Importantly, some steps require information from the source traversal (like the graph's configuration) to be able to construct themselves. Therefore, we cannot construct an anonymous traversal at the time it is created, but we need to build it when it is added to a parent traversal. This inheritance structure is a bit of a hack to allow for this behavior and will inherently cause some issues with type hinting.
This behavior is implemented in the following way.
1. When an anonymous traversal is created, it is empty, and it has a list of step templates.
2. When a step method is retrieved from the anonymous traversal, this __getattribute__
call to obtain the method
is intercepted. Instead of returning the actual step method, which would run immediately and construct the step,
a deferred step method is returned. This deferred step method stores the step method and its arguments in the step templates.
3. When the anonymous traversal is build by a parent traversal, the parent traversal constructs the anonymous traversal.
In the anonymous traversal's build method, it constructs all the steps from the step templates as if the step methods are only called at this point.
4. The anonymous traversal is now ready to be run.
Source code in mogwai/core/traversal.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 |
|
MogwaiGraphTraversalSource
see https://tinkerpop.apache.org/javadocs/current/full/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.html
A GraphTraversalSource is the primary DSL of the Gremlin traversal machine. It provides access to all the configurations and steps for Turing complete graph computing. Any DSL can be constructed based on the methods of both GraphTraversalSource and GraphTraversal.
Source code in mogwai/core/traversal.py
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
|
Traversal
see https://tinkerpop.apache.org/javadocs/3.7.3/core/org/apache/tinkerpop/gremlin/process/traversal/Traversal.html
This class represents the base class for all traversals. Each traversal is a directed walk over a graph, executed
using an iterator-based traversal.
You shouldn't create instances of this class directly, but instead use a Traversal Source, (e.g. the MogwaiGraphTraversalSource
)
to create a new traversal.
Then, you can chain traversal steps to create a query that will be executed when you call the run()
method.
Source code in mogwai/core/traversal.py
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 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
|
has(*args)
Filter traversers based on whether they have the given properties. * If one argument is given, it is assumed to be a key, and the step checks if a property with that key exists, regardless of its value. * If two arguments are given, it is assumed to be a key and a value, and the step checks if a property with that key exists and has the given value. * If three arguments are given, the first argument is assumed to be a label, and the step checks if a property with the given key and value exists on an element with that label.
Source code in mogwai/core/traversal.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
traverser
Created on 2024
@author: Joep Geuskens
Traverser
Bases: BaseTraverser
see https://tinkerpop.apache.org/javadocs/3.7.3/core/org/apache/tinkerpop/gremlin/process/traversal/Traverser.html
A Traverser represents the current state of an object flowing through a Traversal.
A traverser maintains a reference to the current object, a traverser-local "sack", a traversal-global sideEffect, a bulk count, and a path history.
Different types of traversers can exist depending on the semantics of the traversal and the desire for space/time optimizations of the developer.
Source code in mogwai/core/traverser.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 |
|
decorators
decorators
traversal_step_doc(cls)
Decorator to copy the docstring from the init method of a class.
Source code in mogwai/decorators/decorators.py
40 41 42 43 44 45 |
|
examples
modern
Created on 2024-11-14
@author: wf
Person
a person
Source code in mogwai/examples/modern.py
12 13 14 15 16 17 18 19 |
|
Software
a software
Source code in mogwai/examples/modern.py
22 23 24 25 26 27 28 29 |
|
schema
Created on 15.11.2024
@author: wf
MogwaiExampleSchema
the mogwai examples schema
Source code in mogwai/examples/schema.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
graph_config
Created on 2024-08-17
@author: wf
GraphConfig
Configuration for a graph in the Examples class
Source code in mogwai/graph_config.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
GraphConfigs
Manages a collection of GraphConfig instances
Source code in mogwai/graph_config.py
36 37 38 39 40 |
|
graphs
Created on 2024-08-17
@author: wf
Graphs
Manage MogwaiGraphs
Source code in mogwai/graphs.py
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 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 |
|
get(name)
Get a graph by name, loading it if necessary
Source code in mogwai/graphs.py
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 |
|
get_names()
Get a list of available graph names
Source code in mogwai/graphs.py
66 67 68 69 70 |
|
load_examples()
Load all example graphs based on configurations
Source code in mogwai/graphs.py
48 49 50 51 52 53 54 |
|
io
mogwai_io
GraphSON
Bases: IOBackend
GraphSON is a JSON-based file format for representing graphs. https://tinkerpop.apache.org/docs/3.7.2/dev/io/#graphson
Source code in mogwai/io/mogwai_io.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 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 |
|
lod
yamlable
Created on 2023-12-08, Extended on 2023-16-12 and 2024-01-25
redudant mogwai copy original is at https://github.com/WolfgangFahl/pyLoDStorage/blob/master/lodstorage/yamlable.py
@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 mogwai/lod/yamlable.py
78 79 80 81 82 83 84 85 86 |
|
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 mogwai/lod/yamlable.py
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 |
|
from_dict2(data)
classmethod
Creates an instance of a dataclass from a dictionary, typically used in deserialization.
Source code in mogwai/lod/yamlable.py
320 321 322 323 324 325 326 327 328 |
|
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 mogwai/lod/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 mogwai/lod/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 mogwai/lod/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 mogwai/lod/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 mogwai/lod/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 mogwai/lod/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 mogwai/lod/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 309 310 311 312 313 314 315 316 317 318 |
|
represent_literal(dumper, data)
Custom representer for block scalar style for strings.
Source code in mogwai/lod/yamlable.py
113 114 115 116 117 118 119 |
|
represent_none(_, __)
Custom representer for ignoring None values in the YAML output.
Source code in mogwai/lod/yamlable.py
107 108 109 110 111 |
|
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 mogwai/lod/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 mogwai/lod/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 mogwai/lod/yamlable.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 |
|
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 mogwai/lod/yamlable.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
mogwai_cmd
Created on 2024-08-15
@author: wf
MogwaiCmd
Bases: WebserverCmd
command line handling for nicesprinkler
Source code in mogwai/mogwai_cmd.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
__init__()
constructor
Source code in mogwai/mogwai_cmd.py
20 21 22 23 24 25 |
|
getArgParser(description, version_msg)
override the default argparser call
Source code in mogwai/mogwai_cmd.py
27 28 29 30 31 32 33 |
|
main(argv=None)
main call
Source code in mogwai/mogwai_cmd.py
36 37 38 39 40 41 42 |
|
parser
excel_converter
filesystem
graphml_converter
graphml_to_mogwaigraph(file, node_label_key, node_name_key, edge_label_key=None, default_node_label='Na', default_edge_label='Na', default_node_name='Na', include_id=False, keep=True)
Converts GraphML file to MogwaiGraph object.
Parameters
file : str
Path to the GraphML file.
node_label_key : str or Callable[[dict],str]
Key to use for the node label. If a string, the value of the key is used as the label.
If a function, it should take a dictionary of node data and return a string.
node_name_key : str or Callable[[dict],str]
Key to use for the node name. If a string, the value of the key is used as the name.
If a function, it should take a dictionary of node data and return a string.
edge_label_key : str or Callable[[dict],str], optional
Key to use for the edge label. If a string, the value of the key is used as the label.
If a function, it should take a dictionary of edge data and return a string.
If None, the node_label_key is used.
default_node_label : str, optional
Default label to use for nodes that do not have a property corresponding to node_label_key
.
default_edge_label : str, optional
Default label to use for edges that do not have a property corresponding to edge_label_key
.
default_node_name : str, optional
Default name to use for nodes that do not have a property corresponding to node_name_key
.
include_id : bool or str, optional
If True, the node id is included in the data dictionary of each node.
If a string, the node id is included in the data dictionary with the given key.
keep : bool, optional
If True, the labels and names are kept as properties in the node data dictionary. If False, they are removed.
Returns
MogwaiGraph The graph object
Source code in mogwai/parser/graphml_converter.py
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 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 |
|
json_converter
Created on 2024-10-09
@author: wf
JsonGraph
json graph handling library
Source code in mogwai/parser/json_converter.py
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 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 |
|
add_node(table_name, data)
Add a single node to the graph
Source code in mogwai/parser/json_converter.py
35 36 37 38 39 40 |
|
add_nodes_from_json(file_name, file_content)
Add nodes from JSON data to the graph
Source code in mogwai/parser/json_converter.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
dump(node_types=None, limit=10)
Dump the content of the graph for investigation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_types |
list
|
List of node types to dump. If None, dump all types. |
None
|
limit |
int
|
Maximum number of nodes to dump for each node type. Default is 10. |
10
|
Source code in mogwai/parser/json_converter.py
42 43 44 45 46 47 48 49 50 51 52 53 |
|
pdfgraph
powerpoint_converter
schema
graph_schema
Created on 2024-10-22
@author: wf
GraphSchema
registry of node types and their configurations
Source code in mogwai/schema/graph_schema.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 |
|
node_id_type: Type
property
Property to convert the node_id_type_name to an actual Python type.
add_to_graph(graph)
add my node type configurations to the given graph
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph(MogwaiGraph) |
the graph to add the configurations to |
required |
Source code in mogwai/schema/graph_schema.py
106 107 108 109 110 111 112 113 114 115 116 117 |
|
get_node_config(node_data)
Get the NodeTypeConfig for the node based on its labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_data |
dict
|
The data of the node containing labels |
required |
Returns:
Type | Description |
---|---|
NodeTypeConfig | None
|
NodeTypeConfig or None: The NodeTypeConfig for the given node if found, otherwise None. |
Source code in mogwai/schema/graph_schema.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
load(yaml_path=None)
classmethod
Load schema from a YAML file, ensuring the file exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_path |
str
|
Optional path to YAML file. If None, uses default path. |
None
|
Returns:
Name | Type | Description |
---|---|---|
GraphSchema |
GraphSchema
|
Loaded schema or empty schema if file doesn't exist |
Source code in mogwai/schema/graph_schema.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
yaml_path()
classmethod
Default path for schema YAML file
Source code in mogwai/schema/graph_schema.py
119 120 121 122 123 124 |
|
NodeTypeConfig
Configuration for a node type in the graph
Source code in mogwai/schema/graph_schema.py
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 |
|
__post_init__()
Initialize the dataclass and view class types
Source code in mogwai/schema/graph_schema.py
59 60 61 62 63 64 65 66 67 |
|
get_class(class_name_attr)
retrievw a class from its module path string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name_attr |
str
|
The attribute name containing the class path string |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the class initialization fails |
Source code in mogwai/schema/graph_schema.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
nx_to_rdf
Created on 2024-10-22
@author: wf
NetworkXToRDFConverter
A converter for converting a NetworkX graph to RDF based on the given GraphSchema.
Source code in mogwai/schema/nx_to_rdf.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 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 |
|
__init__(schema, namespaces)
Initialize the converter with the given schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
GraphSchema
|
The graph schema containing the node type configurations and base URI. |
required |
namespaces |
List[str]
|
A list of namespaces used for managing prefixes in the graph. |
required |
Source code in mogwai/schema/nx_to_rdf.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
convert_edge(source_id, target_id, edge_data)
Convert a NetworkX edge to RDF and add it to the RDFLib graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_id |
The source node identifier |
required | |
target_id |
The target node identifier |
required | |
edge_data |
The data associated with the edge |
required |
Source code in mogwai/schema/nx_to_rdf.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
convert_graph(nx_graph)
Convert the entire NetworkX graph to RDF.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nx_graph |
Graph
|
The NetworkX graph to convert |
required |
Source code in mogwai/schema/nx_to_rdf.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
convert_node(node_id, node_data)
Convert a NetworkX node to RDF and add it to the RDFLib graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_id |
The node identifier |
required | |
node_data |
The data associated with the node |
required |
Source code in mogwai/schema/nx_to_rdf.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
serialize(rdf_format='turtle')
Serialize the RDF graph to the specified format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rdf_format |
str
|
The RDF format to serialize to (e.g., 'turtle', 'xml'). |
'turtle'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The serialized RDF graph. |
Source code in mogwai/schema/nx_to_rdf.py
101 102 103 104 105 106 107 108 109 110 111 |
|
utils
graph_summary
GraphSummary
A class to generate formatted summaries of graph structures.
Source code in mogwai/utils/graph_summary.py
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 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 |
|
__init__(graph, fmt='github', section_formats=None)
constructor
Source code in mogwai/utils/graph_summary.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
dump(node_types=None, limit=10)
Dump the content of the graph for investigation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_types |
list
|
List of node types to dump. If None, dump all types. |
None
|
limit |
int
|
Maximum number of nodes to dump for each node type. Default is 10. |
10
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Formatted string containing the graph summary, nodes, and edges. |
Source code in mogwai/utils/graph_summary.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
format_section_header(header, level=1)
Format the section header using the format string for the current output format.
Source code in mogwai/utils/graph_summary.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
summary(limit=3)
Generate a summary of the graph.
Source code in mogwai/utils/graph_summary.py
38 39 40 41 |
|
SectionFormat
dataclass
Source code in mogwai/utils/graph_summary.py
6 7 8 9 10 11 12 13 14 15 16 |
|
format_section_header(header)
format a given header with my format string
Source code in mogwai/utils/graph_summary.py
11 12 13 14 15 16 |
|
type_utils
TypeUtils
utility functions to handle types
Source code in mogwai/utils/type_utils.py
3 4 5 6 7 8 9 10 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
version
Created on 2024-08-15
@author: wf
Version
dataclass
Bases: object
Version handling for pyMogwai
Source code in mogwai/version.py
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 |
|
web
i18n_config
Created on 21.10.2024
@author: wf
I18nConfig
Internationalization module configuration
Source code in mogwai/web/i18n_config.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
node_view
Created on 2024-10-21
@author: wf
BaseNodeView
Base class for viewing and interacting with nodes in a graph.
Source code in mogwai/web/node_view.py
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 |
|
__init__(config)
Base constructor for initializing the NodeView.
Args:
Source code in mogwai/web/node_view.py
44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
editable_properties(props)
Filter the properties to exclude hidden keys (those starting with '_') and non-string iterables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
props |
dict[str, Any]
|
The dictionary of properties to filter. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: The filtered properties dictionary. |
Source code in mogwai/web/node_view.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
NodeTableView
Bases: BaseNodeView
A view for displaying and interacting with nodes of the same type in a MogwaiGraph.
Source code in mogwai/web/node_view.py
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 |
|
__init__(config)
Initialize the NodeTableView.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
NodeViewConfig
|
The configuration dataclass for the view. |
required |
Source code in mogwai/web/node_view.py
165 166 167 168 169 170 171 172 173 174 175 |
|
get_lod_of_nodes(node_label)
Retrieve a list of dictionaries containing the properties of nodes with the given node_label from the graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_label |
str
|
The label of the nodes to retrieve. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of dictionaries containing the properties of the matching nodes, with 'id' included. |
Source code in mogwai/web/node_view.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
load_and_show_nodes()
async
Load nodes in background and update UI
Source code in mogwai/web/node_view.py
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 |
|
setup_ui()
Set up the user interface for the NodeTableView
Source code in mogwai/web/node_view.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
NodeView
Bases: BaseNodeView
A view for displaying and editing a single node of a NetworkX graph.
Source code in mogwai/web/node_view.py
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 |
|
__init__(config, node_id)
Construct the NodeView with the given configuration and node ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
NodeViewConfig
|
The configuration dataclass for the view. |
required |
node_id |
Any
|
The identifier of the node to view/edit. |
required |
Source code in mogwai/web/node_view.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
close()
Hide the details of the dict edit
Source code in mogwai/web/node_view.py
116 117 118 119 120 121 |
|
get_dict_edit()
Return a DictEdit instance for editing node attributes.
Source code in mogwai/web/node_view.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 |
|
open()
Show the details of the dict edit
Source code in mogwai/web/node_view.py
109 110 111 112 113 114 |
|
update_node(updated_data)
Update the node in the graph with the edited data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
updated_data |
dict
|
The updated node attributes |
required |
Source code in mogwai/web/node_view.py
150 151 152 153 154 155 156 157 |
|
NodeViewConfig
dataclass
parameters for the node views
Source code in mogwai/web/node_view.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
server
Created on 2024-08-15
@author: wf
MogwaiSolution
Bases: InputWebSolution
the Mogwai solution
Source code in mogwai/web/server.py
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 |
|
__init__(webserver, client)
Initialize the solution
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webserver |
MogwaiWebServer
|
The webserver instance associated with this context. |
required |
client |
Client
|
The client instance this context is associated with. |
required |
Source code in mogwai/web/server.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
authenticated()
Check if the user is authenticated. Returns: True if the user is authenticated, False otherwise.
Source code in mogwai/web/server.py
126 127 128 129 130 131 132 |
|
configure_menu()
configure additional non-standard menu entries
Source code in mogwai/web/server.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
handle_upload(e)
Handle file upload
Source code in mogwai/web/server.py
294 295 296 297 298 299 300 301 302 303 304 |
|
home()
async
Provide the main content page
Source code in mogwai/web/server.py
162 163 164 |
|
login_ui()
async
login ui
Source code in mogwai/web/server.py
156 157 158 159 160 |
|
on_run_query(query=None)
Run a Gremlin query on the graph
Source code in mogwai/web/server.py
306 307 308 309 310 311 312 313 314 315 316 317 |
|
query_graph()
async
Graph querying page
Source code in mogwai/web/server.py
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 |
|
show_node(node_type, node_id)
async
show the given node
Source code in mogwai/web/server.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
show_nodes(node_type)
async
show nodes of the given type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_type(str) |
the type of nodes to show |
required |
Source code in mogwai/web/server.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 |
|
MogwaiWebServer
Bases: InputWebserver
Mogwai WebServer
Source code in mogwai/web/server.py
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 |
|
__init__()
Constructs all the necessary attributes for the WebServer object.
Source code in mogwai/web/server.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 |
|
configure_run()
configure with args
Source code in mogwai/web/server.py
96 97 98 99 100 101 102 |
|