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

hashkey without port to support port forwarding #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 12 additions & 5 deletions agentlace/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def __obs_parser_cb(payload: dict) -> dict:
elif payload["type"] == "act" and act_callback is not None:
return act_callback(payload["key"], payload["payload"])
elif payload["type"] == "hash":
config_json = json.dumps(asdict(config), separators=(',', ':'))
return {"success": True, "payload": config_json}
return {"success": True, "payload": config}
return {"success": False, "message": "Invalid payload"}

self.config = config
Expand Down Expand Up @@ -145,11 +144,19 @@ def __init__(self,
raise Exception("Failed to connect to action server")

# Check hash of server config to ensure compatibility
config_json = json.dumps(asdict(config), separators=(',', ':'))
if compute_hash(config_json) != compute_hash(res["payload"]):
def _get_hash_from_config(config: ActionConfig) -> str:
_dict = asdict(config)
# remove port for hash comparison since it can be rerouted
_dict.pop("port_number")
return compute_hash(json.dumps(_dict, separators=(',', ':')))

# Check hash of server config to ensure compatibility
if _get_hash_from_config(config) != _get_hash_from_config(res["payload"]):
raise Exception(
f"Incompatible config with hash with server. "
"Please check the config of the server and client")
"Please check the config of the server and client. "
"Or ensure agentlace commit/version is the same"
)

# use hash for faster lookup. config uses list because it is
# used for hash md5 comparison
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='agentlace',
version='0.1.4',
version='0.1.5',
packages=find_packages(),
description='library to enable distributed agent for ml training and inference',
url='https://github.com/youliangtan/agentlace',
Expand Down