Skip to content
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
8 changes: 4 additions & 4 deletions examples/exmp046_server/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
serverpath="/path/to/working/server/script/from/orca-external-tools"
)

# Start server
status = server.start_server(exe="bash")
if status != ServerStatus.RUNNING:
if status == ServerStatus.ALREADY_RUNNING:
# Start server. Change the method to the method that should be used, e.g., AIMNet2 or UMA.
status = server.start_server(cmd_arguments="method")
if status is not ServerStatus.RUNNING:
if status is ServerStatus.ALREADY_RUNNING:
warnings.warn("Some server was already running. Using old one.")
elif status == ServerStatus.PORT_IN_USE:
warnings.warn("Port for server in use. Continue on your own risk.")
Expand Down
11 changes: 5 additions & 6 deletions src/opi/external_methods/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _wait_for_port(self, host: str, port: int, timeout: float = 10.0) -> bool:
def start_server(
self,
cmd_arguments: str | None = None,
exe: str = sys.executable,
exe: str | None = None,
Comment thread
cplett marked this conversation as resolved.
max_boot_time: float = 20.0,
) -> ServerStatus:
"""
Expand All @@ -95,7 +95,7 @@ def start_server(
----------
cmd_arguments: str | None, default: None
cmd arguments that should be passed to the server
exe: str, default: sys.executable
exe: str | None, default: None
Comment thread
cplett marked this conversation as resolved.
Executable to use for starting the server
max_boot_time: float, default: 5.0 (sec)
Maximum time in sec to wait till server is booted
Expand All @@ -111,10 +111,9 @@ def start_server(
# Start server by running a python process
# Therefore, first set up the command line call for the server script
# Build the command list:
# ["python", server_script] + -b ID:port + optional args
cmd = [exe, self.serverpath]
cmd.append("-b")
cmd.append(f"{self._host_id}:{self._port}")
# optional exe + [server_script] + -b ID:port + optional args
cmd = [exe] if exe else []
cmd += [self.serverpath, "-b", f"{self._host_id}:{self._port}"]
if cmd_arguments:
cmd.append(cmd_arguments)
# Start the server
Expand Down
Loading