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

Add NNsight version to remote request body #336

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions src/nnsight/intervention/backends/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import torch
from tqdm.auto import tqdm

from ... import __IPYTHON__, CONFIG, remote_logger
from ... import __IPYTHON__, __version__, CONFIG, remote_logger
from ...schema.request import RequestModel, StreamValueModel
from ...schema.response import ResponseModel
from ...schema.result import RESULT, ResultModel
Expand Down Expand Up @@ -54,6 +54,7 @@ def __init__(
self.host = host or CONFIG.API.HOST
self.address = f"http{'s' if self.ssl else ''}://{self.host}"
self.ws_address = f"ws{'s' if CONFIG.API.SSL else ''}://{self.host}"
self.version = __version__

def request(self, graph: Graph) -> Tuple[bytes, Dict[str, str]]:

Expand All @@ -65,6 +66,7 @@ def request(self, graph: Graph) -> Tuple[bytes, Dict[str, str]]:
"zlib": str(self.zlib),
"ndif-api-key": self.api_key,
"sent-timestamp": str(time.time()),
"version": self.version,
}

return data, headers
Expand Down Expand Up @@ -197,7 +199,10 @@ def submit_request(
return response

else:
msg = response.reason
try:
msg = response.json()["detail"]
except:
msg = response.reason
raise ConnectionError(msg)

def get_response(self) -> Optional[RESULT]:
Expand Down