Skip to content

Commit b54962f

Browse files
Merge pull request #32 from Exabyte-io/feat/SOF-6640-2
feat/SOF-6640-2
2 parents 0bd07d1 + 26bec5d commit b54962f

37 files changed

+156
-146
lines changed

.github/workflows/cicd.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ concurrency:
88

99
jobs:
1010

11+
run-linter:
12+
runs-on: ubuntu-20.04
13+
strategy:
14+
matrix:
15+
python-version: [3.8.6]
16+
17+
steps:
18+
- name: Checkout this repository
19+
uses: actions/checkout@v3
20+
with:
21+
lfs: true
22+
23+
- name: Checkout actions repository
24+
uses: actions/checkout@v3
25+
with:
26+
repository: Exabyte-io/actions
27+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
28+
path: actions
29+
ref: feat/SOF-6640
30+
31+
- name: Run ruff linter
32+
uses: ./actions/py/lint
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
1136
run-tests:
1237
runs-on: ubuntu-20.04
1338
strategy:
@@ -47,7 +72,7 @@ jobs:
4772

4873

4974
publish:
50-
needs: run-tests
75+
needs: [run-linter, run-tests]
5176
runs-on: ubuntu-latest
5277
if: github.ref_name == 'dev'
5378

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ repos:
44
hooks:
55
- id: ruff
66
- id: black
7-
- id: pydocstyle

exabyte_api_client/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa: F401
12
try:
23
from ._version import version as __version__
34
except ModuleNotFoundError:

exabyte_api_client/endpoints/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import json
1+
import json # noqa: F401
22

33
from ..utils.http import Connection
44

@@ -17,7 +17,7 @@ class BaseEndpoint(object):
1717
conn (httplib.ExabyteConnection): ExabyteConnection instance.
1818
"""
1919

20-
def __init__(self, host, port, version='2018-10-1', secure=True, **kwargs):
20+
def __init__(self, host, port, version="2018-10-1", secure=True, **kwargs):
2121
self.conn = Connection(host, port, version=version, secure=secure, **kwargs)
2222

2323
def request(self, method, endpoint_path, params=None, data=None, headers=None):
@@ -37,9 +37,9 @@ def request(self, method, endpoint_path, params=None, data=None, headers=None):
3737
with self.conn:
3838
self.conn.request(method, endpoint_path, params, data, headers)
3939
response = self.conn.json()
40-
if response['status'] != 'success':
41-
raise BaseException(response['data']['message'])
42-
return response['data']
40+
if response["status"] != "success":
41+
raise BaseException(response["data"]["message"])
42+
return response["data"]
4343

4444
def get_headers(self, account_id, auth_token, content_type="application/json"):
45-
return {'X-Account-Id': account_id, 'X-Auth-Token': auth_token, 'Content-Type': content_type}
45+
return {"X-Account-Id": account_id, "X-Auth-Token": auth_token, "Content-Type": content_type}

exabyte_api_client/endpoints/bank_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ def copy(self, id_, account_id=None):
4444
dict: new entity.
4545
"""
4646
params = {"accountId": account_id}
47-
return self.request('POST', '/'.join((self.name, id_, "copy")), params=params, headers=self.headers)
47+
return self.request("POST", "/".join((self.name, id_, "copy")), params=params, headers=self.headers)

exabyte_api_client/endpoints/bank_materials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ class BankMaterialEndpoints(BankEntityEndpoints):
2222

