forked from VSharp-team/VSharp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from emnigma/server_restart
Update mlSearcher
- Loading branch information
Showing
29 changed files
with
960 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 43 additions & 5 deletions
48
VSharp.ML.AIAgent/connection/broker_conn/socket_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,53 @@ | ||
from contextlib import contextmanager | ||
import logging | ||
import os | ||
import time | ||
from contextlib import contextmanager, suppress | ||
|
||
import websocket | ||
from .requests import aquire_ws, return_ws | ||
|
||
from config import GameServerConnectorConfig | ||
from connection.broker_conn.classes import ServerInstanceInfo | ||
|
||
from .requests import acquire_instance, return_instance | ||
|
||
|
||
def wait_for_connection(server_instance: ServerInstanceInfo): | ||
ws = websocket.WebSocket() | ||
|
||
retries_left = GameServerConnectorConfig.WAIT_FOR_SOCKET_RECONNECTION_MAX_RETRIES | ||
|
||
while retries_left: | ||
with suppress( | ||
ConnectionRefusedError, | ||
ConnectionResetError, | ||
websocket.WebSocketTimeoutException, | ||
): | ||
ws.settimeout(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT_SEC) | ||
ws.connect( | ||
server_instance.ws_url, | ||
skip_utf8_validation=GameServerConnectorConfig.SKIP_UTF_VALIDATION, | ||
) | ||
if ws.connected: | ||
return ws | ||
time.sleep(GameServerConnectorConfig.CREATE_CONNECTION_TIMEOUT_SEC) | ||
logging.info( | ||
f"Try connecting to {server_instance.ws_url}, {retries_left} attempts left; {server_instance}" | ||
) | ||
retries_left -= 1 | ||
raise RuntimeError( | ||
f"Retries exsausted wnen trying to connect to {server_instance.ws_url}: {retries_left} left" | ||
) | ||
|
||
|
||
@contextmanager | ||
def game_server_socket_manager(): | ||
socket_url = aquire_ws() | ||
socket = websocket.create_connection(socket_url, skip_utf8_validation=True) | ||
server_instance = acquire_instance() | ||
|
||
socket = wait_for_connection(server_instance) | ||
|
||
try: | ||
socket.settimeout(GameServerConnectorConfig.RESPONCE_TIMEOUT_SEC) | ||
yield socket | ||
finally: | ||
socket.close() | ||
return_ws(socket_url) | ||
return_instance(server_instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
conda install numpy pandas tabulate | ||
conda install -c pytorch pytorch=1.13.1 torchvision=0.14.1 torchaudio=0.13.1 | ||
python3 -m pip install --force-reinstall -v "torch-scatter==2.1.0" "torch-geometric==2.2.0" "torch-sparse==0.6.16" | ||
python3 -m pip install func_timeout | ||
conda install -c conda-forge dataclasses-json websocket-client pre_commit aiohttp cchardet pygad httplib2 onnx onnxruntime | ||
pre-commit install |
Oops, something went wrong.