Skip to content

Commit 18919a0

Browse files
Golem infrastructure properties in CreateTaskReply (#56)
1 parent 3fbada1 commit 18919a0

File tree

9 files changed

+138
-66
lines changed

9 files changed

+138
-66
lines changed

golem_task_api/proto/golem_task_api.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ service ProviderApp {
2222
rpc Shutdown (ShutdownRequest) returns (ShutdownReply) {}
2323
}
2424

25+
message Infrastructure {
26+
float min_memory_mib = 1;
27+
}
2528

2629
message CreateTaskRequest {
2730
string task_id = 1;
@@ -32,6 +35,7 @@ message CreateTaskRequest {
3235
message CreateTaskReply {
3336
string env_id = 1;
3437
string prerequisites_json = 2;
38+
Infrastructure inf_requirements = 3;
3539
}
3640

3741
message NextSubtaskRequest {

python/golem_task_api/client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
ProviderAppStub,
3838
RequestorAppStub,
3939
)
40-
from golem_task_api.structs import Subtask, Task
40+
from golem_task_api.structs import Subtask, Task, Infrastructure
4141

4242
CONNECTION_TIMEOUT = 5.0 # seconds
4343

@@ -190,10 +190,16 @@ async def create_task(
190190
request.max_subtasks_count = max_subtasks_count
191191
request.task_params_json = json.dumps(task_params)
192192
reply = await self._golem_app.CreateTask(request)
193-
return Task(
193+
194+
inf_requirements = Infrastructure()
195+
inf_requirements.min_memory_mib = reply.inf_requirements.min_memory_mib
196+
197+
task = Task(
194198
env_id=reply.env_id,
195-
prerequisites=json.loads(reply.prerequisites_json)
196-
)
199+
prerequisites=json.loads(reply.prerequisites_json),
200+
inf_requirements=inf_requirements)
201+
202+
return task
197203

198204
async def next_subtask(
199205
self,

python/golem_task_api/envs/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
from golem_task_api.envs.constants import DOCKER_CPU_ENV_ID, DOCKER_GPU_ENV_ID
44
from golem_task_api.proto.envs_pb2 import DockerPrerequisites
5-
from golem_task_api.structs import Task
5+
from golem_task_api.structs import Task, Infrastructure
66

77

88
def _create_docker_task(
99
env_id: str,
1010
image: str,
11-
tag: str
11+
tag: str,
12+
inf: Infrastructure,
1213
) -> Task:
1314
prerequisites = DockerPrerequisites()
1415
prerequisites.image = image
@@ -19,13 +20,13 @@ def _create_docker_task(
1920

2021
return Task(
2122
env_id=env_id,
22-
prerequisites=prerequisites_dict
23-
)
23+
prerequisites=prerequisites_dict,
24+
inf_requirements=inf)
2425

2526

26-
def create_docker_cpu_task(image: str, tag: str) -> Task:
27-
return _create_docker_task(DOCKER_CPU_ENV_ID, image, tag)
27+
def create_docker_cpu_task(image: str, tag: str, inf: Infrastructure) -> Task:
28+
return _create_docker_task(DOCKER_CPU_ENV_ID, image, tag, inf)
2829

2930

30-
def create_docker_gpu_task(image: str, tag: str) -> Task:
31-
return _create_docker_task(DOCKER_GPU_ENV_ID, image, tag)
31+
def create_docker_gpu_task(image: str, tag: str, inf: Infrastructure) -> Task:
32+
return _create_docker_task(DOCKER_GPU_ENV_ID, image, tag, inf)

python/golem_task_api/messages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
AbortTaskReply,
66
CreateTaskRequest,
77
CreateTaskReply,
8+
Infrastructure,
89
NextSubtaskRequest,
910
NextSubtaskReply,
1011
SubtaskReply,

0 commit comments

Comments
 (0)