7 Commits

Author SHA1 Message Date
Gergő Jedlicska 67cb33373b feat: update to new specklepy
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
2024-06-03 16:19:09 +02:00
Gergő Jedlicska 2eec40a4be feat: update to new automate (#22)
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
2024-05-17 14:59:27 +02:00
Jonathon Broughton c0fecb160b Enhance robustness of the basic flatten command (#20)
Older connector versions and still some edge cases in the current set refer to elements with the @ decorator  (Groups in Revit for example)
2024-05-16 18:45:32 +02:00
s 4b9d6b051d added NoneType check (#16) 2024-03-14 12:19:41 +01:00
dependabot[bot] 35ca711c5f chore(deps): bump specklesystems/speckle-automate-github-composite-action (#14)
Bumps [specklesystems/speckle-automate-github-composite-action](https://github.com/specklesystems/speckle-automate-github-composite-action) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/specklesystems/speckle-automate-github-composite-action/releases)
- [Commits](https://github.com/specklesystems/speckle-automate-github-composite-action/compare/0.8.0...0.8.1)

---
updated-dependencies:
- dependency-name: specklesystems/speckle-automate-github-composite-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-12 08:42:59 +00:00
Gergő Jedlicska 811bc7f95b fix: update local testing setup (#13) 2024-02-09 11:36:03 +01:00
Gergő Jedlicska 5c0ac4e8e8 feat: bump specklepy version 2024-01-19 19:36:56 +01:00
7 changed files with 507 additions and 469 deletions
+1 -1
View File
@@ -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.8.0 uses: specklesystems/speckle-automate-github-composite-action@0.8.1
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 -1
View File
@@ -6,7 +6,7 @@
"configurations": [ "configurations": [
{ {
"name": "Speckle Automate function", "name": "Speckle Automate function",
"type": "python", "type": "debugpy",
"request": "launch", "request": "launch",
"program": "main.py", "program": "main.py",
"console": "integratedTerminal", "console": "integratedTerminal",
+8 -8
View File
@@ -2,19 +2,19 @@
"speckleToken": "YOUR SPEKCLE TOKEN", "speckleToken": "YOUR SPEKCLE TOKEN",
"functionInputs": { "functionInputs": {
"whisperMessage": "you are doing something weird", "whisperMessage": "you are doing something weird",
"forbiddenSpeckleType": "" "forbiddenSpeckleType": "wall"
}, },
"automationRunData": { "automationRunData": {
"project_id": "project id", "project_id": "project id",
"model_id": "model id",
"branch_name": "branch name",
"version_id": "version id",
"speckle_server_url": "https://latest.speckle.systems", "speckle_server_url": "https://latest.speckle.systems",
"automation_id": "automation id", "automation_id": "automation id",
"automation_revision_id": "automation revision id",
"automation_run_id": "automation run id", "automation_run_id": "automation run id",
"function_id": "function id", "function_run_id": "function run id",
"function_name": "function name", "triggers": [
"function_logo": null {
"payload": { "modelId": "model id", "versionId": "version id" },
"triggerType": "versionCreation"
}
]
} }
} }
+17 -3
View File
@@ -6,8 +6,22 @@ from specklepy.objects import Base
def flatten_base(base: Base) -> Iterable[Base]: def flatten_base(base: Base) -> Iterable[Base]:
"""Take a base and flatten it to an iterable of bases.""" """Flatten a base object into an iterable of bases.
if hasattr(base, "elements"):
for element in base["elements"]: 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 from flatten_base(element)
yield base yield base
Generated
+458 -450
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -7,7 +7,7 @@ readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.11" python = "^3.11"
specklepy = "2.17.16" specklepy = "^2.19.2"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
black = "^23.3.0" black = "^23.3.0"
+21 -5
View File
@@ -1,11 +1,16 @@
"""Run integration tests with a speckle server.""" """Run integration tests with a speckle server."""
import os import os
import secrets import secrets
import string import string
from pydantic import SecretStr
from specklepy.logging.exceptions import SpeckleException
import pytest import pytest
from gql import gql from gql import gql
from speckle_automate import ( from speckle_automate import (
AutomationContext,
AutomationRunData, AutomationRunData,
AutomationStatus, AutomationStatus,
run_function, run_function,
@@ -115,6 +120,8 @@ def automation_run_data(
test_object, [ServerTransport(project_id, test_client)] test_object, [ServerTransport(project_id, test_client)]
) )
version_id = test_client.commit.create(project_id, root_obj_id) 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_name = crypto_random_string(10)
automation_id = 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) automation_run_id = crypto_random_string(10)
function_id = crypto_random_string(10) function_id = crypto_random_string(10)
function_revision = crypto_random_string(10)
return AutomationRunData( return AutomationRunData(
project_id=project_id, project_id=project_id,
model_id=model_id, model_id=model_id,
@@ -142,17 +149,26 @@ def automation_run_data(
automation_revision_id=automation_revision_id, automation_revision_id=automation_revision_id,
automation_run_id=automation_run_id, automation_run_id=automation_run_id,
function_id=function_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): def test_function_run(automation_run_data: AutomationRunData, speckle_token: str):
"""Run an integration test for the automate function.""" """Run an integration test for the automate function."""
automation_context = AutomationContext.initialize(
automation_run_data, speckle_token
)
automate_sdk = run_function( automate_sdk = run_function(
automation_context,
automate_function, automate_function,
automation_run_data, FunctionInputs(
speckle_token, forbidden_speckle_type="Base",
FunctionInputs(forbidden_speckle_type="Base"), whisper_message=SecretStr("testing automatically"),
),
) )
assert automate_sdk.run_status == AutomationStatus.FAILED assert automate_sdk.run_status == AutomationStatus.FAILED