-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathembed.py
More file actions
67 lines (62 loc) · 1.89 KB
/
embed.py
File metadata and controls
67 lines (62 loc) · 1.89 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
63
64
65
66
67
from embeoj.export import export
from embeoj.preprocess import preprocess_exported_data
from embeoj.train import convert_tsv_to_pbg, train_embeddings
from embeoj.utils import update_config, test_db_connection, logging
import click
import sys
@click.command()
@click.argument("train")
@click.option(
"--project_name",
default="myproject",
help="name of the root folder where embeddings are stored",
show_default=True,
)
@click.option(
"--url",
default="bolt://localhost:7687/",
help="url for neo4j database",
show_default=True,
)
@click.option(
"--username",
default="neo4j",
help="username for neo4j database",
show_default=True,
prompt=True,
)
@click.option(
"--password",
default="neo4j",
help="password for neo4j database",
prompt=True,
hide_input=True,
)
@click.option("--config_path", default=None, help="path to a yml configuration file")
def embed(config_path, project_name, url, username, password, train):
"""Command line interface for training and generating graph embeddings
"""
try:
# test run to check for db connection
if not test_db_connection():
logging.info("could not connect to Neo4j")
sys.exit()
return
if train == "train":
update_config(
config_path=config_path,
project_name=project_name,
neo4j_url=url,
neo4j_user=username,
neo4j_password=password,
)
export() # export graph data to tsv json file
preprocess_exported_data() # convert to tsv file for biggraph to read
convert_tsv_to_pbg() # process data files for training
train_embeddings() # train
logging.info("Done....")
except Exception as e:
logging.info(f"Error: {e}")
sys.exit(e)
if __name__ == "__main__":
embed()