Skip to content

Commit

Permalink
Fix pushing list types to clients programmatically.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaul Kremer authored and roekatz committed Feb 8, 2024
1 parent ab6ef92 commit d829fe1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/opal-common/opal_common/confi/confi.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ def _eval_entry(self, entry: ConfiEntry):
def _process(
self,
key,
*,
default=undefined,
description=None,
cast=no_cast,
cast_from_json=no_cast,
type: ValueT = str,
flags: List[str] = None,
**kwargs,
Expand All @@ -182,20 +184,21 @@ def _process(
# create new entry
res = ConfiEntry(
key,
default,
description,
cast,
type,
default=default,
description=description,
cast=cast,
cast_from_json=cast_from_json,
type=type,
index=self._counter,
flags=flags,
**kwargs,
)
# track count for indexing
self._counter += 1
return res
else:
whole_key = self._prefix_key(key)
return self._evaluate(whole_key, default, cast, **kwargs)

whole_key = self._prefix_key(key)
return self._evaluate(whole_key, default, cast, **kwargs)

def _evaluate(self, key, default=undefined, cast=no_cast, **kwargs):
safe_cast_func = ignore_confi_delay_cast(cast)
Expand Down Expand Up @@ -357,6 +360,7 @@ def model(
description=description,
default=default,
cast=cast_pydantic(model_type),
cast_from_json=cast_pydantic(model_type),
type=model_type,
**kwargs,
)
Expand All @@ -375,6 +379,7 @@ def enum(
description=description,
default=default,
cast=enum_type,
cast_from_json=enum_type,
type=enum_type,
**kwargs,
)
Expand All @@ -398,6 +403,7 @@ def private_key(
description=description,
default=default,
cast=cast_key,
cast_from_json=cast_key,
type=PrivateKey,
**kwargs,
)
Expand All @@ -418,6 +424,7 @@ def public_key(
description=description,
default=default,
cast=cast_key,
cast_from_json=cast_key,
type=PublicKey,
**kwargs,
)
Expand Down
4 changes: 4 additions & 0 deletions packages/opal-common/opal_common/confi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ class ConfiEntry:
default: Any
description: str
cast: Callable
cast_from_json: Callable
kwargs: dict
flags: List[str]
value: Any

def __init__(
self,
key,
*,
default=undefined,
description=None,
cast=no_cast,
cast_from_json=no_cast,
type=str,
index=-1,
flags: List[str] = None,
Expand All @@ -56,6 +59,7 @@ def __init__(
self.default = default
self.description = description
self.cast = cast
self.cast_from_json = cast_from_json
self.type = type
self.kwargs = kwargs
self.flags = flags
Expand Down

0 comments on commit d829fe1

Please sign in to comment.