Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2eec40a4be | |||
| c0fecb160b | |||
| 4b9d6b051d | |||
| 35ca711c5f | |||
| 811bc7f95b | |||
| 5c0ac4e8e8 |
@@ -29,7 +29,7 @@ jobs:
|
||||
run: |
|
||||
python main.py generate_schema ${HOME}/${{ env.FUNCTION_SCHEMA_FILE_NAME }}
|
||||
- name: Speckle Automate Function - Build and Publish
|
||||
uses: specklesystems/speckle-automate-github-composite-action@0.8.0
|
||||
uses: specklesystems/speckle-automate-github-composite-action@0.8.1
|
||||
with:
|
||||
speckle_automate_url: ${{ env.SPECKLE_AUTOMATE_URL || 'https://automate.speckle.dev' }}
|
||||
speckle_token: ${{ secrets.SPECKLE_FUNCTION_TOKEN }}
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Speckle Automate function",
|
||||
"type": "python",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "main.py",
|
||||
"console": "integratedTerminal",
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
"speckleToken": "YOUR SPEKCLE TOKEN",
|
||||
"functionInputs": {
|
||||
"whisperMessage": "you are doing something weird",
|
||||
"forbiddenSpeckleType": ""
|
||||
"forbiddenSpeckleType": "wall"
|
||||
},
|
||||
"automationRunData": {
|
||||
"project_id": "project id",
|
||||
"model_id": "model id",
|
||||
"branch_name": "branch name",
|
||||
"version_id": "version id",
|
||||
"speckle_server_url": "https://latest.speckle.systems",
|
||||
"automation_id": "automation id",
|
||||
"automation_revision_id": "automation revision id",
|
||||
"automation_run_id": "automation run id",
|
||||
"function_id": "function id",
|
||||
"function_name": "function name",
|
||||
"function_logo": null
|
||||
"function_run_id": "function run id",
|
||||
"triggers": [
|
||||
{
|
||||
"payload": { "modelId": "model id", "versionId": "version id" },
|
||||
"triggerType": "versionCreation"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+17
-3
@@ -6,8 +6,22 @@ from specklepy.objects import Base
|
||||
|
||||
|
||||
def flatten_base(base: Base) -> Iterable[Base]:
|
||||
"""Take a base and flatten it to an iterable of bases."""
|
||||
if hasattr(base, "elements"):
|
||||
for element in base["elements"]:
|
||||
"""Flatten a base object into an iterable of bases.
|
||||
|
||||
This function recursively traverses the `elements` or `@elements` attribute of the
|
||||
base object, yielding each nested base object.
|
||||
|
||||
Args:
|
||||
base (Base): The base object to flatten.
|
||||
|
||||
Yields:
|
||||
Base: Each nested base object in the hierarchy.
|
||||
"""
|
||||
# Attempt to get the elements attribute, fallback to @elements if necessary
|
||||
elements = getattr(base, "elements", getattr(base, "@elements", None))
|
||||
|
||||
if elements is not None:
|
||||
for element in elements:
|
||||
yield from flatten_base(element)
|
||||
|
||||
yield base
|
||||
|
||||
Generated
+451
-443
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -7,7 +7,7 @@ readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
specklepy = "2.17.16"
|
||||
specklepy = "^2.19.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.3.0"
|
||||
|
||||
+21
-5
@@ -1,11 +1,16 @@
|
||||
"""Run integration tests with a speckle server."""
|
||||
|
||||
import os
|
||||
import secrets
|
||||
import string
|
||||
|
||||
from pydantic import SecretStr
|
||||
from specklepy.logging.exceptions import SpeckleException
|
||||
|
||||
import pytest
|
||||
from gql import gql
|
||||
from speckle_automate import (
|
||||
AutomationContext,
|
||||
AutomationRunData,
|
||||
AutomationStatus,
|
||||
run_function,
|
||||
@@ -115,6 +120,8 @@ def automation_run_data(
|
||||
test_object, [ServerTransport(project_id, test_client)]
|
||||
)
|
||||
version_id = test_client.commit.create(project_id, root_obj_id)
|
||||
if isinstance(version_id, SpeckleException):
|
||||
raise version_id
|
||||
|
||||
automation_name = crypto_random_string(10)
|
||||
automation_id = crypto_random_string(10)
|
||||
@@ -131,7 +138,7 @@ def automation_run_data(
|
||||
|
||||
automation_run_id = crypto_random_string(10)
|
||||
function_id = crypto_random_string(10)
|
||||
function_revision = crypto_random_string(10)
|
||||
|
||||
return AutomationRunData(
|
||||
project_id=project_id,
|
||||
model_id=model_id,
|
||||
@@ -142,17 +149,26 @@ def automation_run_data(
|
||||
automation_revision_id=automation_revision_id,
|
||||
automation_run_id=automation_run_id,
|
||||
function_id=function_id,
|
||||
function_revision=function_revision,
|
||||
function_name=crypto_random_string(10),
|
||||
function_logo=None,
|
||||
)
|
||||
|
||||
|
||||
@pytest.makr.skip(
|
||||
"For now the new automate experience doesn't have an easy testing mechanism"
|
||||
)
|
||||
def test_function_run(automation_run_data: AutomationRunData, speckle_token: str):
|
||||
"""Run an integration test for the automate function."""
|
||||
automation_context = AutomationContext.initialize(
|
||||
automation_run_data, speckle_token
|
||||
)
|
||||
automate_sdk = run_function(
|
||||
automation_context,
|
||||
automate_function,
|
||||
automation_run_data,
|
||||
speckle_token,
|
||||
FunctionInputs(forbidden_speckle_type="Base"),
|
||||
FunctionInputs(
|
||||
forbidden_speckle_type="Base",
|
||||
whisper_message=SecretStr("testing automatically"),
|
||||
),
|
||||
)
|
||||
|
||||
assert automate_sdk.run_status == AutomationStatus.FAILED
|
||||
|
||||
Reference in New Issue
Block a user