Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Fixed: requestor prerequisites never installed in RequestedTaskManager #4870

Merged
merged 2 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 11 additions & 3 deletions golem/task/requestedtaskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,15 +661,15 @@ async def _get_app_client(
) -> RequestorAppClient:
if app_id not in self._app_clients:
logger.info('Creating app_client for app_id=%r', app_id)
service = self._get_task_api_service(app_id)
service = await self._get_task_api_service(app_id)
logger.info('Got service for app=%r, service=%r', app_id, service)
self._app_clients[app_id] = await RequestorAppClient.create(service)
logger.info(
'app_client created for app_id=%r, clients=%r',
app_id, self._app_clients[app_id])
return self._app_clients[app_id]

def _get_task_api_service(
async def _get_task_api_service(
self,
app_id: str,
) -> EnvironmentTaskApiService:
Expand All @@ -682,15 +682,23 @@ def _get_task_api_service(
if not self._app_manager.enabled(app_id):
raise RuntimeError(
f"Error connecting to app, app not enabled. app={app_id}")

app = self._app_manager.app(app_id)
env_id = app.requestor_env
if not self._env_manager.enabled(env_id):
raise RuntimeError(
"Error connecting to app, environment not enabled."
f" env={env_id}, app={app_id}")

env = self._env_manager.environment(env_id)
payload_builder = self._env_manager.payload_builder(env_id)
prereq = env.parse_prerequisites(app.requestor_prereq)
loop = asyncio.get_event_loop()
if not await env.install_prerequisites(prereq).asFuture(loop):
raise RuntimeError(
f"Cannot install prerequisites for running app. "
f"env={env_id}, app={app_id}")

payload_builder = self._env_manager.payload_builder(env_id)
shared_dir = self._app_dir(app_id)

return EnvironmentTaskApiService(
Expand Down
4 changes: 4 additions & 0 deletions tests/golem/task/test_requestedtaskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from golem_task_api.structs import Subtask
from mock import ANY, Mock
import pytest
from twisted.internet import defer

from golem.apps.manager import AppManager
from golem.model import default_now, RequestedTask, RequestedSubtask
Expand Down Expand Up @@ -63,6 +64,9 @@ def setup_method(self, tmpdir, monkeypatch):
root_path=self.rtm_path
)

self.env_manager.environment().install_prerequisites.return_value = \
defer.succeed(True)

monkeypatch.setattr(
requestedtaskmanager,
'_build_legacy_task_state',
Expand Down