Skip to content

fix for run agent in dev mode #118

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

Merged
merged 2 commits into from
Jun 18, 2025
Merged
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
23 changes: 16 additions & 7 deletions operate/services/deployment_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class BaseDeploymentRunner(AbstractDeploymentRunner, metaclass=ABCMeta):
def _run_aea_command(self, *args: str, cwd: Path) -> Any:
"""Run aea command."""
cmd = " ".join(args)
print("Runnin aea command: ", cmd, " at ", str(cwd))
print("Running aea command: ", cmd, " at ", str(cwd))
p = multiprocessing.Process(
target=self.__class__._call_aea_command, # pylint: disable=protected-access
args=(cwd, args),
Expand Down Expand Up @@ -512,6 +512,9 @@ def _start_agent(self) -> None:
env = json.loads((working_dir / "agent.json").read_text(encoding="utf-8"))
env["PYTHONUTF8"] = "1"
env["PYTHONIOENCODING"] = "utf8"
agent_runner_log_file = (
Path(self._work_directory).parent.parent.parent / "agent_runner.log"
).open("a+")

process = subprocess.Popen( # pylint: disable=consider-using-with # nosec
args=[
Expand All @@ -521,6 +524,8 @@ def _start_agent(self) -> None:
], # TODO: Patch for Windows failing hash
cwd=str(working_dir / "agent"),
env={**os.environ, **env},
stdout=agent_runner_log_file,
stderr=agent_runner_log_file,
creationflags=(
0x00000008 if platform.system() == "Windows" else 0
), # Detach process from the main process
Expand Down Expand Up @@ -588,15 +593,19 @@ def _setup_venv(self) -> None:

def _setup_agent(self) -> None:
"""Prepare agent."""
multiprocessing.set_start_method("spawn")
self._setup_venv()
super()._setup_agent()
# Install agent dependencies
self._run_aea_command(
"-v",
"debug",
"install",
"--timeout",
"600",
self._run_cmd(
args=[
self._agent_runner_bin,
"-v",
"debug",
"install",
"--timeout",
"600",
],
cwd=self._work_directory / "agent",
)

Expand Down
5 changes: 5 additions & 0 deletions operate/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,18 @@ def generate_config_tendermint(self) -> "HostDeploymentGenerator":
tendermint_executable = str(
shutil.which("tendermint"),
)
env = {}
env["PATH"] = os.path.dirname(sys.executable) + ":" + os.environ["PATH"]
tendermint_executable = str(
Path(os.path.dirname(sys.executable)) / "tendermint"
)
tendermint_executable = "tendermint"
if platform.system() == "Windows":
env["PATH"] = os.path.dirname(sys.executable) + ";" + os.environ["PATH"]
tendermint_executable = str(
Path(os.path.dirname(sys.executable)) / "tendermint.exe"
)
tendermint_executable = "tendermint.exe"
subprocess.run( # pylint: disable=subprocess-run-check # nosec
args=[
tendermint_executable,
Expand Down