2323
def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs):
2424
super(BankMaterialEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
25-
self.name = 'bank-materials'
25+
self.name = "bank-materials"

exabyte_api_client/endpoints/bank_workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ class BankWorkflowEndpoints(BankEntityEndpoints):
2222

2323
def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs):
2424
super(BankWorkflowEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
25-
self.name = 'bank-workflows'
25+
self.name = "bank-workflows"

exabyte_api_client/endpoints/charges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ChargeEndpoints(EntityEndpoint):
2525

2626
def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs):
2727
super(ChargeEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
28-
self.name = 'charges'
28+
self.name = "charges"
2929

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

exabyte_api_client/endpoints/entity.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def list(self, query=None, projection=None):
4040
list[dict]
4141
"""
4242
params = {"query": json.dumps(query or {}), "projection": json.dumps(projection or {})}
43-
return self.request('GET', self.name, params=params, headers=self.headers)
43+
return self.request("GET", self.name, params=params, headers=self.headers)
4444

4545
def get(self, id_):
4646
"""
@@ -52,7 +52,7 @@ def get(self, id_):
5252
Returns:
5353
dict: entity.
5454
"""
55-
return self.request('GET', '/'.join((self.name, id_)), headers=self.headers)
55+
return self.request("GET", "/".join((self.name, id_)), headers=self.headers)
5656

5757
def delete(self, id_):
5858
"""
@@ -61,7 +61,7 @@ def delete(self, id_):
6161
Args:
6262
id_ (str): entity ID.
6363
"""
64-
return self.request('DELETE', '/'.join((self.name, id_)), headers=self.headers)
64+
return self.request("DELETE", "/".join((self.name, id_)), headers=self.headers)
6565

6666
def update(self, id_, modifier):
6767
"""
@@ -74,7 +74,7 @@ def update(self, id_, modifier):
7474
Returns:
7575
dict: updated entity.
7676
"""
77-
return self.request('PATCH', '/'.join((self.name, id_)), data=json.dumps(modifier), headers=self.headers)
77+
return self.request("PATCH", "/".join((self.name, id_)), data=json.dumps(modifier), headers=self.headers)
7878

7979
def create(self, config):
8080
"""
@@ -86,7 +86,7 @@ def create(self, config):
8686
Returns:
8787
dict: new entity.
8888
"""
89-
return self.request('PUT', '/'.join((self.name, "create")), data=json.dumps(config), headers=self.headers)
89+
return self.request("PUT", "/".join((self.name, "create")), data=json.dumps(config), headers=self.headers)
9090

9191
def copy(self, id_):
9292
"""
@@ -98,4 +98,4 @@ def copy(self, id_):
9898
Returns:
9999
dict: new entity.
100100
"""
101-
return self.request('POST', '/'.join((self.name, id_, "copy")), headers=self.headers)
101+
return self.request("POST", "/".join((self.name, id_, "copy")), headers=self.headers)

exabyte_api_client/endpoints/jobs.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class JobEndpoints(EntitySetEndpointsMixin, EntityEndpoint):
2525

2626
def __init__(self, host, port, account_id, auth_token, version=DEFAULT_API_VERSION, secure=SECURE, **kwargs):
2727
super(JobEndpoints, self).__init__(host, port, account_id, auth_token, version, secure, **kwargs)
28-
self.name = 'jobs'
28+
self.name = "jobs"
2929

3030
def submit(self, id_):
3131
"""
@@ -34,7 +34,7 @@ def submit(self, id_):
3434
Args:
3535
id_ (str): job ID.
3636
"""
37-
self.request('POST', '/'.join((self.name, id_, "submit")), headers=self.headers)
37+
self.request("POST", "/".join((self.name, id_, "submit")), headers=self.headers)
3838

3939
def purge(self, id_):
4040
"""
@@ -43,7 +43,7 @@ def purge(self, id_):
4343
Args:
4444
id_ (str): job ID.
4545
"""
46-
self.request('POST', '/'.join((self.name, id_, "submit")), headers=self.headers)
46+
self.request("POST", "/".join((self.name, id_, "submit")), headers=self.headers)
4747

4848
def terminate(self, id_):
4949
"""
@@ -52,7 +52,7 @@ def terminate(self, id_):
5252
Args:
5353
id_ (str): job ID.
5454
"""
55-
self.request('POST', '/'.join((self.name, id_, "submit")), headers=self.headers)
55+
self.request("POST", "/".join((self.name, id_, "submit")), headers=self.headers)
5656

5757
def get_config(self, material_ids, workflow_id, project_id, owner_id, name, compute=None, is_multi_material=False):
5858
"""
@@ -71,16 +71,10 @@ def get_config(self, material_ids, workflow_id, project_id, owner_id, name, comp
7171
dict
7272
"""
7373
config = {
74-
"_project": {
75-
"_id": project_id
76-
},
77-
"workflow": {
78-
"_id": workflow_id
79-
},
80-
"owner": {
81-
"_id": owner_id
82-
},
83-
"name": name
74+
"_project": {"_id": project_id},
75+
"workflow": {"_id": workflow_id},
76+
"owner": {"_id": owner_id},
77+
"name": name,
8478
}
8579

8680
if compute:
@@ -112,10 +106,8 @@ def get_compute(self, cluster, ppn=1, nodes=1, queue="D", time_limit="01:00:00",
112106
"queue": queue,
113107
"timeLimit": time_limit,
114108
"notify": notify,
115-
"cluster": {
116-
"fqdn": cluster
117-
},
118-
"arguments": {}
109+
"cluster": {"fqdn": cluster},
110+
"arguments": {},
119111
}
120112

121113
def create_by_ids(self, materials, workflow_id, project_id, owner_id, prefix, compute=None):
@@ -152,7 +144,7 @@ def get_presigned_urls(self, id_, files):
152144
list: [{"file": "", "URL": ""}]
153145
"""
154146
data = json.dumps({"files": files})
155-
response = self.request('POST', '/'.join((self.name, id_, "presigned-urls")), data=data, headers=self.headers)
147+
response = self.request("POST", "/".join((self.name, id_, "presigned-urls")), data=data, headers=self.headers)
156148
return response["presignedURLs"]
157149

158150
def list_files(self, id_):
@@ -166,7 +158,7 @@ def list_files(self, id_):
166158
list: [{ "key" : str, "size" : int, "bucket" : str, "region" : str,
167159
"provider" : str, "lastModified" : int, "name" : str, "signedURL" : str }]
168160
"""
169-
response = self.request('GET', '/'.join(('jobs', id_, 'files')), headers=self.headers)
161+
response = self.request("GET", "/".join(("jobs", id_, "files")), headers=self.headers)
170162
return response
171163

172164
def insert_output_files(self, id_, data):

0 commit comments

Comments
 (0)