Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bea53621d | |||
| 00874c2e0c | |||
| efd1b0d567 | |||
| 2c7985843b | |||
| 06d765e763 |
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
@@ -11,7 +11,7 @@ jobs:
|
|||||||
FUNCTION_SCHEMA_FILE_NAME: functionSchema.json
|
FUNCTION_SCHEMA_FILE_NAME: functionSchema.json
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.4.0
|
- uses: actions/checkout@v4.1.1
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python main.py generate_schema ${HOME}/${{ env.FUNCTION_SCHEMA_FILE_NAME }}
|
python main.py generate_schema ${HOME}/${{ env.FUNCTION_SCHEMA_FILE_NAME }}
|
||||||
- name: Speckle Automate Function - Build and Publish
|
- name: Speckle Automate Function - Build and Publish
|
||||||
uses: specklesystems/speckle-automate-github-composite-action@0.6.8
|
uses: specklesystems/speckle-automate-github-composite-action@0.7.2
|
||||||
with:
|
with:
|
||||||
speckle_automate_url: ${{ env.SPECKLE_AUTOMATE_URL || 'https://automate.speckle.dev' }}
|
speckle_automate_url: ${{ env.SPECKLE_AUTOMATE_URL || 'https://automate.speckle.dev' }}
|
||||||
speckle_token: ${{ secrets.SPECKLE_FUNCTION_TOKEN }}
|
speckle_token: ${{ secrets.SPECKLE_FUNCTION_TOKEN }}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
"""This module contains the business logic of the function.
|
"""This module contains the business logic of the function.
|
||||||
|
|
||||||
use the automation_context module to wrap your function in an Autamate context helper
|
Use the automation_context module to wrap your function in an Autamate context helper
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
from speckle_automate import (
|
from speckle_automate import (
|
||||||
AutomateBase,
|
AutomateBase,
|
||||||
@@ -48,27 +46,22 @@ def automate_function(
|
|||||||
# the context provides a conveniet way, to receive the triggering version
|
# the context provides a conveniet way, to receive the triggering version
|
||||||
version_root_object = automate_context.receive_version()
|
version_root_object = automate_context.receive_version()
|
||||||
|
|
||||||
sleep_cycles = 10
|
objects_with_forbidden_speckle_type = [
|
||||||
for i in range(sleep_cycles):
|
b
|
||||||
print(f"sleeping {i}/{sleep_cycles}")
|
for b in flatten_base(version_root_object)
|
||||||
time.sleep(5)
|
if b.speckle_type == function_inputs.forbidden_speckle_type
|
||||||
|
]
|
||||||
count = 0
|
count = len(objects_with_forbidden_speckle_type)
|
||||||
for b in flatten_base(version_root_object):
|
|
||||||
if b.speckle_type == function_inputs.forbidden_speckle_type:
|
|
||||||
if not b.id:
|
|
||||||
raise ValueError("Cannot operate on objects without their id's.")
|
|
||||||
|
|
||||||
automate_context.attach_error_to_objects(
|
|
||||||
category="Forbidden speckle_type",
|
|
||||||
object_ids=b.id,
|
|
||||||
message="This project should not contain the type: "
|
|
||||||
f"{b.speckle_type}",
|
|
||||||
)
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
if count > 0:
|
if count > 0:
|
||||||
# this is how a run is marked with a failure cause
|
# this is how a run is marked with a failure cause
|
||||||
|
automate_context.attach_error_to_objects(
|
||||||
|
category="Forbidden speckle_type"
|
||||||
|
" ({function_inputs.forbidden_speckle_type})",
|
||||||
|
object_ids=[o.id for o in objects_with_forbidden_speckle_type if o.id],
|
||||||
|
message="This project should not contain the type: "
|
||||||
|
f"{function_inputs.forbidden_speckle_type}",
|
||||||
|
)
|
||||||
automate_context.mark_run_failed(
|
automate_context.mark_run_failed(
|
||||||
"Automation failed: "
|
"Automation failed: "
|
||||||
f"Found {count} object that have one of the forbidden speckle types: "
|
f"Found {count} object that have one of the forbidden speckle types: "
|
||||||
|
|||||||
Reference in New Issue
Block a user