gigl.common.utils.jupyter_magics#
Attributes#
Classes#
Used to build and visualize graph which is user configured in a yaml file. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
Functions#
Can be used inside notebooks to change the working directory to the GIGL root directory. |
|
|
|
|
Displays a colored unified diff of two task config files. |
Module Contents#
- class gigl.common.utils.jupyter_magics.GraphVisualizer[source]#
Used to build and visualize graph which is user configured in a yaml file.
- static assign_edge_color(name)[source]#
Assign an edge color to a name based on deterministic hash and a fixed palette (optimized for white background).
- Parameters:
name (str)
- Return type:
str
- static assign_node_color(name)[source]#
Assign a node color to a name based on deterministic hash and a fixed palette.
- Parameters:
name (str)
- Return type:
str
- static visualize_graph(data, seed=42, layout_mode=GraphVisualizerLayoutMode.BIPARTITE, subgraph_node_to_unenumerated_node_id_map=None, pos_edges=None, global_root_node=None)[source]#
Warning: This is mostly just AI slop, but it serves the purpose for now. Visualize a graph.
- Parameters:
data (torch_geometric.data.HeteroData) – The HeteroData object to visualize.
seed – The seed for the random number generator - fix it to ensure reproducibility in visualizations
layout_mode – Either GraphVisualizerLayoutMode.HOMOGENEOUS or GraphVisualizerLayoutMode.BIPARTITE
subgraph_node_to_global_node_mapping – A mapping from local node indices to global node indices.
subgraph_node_to_unenumerated_node_id_map (Optional[gigl.common.collections.frozen_dict.FrozenDict[gigl.src.common.types.graph_data.Node, gigl.src.common.types.graph_data.Node]])
pos_edges (Optional[dict[tuple[str, str, str], list[tuple[int, int]]]])
global_root_node (Optional[tuple[int, str]])
- class gigl.common.utils.jupyter_magics.GraphVisualizerLayoutMode(*args, **kwds)[source]#
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- class gigl.common.utils.jupyter_magics.PbVisualizer(frozen_task_config)[source]#
- Parameters:
frozen_task_config (gigl.src.common.types.pb_wrappers.gbml_config.GbmlConfigPbWrapper)
- find_node_pb(unenumerated_node_id, unenumerated_node_type, from_output, pb_type)[source]#
- Parameters:
unenumerated_node_id (int)
unenumerated_node_type (str)
from_output (PbVisualizerFromOutput)
pb_type (Type[Union[snapchat.research.gbml.training_samples_schema_pb2.NodeAnchorBasedLinkPredictionSample, snapchat.research.gbml.training_samples_schema_pb2.RootedNodeNeighborhood]])
- Return type:
Optional[Union[snapchat.research.gbml.training_samples_schema_pb2.NodeAnchorBasedLinkPredictionSample, snapchat.research.gbml.training_samples_schema_pb2.RootedNodeNeighborhood]]
- class gigl.common.utils.jupyter_magics.PbVisualizerFromOutput(*args, **kwds)[source]#
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- gigl.common.utils.jupyter_magics.change_working_dir_to_gigl_root()[source]#
Can be used inside notebooks to change the working directory to the GIGL root directory. This is useful for ensuring that relative imports and file paths work correctly no matter where the notebook is located.
- gigl.common.utils.jupyter_magics.show_colored_unified_diff(f1_lines, f2_lines, f1_name, f2_name)[source]#
- gigl.common.utils.jupyter_magics.show_task_config_colored_unified_diff(f1_uri, f2_uri, f1_name, f2_name)[source]#
Displays a colored unified diff of two task config files. :param f1_uri: URI of the first file. :type f1_uri: Uri :param f2_uri: URI of the second file. :type f2_uri: Uri
- Parameters:
f1_uri (gigl.common.Uri)
f2_uri (gigl.common.Uri)
f1_name (str)
f2_name (str)