66
77from __future__ import annotations
88
9- from dataclasses import dataclass , field
9+ from dataclasses import dataclass , field , replace
1010from pathlib import Path
1111from typing import Any , Dict , Literal , Mapping , Optional , Union , cast
1212
1515import temporalio .service
1616from temporalio .bridge .temporal_sdk_bridge import envconfig as _bridge_envconfig
1717
18+ DEFAULT_TARGET_HOST = "localhost:7233"
19+
1820DataSource : TypeAlias = Union [
1921 Path , str , bytes
2022] # str represents a file contents, bytes represents raw data
@@ -253,7 +255,7 @@ def to_client_connect_config(self) -> ClientConnectConfig:
253255
254256 @staticmethod
255257 def load (
256- profile : str = "default" ,
258+ profile : Optional [ str ] = None ,
257259 * ,
258260 config_source : Optional [DataSource ] = None ,
259261 disable_file : bool = False ,
@@ -268,7 +270,8 @@ def load(
268270 :py:meth:`to_client_connect_config` method on the returned profile.
269271
270272 Args:
271- profile: Profile to load from the config.
273+ profile: Profile to load from the config. If the profile is provided,
274+ the default profile is returned.
272275 config_source: If present, this is used as the configuration source
273276 instead of default file locations. This can be a path to the file
274277 or the string/byte contents of the file.
@@ -298,7 +301,13 @@ def load(
298301 config_file_strict = config_file_strict ,
299302 env_vars = override_env_vars ,
300303 )
301- return ClientConfigProfile .from_dict (raw_profile )
304+ prof = ClientConfigProfile .from_dict (raw_profile )
305+
306+ # If no address is present, default to localhost
307+ if prof .address is None :
308+ prof = replace (prof , address = DEFAULT_TARGET_HOST )
309+
310+ return prof
302311
303312
304313@dataclass
@@ -377,7 +386,7 @@ def load(
377386
378387 @staticmethod
379388 def load_client_connect_config (
380- profile : str = "default" ,
389+ profile : Optional [ str ] = None ,
381390 * ,
382391 config_file : Optional [str ] = None ,
383392 disable_file : bool = False ,
@@ -392,7 +401,8 @@ def load_client_connect_config(
392401 process's environment for overrides unless disabled.
393402
394403 Args:
395- profile: The profile to load from the config. Defaults to "default".
404+ profile: Profile to load from the config. If the profile is provided,
405+ the default profile is returned.
396406 config_file: Path to a specific TOML config file. If not provided,
397407 default file locations are used. This is ignored if
398408 ``disable_file`` is true.
0 commit comments