Cegal Hub - run multiple Petrel instances demo#

Ensure the Cegal Hub Petrel plugin is installed. This demo will run multiple instances of Petrel in the background.

Launch Cegal Hub in local mode from the terminal (Windows Terminal is recommended).

image-3.png

Create a Cegal Hub object for use on the local machine

[ ]:
from cegalprizm.hub import Hub, ConnectorFilter
[ ]:
hub = Hub()
hub

Query the Cegal Hub server and check available Cegal Hub Connectors

[ ]:
hub.print_query_server()
[ ]:
hub.print_query_connectors(show_meta=False, show_labels=False, show_payloads=False)

Obtain a handle to the Cegal Hub Agent on the local machine

[ ]:
agent = hub.default_agent_ctx()

Get a list of Petrel projects on a disk location using the Cegal Hub Agent

[ ]:
results = agent.list_files(path=r"C:\data", suffix=".pet", recursive=True)
filesList = results.paths
filesList

Launch several instances of Petrel from the Cegal Hub Agent

[ ]:
for i in range(1):
    agent.new_petrel_instance(petrel_version=2021)

Query Cegal Hub Server and get a strong handle (petrel context) to each instance of Petrel

[ ]:
connectors = hub.query_connectors(wellknown_identifier='cegal.hub.petrel')
petrels = []
for c in connectors:
    cf = ConnectorFilter(target_connector_id=c.connector_id)
    petrel_ctx = hub.new_petrel_ctx(connector_filter=cf)
    petrels.append(petrel_ctx)
petrels

Load as many projects from the list as you have instances of Petrel

[ ]:
for index, petrel in enumerate(petrels):
    petrel.load_project(path=filesList[i])
    print(filesList[i])

Print the project Info for each Petrel instance

[ ]:
for index, petrel in enumerate(petrels):
    info = petrel.project_info()
    print(info)

Kill the running Petrel instance

[ ]:
for petrel in petrels:
    petrel.poison_petrel()