-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_construction.py
More file actions
62 lines (50 loc) · 1.92 KB
/
Copy pathgraph_construction.py
File metadata and controls
62 lines (50 loc) · 1.92 KB
1
2
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
57
58
59
60
61
62
from dotenv import load_dotenv
from neo4j import GraphDatabase
import os
from utils import (
add_chef_licenses_relationships,
add_license_nodes,
add_planet_distances_relationships,
add_planet_nodes,
add_menu_nodes,
aggiorna_tecniche,
create_indexes,
get_graph_schema,
)
# set up FLAGS
CREATE_MENU_NODES = False
CREATE_PLANET_NODES = False
CREATE_PLANET_DISTANCES_RELATIONSHIPS = False
CREATE_LICENSE_NODES = False
CREATE_CHEF_LICENSES_RELATIONSHIPS = False
# set up environment variables
os.environ["NEO4J_URI"] = os.getenv("NEO4J_URI")
os.environ["NEO4J_USERNAME"] = os.getenv("NEO4J_USERNAME")
os.environ["NEO4J_PASSWORD"] = os.getenv("NEO4J_PASSWORD")
# set up neo4j driver
driver = GraphDatabase.driver(os.environ["NEO4J_URI"], auth=(os.environ["NEO4J_USERNAME"], os.environ["NEO4J_PASSWORD"]))
# get schema
schema = get_graph_schema(driver)
# add nodes: restaurants, chef, dishes, ingredients, techniques
if CREATE_MENU_NODES:
restaurant_menu_directory = 'restaurant_menu'
add_menu_nodes(driver, restaurant_menu_directory)
# add nodes: planets
if CREATE_PLANET_NODES:
restaurant_planet_directory = 'restaurant_planet'
add_planet_nodes(driver, restaurant_planet_directory)
# add additonal relationship: distance between planets
if CREATE_PLANET_DISTANCES_RELATIONSHIPS:
planet_distances_path = "data/Misc/Distanze.csv"
add_planet_distances_relationships(driver, planet_distances_path)
# add nodes: licenses
if CREATE_LICENSE_NODES:
manual_licenses_path = "manual_licenses/licenze.json"
add_license_nodes(driver, manual_licenses_path)
# add additional relationship: chef --> licenses
if CREATE_CHEF_LICENSES_RELATIONSHIPS:
restaurant_licenses_directory = "restaurant_licenses"
add_chef_licenses_relationships(driver, restaurant_licenses_directory)
# tecniche_directory = "tecniche.json"
# aggiorna_tecniche(driver, tecniche_directory)
create_indexes(driver)