in gym_wikinav/envs/wikinav_env/web_graph.py [0:0]
def get_default_graph(cls, path_length=10):
if hasattr(cls, "_default_graph"):
return cls._default_graph
# Load the built-in graph data, downloading if necessary.
script_dir = os.path.dirname(os.path.realpath(__file__))
graph_path = os.path.join(script_dir, cls.LOCAL_GRAPH_PATH)
if not os.path.exists(graph_path):
print("Downloading default Wikispeedia graph.", file=sys.stderr)
download_file(cls.REMOTE_GRAPH_URL, graph_path)
emb_path = os.path.join(script_dir, cls.LOCAL_EMBEDDINGS_PATH)
if not os.path.exists(emb_path):
print("Downloading default Wikispeedia embeddings.", file=sys.stderr)
download_file(cls.REMOTE_EMBEDDINGS_URL, emb_path)
graph = cls(graph_path, path_length, emb_paths=[emb_path])
cls._default_graph = graph
return graph