Skip to content

Commit

Permalink
fix(slurm_ops): use correct type hints for environment variables getters
Browse files Browse the repository at this point in the history
Environment variable getters can reuturn str or None, not just str.
None is returned if the environment variable is not defined in
the corresponding environment file.

Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Dec 6, 2024
1 parent b51c2fe commit 935cd26
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/charms/hpc_libs/v0/slurm_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,10 @@ def __init__(self, *args, **kwargs) -> None:
self._env_manager = self._ops_manager.env_manager_for(_ServiceType.SACKD)

@property
def config_server(self) -> str:
def config_server(self) -> str | None:
"""Get the configuration server address of this `sackd` node."""
return self._env_manager.get("SACKD_CONFIG_SERVER")
result = self._env_manager.get("SACKD_CONFIG_SERVER")
return None if result == "" else result

@config_server.setter
def config_server(self, addr: str) -> None:
Expand Down Expand Up @@ -971,7 +972,7 @@ def group(self) -> str:
return "root"

@property
def config_server(self) -> str:
def config_server(self) -> str | None:
"""Get the configuration server address of this `slurmd` node."""
return self._env_manager.get("SLURMD_CONFIG_SERVER")

Expand Down Expand Up @@ -1000,7 +1001,7 @@ def __init__(self, *args, **kwargs) -> None:
)

@property
def mysql_unix_port(self) -> str:
def mysql_unix_port(self) -> str | None:
"""Get the URI of the unix socket `slurmdbd` uses to communicate with MySQL."""
return self._env_manager.get("MYSQL_UNIX_PORT")

Expand Down

0 comments on commit 935cd26

Please sign in to comment.