Skip to content

Commit

Permalink
added exclude_none to be more core code compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Jan 15, 2025
1 parent d7bbdaa commit 71350df
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions bibigrid/core/actions/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ def start_start_server_threads(self):
start_server_threads.append(start_server_thread)
for worker in configuration.get("workerInstances", []):
if not worker.get("onDemand", True):
for _ in range(int(worker["count"])):
for _ in range(int(worker.get("count", 1))):
start_server_thread = return_threading.ReturnThread(target=self.start_worker,
args=[worker, worker_count, configuration,
provider])
start_server_thread.start()
start_server_threads.append(start_server_thread)
worker_count += 1
else:
worker_count += worker["count"]
worker_count += worker.get("count", 1)
for start_server_thread in start_server_threads:
start_server_thread.join()

Expand Down
60 changes: 30 additions & 30 deletions bibigrid/core/rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ class Role(BaseModel):
class UserRole(BaseModel):
hosts: List[str]
roles: List[Role]
varsFiles: Optional[List[str]]
varsFiles: Optional[List[str]] = Field(default=[])

class CloudScheduling(BaseModel):
sshTimeout: Optional[int] = 5

class BootVolume(BaseModel):
name: Optional[str]
name: Optional[str] = None
terminate: Optional[bool] = True
size: Optional[int] = 50

class Volume(BaseModel):
name: Optional[str]
snapshot: Optional[str]
name: Optional[str] = None
snapshot: Optional[str] = None
permanent: Optional[bool] = False
semiPermanent: Optional[bool] = False
exists: Optional[bool] = False
mountPoint: Optional[str]
mountPoint: Optional[str] = None
size: Optional[int] = 50
fstype: Optional[str]
type: Optional[str]
fstype: Optional[str] = None
type: Optional[str] = None

class Instance(BaseModel):
type: str
image: str
onDemand: Optional[bool] = True
partitions: Optional[List[str]]
features: Optional[List[str]]
bootVolume: Optional[BootVolume]
volumes: Optional[List[Volume]]
partitions: Optional[List[str]] = Field(default=[])
features: Optional[List[str]] = Field(default=[])
bootVolume: Optional[BootVolume] = None
volumes: Optional[List[Volume]] = Field(default=[])

class ElasticScheduling(BaseModel):
SuspendTime: Optional[int] = 1800
Expand All @@ -48,11 +48,11 @@ class ElasticScheduling(BaseModel):
TreeWidth: Optional[int] = 128

class SlurmConf(BaseModel):
db: Optional[str]
db_user: Optional[str]
db_password: Optional[str]
munge_key: Optional[str]
elastic_scheduling: Optional[ElasticScheduling]
db: Optional[str] = "slurm"
db_user: Optional[str] = "slurm"
db_password: Optional[str] = "changeme"
munge_key: Optional[str] = None
elastic_scheduling: Optional[ElasticScheduling] = None

class Gateway(BaseModel):
ip: str
Expand All @@ -64,42 +64,42 @@ class MasterConfig(BaseModel):
sshUser: str
subnet: Optional[str] = Field(default=None)
network: Optional[str] = Field(default=None)
cloud_identifier: str
sshPublicKeyFiles: Optional[List[str]]
cloud_identifier: Optional[str] = None
sshPublicKeyFiles: Optional[List[str]] = Field(default=[])
sshTimeout: Optional[int] = 5
cloudScheduling: Optional[CloudScheduling]
nfsShares: Optional[List[str]]
userRoles: Optional[List[UserRole]]
cloudScheduling: Optional[CloudScheduling] = None
nfsShares: Optional[List[str]] = Field(default=[])
userRoles: Optional[List[UserRole]] = Field(default=[])
localFS: Optional[bool] = False
localDNSlookup: Optional[bool] = False
slurm: Optional[bool] = True
slurmConf: Optional[SlurmConf]
slurmConf: Optional[SlurmConf] = None
zabbix: Optional[bool] = False
nfs: Optional[bool] = False
ide: Optional[bool] = False
useMasterAsCompute: Optional[bool] = True
useMasterWithPublicIp: Optional[bool] = True
waitForServices: Optional[List[str]]
gateway: Optional[Gateway]
waitForServices: Optional[List[str]] = Field(default=[])
gateway: Optional[Gateway] = None
dontUploadCredentials: Optional[bool] = False
fallbackOnOtherImage: Optional[bool] = False
features: Optional[List[str]]
features: Optional[List[str]] = Field(default=[])
workerInstances: List[Instance]
masterInstance: Instance
bootVolume: Optional[BootVolume]
bootVolume: Optional[BootVolume] = None

class OtherConfig(BaseModel):
infrastructure: str
cloud: str
sshUser: str
subnet: Optional[str] = Field(default=None)
network: Optional[str] = Field(default=None)
cloud_identifier: str
waitForServices: Optional[List[str]]
features: Optional[List[str]]
cloud_identifier: Optional[str] = None
waitForServices: Optional[List[str]] = Field(default=[])
features: Optional[List[str]] = Field(default=[])
workerInstances: List[Instance]
vpnInstance: Instance
bootVolume: Optional[BootVolume]
bootVolume: Optional[BootVolume] = None

class ConfigurationsModel(BaseModel):
configurations: List[Union[MasterConfig, OtherConfig]]
Expand Down
2 changes: 1 addition & 1 deletion bibigrid/core/startup_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def create_async():
creator.create()

try:
configurations = configurations_json.model_dump()
configurations = configurations_json.model_dump(exclude_none=True)["configurations"]
providers = provider_handler.get_providers(configurations, log)
creator = create.Create(providers=providers, configurations=configurations, log=log,
config_path=None, cluster_id=cluster_id)
Expand Down

0 comments on commit 71350df

Please sign in to comment.