Skip to content

Commit

Permalink
feat: VM host URL
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Nov 12, 2024
1 parent ef84f00 commit c74a391
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libertai_client/commands/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from libertai_client.config import config
from libertai_client.interfaces.agent import DockerCommand, UpdateAgentResponse
from libertai_client.utils.agent import parse_agent_config_env
from libertai_client.utils.agent import parse_agent_config_env, get_vm_host_url
from libertai_client.utils.rich import TaskOfTotalColumn, TEXT_PROGRESS_FORMAT
from libertai_client.utils.system import get_full_path

Expand Down Expand Up @@ -111,4 +111,4 @@ def deploy(path: Annotated[str, typer.Option(help="Path to the root of your repo

if agent_result is not None:
agent_data = UpdateAgentResponse(**json.loads(agent_result))
print(f"Agent successfully deployed on https://aleph.sh/vm/{agent_data.vm_hash}")
print(f"Agent successfully deployed on {get_vm_host_url(agent_data.vm_hash)}")
7 changes: 7 additions & 0 deletions libertai_client/utils/agent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from base64 import b32encode, b16decode

from libertai_client.interfaces.agent import AgentConfig


Expand All @@ -10,3 +12,8 @@ def parse_agent_config_env(env: dict[str, str | None]) -> AgentConfig:
f"Missing {'LIBERTAI_AGENT_ID' if agent_id is None else 'LIBERTAI_AGENT_SECRET'} variable in your project's .env.libertai")

return AgentConfig(id=agent_id, secret=agent_secret)

def get_vm_host_url(item_hash: str) -> str:
# From aleph-client
hash_base32 = b32encode(b16decode(item_hash.upper())).strip(b"=").lower().decode()
return f"https://{hash_base32}.aleph.sh"

0 comments on commit c74a391

Please sign in to comment.