Skip to content

Commit

Permalink
Change Parameter.default_value type
Browse files Browse the repository at this point in the history
  • Loading branch information
olokobayusuf committed Oct 25, 2023
1 parent 7fabf44 commit 4c0378b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.24
+ Changed `Parameter.default_value` field type to `Value`.

## 0.0.23
+ Added `AccessMode.Protected` enumeration member for working with protected predictors.
+ Added `pydantic` as an explicit dependency.
Expand Down
6 changes: 3 additions & 3 deletions fxn/api/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class Parameter:
optional (bool): Parameter is optional.
range (tuple): Parameter value range for numeric parameters.
enumeration (list): Parameter value choices for enumeration parameters.
default_value (str | float | int | bool): Parameter default value.
default_value (Value): Parameter default value.
schema (dict): Parameter JSON schema. This is only populated for `list` and `dict` parameters.
"""
name: Optional[str] = None
Expand All @@ -382,11 +382,11 @@ class Parameter:
optional: Optional[bool] = None
range: Optional[Tuple[float, float]] = None
enumeration: Optional[List[EnumerationMember]] = None
default_value: Optional[Union[str, float, int, bool]] = None
default_value: Optional[Value] = None
schema: Optional[dict] = None

def __post_init__ (self):
default_value = Value(**self.default_value).to_value() if isinstance(self.default_value, dict) and all(x in self.default_value for x in ["data", "type", "shape"]) else self.default_value
default_value = Value(**self.default_value) if isinstance(self.default_value, dict) else self.default_value
enumeration = [EnumerationMember(**member) if isinstance(member, dict) else member for member in self.enumeration] if self.enumeration else self.enumeration
object.__setattr__(self, "default_value", default_value)
object.__setattr__(self, "enumeration", enumeration)
Expand Down
2 changes: 1 addition & 1 deletion fxn/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Copyright © 2023 NatML Inc. All Rights Reserved.
#

__version__ = "0.0.23"
__version__ = "0.0.24"

0 comments on commit 4c0378b

Please sign in to comment.