Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ec2b59b24 | |||
| 2e0743d626 | |||
| 25f16c700d | |||
| c12799b7c6 | |||
| 4530e0702d | |||
| e9443b22ad | |||
| f1b51848cf | |||
| 08fb3f6cd7 | |||
| fe7909c913 | |||
| a00e16929d | |||
| 44d1ef9f93 | |||
| 404dbd1d1e | |||
| fe03d96ae2 | |||
| 078a6c8da8 | |||
| 905377dea1 | |||
| 62c5114cb3 | |||
| 43a5302a90 | |||
| addaa996ea | |||
| 3b5421a5bc | |||
| 88e8c86fa6 | |||
| d6843b9971 | |||
| 302a9f7f30 | |||
| ede9591c6a | |||
| c5b339d891 | |||
| 2e35fb9e5c | |||
| e6b822b0e3 | |||
| 239bc4b5b9 | |||
| 4eea15ddc1 | |||
| 204aa7466e |
+10
-52
@@ -52,28 +52,26 @@ services:
|
||||
####
|
||||
# Speckle Server
|
||||
#######
|
||||
|
||||
speckle-frontend:
|
||||
image: speckle/speckle-frontend:latest
|
||||
image: speckle/speckle-frontend-2:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "0.0.0.0:8080:8080"
|
||||
environment:
|
||||
FILE_SIZE_LIMIT_MB: 100
|
||||
|
||||
speckle-server:
|
||||
image: speckle/speckle-server:latest
|
||||
restart: always
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD",
|
||||
"node",
|
||||
"-e",
|
||||
"require('node:http').request({headers: {'Content-Type': 'application/json'}, port:3000, hostname:'127.0.0.1', path:'/graphql?query={serverInfo{version}}', method: 'GET' }, (res) => { body = ''; res.on('data', (chunk) => {body += chunk;}); res.on('end', () => {process.exit(res.statusCode != 200 || body.toLowerCase().includes('error'));}); }).end();",
|
||||
]
|
||||
- CMD
|
||||
- /nodejs/bin/node
|
||||
- -e
|
||||
- "try { require('node:http').request({headers: {'Content-Type': 'application/json'}, port:3000, hostname:'127.0.0.1', path:'/readiness', method: 'GET', timeout: 2000 }, (res) => { body = ''; res.on('data', (chunk) => {body += chunk;}); res.on('end', () => {process.exit(res.statusCode != 200 || body.toLowerCase().includes('error'));}); }).end(); } catch { process.exit(1); }"
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 90s
|
||||
ports:
|
||||
- "0.0.0.0:3000:3000"
|
||||
depends_on:
|
||||
@@ -98,6 +96,7 @@ services:
|
||||
S3_CREATE_BUCKET: "true"
|
||||
|
||||
FILE_SIZE_LIMIT_MB: 100
|
||||
MAX_PROJECT_MODELS_PER_PAGE: 500
|
||||
|
||||
# TODO: Change this to a unique secret for this server
|
||||
SESSION_SECRET: "TODO:ReplaceWithLongString"
|
||||
@@ -111,47 +110,6 @@ services:
|
||||
POSTGRES_DB: "speckle"
|
||||
ENABLE_MP: "false"
|
||||
|
||||
preview-service:
|
||||
image: speckle/speckle-preview-service:latest
|
||||
restart: always
|
||||
depends_on:
|
||||
speckle-server:
|
||||
condition: service_healthy
|
||||
mem_limit: "1000m"
|
||||
memswap_limit: "1000m"
|
||||
environment:
|
||||
DEBUG: "preview-service:*"
|
||||
PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"
|
||||
|
||||
webhook-service:
|
||||
image: speckle/speckle-webhook-service:latest
|
||||
restart: always
|
||||
depends_on:
|
||||
speckle-server:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DEBUG: "webhook-service:*"
|
||||
PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"
|
||||
WAIT_HOSTS: postgres:5432
|
||||
|
||||
fileimport-service:
|
||||
image: speckle/speckle-fileimport-service:latest
|
||||
restart: always
|
||||
depends_on:
|
||||
speckle-server:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DEBUG: "fileimport-service:*"
|
||||
PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"
|
||||
WAIT_HOSTS: postgres:5432
|
||||
|
||||
S3_ENDPOINT: "http://minio:9000"
|
||||
S3_ACCESS_KEY: "minioadmin"
|
||||
S3_SECRET_KEY: "minioadmin"
|
||||
S3_BUCKET: "speckle-server"
|
||||
|
||||
SPECKLE_SERVER_URL: "http://speckle-server:3000"
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: speckle-server
|
||||
|
||||
Generated
+682
-493
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,7 @@ pytest-ordering = "^0.6"
|
||||
pytest-cov = "^3.0.0"
|
||||
devtools = "^0.8.0"
|
||||
pylint = "^2.14.4"
|
||||
pydantic-settings = "^2.3.0"
|
||||
mypy = "^0.982"
|
||||
pre-commit = "^2.20.0"
|
||||
commitizen = "^2.38.0"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""This module contains an SDK for working with Speckle Automate."""
|
||||
|
||||
from speckle_automate.automation_context import AutomationContext
|
||||
from speckle_automate.runner import execute_automate_function, run_function
|
||||
from speckle_automate.schema import (
|
||||
|
||||
@@ -264,7 +264,7 @@ class AutomationContext:
|
||||
files = {path_obj.name: open(str(path_obj), "rb")}
|
||||
|
||||
url = (
|
||||
f"{self.automation_run_data.speckle_server_url}/api/stream/"
|
||||
f"{self.automation_run_data.speckle_server_url}api/stream/"
|
||||
f"{self.automation_run_data.project_id}/blob"
|
||||
)
|
||||
data = (
|
||||
@@ -290,6 +290,10 @@ class AutomationContext:
|
||||
"""Mark the current run a failure."""
|
||||
self._mark_run(AutomationStatus.FAILED, status_message)
|
||||
|
||||
def mark_run_exception(self, status_message: str) -> None:
|
||||
"""Mark the current run a failure."""
|
||||
self._mark_run(AutomationStatus.EXCEPTION, status_message)
|
||||
|
||||
def mark_run_success(self, status_message: Optional[str]) -> None:
|
||||
"""Mark the current run a success with an optional message."""
|
||||
self._mark_run(AutomationStatus.SUCCEEDED, status_message)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
"""Some useful helpers for working with automation data."""
|
||||
import secrets
|
||||
import string
|
||||
|
||||
import pytest
|
||||
from gql import gql
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
from speckle_automate.schema import AutomationRunData, TestAutomationRunData
|
||||
from specklepy.api.client import SpeckleClient
|
||||
|
||||
|
||||
class TestAutomationEnvironment(BaseSettings):
|
||||
"""Get known environment variables from local `.env` file"""
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
env_prefix="speckle_",
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
token: str = Field()
|
||||
server_url: str = Field()
|
||||
project_id: str = Field()
|
||||
automation_id: str = Field()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def test_automation_environment() -> TestAutomationEnvironment:
|
||||
return TestAutomationEnvironment()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def test_automation_token(
|
||||
test_automation_environment: TestAutomationEnvironment,
|
||||
) -> str:
|
||||
"""Provide a speckle token for the test suite."""
|
||||
|
||||
return test_automation_environment.token
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def speckle_client(
|
||||
test_automation_environment: TestAutomationEnvironment,
|
||||
) -> SpeckleClient:
|
||||
"""Initialize a SpeckleClient for testing."""
|
||||
speckle_client = SpeckleClient(
|
||||
test_automation_environment.server_url,
|
||||
test_automation_environment.server_url.startswith("https"),
|
||||
)
|
||||
speckle_client.authenticate_with_token(test_automation_environment.token)
|
||||
return speckle_client
|
||||
|
||||
|
||||
def create_test_automation_run(
|
||||
speckle_client: SpeckleClient, project_id: str, test_automation_id: str
|
||||
) -> TestAutomationRunData:
|
||||
"""Create test run to report local test results to"""
|
||||
|
||||
query = gql(
|
||||
"""
|
||||
mutation CreateTestRun(
|
||||
$projectId: ID!,
|
||||
$automationId: ID!
|
||||
) {
|
||||
projectMutations {
|
||||
automationMutations(projectId: $projectId) {
|
||||
createTestAutomationRun(automationId: $automationId) {
|
||||
automationRunId
|
||||
functionRunId
|
||||
triggers {
|
||||
payload {
|
||||
modelId
|
||||
versionId
|
||||
}
|
||||
triggerType
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
params = {"automationId": test_automation_id, "projectId": project_id}
|
||||
|
||||
result = speckle_client.httpclient.execute(query, params)
|
||||
|
||||
print(result)
|
||||
|
||||
return (
|
||||
result.get("projectMutations")
|
||||
.get("automationMutations")
|
||||
.get("createTestAutomationRun")
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def test_automation_run(
|
||||
speckle_client: SpeckleClient,
|
||||
test_automation_environment: TestAutomationEnvironment,
|
||||
) -> TestAutomationRunData:
|
||||
return create_test_automation_run(
|
||||
speckle_client,
|
||||
test_automation_environment.project_id,
|
||||
test_automation_environment.automation_id,
|
||||
)
|
||||
|
||||
|
||||
def create_test_automation_run_data(
|
||||
speckle_client: SpeckleClient,
|
||||
test_automation_environment: TestAutomationEnvironment,
|
||||
) -> AutomationRunData:
|
||||
"""Create automation run data for a new run for a given test automation"""
|
||||
|
||||
test_automation_run_data = create_test_automation_run(
|
||||
speckle_client,
|
||||
test_automation_environment.project_id,
|
||||
test_automation_environment.automation_id,
|
||||
)
|
||||
|
||||
return AutomationRunData(
|
||||
project_id=test_automation_environment.project_id,
|
||||
speckle_server_url=test_automation_environment.server_url,
|
||||
automation_id=test_automation_environment.automation_id,
|
||||
automation_run_id=test_automation_run_data["automationRunId"],
|
||||
function_run_id=test_automation_run_data["functionRunId"],
|
||||
triggers=test_automation_run_data["triggers"],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def test_automation_run_data(
|
||||
speckle_client: SpeckleClient,
|
||||
test_automation_environment: TestAutomationEnvironment,
|
||||
) -> AutomationRunData:
|
||||
return create_test_automation_run_data(speckle_client, test_automation_environment)
|
||||
|
||||
|
||||
def crypto_random_string(length: int) -> str:
|
||||
"""Generate a semi crypto random string of a given length."""
|
||||
alphabet = string.ascii_letters + string.digits
|
||||
return "".join(secrets.choice(alphabet) for _ in range(length)).lower()
|
||||
|
||||
|
||||
__all__ = [
|
||||
"test_automation_environment",
|
||||
"test_automation_token",
|
||||
"speckle_client",
|
||||
"test_automation_run",
|
||||
"test_automation_run_data",
|
||||
]
|
||||
@@ -1,55 +0,0 @@
|
||||
"""Some useful helpers for working with automation data."""
|
||||
import secrets
|
||||
import string
|
||||
|
||||
from gql import gql
|
||||
|
||||
from specklepy.api.client import SpeckleClient
|
||||
|
||||
|
||||
def register_new_automation(
|
||||
speckle_client: SpeckleClient,
|
||||
project_id: str,
|
||||
model_id: str,
|
||||
automation_id: str,
|
||||
automation_name: str,
|
||||
automation_revision_id: str,
|
||||
) -> bool:
|
||||
"""Register a new automation in the speckle server."""
|
||||
query = gql(
|
||||
"""
|
||||
mutation CreateAutomation(
|
||||
$projectId: String!
|
||||
$modelId: String!
|
||||
$automationName: String!
|
||||
$automationId: String!
|
||||
$automationRevisionId: String!
|
||||
) {
|
||||
automationMutations {
|
||||
create(
|
||||
input: {
|
||||
projectId: $projectId
|
||||
modelId: $modelId
|
||||
automationName: $automationName
|
||||
automationId: $automationId
|
||||
automationRevisionId: $automationRevisionId
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
"""
|
||||
)
|
||||
params = {
|
||||
"projectId": project_id,
|
||||
"modelId": model_id,
|
||||
"automationName": automation_name,
|
||||
"automationId": automation_id,
|
||||
"automationRevisionId": automation_revision_id,
|
||||
}
|
||||
return speckle_client.httpclient.execute(query, params)
|
||||
|
||||
|
||||
def crypto_random_string(length: int) -> str:
|
||||
"""Generate a semi crypto random string of a given length."""
|
||||
alphabet = string.ascii_letters + string.digits
|
||||
return "".join(secrets.choice(alphabet) for _ in range(length)).lower()
|
||||
@@ -3,6 +3,7 @@
|
||||
Provides mechanisms to execute any function,
|
||||
that conforms to the AutomateFunction "interface"
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
import traceback
|
||||
@@ -65,7 +66,9 @@ def execute_automate_function(
|
||||
|
||||
|
||||
@overload
|
||||
def execute_automate_function(automate_function: AutomateFunctionWithoutInputs) -> None:
|
||||
def execute_automate_function(
|
||||
automate_function: AutomateFunctionWithoutInputs,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
|
||||
@@ -127,8 +130,10 @@ def execute_automate_function(
|
||||
automate_function, # type: ignore
|
||||
)
|
||||
|
||||
# if we've gotten this far, the execution should technically be completed as expected
|
||||
# thus exiting with 0 is the schemantically correct thing to do
|
||||
exit_code = (
|
||||
0 if automation_context.run_status == AutomationStatus.SUCCEEDED else 1
|
||||
1 if automation_context.run_status == AutomationStatus.EXCEPTION else 0
|
||||
)
|
||||
exit(exit_code)
|
||||
|
||||
@@ -173,6 +178,7 @@ def run_function(
|
||||
if automation_context.run_status not in [
|
||||
AutomationStatus.FAILED,
|
||||
AutomationStatus.SUCCEEDED,
|
||||
AutomationStatus.EXCEPTION,
|
||||
]:
|
||||
automation_context.mark_run_success(
|
||||
"WARNING: Automate assumed a success status,"
|
||||
@@ -181,7 +187,7 @@ def run_function(
|
||||
except Exception:
|
||||
trace = traceback.format_exc()
|
||||
print(trace)
|
||||
automation_context.mark_run_failed(
|
||||
automation_context.mark_run_exception(
|
||||
"Function error. Check the automation run logs for details."
|
||||
)
|
||||
finally:
|
||||
|
||||
@@ -43,6 +43,19 @@ class AutomationRunData(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class TestAutomationRunData(BaseModel):
|
||||
"""Values of the run created in the test automation for local test results."""
|
||||
|
||||
automation_run_id: str
|
||||
function_run_id: str
|
||||
|
||||
triggers: List[VersionCreationTrigger]
|
||||
|
||||
model_config = ConfigDict(
|
||||
alias_generator=camelcase, populate_by_name=True, protected_namespaces=()
|
||||
)
|
||||
|
||||
|
||||
class AutomationStatus(str, Enum):
|
||||
"""Set the status of the automation."""
|
||||
|
||||
@@ -50,6 +63,7 @@ class AutomationStatus(str, Enum):
|
||||
RUNNING = "RUNNING"
|
||||
FAILED = "FAILED"
|
||||
SUCCEEDED = "SUCCEEDED"
|
||||
EXCEPTION = "EXCEPTION"
|
||||
|
||||
|
||||
class ObjectResultLevel(str, Enum):
|
||||
|
||||
@@ -21,7 +21,7 @@ class SpeckleClient(CoreSpeckleClient):
|
||||
The `SpeckleClient` is your entry point for interacting with
|
||||
your Speckle Server's GraphQL API.
|
||||
You'll need to have access to a server to use it,
|
||||
or you can use our public server `speckle.xyz`.
|
||||
or you can use our public server `app.speckle.systems`.
|
||||
|
||||
To authenticate the client, you'll need to have downloaded
|
||||
the [Speckle Manager](https://speckle.guide/#speckle-manager)
|
||||
@@ -32,7 +32,7 @@ class SpeckleClient(CoreSpeckleClient):
|
||||
from specklepy.api.credentials import get_default_account
|
||||
|
||||
# initialise the client
|
||||
client = SpeckleClient(host="speckle.xyz") # or whatever your host is
|
||||
client = SpeckleClient(host="app.speckle.systems") # or whatever your host is
|
||||
# client = SpeckleClient(host="localhost:3000", use_ssl=False) or use local server
|
||||
|
||||
# authenticate the client with an account (account has been added in Speckle Manager)
|
||||
@@ -47,7 +47,7 @@ class SpeckleClient(CoreSpeckleClient):
|
||||
```
|
||||
"""
|
||||
|
||||
DEFAULT_HOST = "speckle.xyz"
|
||||
DEFAULT_HOST = "app.speckle.systems"
|
||||
USE_SSL = True
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -22,7 +22,7 @@ class StreamWrapper(CoreStreamWrapper):
|
||||
from specklepy.api.wrapper import StreamWrapper
|
||||
|
||||
# provide any stream, branch, commit, object, or globals url
|
||||
wrapper = StreamWrapper("https://speckle.xyz/streams/3073b96e86/commits/604bea8cc6")
|
||||
wrapper = StreamWrapper("https://app.speckle.systems/streams/3073b96e86/commits/604bea8cc6")
|
||||
|
||||
# get an authenticated SpeckleClient if you have a local account for the server
|
||||
client = wrapper.get_client()
|
||||
|
||||
@@ -30,7 +30,7 @@ class SpeckleClient:
|
||||
The `SpeckleClient` is your entry point for interacting with
|
||||
your Speckle Server's GraphQL API.
|
||||
You'll need to have access to a server to use it,
|
||||
or you can use our public server `speckle.xyz`.
|
||||
or you can use our public server `app.speckle.systems`.
|
||||
|
||||
To authenticate the client, you'll need to have downloaded
|
||||
the [Speckle Manager](https://speckle.guide/#speckle-manager)
|
||||
@@ -41,7 +41,7 @@ class SpeckleClient:
|
||||
from specklepy.api.credentials import get_default_account
|
||||
|
||||
# initialise the client
|
||||
client = SpeckleClient(host="speckle.xyz") # or whatever your host is
|
||||
client = SpeckleClient(host="app.speckle.systems") # or whatever your host is
|
||||
# client = SpeckleClient(host="localhost:3000", use_ssl=False) or use local server
|
||||
|
||||
# authenticate the client with an account (account has been added in Speckle Manager)
|
||||
@@ -56,7 +56,7 @@ class SpeckleClient:
|
||||
```
|
||||
"""
|
||||
|
||||
DEFAULT_HOST = "speckle.xyz"
|
||||
DEFAULT_HOST = "app.speckle.systems"
|
||||
USE_SSL = True
|
||||
|
||||
def __init__(
|
||||
@@ -64,6 +64,8 @@ class SpeckleClient:
|
||||
host: str = DEFAULT_HOST,
|
||||
use_ssl: bool = USE_SSL,
|
||||
verify_certificate: bool = True,
|
||||
connection_retries: int = 3,
|
||||
connection_timeout: int = 10,
|
||||
) -> None:
|
||||
ws_protocol = "ws"
|
||||
http_protocol = "http"
|
||||
@@ -80,10 +82,15 @@ class SpeckleClient:
|
||||
self.ws_url = f"{ws_protocol}://{host}/graphql"
|
||||
self.account = Account()
|
||||
self.verify_certificate = verify_certificate
|
||||
self.connection_retries = connection_retries
|
||||
self.connection_timeout = connection_timeout
|
||||
|
||||
self.httpclient = Client(
|
||||
transport=RequestsHTTPTransport(
|
||||
url=self.graphql, verify=self.verify_certificate, retries=3
|
||||
url=self.graphql,
|
||||
verify=self.verify_certificate,
|
||||
retries=self.connection_retries,
|
||||
timeout=self.connection_timeout,
|
||||
)
|
||||
)
|
||||
self.wsclient = None
|
||||
|
||||
@@ -30,7 +30,7 @@ class StreamWrapper:
|
||||
from specklepy.api.wrapper import StreamWrapper
|
||||
|
||||
# provide any stream, branch, commit, object, or globals url
|
||||
wrapper = StreamWrapper("https://speckle.xyz/streams/3073b96e86/commits/604bea8cc6")
|
||||
wrapper = StreamWrapper("https://app.speckle.systems/streams/3073b96e86/commits/604bea8cc6")
|
||||
|
||||
# get an authenticated SpeckleClient if you have a local account for the server
|
||||
client = wrapper.get_client()
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
"""Builtin Speckle object kit."""
|
||||
|
||||
from specklepy.objects.GIS.CRS import CRS
|
||||
from specklepy.objects.GIS.features import (
|
||||
GisMultipatchFeature,
|
||||
GisNonGeometricFeature,
|
||||
GisPointFeature,
|
||||
GisPolygonFeature,
|
||||
GisPolylineFeature,
|
||||
)
|
||||
from specklepy.objects.GIS.geometry import (
|
||||
GisLineElement,
|
||||
GisPointElement,
|
||||
GisPolygonElement,
|
||||
GisPolygonGeometry,
|
||||
GisRasterElement,
|
||||
PolygonGeometry,
|
||||
PolygonGeometry3d,
|
||||
GisMultipatchGeometry,
|
||||
)
|
||||
from specklepy.objects.GIS.layers import RasterLayer, VectorLayer
|
||||
|
||||
@@ -14,9 +24,17 @@ __all__ = [
|
||||
"VectorLayer",
|
||||
"RasterLayer",
|
||||
"GisPolygonGeometry",
|
||||
"PolygonGeometry",
|
||||
"PolygonGeometry3d",
|
||||
"GisMultipatchGeometry",
|
||||
"GisPolygonElement",
|
||||
"GisLineElement",
|
||||
"GisPointElement",
|
||||
"GisRasterElement",
|
||||
"CRS",
|
||||
"GisPointFeature",
|
||||
"GisPolylineFeature",
|
||||
"GisPolygonFeature",
|
||||
"GisMultipatchFeature",
|
||||
"GisNonGeometricFeature",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
from typing import List, Optional
|
||||
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.geometry import Mesh, Point, Polyline
|
||||
from specklepy.objects.GIS.geometry import PolygonGeometry
|
||||
|
||||
|
||||
class GisNonGeometricFeature(Base, speckle_type="Objects.GIS.GisNonGeometricFeature"):
|
||||
"""GIS Table feature"""
|
||||
|
||||
attributes: Base
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
attributes: Optional[Base] = None,
|
||||
) -> None:
|
||||
self.attributes = attributes or Base()
|
||||
|
||||
|
||||
class GisPointFeature(
|
||||
Base,
|
||||
detachable={"displayValue"},
|
||||
speckle_type="Objects.GIS.GisPointFeature",
|
||||
):
|
||||
"""Gis Point Feature"""
|
||||
|
||||
attributes: Base
|
||||
displayValue: List[Point]
|
||||
|
||||
@property
|
||||
def geometry(self) -> List[Point]:
|
||||
return self.displayValue
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
attributes: Optional[Base] = None,
|
||||
displayValue: Optional[List[Point]] = None,
|
||||
) -> None:
|
||||
self.attributes = attributes or Base()
|
||||
displayValue = displayValue or []
|
||||
|
||||
|
||||
class GisPolylineFeature(
|
||||
Base,
|
||||
detachable={"displayValue"},
|
||||
speckle_type="Objects.GIS.GisPolylineFeature",
|
||||
):
|
||||
"""Gis Polyline Feature"""
|
||||
|
||||
attributes: Base
|
||||
displayValue: List[Polyline]
|
||||
|
||||
@property
|
||||
def geometry(self) -> List[Polyline]:
|
||||
return self.displayValue
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
attributes: Optional[Base] = None,
|
||||
displayValue: Optional[List[Point]] = None,
|
||||
) -> None:
|
||||
self.attributes = attributes or Base()
|
||||
displayValue = displayValue or []
|
||||
|
||||
|
||||
class GisPolygonFeature(
|
||||
Base,
|
||||
detachable={"displayValue", "geometry"},
|
||||
speckle_type="Objects.GIS.GisPolygonFeature",
|
||||
):
|
||||
"""Gis Polygon Feature"""
|
||||
|
||||
attributes: Base
|
||||
displayValue: List[Mesh]
|
||||
geometry: List[PolygonGeometry]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
geometry: List[PolygonGeometry],
|
||||
attributes: Optional[Base] = None,
|
||||
displayValue: Optional[List[Point]] = None,
|
||||
) -> None:
|
||||
self.geometry = geometry
|
||||
self.attributes = attributes or Base()
|
||||
displayValue = displayValue or []
|
||||
|
||||
|
||||
class GisMultipatchFeature(
|
||||
Base,
|
||||
detachable={"displayValue", "geometry"},
|
||||
speckle_type="Objects.GIS.GisMultipatchFeature",
|
||||
):
|
||||
"""Gis Multipatch Feature"""
|
||||
|
||||
attributes: Base
|
||||
displayValue: List[Mesh]
|
||||
geometry: List[Base] # GisMultipatchGeometry or PolygonGeometry3d
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
geometry: List[Base],
|
||||
attributes: Optional[Base] = None,
|
||||
displayValue: Optional[List[Point]] = None,
|
||||
) -> None:
|
||||
self.geometry = geometry
|
||||
self.attributes = attributes or Base()
|
||||
displayValue = displayValue or []
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from deprecated import deprecated
|
||||
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.geometry import (
|
||||
Arc,
|
||||
@@ -12,23 +14,69 @@ from specklepy.objects.geometry import (
|
||||
)
|
||||
|
||||
|
||||
class GisPolygonGeometry(
|
||||
Base, speckle_type="Objects.GIS.PolygonGeometry", detachable={"displayValue"}
|
||||
):
|
||||
class PolygonGeometry(Base, speckle_type="Objects.GIS.PolygonGeometry"):
|
||||
"""GIS Polygon Geometry"""
|
||||
|
||||
boundary: Optional[Union[Polyline, Arc, Line, Circle, Polycurve]] = None
|
||||
voids: Optional[List[Union[Polyline, Arc, Line, Circle, Polycurve]]] = None
|
||||
displayValue: Optional[List[Mesh]] = None
|
||||
boundary: Polyline
|
||||
voids: List[Polyline]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
units: str,
|
||||
boundary: Polyline,
|
||||
voids: Optional[List[Polyline]] = None,
|
||||
) -> None:
|
||||
super().__init__(units=units)
|
||||
self.boundary = boundary
|
||||
self.voids = voids or []
|
||||
|
||||
|
||||
GisPolygonGeometry = PolygonGeometry
|
||||
|
||||
|
||||
class PolygonGeometry3d(
|
||||
PolygonGeometry,
|
||||
speckle_type="Objects.GIS.PolygonGeometry3d",
|
||||
):
|
||||
"""GIS Polygon3d Geometry"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
units: str,
|
||||
boundary: Polyline,
|
||||
voids: Optional[List[Polyline]] = None,
|
||||
) -> None:
|
||||
super().__init__(units=units, boundary=boundary, voids=voids)
|
||||
|
||||
|
||||
class GisMultipatchGeometry(
|
||||
Base,
|
||||
speckle_type="Objects.GIS.GisMultipatchGeometry",
|
||||
):
|
||||
"""GIS Polygon3d Geometry"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
units: str,
|
||||
faces: List[int],
|
||||
vertices: List[float],
|
||||
colors: Optional[List[int]],
|
||||
) -> None:
|
||||
super().__init__(units=units)
|
||||
self.faces = faces
|
||||
self.vertices = vertices
|
||||
self.colors = colors or []
|
||||
|
||||
|
||||
@deprecated(version="2.20", reason="Replaced with GisPolygonFeature")
|
||||
class GisPolygonElement(Base, speckle_type="Objects.GIS.PolygonElement"):
|
||||
"""GIS Polygon element"""
|
||||
|
||||
geometry: Optional[List[GisPolygonGeometry]] = None
|
||||
geometry: Optional[List[PolygonGeometry]] = None
|
||||
attributes: Optional[Base] = None
|
||||
|
||||
|
||||
@deprecated(version="2.20", reason="Replaced with GisPolyineFeature")
|
||||
class GisLineElement(Base, speckle_type="Objects.GIS.LineElement"):
|
||||
"""GIS Polyline element"""
|
||||
|
||||
@@ -36,6 +84,7 @@ class GisLineElement(Base, speckle_type="Objects.GIS.LineElement"):
|
||||
attributes: Optional[Base] = None
|
||||
|
||||
|
||||
@deprecated(version="2.20", reason="Replaced with GisPointFeature")
|
||||
class GisPointElement(Base, speckle_type="Objects.GIS.PointElement"):
|
||||
"""GIS Point element"""
|
||||
|
||||
@@ -68,6 +117,7 @@ class GisTopography(
|
||||
"""GIS Raster element with 3d Topography representation"""
|
||||
|
||||
|
||||
@deprecated(version="2.20", reason="Replaced with GisNonGeometricFeature")
|
||||
class GisNonGeometryElement(Base, speckle_type="Objects.GIS.NonGeometryElement"):
|
||||
"""GIS Table feature"""
|
||||
|
||||
|
||||
@@ -295,17 +295,33 @@ class RevitParameter(Base, speckle_type="Objects.BuiltElements.Revit.Parameter")
|
||||
value: Any = None
|
||||
applicationUnitType: Optional[str] = None # eg UnitType UT_Length
|
||||
applicationUnit: Optional[str] = None # DisplayUnitType eg DUT_MILLIMITERS
|
||||
applicationInternalName: Optional[
|
||||
str
|
||||
] = None # BuiltInParameterName or GUID for shared parameter
|
||||
applicationInternalName: Optional[str] = (
|
||||
None # BuiltInParameterName or GUID for shared parameter
|
||||
)
|
||||
isShared: bool = False
|
||||
isReadOnly: bool = False
|
||||
isTypeParameter: bool = False
|
||||
|
||||
|
||||
@deprecated(
|
||||
version="2.20", reason="Collections namespace changed, collectionType deprecated"
|
||||
)
|
||||
class Collection(
|
||||
Base, speckle_type="Speckle.Core.Models.Collection", detachable={"elements"}
|
||||
):
|
||||
name: Optional[str] = None
|
||||
collectionType: Optional[str] = None
|
||||
elements: Optional[List[Base]] = None
|
||||
|
||||
|
||||
class Collection( # noqa: F811
|
||||
Base,
|
||||
speckle_type="Speckle.Core.Models.Collections.Collection",
|
||||
detachable={"elements"},
|
||||
):
|
||||
name: str
|
||||
elements: List[Base]
|
||||
|
||||
def init(self, name: str, elements: Optional[List[Base]] = None):
|
||||
self.name = name
|
||||
self.elements = elements or []
|
||||
|
||||
@@ -23,7 +23,7 @@ def host():
|
||||
def seed_user(host):
|
||||
seed = uuid.uuid4().hex
|
||||
user_dict = {
|
||||
"email": f"{seed[0:7]}@spockle.com",
|
||||
"email": f"{seed[0:7]}@example.org",
|
||||
"password": "$uper$3cr3tP@ss",
|
||||
"name": f"{seed[0:7]} Name",
|
||||
"company": "test spockle",
|
||||
|
||||
@@ -12,12 +12,13 @@ from speckle_automate import (
|
||||
AutomationStatus,
|
||||
run_function,
|
||||
)
|
||||
from speckle_automate.helpers import crypto_random_string, register_new_automation
|
||||
from speckle_automate.fixtures import (
|
||||
create_test_automation_run_data,
|
||||
crypto_random_string,
|
||||
)
|
||||
from speckle_automate.schema import AutomateBase
|
||||
from specklepy.api import operations
|
||||
from specklepy.api.client import SpeckleClient
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.transports.server import ServerTransport
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -40,58 +41,16 @@ def test_client(speckle_server_url: str, speckle_token: str) -> SpeckleClient:
|
||||
return test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_object() -> Base:
|
||||
"""Create a Base model for testing."""
|
||||
root_object = Base()
|
||||
root_object.foo = "bar"
|
||||
return root_object
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def automation_run_data(
|
||||
test_object: Base, test_client: SpeckleClient, speckle_server_url: str
|
||||
test_client: SpeckleClient, speckle_server_url: str
|
||||
) -> AutomationRunData:
|
||||
"""Set up an automation context for testing."""
|
||||
project_id = test_client.stream.create("Automate function e2e test")
|
||||
branch_name = "main"
|
||||
"""TODO: Set up a test automation for integration testing"""
|
||||
project_id = crypto_random_string(10)
|
||||
test_automation_id = crypto_random_string(10)
|
||||
|
||||
model = test_client.branch.get(project_id, branch_name, commits_limit=1)
|
||||
model_id: str = model.id
|
||||
|
||||
root_obj_id = operations.send(
|
||||
test_object, [ServerTransport(project_id, test_client)]
|
||||
)
|
||||
version_id = test_client.commit.create(project_id, root_obj_id)
|
||||
|
||||
automation_name = crypto_random_string(10)
|
||||
automation_id = crypto_random_string(10)
|
||||
automation_revision_id = crypto_random_string(10)
|
||||
|
||||
register_new_automation(
|
||||
test_client,
|
||||
project_id,
|
||||
model_id,
|
||||
automation_id,
|
||||
automation_name,
|
||||
automation_revision_id,
|
||||
)
|
||||
|
||||
automation_run_id = crypto_random_string(10)
|
||||
function_id = crypto_random_string(10)
|
||||
function_name = f"automate test {crypto_random_string(3)}"
|
||||
return AutomationRunData(
|
||||
project_id=project_id,
|
||||
model_id=model_id,
|
||||
branch_name=branch_name,
|
||||
version_id=version_id,
|
||||
speckle_server_url=speckle_server_url,
|
||||
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=None,
|
||||
return create_test_automation_run_data(
|
||||
test_client, speckle_server_url, project_id, test_automation_id
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ class TestStream:
|
||||
# NOTE: only works for server admins
|
||||
# invited = client.stream.invite_batch(
|
||||
# stream_id=stream.id,
|
||||
# emails=["userA@speckle.xyz", "userB@speckle.xyz"],
|
||||
# emails=["userA@example.org", "userB@example.org"],
|
||||
# user_ids=[second_user.id],
|
||||
# message="yeehaw 🤠",
|
||||
# )
|
||||
@@ -192,7 +192,7 @@ class TestStream:
|
||||
|
||||
# invited_only_email = client.stream.invite_batch(
|
||||
# stream_id=stream.id,
|
||||
# emails=["userC@speckle.xyz"],
|
||||
# emails=["userC@example.org"],
|
||||
# message="yeehaw 🤠",
|
||||
# )
|
||||
|
||||
|
||||
@@ -100,16 +100,20 @@ def test_parse_globals_as_commit():
|
||||
|
||||
|
||||
#! NOTE: the following three tests may not pass locally
|
||||
# if you have a `speckle.xyz` account in manager
|
||||
# if you have a `app.speckle.systems` account in manager
|
||||
def test_get_client_without_auth():
|
||||
wrap = StreamWrapper("https://speckle.xyz/streams/4c3ce1459c/commits/8b9b831792")
|
||||
wrap = StreamWrapper(
|
||||
"https://app.speckle.systems/streams/4c3ce1459c/commits/8b9b831792"
|
||||
)
|
||||
client = wrap.get_client()
|
||||
|
||||
assert client is not None
|
||||
|
||||
|
||||
def test_get_new_client_with_token(user_path):
|
||||
wrap = StreamWrapper("https://speckle.xyz/streams/4c3ce1459c/commits/8b9b831792")
|
||||
wrap = StreamWrapper(
|
||||
"https://app.speckle.systems/streams/4c3ce1459c/commits/8b9b831792"
|
||||
)
|
||||
client = wrap.get_client()
|
||||
client = wrap.get_client(token="super-secret-token")
|
||||
|
||||
@@ -117,7 +121,9 @@ def test_get_new_client_with_token(user_path):
|
||||
|
||||
|
||||
def test_get_transport_with_token():
|
||||
wrap = StreamWrapper("https://speckle.xyz/streams/4c3ce1459c/commits/8b9b831792")
|
||||
wrap = StreamWrapper(
|
||||
"https://app.speckle.systems/streams/4c3ce1459c/commits/8b9b831792"
|
||||
)
|
||||
client = wrap.get_client()
|
||||
assert not client.account.token # unauthenticated bc no local accounts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user