gigl.common.utils.jupyter_magics#

Attributes#

Classes#

GraphVisualizer

Used to build and visualize graph which is user configured in a yaml file.

Functions#

change_working_dir_to_gigl_root()

Can be used inside notebooks to change the working directory to the GIGL root directory.

find_node_pb(tfrecord_uri_prefix, node_id, pb_type)

show_colored_unified_diff(f1_lines, f2_lines, f1_name, ...)

show_task_config_colored_unified_diff(f1_uri, f2_uri, ...)

Displays a colored unified diff of two task config files.

sort_yaml_dict_recursively(obj)

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_color(name)[source]#

Assign a color to a name based on hash and a fixed palette.

Parameters:

name (str)

Return type:

str

static plot_graph(pb)[source]#

Visualize the graph from the protobuf message.

Parameters:

pb (Union[snapchat.research.gbml.training_samples_schema_pb2.RootedNodeNeighborhood, snapchat.research.gbml.training_samples_schema_pb2.NodeAnchorBasedLinkPredictionSample])

static visualize_graph(data)[source]#
Parameters:

data (torch_geometric.data.HeteroData)

fixed_colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f',...[source]#
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.find_node_pb(tfrecord_uri_prefix, node_id, pb_type)[source]#
Parameters:
Return type:

Optional[Union[snapchat.research.gbml.training_samples_schema_pb2.NodeAnchorBasedLinkPredictionSample, snapchat.research.gbml.training_samples_schema_pb2.RootedNodeNeighborhood]]

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:
gigl.common.utils.jupyter_magics.sort_yaml_dict_recursively(obj)[source]#
Parameters:

obj (dict)

Return type:

dict

gigl.common.utils.jupyter_magics.gigl_root_dir[source]#