Skip to content
This repository was archived by the owner on Mar 30, 2023. It is now read-only.

Commit 4b56419

Browse files
author
Jason Costello
committed
[WIP] Adding .refresh() method, tests + handling for ensemble parsing
1 parent b2c7425 commit 4b56419

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

hypervector/resources/core/definition.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def to_response(self):
3737
def from_get(cls, response):
3838
return cls.from_response(response.json())
3939

40+
def refresh(self):
41+
definition = self.get(self.definition_uuid)
42+
self.__dict__.update(definition.__dict__)
43+
4044
@classmethod
4145
def list(cls):
4246
endpoint = f"{hypervector.API_BASE}/definitions"
@@ -59,6 +63,9 @@ def _parse_definition_from_json_file(definition_json_file):
5963

6064

6165
def _parse_ensembles(ensembles):
66+
if not ensembles or len(ensembles) == 0:
67+
return None
68+
6269
parsed_ensembles = []
6370
for ensemble in ensembles:
6471
parsed_ensemble = Ensemble.from_response(ensemble)

tests/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def mocked_resources(mocked_responses):
3737
"definition_uuid": str(uuid.uuid4()),
3838
"definition_name": "Mocked definition",
3939
"project_uuid": project.project_uuid,
40-
"added": "Mon, 1 Jan 1970 00:00:00 GMT"
40+
"added": "Mon, 1 Jan 1970 00:00:00 GMT",
41+
"ensembles": []
4142
}
4243
)
4344

0 commit comments

Comments
 (0)