Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] add state_thresholds support #764

Merged
merged 10 commits into from
Jan 1, 2024
2 changes: 2 additions & 0 deletions cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def get_item_yaml_values(
if values:
if isinstance(values, list):
values_set = set(values)
elif isinstance(values, dict):
values_set = values
else:
values_set.add(values)
values_dict[key] = values_set
Expand Down
31 changes: 16 additions & 15 deletions cli/item_to_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@
help="If -b/--bump_version is enabled, increase the minor version in the item.yaml file",
)
def item_to_function_cli(
item_path: str, output_path: Optional[str], code_output: bool, format_code: bool, bump_version: bool
item_path: str, output_path: Optional[str], code_output: bool, format_code: bool, bump_version: bool
):
item_to_function(item_path, output_path, code_output, format_code, bump_version)


def item_to_function(
item_path: str,
output_path: Optional[str] = None,
code_output: bool = False,
format_code: bool = True,
bump_version: bool = False,
item_path: str,
output_path: Optional[str] = None,
code_output: bool = False,
format_code: bool = True,
bump_version: bool = False,
):
item_path = Path(item_path)
if item_path.is_dir():
Expand All @@ -78,9 +78,9 @@ def item_to_function(
# That means we need to search for items inside this direcotry
else:
for inner_dir in PathIterator(
root=item_path.parent,
rule=is_item_dir,
as_path=True,
root=item_path.parent,
rule=is_item_dir,
as_path=True,
):
try:
_output_path = output_path or (inner_dir / "function.yaml")
Expand Down Expand Up @@ -119,11 +119,11 @@ def _get_item_yaml(item_path: Path) -> dict:


def create_function_yaml(
item_path: Union[str, Path],
output_path: Optional[str] = None,
code_output: bool = False,
format_code: bool = True,
bump_version: bool = False,
item_path: Union[str, Path],
output_path: Optional[str] = None,
code_output: bool = False,
format_code: bool = True,
bump_version: bool = False,
):
item_path = Path(item_path)
if bump_version:
Expand Down Expand Up @@ -161,7 +161,8 @@ def create_function_yaml(
# remove build info from object
function_object.spec.build.code_origin = ''
function_object.spec.build.origin_filename = ''
function_object.spec.state_thresholds=None
if 'state_thresholds' not in spec:
function_object.spec.state_thresholds = None

custom_fields = spec.get("customFields", {})
for key, value in custom_fields.items():
Expand Down
Loading