import avesterra as av
from dotenv import load_dotenv, find_dotenv
import orchestra.env as env
from utils import (
create_company_entity,
create_person_entity,
set_company_facts,
set_person_facts,
set_relationships,
)
[docs]
def main():
# Initialize connection to AvesTerra server at IP Address
load_dotenv(find_dotenv())
host = env.get_or_raise("AVESTERRA_HOST")
cert_dir = env.get_or_raise("AVESTERRA_CERTIFICATE_DIR_PATH")
auth = env.get_or_raise("AVESTERRA_AUTH", av.AvAuthorization)
av.initialize(server=host, directory=cert_dir, socket_count=2)
# Create the person
person_entity = create_person_entity.create_entity("John Smith", auth=auth)
# Create the company
company_entity = create_company_entity.create_company("IBM", auth=auth)
# Set some facts
set_person_facts.set_person_facts(
person_entity=person_entity,
name="John Smith",
address="101 South Home",
occupation="Software Engineer",
company="IBM",
auth=auth,
)
# Set some facts
set_company_facts.set_company_facts(
company_entity=company_entity,
name="IBM",
address="201 IBM Way",
employee="John Smith",
auth=auth,
)
# Create a bidirectional relationship between Person & Company entities
set_relationships.set_relationships(
person_entity=person_entity, company_entity=company_entity, auth=auth
)
print(f"person_entity: {person_entity}")
print(f"company_entity: {company_entity}")
av.finalize()
if __name__ == "__main__":
main()