-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathray_test.py
42 lines (29 loc) · 837 Bytes
/
ray_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations
import os
from typing import Any
import ray
from ray.actor import ActorHandle
from baseGame import EvalGame, RunGame
from runnerConfiguration import RunnerConfig
ray.init();
original = EvalGame(RunGame);
ref = ray.put(original);
@ray.remote
class IdQueue():
def __init__(self):
self.ids = dict[Any,int]();
self.max_id=-1;
def get_id(self,key):
if key not in self.ids:
self.max_id += 1;
self.ids[key] = self.max_id;
return self.max_id;
return self.ids[key];
@ray.remote
def task_func(inc:int,queue,*args,**kwargs):
id = ray.get(queue.get_id.remote(os.getpid()));
print(id);
a = IdQueue.remote();
# normal = Normal(17);
tasks = [task_func.remote(1,a) for i in range(15)];
print(ray.get(tasks));