Skip to content

Commit b740d3f

Browse files
committed
place agent release details from template
1 parent 99b560b commit b740d3f

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

operate/services/agent_runner.py

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# -------------------------------------------------------------
2020
"""Source dode to download and run agent from the repos."""
2121
import hashlib
22+
import json
2223
import os
2324
import platform
2425
import shutil
@@ -40,6 +41,7 @@ class AgentRelease:
4041
owner: str
4142
repo: str
4243
release: str
44+
is_aea: bool
4345

4446
@property
4547
def release_url(self) -> str:
@@ -62,25 +64,10 @@ def get_url_and_hash(self, asset_name: str) -> tuple[str, str]:
6264
return file_url, file_hash
6365

6466

65-
# list of agents releases supported
66-
AGENTS_SUPPORTED = {
67-
"valory/trader": AgentRelease(
68-
owner="valory-xyz", repo="trader", release="v0.0.101"
69-
),
70-
"valory/optimus": AgentRelease(
71-
owner="valory-xyz", repo="optimus", release="v0.0.103"
72-
),
73-
"dvilela/memeooorr": AgentRelease(
74-
owner="valory-xyz", repo="meme-ooorr", release="v0.0.101"
75-
),
76-
}
77-
78-
7967
class AgentRunnerManager:
8068
"""Agent Runner Manager."""
8169

8270
logger = setup_logger(name="operate.agent_runner_manager")
83-
AGENTS = AGENTS_SUPPORTED
8471

8572
@staticmethod
8673
def get_agent_runner_executable_name() -> str:
@@ -131,14 +118,19 @@ def download_file(cls, url: str, save_path: Path) -> None:
131118
raise
132119

133120
@classmethod
134-
def get_agent_release_by_public_id(cls, agent_public_id_str: str) -> AgentRelease:
121+
def get_agent_release_from_service_dir(cls, service_dir: Path) -> AgentRelease:
135122
"""Get agent release object according to public id."""
136-
agent_author, agent_name = cls.parse_agent(public_id_str=agent_public_id_str)
137-
138-
agent_name = f"{agent_author}/{agent_name}"
139-
agent_release = cls.AGENTS.get(agent_name, None)
140-
if agent_release is None:
141-
raise ValueError(f"{agent_name} is not supported!")
123+
service_config_file = service_dir / "config.json"
124+
service_config = json.loads(service_config_file.read_text())
125+
if "agent_release" not in service_config:
126+
raise ValueError(f"Agent release details are not found in {service_config}")
127+
agent_release_data = service_config["agent_release"]
128+
agent_release = AgentRelease(
129+
is_aea=agent_release_data["is_aea"],
130+
owner=agent_release_data["repo_owner"],
131+
repo=agent_release_data["repo_name"],
132+
release=agent_release_data["version"],
133+
)
142134
return agent_release
143135

144136
@staticmethod
@@ -187,13 +179,11 @@ def update_agent_runner(
187179
raise
188180

189181
@classmethod
190-
def get_agent_runner_path(cls, service_dir: Path, agent_public_id_str: str) -> str:
182+
def get_agent_runner_path(cls, service_dir: Path) -> str:
191183
"""Get path to the agent runner bin palced."""
192184
agent_runner_name = cls.get_agent_runner_executable_name()
193185
agent_runner_path: Path = service_dir / agent_runner_name
194-
agent_release = cls.get_agent_release_by_public_id(
195-
agent_public_id_str=agent_public_id_str
196-
)
186+
agent_release = cls.get_agent_release_from_service_dir(service_dir=service_dir)
197187

198188
cls.update_agent_runner(
199189
target_path=agent_runner_path,
@@ -203,8 +193,8 @@ def get_agent_runner_path(cls, service_dir: Path, agent_public_id_str: str) -> s
203193
return str(agent_runner_path)
204194

205195

206-
def get_agent_runner_path(service_dir: Path, agent_public_id_str: str) -> str:
196+
def get_agent_runner_path(service_dir: Path) -> str:
207197
"""Get path to the agent runner bin placed."""
208198
return AgentRunnerManager.get_agent_runner_path(
209-
service_dir=service_dir, agent_public_id_str=agent_public_id_str
199+
service_dir=service_dir,
210200
)

operate/services/deployment_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _agent_runner_bin(self) -> str:
306306
service_dir = self._work_directory.parent
307307

308308
agent_runner_bin = get_agent_runner_path(
309-
service_dir=service_dir, agent_public_id_str=agent_publicid_str
309+
service_dir=service_dir
310310
)
311311
return str(agent_runner_bin)
312312

operate/services/service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ class Service(LocalResource):
724724
chain_configs: ChainConfigs
725725
description: str
726726
env_variables: EnvVariables
727+
agent_release: t.Dict
727728

728729
path: Path
729730
package_path: Path
@@ -850,6 +851,7 @@ def new( # pylint: disable=too-many-locals
850851
path=package_absolute_path.parent,
851852
package_path=Path(package_absolute_path.name),
852853
env_variables=service_template["env_variables"],
854+
agent_release=service_template["agent_release"],
853855
)
854856
service.store()
855857
return service

0 commit comments

Comments
 (0)