@@ -31,7 +31,7 @@ def from_response(cls, dictionary):
31
31
ensemble_uuid = dictionary ['ensemble_uuid' ],
32
32
definition_uuid = dictionary ['definition_uuid' ],
33
33
size = dictionary ['size' ],
34
- benchmarks = None
34
+ benchmarks = _parse_benchmarks ( dictionary [ 'benchmarks' ])
35
35
)
36
36
37
37
def to_response (self ):
@@ -44,16 +44,7 @@ def to_response(self):
44
44
45
45
@classmethod
46
46
def from_get (cls , response ):
47
- # Return hypervectors on get
48
- dictionary = json .loads (response .content )
49
- ensemble_result = EnsembleResult (
50
- ensemble_uuid = dictionary ['ensemble_uuid' ],
51
- hypervectors = dictionary ['hypervectors' ],
52
- size = dictionary ['size' ],
53
- benchmarks = dictionary ['benchmarks' ]
54
- )
55
-
56
- return ensemble_result
47
+ return cls .from_response (response .json ())
57
48
58
49
@classmethod
59
50
def list (cls , definition ):
@@ -69,6 +60,11 @@ def new(cls, definition_uuid, size):
69
60
response = requests .post (endpoint , json = data , headers = cls .get_headers ()).json ()
70
61
return cls .from_response (response )
71
62
63
+ def hypervectors (self ):
64
+ endpoint = f"{ hypervector .API_BASE } /ensemble/{ self .ensemble_uuid } /data"
65
+ response = requests .get (endpoint , headers = self .get_headers ()).json ()
66
+ return response ['hypervectors' ]
67
+
72
68
73
69
class EnsembleResult :
74
70
@@ -80,7 +76,7 @@ def __init__(self, ensemble_uuid, hypervectors, size, benchmarks):
80
76
81
77
82
78
def _parse_benchmarks (benchmarks ):
83
- if not benchmarks :
79
+ if not benchmarks or len ( benchmarks ) == 0 :
84
80
return None
85
81
86
82
parsed_benchmarks = []
0 commit comments