Skip to content

Commit 73d730d

Browse files
Merge pull request #33 from Exabyte-io/chore/SOF-7012
chore: add 'properties' and 'metaproperties' endpoints
2 parents 6f761ab + 25c4bc8 commit 73d730d

File tree

15 files changed

+51
-34
lines changed

15 files changed

+51
-34
lines changed

.github/workflows/cicd.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
runs-on: ubuntu-20.04
3737
strategy:
3838
matrix:
39-
python-version: [3.6, 3.7, 3.8]
39+
python-version: [3.8.6]
4040

4141
steps:
4242
- name: Checkout this repository
@@ -58,7 +58,6 @@ jobs:
5858
unit-test-directory: tests/unit
5959

6060
- name: Run integration tests
61-
if: matrix.python-version == '3.8'
6261
uses: ./actions/py/test
6362
with:
6463
integration-test-directory: tests/integration

exabyte_api_client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from exabyte_api_client.endpoints.login import LoginEndpoint
1111
from exabyte_api_client.endpoints.logout import LogoutEndpoint
1212
from exabyte_api_client.endpoints.materials import MaterialEndpoints
13+
from exabyte_api_client.endpoints.metaproperties import MetaPropertiesEndpoints
1314
from exabyte_api_client.endpoints.projects import ProjectEndpoints
14-
from exabyte_api_client.endpoints.raw_properties import RawPropertiesEndpoints
15-
from exabyte_api_client.endpoints.refined_properties import RefinedPropertiesEndpoints
15+
from exabyte_api_client.endpoints.properties import PropertiesEndpoints
1616
from exabyte_api_client.endpoints.workflows import WorkflowEndpoints

exabyte_api_client/endpoints/refined_properties.py renamed to exabyte_api_client/endpoints/metaproperties.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from .enums import DEFAULT_API_VERSION, SECURE
2-
from .raw_properties import BasePropertiesEndpoints
2+
from .properties import BasePropertiesEndpoints
33

44

5-
class RefinedPropertiesEndpoints(BasePropertiesEndpoints):
5+
class MetaPropertiesEndpoints(BasePropertiesEndpoints):
66
"""
7-
RefinedProperties endpoints.
7+
MetaProperties endpoints.
88
99
Args:
1010
host (str): Exabyte API hostname.
@@ -24,8 +24,8 @@ class RefinedPropertiesEndpoints(BasePropertiesEndpoints):
2424
"""
2525

