Source code for module.lesson_2_facts

from dotenv import find_dotenv, load_dotenv
import avesterra as av
import orchestra.env as env
from utils import (
    create_company_entity,
    create_person_entity,
    how_to_get_facts_from_entities,
    set_company_facts,
    set_person_facts,
)


[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 people john_entity = create_person_entity.create_entity("John Smith", auth=auth) jane_entity = create_person_entity.create_entity("Jane Smith", auth=auth) # Create companies ibm_entity = create_company_entity.create_company("IBM", auth=auth) amazon_entity = create_company_entity.create_company("AMAZON", auth=auth) # Set some person facts set_person_facts.set_person_facts( person_entity=john_entity, name="John Smith", address="101 South Home", occupation="Software Engineer", company="IBM", auth=auth, ) set_person_facts.set_person_facts( person_entity=jane_entity, name="Jane Smith", address="501 North Home", occupation="Sales", company="AMAZON", auth=auth, ) # Set some company facts set_company_facts.set_company_facts( company_entity=ibm_entity, name="IBM", address="201 IBM Way", employee="John Smith", auth=auth, ) set_company_facts.set_company_facts( company_entity=amazon_entity, name="AMAZON", address="601 AMAZON Way", employee="Jane Smith", auth=auth, ) # Examples of how to get John's facts. Code can be used for any entity. how_to_get_facts_from_entities.examples_of_get_facts_by_retrieve( entity=john_entity, auth=auth ) how_to_get_facts_from_entities.examples_of_get_facts_by_brute_force( entity=john_entity, auth=auth ) print("") print("----------------Lookup these Entity IDs in Maestro or avu ----------------") print(f"John_entity: {john_entity}") print(f"Jane_entity: {jane_entity}") print(f"ibm_entity: {ibm_entity}") print(f"amazon_entity: {amazon_entity}") print("------------------------------------------------------------------") av.finalize()
if __name__ == "__main__": main()