Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement all queries. #115

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ connection:

osl = Optislang()
file_path = r"C:\Users\Username\my_scripts\myscript.py"
osl.run_python_file(path=script_path)
osl.run_python_file(path=file_path)
osl.save_copy("MyNewProject.opf")
osl.dispose()

Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions src/ansys/optislang/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def create_logger(self, new_logger_name: str, level: str = None) -> logging.Logg

if level is None:
level = self.log_level
level = level.upper()
new_logger.setLevel(level)

if self.file_handler:
Expand Down
281 changes: 280 additions & 1 deletion src/ansys/optislang/core/osl_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,82 @@ def get_actor_info(self, uid: str) -> Dict: # pragma: no cover
"""
pass

@abstractmethod
def get_actor_states(self, uid: str) -> Dict: # pragma: no cover
"""Get available actor states for a certain actor (only the IDs of the available states).

These can be used in conjunction with "get_actor_status_info" to obtain actor status info
for a specific state ID.

Parameters
----------
uid : str
Actor uid.
Returns
-------
Dict
Actor state.
Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_actor_status_info(self, uid: str, hid: str) -> Dict: # pragma: no cover
"""Get status info of actor defined by uid.

Parameters
----------
uid : str
Actor uid.
Returns
-------
Dict
Actor status info.
Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_actor_supports(self, uid: str, feature_name: str) -> bool: # pragma: no cover
"""Get supported features of actor defined by uid.

Parameters
----------
uid : str
Actor uid.
feature_name : str
Name of the feature.

Returns
-------
bool
Whether the given feature is supported.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_actor_properties(self, uid: str) -> Dict: # pragma: no cover
"""Get properties of actor defined by uid.
Expand All @@ -114,14 +190,137 @@ def get_actor_properties(self, uid: str) -> Dict: # pragma: no cover
"""
pass

@abstractmethod
def get_full_project_status_info(self) -> Dict: # pragma: no cover
"""Get full project status info.

Returns
-------
Dict
Full project status info.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_full_project_tree(self) -> Dict: # pragma: no cover
"""Get full project tree.

Returns
-------
Dict
Dictionary of full project tree without properties.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_full_project_tree_with_properties(self) -> Dict: # pragma: no cover
"""Get full project tree with properties..

Returns
-------
Dict
Properties of actor defined by uid.
Dictionary of full project tree with properties.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_hpc_licensing_forwarded_environment(self, uid: str) -> Dict: # pragma: no cover
"""Get hpc licensing forwarded environment for certain actor.

Parameters
----------
uid : str
Actor uid.

Returns
-------
Dict
Dictionary with hpc licensing forwarded environment for certain actor.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_input_slot_value(self, uid: str, hid: str, slot_name: str) -> Dict: # pragma: no cover
"""Get input slot value of actor defined by uid.

Parameters
----------
uid : str
Actor uid.
hid: str
Hid entry.
slot_name: str
Slot name.

Returns
-------
Dict
Input slot value of the actor.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_output_slot_value(self, uid: str, hid: str, slot_name: str) -> Dict: # pragma: no cover
"""Get output slot value of actor defined by uid.

Parameters
----------
uid : str
Actor uid.
hid: str
Hid entry.
slot_name: str
Slot name.

Returns
-------
Dict
Output slot value of the actor.

Raises
------
Expand Down Expand Up @@ -279,6 +478,86 @@ def get_project_status(self) -> str: # pragma: no cover
"""
pass

@abstractmethod
def get_project_tree_systems(self) -> Dict: # pragma: no cover
"""Get project tree systems without properties.

Returns
-------
Dict
Dictionary of project tree systems without properties.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_project_tree_systems_with_properties(self) -> Dict: # pragma: no cover
"""Get project tree systems with properties.

Returns
-------
Dict
Dictionary of project tree systems with properties.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_server_is_alive(self) -> bool: # pragma: no cover
"""Get info whether the server is alive.

Returns
-------
bool
Whether the server is alive.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_systems_status_info(self) -> Dict: # pragma: no cover
"""Get project status info, including systems only.

Returns
-------
Dict
Project status info including systems only.

Raises
------
OslCommunicationError
Raised when an error occurs while communicating with server.
OslCommandError
Raised when the command or query fails.
TimeoutError
Raised when the timeout float value expires.
"""
pass

@abstractmethod
def get_timeout(self) -> Union[float, None]: # pragma: no cover
"""Get current timeout value for execution of commands.
Expand Down
Loading