2626
def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs):
27-
super(RefinedPropertiesEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
28-
self.name = "refined-properties"
27+
super(MetaPropertiesEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
28+
self.name = "metaproperties"
2929

3030
def delete(self, id_):
3131
raise NotImplementedError

exabyte_api_client/endpoints/raw_properties.py renamed to exabyte_api_client/endpoints/properties.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def get_direct_band_gap(self, job_id, unit_flowchart_id):
2121
return self.get_band_gap_by_type(job_id, unit_flowchart_id, "direct")
2222

2323

24-
class RawPropertiesEndpoints(BasePropertiesEndpoints):
24+
class PropertiesEndpoints(BasePropertiesEndpoints):
2525
"""
26-
RawProperties endpoints.
26+
Properties endpoints.
2727
2828
Args:
2929
host (str): Exabyte API hostname.
@@ -43,8 +43,8 @@ class RawPropertiesEndpoints(BasePropertiesEndpoints):
4343
"""
4444

4545
def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs):
46-
super(RawPropertiesEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
47-
self.name = "raw-properties"
46+
super(PropertiesEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
47+
self.name = "properties"
4848

4949
def delete(self, id_):
5050
raise NotImplementedError

tests/integration/entity.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import time
22

3+
from requests.exceptions import HTTPError
4+
35
from tests.integration import BaseIntegrationTest
46

57

@@ -11,6 +13,7 @@ class EntityIntegrationTest(BaseIntegrationTest):
1113
def __init__(self, *args, **kwargs):
1214
super(EntityIntegrationTest, self).__init__(*args, **kwargs)
1315
self.endpoints = None
16+
self.entity_id: str = ""
1417

1518
def entities_selector(self):
1619
"""
@@ -20,8 +23,21 @@ def entities_selector(self):
2023
return {"tags": "INTEGRATION-TEST"}
2124

2225
def tearDown(self):
23-
for entity in [e for e in self.endpoints.list(query=self.entities_selector())]:
24-
self.endpoints.delete(entity["_id"])
26+
"""Delete only the current test entity if it still exists after test.
27+
28+
Warn if the filtering fails, failsafe attempt to delete the entity anyways.
29+
"""
30+
tagged_test_entity_id_list = [e["_id"] for e in self.endpoints.list(query=self.entities_selector())]
31+
try:
32+
if self.entity_id not in tagged_test_entity_id_list:
33+
print(
34+
f"WARNING: Entity with ID {self.entity_id} not found in the list of tagged entities:"
35+
f" {tagged_test_entity_id_list}"
36+
)
37+
self.endpoints.delete(self.entity_id)
38+
39+
except HTTPError as e:
40+
print(f"WARNING: Failed to delete entity with ID {self.entity_id}: {e}")
2541

2642
def get_default_config(self):
2743
"""
@@ -33,9 +49,10 @@ def get_default_config(self):
3349
def create_entity(self, kwargs=None):
3450
entity = self.get_default_config()
3551
entity.update(kwargs or {})
36-
entity["tags"] = entity.get("tags", [])
37-
entity["tags"].append("INTEGRATION-TEST")
38-
return self.endpoints.create(entity)
52+
entity.setdefault("tags", []).append("INTEGRATION-TEST")
53+
created_entity = self.endpoints.create(entity)
54+
self.entity_id = created_entity["_id"]
55+
return created_entity
3956

4057
def list_entities_test(self):
4158
entity = self.create_entity()
@@ -47,9 +64,10 @@ def get_entity_by_id_test(self):
4764

4865
def create_entity_test(self):
4966
name = "test-{}".format(time.time())
50-
job = self.create_entity({"name": name})
51-
self.assertEqual(job["name"], name)
52-
self.assertIsNotNone(job["_id"])
67+
entity = self.create_entity({"name": name})
68+
self.assertEqual(entity["name"], name)
69+
self.assertIsNotNone(entity["_id"])
70+
self.assertIn("INTEGRATION-TEST", entity["tags"])
5371

5472
def delete_entity_test(self):
5573
entity = self.create_entity()

tests/integration/test_jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_delete_job(self):
4242
def test_update_job(self):
4343
self.update_entity_test()
4444

45-
def _wait_for_job_to_finish(self, id_, timeout=300):
45+
def _wait_for_job_to_finish(self, id_, timeout=600):
4646
end = time.time() + timeout
4747
while time.time() < end:
4848
job = self.endpoints.get(id_)

tests/unit/test_bank_materials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import mock
1+
from unittest import mock
22
from exabyte_api_client.endpoints.bank_materials import BankMaterialEndpoints
33
from tests.unit.entity import EntityEndpointsUnitTest
44

tests/unit/test_bank_workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import mock
1+
from unittest import mock
22
from exabyte_api_client.endpoints.bank_workflows import BankWorkflowEndpoints
33
from tests.unit.entity import EntityEndpointsUnitTest
44

tests/unit/test_httpBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import mock
1+
from unittest import mock
22
from exabyte_api_client.utils.http import Connection
33
from requests.exceptions import HTTPError
44
from tests.unit import EndpointBaseUnitTest

tests/unit/test_jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import mock
1+
from unittest import mock
22

33
from exabyte_api_client.endpoints.jobs import JobEndpoints
44
from tests.unit.entity import EntityEndpointsUnitTest

0 commit comments

Comments
 (0)