Get a server by name. If name is None, get the default server.
Source code in src/appl/servers/manager.py
| def get_server(self, name: Optional[str]) -> BaseServer:
"""Get a server by name. If name is None, get the default server."""
if name == "small":
name = global_vars.configs.default_servers.small
elif name == "large":
name = global_vars.configs.default_servers.large
if name is None: # if still None, fall back to default server
name = global_vars.configs.default_servers.default
if name is None: # backward-compatible for now
name = global_vars.configs.servers.get("default", None) # type: ignore
# logger.warning(
# "Default server is moved to default_servers.default, "
# "please update your config file to set the default server. "
# "The current way will be deprecated in the future."
# )
if name is None:
raise ValueError(
"Default server is not configured. Please set the default server in your config file. "
"See https://appl-team.github.io/appl/setup/#setup-appl-configuration for more details."
)
with self._lock:
if name not in self._servers:
server_configs = _get_server_configs(name)
server = _init_server(**server_configs)
self.register_server(name, server)
return self._servers[name]
|