Compare commits

..

5 Commits

Author SHA1 Message Date
Jonathon Broughton 089ecca34e Update README with clearer instructions
- Updated the template spreadsheet link.
- Changed steps for rule publishing and automation creation.
- Improved formatting of supported predicates table.
- Added a new support contact method via community forum.
2025-03-01 10:20:41 +00:00
Jonathon Broughton 1c09449f19 Add 'is set' predicate and not empty check
- Introduced a new predicate for checking if a parameter is set.
- Added a method to verify if a parameter exists and isn't empty.
- Updated tests to cover the new 'not empty' functionality.
2025-02-28 17:36:40 +00:00
Jonathon Broughton 0e81ac07f0 Merge remote-tracking branch 'origin/main' 2025-02-28 17:35:43 +00:00
Jonathon Broughton 7d3afe4f9f Merge remote-tracking branch 'origin/main' 2025-02-28 15:00:09 +00:00
Jonathon Broughton 997b1049aa Added over the top levels of documentation for future developers 2025-02-28 14:54:46 +00:00
4 changed files with 50 additions and 1 deletions
-1
View File
@@ -44,4 +44,3 @@ jobs:
speckle_function_id: ${{ secrets.SPECKLE_FUNCTION_ID }}
speckle_function_input_schema_file_path: ${{ env.FUNCTION_SCHEMA_FILE_NAME }}
speckle_function_command: 'python -u main.py run'
speckle_function_recommended_memory_mi: 5000
+1
View File
@@ -17,4 +17,5 @@ PREDICATE_METHOD_MAP = {
"identical to": PropertyRules.is_identical_value.__name__,
"contains": PropertyRules.is_parameter_value_containing.__name__,
"does not contain": PropertyRules.is_parameter_value_not_containing.__name__,
"is set": PropertyRules.is_parameter_value_not_empty.__name__,
}
+32
View File
@@ -890,3 +890,35 @@ class PropertyRules:
return PropertyRules.compare_values(
parameter_value, value_to_match, case_sensitive=True, tolerance=0, allow_yes_no_bools=False, use_exact=True
)
@staticmethod
def is_parameter_value_not_empty(speckle_object: Base, parameter_name: str) -> bool:
"""Checks if parameter exists and has a non-empty value.
Args:
speckle_object: The Speckle object to check
parameter_name: Name of the parameter to check
Returns:
bool: True if parameter exists and has a non-empty value
"""
# Get the parameter value
parameter_value = PropertyRules.get_parameter_value(speckle_object, parameter_name)
# Check if parameter exists
if parameter_value is None:
return False
# Check if value is an empty string
if isinstance(parameter_value, str) and parameter_value.strip() == "":
return False
# Check if value is an empty list or collection
if hasattr(parameter_value, "__len__") and len(parameter_value) == 0:
return False
# Additional check for "None" string which can sometimes appear in exports
if isinstance(parameter_value, str) and parameter_value.lower() == "none":
return False
return True
+17
View File
@@ -415,3 +415,20 @@ class TestParameterHandling:
"""Test negative substring matching on parameter values."""
v2_obj, _ = test_objects
assert PropertyRules.is_parameter_value_not_containing(v2_obj, param_name, substring) == expected_result
@pytest.mark.parametrize(
"param_name, expected_result",
[
("category", True), # Parameter exists with non-empty value
("family", True), # Parameter exists with non-empty value
("non_existent_param", False), # Parameter doesn't exist
# The following would require setup with empty values
# ("empty_string_param", False), # Parameter exists but has empty string value
# ("none_string_param", False), # Parameter exists but has "None" string value
],
)
def test_parameter_not_empty(self, test_objects, param_name, expected_result):
"""Test 'not empty' check on parameter values."""
v2_obj, _ = test_objects
assert PropertyRules.is_parameter_value_not_empty(v2_obj, param_name) == expected_result