AgentContext#
- class cegalprizm.hub.AgentContext(hub_client: cegalprizm.hub.client.HubClient, wellknown_connector_id: str, connector_filter: Optional[cegalprizm.hub.connector_filter.ConnectorFilter] = None)#
A context or handle to a Cegal Hub Agent or Agents. Connectors may be targted by providing a ConnectorFilter
Create an AgentContext from the specified parameters.
- Parameters
hub_client (HubClient) – The HubClient which makes client requests to Cegal Hub Server.
wellknown_connector_id (str) – The wellknown string that represents the type of connector. i.e cegal.hub.petrel or cegal.hub.agent etc
connector_filter – A Connector filter to target a specific instance or instances of a Connector. Defaults to None.
- launch_application(profile_name: str, cmdline_args: Optional[Sequence] = None, override_default_args: bool = False, env_var_override: Optional[str] = None, is_hub_connector: bool = False, wait_for_connect: bool = False, connect_timeout_secs: int = 120)#
Lauch an application profile with the given name from the Agent.
- Parameters
profile_name (str) – The name of the application profile
cmdline_args (Sequence, optional) – Additional cmdline arguments to those in the application profile. Defaults to None.
override_default_args (bool, optional) – Override the default profile cmdline arguments with those specified in cmdline_args. Defaults to False.
env_var_override (str, optional) – Override the environment variable name in the profile (if one was specified). Defaults to None.
is_hub_connector (bool, optional) – Inform the Agent that the application profile corresponds to Cegal Hub Connector and wait for the Connector
False. (to join accordingly. Defaults to) –
wait_for_connect (bool, optional) – True if the profile corresponds to a Cegal Hub Connector and should wait for the Connector to connect. Defaults to False.
connect_timeout_secs (int, optional) – The number of seconds to wait before assuming the Connector connect has failed. Only relevant if the application profile
120. (name corresponds to a Connector. Defaults to) –
- Raises
Exception – If there was a problem launching the application profile.
- Returns
An object representing the result of launching an application profile
- Return type
LaunchApplicationResult
- list_files(path: str, suffix: str = '', timeout: int = 60, recursive: bool = False, skip_folder_starts_with: List[str] = [], skip_folder_contains=[])#
List the files seen by the Agent on the directory path provided.
- Parameters
path (str) – The path directory to search on the Agent
suffix (str, optional) – An optional file suffix to filter search results. Defaults to “”.
timeout (int, optional) – The maximum time in seconds to wait for the results of the search. Defaults to 60.
recursive (bool, optional) – Recursively search the directory specified in the path. Defaults to False.
skip_folder_starts_with (List[str], optional) – Skip folders that start with the given string. Defaults to [].
skip_folder_contains (list, optional) – Skip folders that contain the given string. Defaults to [].
- Raises
Exception – If there was an error during the list files search.
- Returns
An object containing the files found during the list files search.
- Return type
ListFilesResult
- new_petrel_instance(project_path: Optional[str] = None, petrel_version: int = 2021, license_profile: Optional[str] = None, read_only: bool = True, wait_for_connect=True, connect_timeout_secs: int = 180)#
Launch a new instance of Petrel in the background.
- Parameters
project_path (str, optional) – The path to a .pet file to ensure Petrel opens with a project already loaded. Defaults to None.
petrel_version (int, optional) – The version of Petrel i.e 2021 or 2020 etc. Defaults to 2021.
license_profile (str, optional) – The license profile name to use If not specified it will try to choose the last selected profile name. Defaults to None.
read_only (bool, optional) – Whether the Petrel project is opened in readonly mode. Defaults to True.
wait_for_connect (bool, optional) – If True this method will not return until Petrel has started up and connected to Cegal Hub Server. Defaults to True.
connect_timeout_secs (int, optional) – The number of seconds the Agent will wait for before assuming that Petrel Connector - Hub Server connection failed.
180. (Only relevant if wait_for_connect is True. Defaults to) –
- Raises
Exception – If there was an error whilst trying to launch Petrel.
- Returns
A strong handle to the launched instance of Petrel.
- Return type
- property available#
Get the available Cegal Hub Connectors
- Raises
Exception – If there was a problem obtaining the available Cegal Hub Connectors
- Returns
An enumeration of objects for available Connectors
- Return type
Connector[]
- property connection_parameters#
Get a deep copy of the ConnectionParameters corresponding to the running Cegal Hub Server
- Returns
The ConnectionParameters object.
- Return type
- property connector_filter#
Get the ConnectorFilter associated with the context.
- Returns
The ConnectorFilter object.
- Return type