Appearance
module hub.agent
class AgentContext
A context or handle to a Cegal Hub Agent or Agents. Connectors may be targeted by providing a ConnectorFilter
method __init__
python
__init__(
hub_client: HubClient,
wellknown_connector_id: str,
connector_filter: ConnectorFilter = None
)Create an AgentContext from the specified parameters.
Args:
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 etcconnector_filter(ConnectorFilter, optional): A Connector filter to target a specific instance or instances of a Connector. Defaults to None.
property available
Get the available Cegal Hub Connectors
Raises:
Exception: If there was a problem obtaining the available Cegal Hub Connectors
Returns:
Connector[]: An enumeration of objects for available Connectors
property connection_parameters
Get a deep copy of the ConnectionParameters corresponding to the running Cegal Hub Server
Returns:
ConnectionParameters: The ConnectionParameters object.
property connector_filter
Get the ConnectorFilter associated with the context.
Returns:
ConnectorFilter: The ConnectorFilter object.
method download_file
python
download_file(src_path: str, dest_path: str, overwrite: bool = False)Download a file from a Cegal Hub Agent (if permitted by the Agent).
Args:
src_path(str): the src path of the file on the Agentdest_path(str): the destination path to save the file locally.overwrite(bool, optional): Whether or not to permit file overwrite if the file exists locally. Defaults to False.
Raises:
Exception: If there was an issue downloading the file.
method launch_application
python
launch_application(
profile_name: str,
cmdline_args: Sequence = None,
override_default_args: bool = False,
env_var_override: 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.
Args:
profile_name(str): The name of the application profilecmdline_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 to join accordingly. Defaults to False.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 name corresponds to a Connector. Defaults to 120.
Raises:
Exception: If there was a problem launching the application profile.
Returns:
LaunchApplicationResult: An object representing the result of launching an application profile
method list_files
python
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.
Args:
path(str): The path directory to search on the Agentsuffix(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:
ListFilesResult: An object containing the files found during the list files search.
method new_petrel_instance
python
new_petrel_instance(
project_path: str = None,
petrel_version: int = 2022,
license_profile: str = None,
read_only: bool = True,
wait_for_connect: bool = True,
connect_timeout_secs: int = 180
)Launch a new instance of Petrel in the background.
Args:
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 2022 etc. Defaults to 2022.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. Only relevant if wait_for_connect is True. Defaults to 180.
Raises:
Exception: If there was an error whilst trying to launch Petrel.
Returns:
PetrelContext: A strong handle to the launched instance of Petrel.
method upload_file
python
upload_file(
src_path: str,
rel_dest_path: str = None,
abs_dest_path: str = None,
overwrite: bool = False
)upload a file to a Cegal Hub Agent if the Cegal Hub Agent permits file upload. A file can be uploaded by only specifying the src file and the file will be uploaded to the default directory. The second alternative is to specify a relative destination path in addition to the src file path which will be the relative path from the default Agent upload directory. The last alternative is to specify an absolute path for upload on the Agent (again the Agent must support this).
Args:
src_path(str): the src path of the file on the clientrel_dest_path(str): the relative path to the default file upload shared path on the Agent (if permitted by the Agent)abs_dest_path(str): the absolute path to upload to on the Agent (if permitted by the Agent)overwrite(bool, optional): whether or not you to overwrite the file if already existing on the Agent (if permitted by the Agent). Defaults to False.
Raises:
Exception: if there is an issue uploading the file
Returns:
UploadFileResult: the empty upload result message if successful
This file was automatically generated via lazydocs.