Compare commits

..

2 Commits

Author SHA1 Message Date
Jonathon Broughton cccf3b1dc3 Update developer guide for Checker function
Expanded the developer guide with detailed setup instructions, project overview, and testing procedures. Added sections on test automation environment, integration tests, and TDD workflow for rule development. Included troubleshooting tips and future development ideas to enhance functionality.
2025-02-28 16:00:53 +00:00
Jonathon Broughton 5c93c6861a Update README for Speckle Checker functionality
Expanded the overview of the Speckle Checker, detailing its purpose and how it simplifies validation through spreadsheets. Updated usage instructions to include step-by-step guidance on preparing rule spreadsheets and creating automations. Added sections on rule definition format, supported predicates, and example rules for clarity. Enhanced support information at the end.
2025-02-28 16:00:42 +00:00
4 changed files with 22 additions and 72 deletions
+22 -22
View File
@@ -18,19 +18,19 @@ The Checker function allows you to:
### 1. Prepare Your Rule Spreadsheet
1. Access
the [template spreadsheet](https://docs.google.com/spreadsheets/d/1eB0RVuOXdjLyn4_GAPSahV05p1lqfSGQbH8WWijnkkA/edit?gid=0#gid=0)
2. Use the Speckle menu to launch the Speckle sidebar and make a copy.
3. Define your rules using the format explained below
4. Publish your rules by clicking "Publish Rules". Copy the resultant URL.
1. Access the [template spreadsheet](https://docs.google.com/spreadsheets/d/1hiPSw23eOaqd27QD_YsXvZg9PWm7_XBx/edit) (
make a copy to your drive)
2. Define your rules using the format explained below
3. Publish your rules by clicking "File > Download > Tab-separated values (.tsv)"
4. Upload the TSV file to a hosting service (Google Drive, Dropbox, etc.) and get a public URL
### 2. Create an Automation
1. Go to your workspace project in [Speckle](https://app.speckle.systems/)
1. Go to [Speckle Automate](https://automate.speckle.dev/)
2. Create a new Automation
3. Select the Checker function
4. Configure the function:
- Paste your published rules URL
- Paste your TSV URL
- Set minimum severity level to report
- Configure other options as needed
5. Save and run your automation
@@ -58,20 +58,20 @@ Rules are defined in a spreadsheet with the following columns:
### Supported Predicates
| Predicate | Description | Example |
|------------------|-----------------------------|---------------------------------------|
| exists | Checks if a property exists | `height` exists |
| equal to | Exact value match | `width` equal to `300` |
| not equal to | Value doesn't match | `material` not equal to `Concrete` |
| greater than | Value exceeds threshold | `height` greater than `3000` |
| less than | Value below threshold | `thickness` less than `50` |
| in range | Value within bounds | `elevation` in range `0,10000` |
| in list | Value in allowed set | `type` in list `W1,W2,W3` |
| contains | Property contains substring | `name` contains `Beam` |
| does not contain | Property doesn't contain | `name` does not contain `temp` |
| is true | Boolean property is true | `is_structural` is true |
| is false | Boolean property is false | `is_placeholder` is false |
| is like | Loose text matching | `name` is like `Wall` matches `Walls` |
| Predicate | Description | Example |
|------------------|-----------------------------|------------------------------------|
| exists | Checks if a property exists | `height` exists |
| equal to | Exact value match | `width` equal to `300` |
| not equal to | Value doesn't match | `material` not equal to `Concrete` |
| greater than | Value exceeds threshold | `height` greater than `3000` |
| less than | Value below threshold | `thickness` less than `50` |
| in range | Value within bounds | `elevation` in range `0,10000` |
| in list | Value in allowed set | `type` in list `W1,W2,W3` |
| contains | Property contains substring | `name` contains `Beam` |
| does not contain | Property doesn't contain | `name` does not contain `temp` |
| is true | Boolean property is true | `is_structural` is true |
| is false | Boolean property is false | `is_placeholder` is false |
| is like | Pattern matching | `name` is like `^BR\d+$` |
## Rule Logic
@@ -118,4 +118,4 @@ Severity: ERROR
## Support
For issues or questions, please let us know on the [Speckle Community Forum](https://speckle.community/).
For issues or questions, please open a GitHub issue or contact your Speckle support representative.
-1
View File
@@ -17,5 +17,4 @@ 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,35 +890,3 @@ 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,20 +415,3 @@ 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