Skip to content

Commit 8c85bee

Browse files
Pleasing pylint
1 parent 148878b commit 8c85bee

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

bibigrid/core/actions/create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def write_cluster_state(self, state):
8282
# all clusters
8383
cluster_info_path = os.path.normpath(os.path.join(CLUSTER_INFO_FOLDER, f"{self.cluster_id}.yaml"))
8484
if not cluster_info_path.startswith(os.path.normpath(CLUSTER_INFO_FOLDER)):
85-
raise Exception("Invalid cluster_id resulting in path traversal")
85+
raise ValueError("Invalid cluster_id resulting in path traversal")
8686
with open(cluster_info_path, mode="w+", encoding="UTF-8") as cluster_info_file:
8787
yaml.safe_dump(data=state, stream=cluster_info_file)
8888

bibigrid/core/actions/terminate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def write_cluster_state(cluster_id, state):
2222
# all clusters
2323
cluster_info_path = os.path.normpath(os.path.join(CLUSTER_INFO_FOLDER, f"{cluster_id}.yaml"))
2424
if not cluster_info_path.startswith(CLUSTER_INFO_FOLDER):
25-
raise Exception("Invalid cluster_id")
25+
raise ValueError("Invalid cluster_id resulting in path traversal")
2626
with open(cluster_info_path, mode="w+", encoding="UTF-8") as cluster_info_file:
2727
yaml.safe_dump(data=state, stream=cluster_info_file)
2828

bibigrid/core/rest/models.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66

77

88
class BootVolume(BaseModel):
9+
"""
10+
Holds information about where the server boots from
11+
"""
912
name: Optional[str]
1013
terminate: Optional[bool]
1114
size: Optional[int]
1215

1316

1417
class Volume(BaseModel):
18+
"""
19+
Holds volume/attached storage information
20+
"""
1521
name: Optional[str]
1622
snapshot: Optional[str]
1723
permanent: Optional[bool]
@@ -24,6 +30,9 @@ class Volume(BaseModel):
2430

2531

2632
class Instance(BaseModel):
33+
"""
34+
Holds instance/server information
35+
"""
2736
type: str
2837
image: str
2938
count: Optional[int]
@@ -35,19 +44,28 @@ class Instance(BaseModel):
3544

3645

3746
class UserRole(BaseModel):
47+
"""
48+
Allows users to add custom ansible roles
49+
"""
3850
hosts: List[str]
3951
roles: List[dict] # Replace 'dict' with more specific type if possible
4052
varsFiles: Optional[List[str]]
4153

4254

4355
class ElasticScheduling(BaseModel):
56+
"""
57+
Holds info on Slurms scheduling
58+
"""
4459
SuspendTime: Optional[int]
4560
SuspendTimeout: Optional[int]
4661
ResumeTimeout: Optional[int]
4762
TreeWidth: Optional[int]
4863

4964

5065
class SlurmConf(BaseModel):
66+
"""
67+
Holds info on basic Slurm settings
68+
"""
5169
db: Optional[str]
5270
db_user: Optional[str]
5371
db_password: Optional[str]
@@ -56,11 +74,17 @@ class SlurmConf(BaseModel):
5674

5775

5876
class Gateway(BaseModel):
77+
"""
78+
Holds info regarding whether a gateway is used to connect to the master
79+
"""
5980
ip: str
6081
portFunction: str
6182

6283

6384
class ConfigModel(BaseModel):
85+
"""
86+
Holds info regarding the configuration
87+
"""
6488
infrastructure: str
6589
cloud: str
6690
sshUser: str
@@ -95,6 +119,10 @@ class ConfigModel(BaseModel):
95119

96120

97121
class OtherConfigModel(ConfigModel):
122+
"""
123+
Holds info about other configurations
124+
TODO: Fill in the missing bits
125+
"""
98126
vpnInstance: Instance
99127

100128

@@ -142,6 +170,9 @@ class LogResponseModel(BaseModel):
142170

143171

144172
class ClusterStateResponseModel(BaseModel):
173+
"""
174+
Response model for state
175+
"""
145176
cluster_id: str
146177
floating_ip: IPvAnyAddress
147178
message: str

bibigrid/core/startup_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async def get_log(cluster_id: str, lines: int = None):
248248
return JSONResponse(content={"error": str(exc)}, status_code=400)
249249

250250

251-
@app.get("/bibigrid/ready/", response_model=ReadyResponseModel)
251+
@app.get("/bibigrid/ready/", response_model=ClusterStateResponseModel)
252252
async def ready(cluster_id: str):
253253
"""
254254
Expects a cluster id.

bibigrid/core/utility/paths/basic_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
CLUSTER_MEMORY_FOLDER = KEY_FOLDER
2121
CLUSTER_MEMORY_FILE = ".bibigrid.mem"
22-
CLUSTER_MEMORY_PATH = os.path.join(CONFIG_FOLDER, CLUSTER_MEMORY_FILE)
22+
CLUSTER_MEMORY_PATH = os.path.join(CONFIG_FOLDER, CLUSTER_MEMORY_FILE)

bibigrid/core/utility/statics/create_statics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Containg static variables for create.py to avoid cyclic imports
33
"""
44

5-
import os
65
from functools import partial
76

87
from bibigrid.core.utility.paths import ansible_resources_path as a_rp

bibigrid/core/utility/validate_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
Optional('sshPublicKeyFiles'): [str], Optional('sshTimeout'): int,
5050
Optional('cloudScheduling'): {Optional('sshTimeout'): int}, Optional('autoMount'): bool,
5151
Optional('nfsShares'): [str],
52-
Optional('userRoles'): [{'hosts': [str], 'roles': [{'name': str, Optional('tags'): [str]}], Optional('varsFiles'): [str]}],
52+
Optional('userRoles'): [
53+
{'hosts': [str], 'roles': [{'name': str, Optional('tags'): [str]}], Optional('varsFiles'): [str]}],
5354
Optional('localFS'): bool, Optional('localDNSlookup'): bool, Optional('slurm'): bool,
5455
Optional('slurmConf'): {Optional('db'): str, Optional('db_user'): str, Optional('db_password'): str,
5556
Optional('munge_key'): str, Optional('elastic_scheduling'): {Optional('SuspendTime'): int,

0 commit comments

Comments
 (0)