Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee55680b03 | |||
| 0728239915 | |||
| 77016e6f0b | |||
| ce39aa5101 | |||
| f32196ce1b | |||
| 6b24e187a5 | |||
| 129d25df0e | |||
| fa31bd0223 | |||
| 21209b384d | |||
| 1a9c95871f | |||
| dc4d583121 | |||
| ed39f0288f | |||
| 3830706eb1 | |||
| f7ae62ade2 | |||
| 38ffbc27b7 | |||
| 8cebccf250 | |||
| 17aac0b552 | |||
| c281a329a4 | |||
| ca472716db | |||
| af50afe3ff | |||
| b6493df77f | |||
| 59d3c8c3ea | |||
| 4e3405f1fb | |||
| 3772c10b31 | |||
| 242be2fa60 | |||
| 49eabdd712 | |||
| 96a31f0678 | |||
| 91506b0b20 | |||
| b0de9e31b5 | |||
| 2075783134 | |||
| 071f2449c3 | |||
| ffa4f29200 | |||
| 40a691b098 | |||
| 487ce3aeb4 | |||
| 6c0f10ae45 | |||
| 436b26c91c | |||
| f7bac26aed | |||
| a31c049b51 | |||
| a419664461 | |||
| 4a0c07009b | |||
| 682bcbfa9f | |||
| ccf284e8fa | |||
| 23102a28ff | |||
| 5475edb253 | |||
| c52f80c1ef | |||
| 21eecfa24c | |||
| 5dde1bfcf1 | |||
| 82c9d874c9 | |||
| 9acf2c8a92 | |||
| 95012e60c1 | |||
| 19b6500bbd | |||
| e5a8b40bb2 |
+13
-4
@@ -2,14 +2,15 @@ version: 2.1
|
||||
|
||||
orbs:
|
||||
python: circleci/python@1.3.2
|
||||
codecov: codecov/codecov@3.2.2
|
||||
|
||||
jobs:
|
||||
test:
|
||||
docker:
|
||||
- image: "cimg/python:<<parameters.tag>>"
|
||||
- image: "circleci/node:12"
|
||||
- image: "circleci/redis:6"
|
||||
- image: "circleci/postgres:12"
|
||||
- image: 'cimg/node:14.18'
|
||||
- image: 'circleci/redis:6'
|
||||
- image: 'cimg/postgres:12.8'
|
||||
environment:
|
||||
POSTGRES_DB: speckle2_test
|
||||
POSTGRES_PASSWORD: speckle
|
||||
@@ -38,7 +39,15 @@ jobs:
|
||||
name: upgrade pip
|
||||
- python/install-packages:
|
||||
pkg-manager: poetry
|
||||
- run: poetry run pytest
|
||||
- run: poetry run pytest --cov --cov-report xml:reports/coverage.xml --junitxml=reports/test-results.xml
|
||||
|
||||
- store_test_results:
|
||||
path: reports
|
||||
|
||||
- store_artifacts:
|
||||
path: reports
|
||||
|
||||
- codecov/upload
|
||||
|
||||
deploy:
|
||||
docker:
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/python-3/.devcontainer/base.Dockerfile
|
||||
|
||||
# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
|
||||
ARG VARIANT="3.9"
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
|
||||
|
||||
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
|
||||
ARG NODE_VERSION="none"
|
||||
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
||||
|
||||
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
|
||||
# COPY requirements.txt /tmp/pip-tmp/
|
||||
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
|
||||
# && rm -rf /tmp/pip-tmp
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
# [Optional] Uncomment this line to install global node packages.
|
||||
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
||||
|
||||
USER vscode
|
||||
|
||||
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
|
||||
|
||||
ENV PATH=$PATH:$HOME/.poetry/env
|
||||
@@ -0,0 +1,52 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/python-3
|
||||
{
|
||||
"name": "Python 3",
|
||||
// "build": {
|
||||
// "dockerfile": "Dockerfile",
|
||||
// "context": "..",
|
||||
// "args": {
|
||||
// // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
|
||||
// "VARIANT": "3.6",
|
||||
// // Options
|
||||
// "NODE_VERSION": "lts/*"
|
||||
// }
|
||||
// },
|
||||
"dockerComposeFile": "./docker-compose.yaml",
|
||||
"service": "specklepy",
|
||||
"workspaceFolder": "/workspaces/specklepy",
|
||||
"shutdownAction": "stopCompose",
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {
|
||||
"python.pythonPath": "/usr/local/bin/python",
|
||||
"python.languageServer": "Pylance",
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.pylintEnabled": true,
|
||||
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
|
||||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
|
||||
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
|
||||
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
|
||||
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
|
||||
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
|
||||
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
|
||||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
|
||||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
|
||||
"python.testing.pytestArgs": [
|
||||
"tests/",
|
||||
"-s"
|
||||
],
|
||||
"python.testing.pytestEnabled": true,
|
||||
"editor.formatOnSave": true,
|
||||
},
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance"
|
||||
],
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "poetry config virtualenvs.create false && poetry install",
|
||||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "vscode"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
version: "3.3" # optional since v1.27.0
|
||||
services:
|
||||
postgres:
|
||||
image: circleci/postgres:12
|
||||
environment:
|
||||
POSTGRES_DB: speckle2_test
|
||||
POSTGRES_PASSWORD: speckle
|
||||
POSTGRES_USER: speckle
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
network_mode: host
|
||||
redis:
|
||||
image: circleci/redis:6
|
||||
# ports:
|
||||
# - "6379:6379"
|
||||
network_mode: host
|
||||
speckle-server:
|
||||
image: speckle/speckle-server
|
||||
command: ["bash", "-c", "/wait && node bin/www"]
|
||||
environment:
|
||||
POSTGRES_URL: "localhost"
|
||||
POSTGRES_USER: "speckle"
|
||||
POSTGRES_PASSWORD: "speckle"
|
||||
POSTGRES_DB: "speckle2_test"
|
||||
REDIS_URL: "redis://localhost"
|
||||
SESSION_SECRET: "keyboard cat"
|
||||
STRATEGY_LOCAL: "true"
|
||||
CANONICAL_URL: "http://localhost:3000"
|
||||
WAIT_HOSTS: localhost:5432, localhost:6379
|
||||
# ports:
|
||||
# - "3000:3000"
|
||||
network_mode: host
|
||||
|
||||
specklepy:
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
args:
|
||||
VARIANT: 3.9
|
||||
NODE_VERSION: lts/*
|
||||
volumes:
|
||||
# Mounts the project folder to '/workspace'. While this file is in .devcontainer,
|
||||
# mounts are relative to the first file in the list, which is a level up.
|
||||
- ..:/workspaces/specklepy:cached
|
||||
# Overrides default command so things don't shut down after the process ends.
|
||||
command: /bin/sh -c "while sleep 1000; do :; done"
|
||||
network_mode: host
|
||||
# networks:
|
||||
# default:
|
||||
@@ -0,0 +1,3 @@
|
||||
* text=auto eol=lf
|
||||
*.{cmd,[cC][mM][dD]} text eol=crlf
|
||||
*.{bat,[bB][aA][tT]} text eol=crlf
|
||||
@@ -1,4 +1,6 @@
|
||||
.tool-versions
|
||||
.envrc
|
||||
reports/
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
<p align="center"><b>Speckle</b> is the data infrastructure for the AEC industry.</p><br/>
|
||||
|
||||
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&style=flat-square&logo=discourse&logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&logo=read-the-docs&logoColor=white" alt="docs"></a></p>
|
||||
<p align="center"><a href="https://github.com/specklesystems/specklepy/"><img src="https://circleci.com/gh/specklesystems/specklepy.svg?style=svg&circle-token=76eabd350ea243575cbb258b746ed3f471f7ac29" alt="Speckle-Next"></a> </p>
|
||||
<p align="center"><a href="https://github.com/specklesystems/specklepy/"><img src="https://circleci.com/gh/specklesystems/specklepy.svg?style=svg&circle-token=76eabd350ea243575cbb258b746ed3f471f7ac29" alt="Speckle-Next"></a><a href="https://codecov.io/gh/specklesystems/specklepy">
|
||||
<img src="https://codecov.io/gh/specklesystems/specklepy/branch/main/graph/badge.svg?token=8KQFL5N0YF"/>
|
||||
</a> </p>
|
||||
|
||||
# About Speckle
|
||||
|
||||
|
||||
Generated
+531
-281
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -12,16 +12,17 @@ homepage = "https://speckle.systems/"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.6.5"
|
||||
pydantic = "^1.7.3"
|
||||
pydantic = "^1.8.2"
|
||||
appdirs = "^1.4.4"
|
||||
gql = {version = ">=3.0.0a6", extras = ["all"], allow-prereleases = true}
|
||||
ujson = "^4.1.0"
|
||||
gql = {version = ">=3.0.0b1", extras = ["all"], allow-prereleases = true}
|
||||
ujson = "^4.3.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = "^20.8b1"
|
||||
isort = "^5.7.0"
|
||||
pytest = "^6.2.2"
|
||||
pytest-ordering = "^0.6"
|
||||
pytest-cov = "^3.0.0"
|
||||
|
||||
|
||||
[tool.black]
|
||||
|
||||
+16
-4
@@ -1,6 +1,10 @@
|
||||
import re
|
||||
from gql.client import SyncClientSession
|
||||
from specklepy.logging.exceptions import SpeckleException
|
||||
from warnings import warn
|
||||
from specklepy.logging.exceptions import (
|
||||
GraphQLException,
|
||||
SpeckleException,
|
||||
SpeckleWarning,
|
||||
)
|
||||
from typing import Dict
|
||||
|
||||
from specklepy.api import resources
|
||||
@@ -14,9 +18,8 @@ from specklepy.api.resources import (
|
||||
subscriptions,
|
||||
)
|
||||
from specklepy.api.models import ServerInfo
|
||||
from gql import Client, gql
|
||||
from gql import Client
|
||||
from gql.transport.requests import RequestsHTTPTransport
|
||||
from gql.transport.aiohttp import AIOHTTPTransport
|
||||
from gql.transport.websockets import WebsocketsTransport
|
||||
|
||||
|
||||
@@ -77,6 +80,8 @@ class SpeckleClient:
|
||||
# Check compatibility with the server
|
||||
try:
|
||||
serverInfo = self.server.get()
|
||||
if isinstance(serverInfo, Exception):
|
||||
raise serverInfo
|
||||
if not isinstance(serverInfo, ServerInfo):
|
||||
raise Exception("Couldn't get ServerInfo")
|
||||
except Exception as ex:
|
||||
@@ -111,6 +116,13 @@ class SpeckleClient:
|
||||
|
||||
self._init_resources()
|
||||
|
||||
if isinstance(self.user.get(), GraphQLException):
|
||||
warn(
|
||||
SpeckleWarning(
|
||||
f"Invalid token - could not authenticate Speckle Client for server {self.url}"
|
||||
)
|
||||
)
|
||||
|
||||
def execute_query(self, query: str) -> Dict:
|
||||
return self.httpclient.execute(query)
|
||||
|
||||
|
||||
@@ -118,8 +118,8 @@ class StreamWrapper:
|
||||
commit_id: str = None
|
||||
object_id: str = None
|
||||
branch_name: str = None
|
||||
client: SpeckleClient = None
|
||||
account: Account = None
|
||||
_client: SpeckleClient = None
|
||||
_account: Account = None
|
||||
|
||||
def __repr__(self):
|
||||
return f"StreamWrapper( server: {self.host}, stream_id: {self.stream_id}, type: {self.type} )"
|
||||
@@ -144,9 +144,9 @@ class StreamWrapper:
|
||||
parsed = urlparse(url)
|
||||
self.host = parsed.netloc
|
||||
self.use_ssl = parsed.scheme == "https"
|
||||
segments = parsed.path.strip("/").split("/")
|
||||
segments = parsed.path.strip("/").split("/", 3)
|
||||
|
||||
if not segments or len(segments) > 4 or len(segments) < 2:
|
||||
if not segments or len(segments) < 2:
|
||||
raise SpeckleException(
|
||||
f"Cannot parse {url} into a stream wrapper class - invalid URL provided."
|
||||
)
|
||||
@@ -179,15 +179,15 @@ class StreamWrapper:
|
||||
"""
|
||||
Gets an account object for this server from the local accounts db (added via Speckle Manager or a json file)
|
||||
"""
|
||||
if self.account:
|
||||
return self.account
|
||||
if self._account:
|
||||
return self._account
|
||||
|
||||
self.account = next(
|
||||
self._account = next(
|
||||
(a for a in get_local_accounts() if self.host in a.serverInfo.url),
|
||||
None,
|
||||
)
|
||||
|
||||
return self.account
|
||||
return self._account
|
||||
|
||||
def get_client(self, token: str = None) -> SpeckleClient:
|
||||
"""
|
||||
@@ -200,22 +200,22 @@ class StreamWrapper:
|
||||
Returns:
|
||||
SpeckleClient -- authenticated with a corresponding local account or the provided token
|
||||
"""
|
||||
if self.client and token is None:
|
||||
return self.client
|
||||
if self._client and token is None:
|
||||
return self._client
|
||||
|
||||
if not self.account:
|
||||
if not self._account:
|
||||
self.get_account()
|
||||
|
||||
if not self.client:
|
||||
self.client = SpeckleClient(host=self.host, use_ssl=self.use_ssl)
|
||||
if not self._client:
|
||||
self._client = SpeckleClient(host=self.host, use_ssl=self.use_ssl)
|
||||
|
||||
if self.account is None and token is None:
|
||||
if self._account is None and token is None:
|
||||
warn(f"No local account found for server {self.host}", SpeckleWarning)
|
||||
return self.client
|
||||
return self._client
|
||||
|
||||
self.client.authenticate(self.account.token if self.account else token)
|
||||
self._client.authenticate(self._account.token if self._account else token)
|
||||
|
||||
return self.client
|
||||
return self._client
|
||||
|
||||
def get_transport(self, token: str = None) -> ServerTransport:
|
||||
"""
|
||||
@@ -225,6 +225,6 @@ class StreamWrapper:
|
||||
Returns:
|
||||
ServerTransport -- constructed for this stream with a pre-authenticated client
|
||||
"""
|
||||
if not self.client or not self.client.me:
|
||||
if not self._client or not self._client.me:
|
||||
self.get_client(token)
|
||||
return ServerTransport(self.stream_id, self.client)
|
||||
return ServerTransport(self.stream_id, self._client)
|
||||
|
||||
@@ -30,7 +30,7 @@ class Commit(BaseModel):
|
||||
parents: Optional[List[str]]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"Commit( id: {self.id}, message: {self.message}, referencedObject: {self.referencedObject}, authorName: {self.authorName}, createdAt: {self.createdAt} )"
|
||||
return f"Commit( id: {self.id}, message: {self.message}, referencedObject: {self.referencedObject}, authorName: {self.authorName}, branchName: {self.branchName}, createdAt: {self.createdAt} )"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.__repr__()
|
||||
|
||||
@@ -34,8 +34,8 @@ class Resource(ResourceBase):
|
||||
stream(id: $stream_id) {
|
||||
commit(id: $commit_id) {
|
||||
id
|
||||
referencedObject
|
||||
message
|
||||
referencedObject
|
||||
authorId
|
||||
authorName
|
||||
authorAvatar
|
||||
@@ -79,6 +79,7 @@ class Resource(ResourceBase):
|
||||
authorId
|
||||
authorName
|
||||
authorAvatar
|
||||
branchName
|
||||
createdAt
|
||||
sourceApplication
|
||||
totalChildrenCount
|
||||
|
||||
@@ -207,7 +207,7 @@ class Base(_RegisteringBase):
|
||||
try:
|
||||
attr.__set__(self, value)
|
||||
except AttributeError:
|
||||
pass # the prop probably doesn't have a setter
|
||||
return # the prop probably doesn't have a setter
|
||||
super().__setattr__(name, value)
|
||||
|
||||
@classmethod
|
||||
@@ -252,6 +252,9 @@ class Base(_RegisteringBase):
|
||||
if t is None:
|
||||
return value
|
||||
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
if t.__module__ == "typing":
|
||||
origin = getattr(t, "__origin__")
|
||||
t = (
|
||||
@@ -310,7 +313,9 @@ class Base(_RegisteringBase):
|
||||
|
||||
@units.setter
|
||||
def units(self, value: str):
|
||||
self._units = get_units_from_string(value)
|
||||
units = get_units_from_string(value)
|
||||
if units:
|
||||
self._units = units
|
||||
|
||||
def get_member_names(self) -> List[str]:
|
||||
"""Get all of the property names on this object, dynamic or not"""
|
||||
|
||||
@@ -33,6 +33,7 @@ class Point(Base, speckle_type=GEOMETRY + "Point"):
|
||||
|
||||
@classmethod
|
||||
def from_list(cls, args: List[float]) -> "Point":
|
||||
"""Create a new Point from a list of three floats representing the x, y, and z coordinates"""
|
||||
return cls(x=args[0], y=args[1], z=args[2])
|
||||
|
||||
def to_list(self) -> List[Any]:
|
||||
@@ -40,6 +41,7 @@ class Point(Base, speckle_type=GEOMETRY + "Point"):
|
||||
|
||||
@classmethod
|
||||
def from_coords(cls, x: float = 0.0, y: float = 0.0, z: float = 0.0):
|
||||
"""Create a new Point from x, y, and z values"""
|
||||
pt = Point()
|
||||
pt.x, pt.y, pt.z = x, y, z
|
||||
return pt
|
||||
@@ -216,6 +218,7 @@ class Polyline(Base, speckle_type=GEOMETRY + "Polyline", chunkable={"value": 200
|
||||
|
||||
@classmethod
|
||||
def from_points(cls, points: List[Point]):
|
||||
"""Create a new Polyline from a list of Points"""
|
||||
polyline = cls()
|
||||
polyline.units = points[0].units
|
||||
polyline.value = []
|
||||
@@ -391,6 +394,28 @@ class Mesh(
|
||||
area: float = None
|
||||
volume: float = None
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
cls,
|
||||
vertices: List[float],
|
||||
faces: List[int],
|
||||
colors: List[int] = None,
|
||||
texture_coordinates: List[float] = None,
|
||||
) -> "Mesh":
|
||||
"""
|
||||
Create a new Mesh from lists representing its vertices, faces,
|
||||
colors (optional), and texture coordinates (optional).
|
||||
|
||||
This will initialise empty lists for colors and texture coordinates
|
||||
if you do not provide any.
|
||||
"""
|
||||
return cls(
|
||||
vertices=vertices,
|
||||
faces=faces,
|
||||
colors=colors or [],
|
||||
textureCoordinates=texture_coordinates or [],
|
||||
)
|
||||
|
||||
|
||||
class Surface(Base, speckle_type=GEOMETRY + "Surface"):
|
||||
degreeU: int = None
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
from typing import List
|
||||
from specklepy.objects.geometry import Point, Vector
|
||||
from .base import Base
|
||||
|
||||
OTHER = "Objects.Other."
|
||||
|
||||
IDENTITY_TRANSFORM = [
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
]
|
||||
|
||||
|
||||
class RenderMaterial(Base, speckle_type=OTHER + "RenderMaterial"):
|
||||
name: str = None
|
||||
@@ -10,3 +31,169 @@ class RenderMaterial(Base, speckle_type=OTHER + "RenderMaterial"):
|
||||
roughness: float = 1
|
||||
diffuse: int = -2894893 # light gray arbg
|
||||
emissive: int = -16777216 # black arbg
|
||||
|
||||
|
||||
class Transform(
|
||||
Base,
|
||||
speckle_type=OTHER + "Transform",
|
||||
serialize_ignore={"translation", "scaling", "is_identity"},
|
||||
):
|
||||
"""The 4x4 transformation matrix
|
||||
|
||||
The 3x3 sub-matrix determines scaling.
|
||||
The 4th column defines translation, where the last value is a divisor (usually equal to 1).
|
||||
"""
|
||||
|
||||
_value: List[float] = None
|
||||
|
||||
@property
|
||||
def value(self) -> List[float]:
|
||||
"""The transform matrix represented as a flat list of 16 floats"""
|
||||
return self._value
|
||||
|
||||
@value.setter
|
||||
def value(self, value: List[float]) -> None:
|
||||
try:
|
||||
value = [float(x) for x in value]
|
||||
except (ValueError, TypeError):
|
||||
raise ValueError(
|
||||
f"Could not create a Transform object with the requested value. Input must be a 16 element list of numbers. Value provided: {value}"
|
||||
)
|
||||
if len(value) != 16:
|
||||
raise ValueError(
|
||||
f"Could not create a Transform object: input list should be 16 floats long, but was {len(value)} long"
|
||||
)
|
||||
|
||||
self._value = value
|
||||
|
||||
@property
|
||||
def translation(self) -> List[float]:
|
||||
"""The final column of the matrix which defines the translation"""
|
||||
return [self._value[i] for i in (3, 7, 11, 15)]
|
||||
|
||||
@property
|
||||
def scaling(self) -> List[float]:
|
||||
"""The 3x3 scaling sub-matrix"""
|
||||
return [self._value[i] for i in (0, 1, 2, 4, 5, 6, 8, 9, 10)]
|
||||
|
||||
@property
|
||||
def is_identity(self) -> bool:
|
||||
return self.value == IDENTITY_TRANSFORM
|
||||
|
||||
def apply_to_point(self, point: Point) -> Point:
|
||||
"""Transform a single speckle Point
|
||||
|
||||
Arguments:
|
||||
point {Point} -- the speckle Point to transform
|
||||
|
||||
Returns:
|
||||
Point -- a new transformed point
|
||||
"""
|
||||
coords = self.apply_to_point_value([point.x, point.y, point.z])
|
||||
return Point(x=coords[0], y=coords[1], z=coords[2], units=point.units)
|
||||
|
||||
def apply_to_point_value(self, point_value: List[float]) -> List[float]:
|
||||
"""Transform a list of three floats representing a point
|
||||
|
||||
Arguments:
|
||||
point_value {List[float]} -- a list of 3 floats
|
||||
|
||||
Returns:
|
||||
List[float] -- the list with the transform applied
|
||||
"""
|
||||
transformed = [
|
||||
point_value[0] * self._value[i]
|
||||
+ point_value[1] * self._value[i + 1]
|
||||
+ point_value[2] * self._value[i + 2]
|
||||
+ self._value[i + 3]
|
||||
for i in range(0, 15, 4)
|
||||
]
|
||||
|
||||
return [transformed[i] / transformed[3] for i in range(3)]
|
||||
|
||||
def apply_to_points(self, points: List[Point]) -> List[Point]:
|
||||
"""Transform a list of speckle Points
|
||||
|
||||
Arguments:
|
||||
points {List[Point]} -- the list of speckle Points to transform
|
||||
|
||||
Returns:
|
||||
List[Point] -- a new list of transformed points
|
||||
"""
|
||||
return [self.apply_to_point(point) for point in points]
|
||||
|
||||
def apply_to_points_values(self, points_value: List[float]) -> List[float]:
|
||||
"""Transform a list of speckle Points
|
||||
|
||||
Arguments:
|
||||
points {List[float]} -- a flat list of floats representing points to transform
|
||||
|
||||
Returns:
|
||||
List[float] -- a new transformed list
|
||||
"""
|
||||
if len(points_value) % 3 != 0:
|
||||
raise ValueError(
|
||||
"Cannot apply transform as the points list is malformed: expected length to be multiple of 3"
|
||||
)
|
||||
transformed = []
|
||||
for i in range(0, len(points_value), 3):
|
||||
transformed.extend(self.apply_to_point_value(points_value[i : i + 3]))
|
||||
|
||||
return transformed
|
||||
|
||||
def apply_to_vector(self, vector: Vector) -> Vector:
|
||||
"""Transform a single speckle Vector
|
||||
|
||||
Arguments:
|
||||
point {Vector} -- the speckle Vector to transform
|
||||
|
||||
Returns:
|
||||
Vector -- a new transformed point
|
||||
"""
|
||||
coords = self.apply_to_vector_value([vector.x, vector.y, vector.z])
|
||||
return Vector(x=coords[0], y=coords[1], z=coords[2], units=vector.units)
|
||||
|
||||
def apply_to_vector_value(self, vector_value: List[float]) -> List[float]:
|
||||
"""Transform a list of three floats representing a vector
|
||||
|
||||
Arguments:
|
||||
vector_value {List[float]} -- a list of 3 floats
|
||||
|
||||
Returns:
|
||||
List[float] -- the list with the transform applied
|
||||
"""
|
||||
return [
|
||||
vector_value[0] * self._value[i]
|
||||
+ vector_value[1] * self._value[i + 1]
|
||||
+ vector_value[2] * self._value[i + 2]
|
||||
for i in range(0, 15, 4)
|
||||
][:3]
|
||||
|
||||
@classmethod
|
||||
def from_list(cls, value: List[float] = None) -> "Transform":
|
||||
"""Returns a Transform object from a list of 16 numbers. If no value is provided, an identity transform will be returned.
|
||||
|
||||
Arguments:
|
||||
value {List[float]} -- the matrix as a flat list of 16 numbers (defaults to the identity transform)
|
||||
|
||||
Returns:
|
||||
Transform -- a complete transform object
|
||||
"""
|
||||
if not value:
|
||||
value = IDENTITY_TRANSFORM
|
||||
return cls(value=value)
|
||||
|
||||
|
||||
class BlockDefinition(
|
||||
Base, speckle_type=OTHER + "BlockDefinition", detachable={"geometry"}
|
||||
):
|
||||
name: str = None
|
||||
basePoint: Point = None
|
||||
geometry: List[Base] = None
|
||||
|
||||
|
||||
class BlockInstance(
|
||||
Base, speckle_type=OTHER + "BlockInstance", detachable={"blockDefinition"}
|
||||
):
|
||||
blockDefinition: BlockDefinition = None
|
||||
transform: Transform = None
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Builtin Speckle object kit."""
|
||||
|
||||
from specklepy.objects.structural.analysis import *
|
||||
from specklepy.objects.structural.properties import *
|
||||
from specklepy.objects.structural.material import *
|
||||
from specklepy.objects.structural.geometry import *
|
||||
from specklepy.objects.structural.loading import *
|
||||
from specklepy.objects.structural.axis import Axis
|
||||
|
||||
__all__ = [
|
||||
"Element1D",
|
||||
"Element2D",
|
||||
"Element3D",
|
||||
"Axis",
|
||||
"Node",
|
||||
"Restraint",
|
||||
"Load",
|
||||
"LoadBeam",
|
||||
"LoadCase",
|
||||
"LoadCombinations",
|
||||
"LoadFace",
|
||||
"LoadGravity",
|
||||
"LoadNode",
|
||||
"Model",
|
||||
"ModelInfo",
|
||||
"ModelSettings",
|
||||
"ModelUnits",
|
||||
"Concrete",
|
||||
"Material",
|
||||
"Steel",
|
||||
"Timber",
|
||||
"Property",
|
||||
"Property1D",
|
||||
"Property2D",
|
||||
"Property3D",
|
||||
"PropertyDamper",
|
||||
"PropertyMass",
|
||||
"PropertySpring",
|
||||
"SectionProfile",
|
||||
]
|
||||
@@ -0,0 +1,53 @@
|
||||
from enum import Enum
|
||||
import enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from ..base import Base
|
||||
from ..geometry import *
|
||||
from .properties import *
|
||||
|
||||
STRUCTURAL_ANALYSIS = "Objects.Structural.Analysis."
|
||||
|
||||
|
||||
class ModelUnits(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelUnits"):
|
||||
length: str = None
|
||||
sections: str = None
|
||||
displacements: str = None
|
||||
stress: str = None
|
||||
force: str = None
|
||||
mass: str = None
|
||||
time: str = None
|
||||
temperature: str = None
|
||||
velocity: str = None
|
||||
acceleration: str = None
|
||||
energy: str = None
|
||||
angle: str = None
|
||||
strain: str = None
|
||||
|
||||
|
||||
class ModelSettings(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelSettings"):
|
||||
modelUnits: ModelUnits = None
|
||||
steelCode: str = None
|
||||
concreteCode: str = None
|
||||
coincidenceTolerance: float = 0.0
|
||||
|
||||
|
||||
class ModelInfo(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelInfo"):
|
||||
name: str = None
|
||||
description: str = None
|
||||
projectNumber: str = None
|
||||
projectName: str = None
|
||||
settings: ModelSettings = None
|
||||
initials: str = None
|
||||
application: str = None
|
||||
|
||||
|
||||
class Model(Base, speckle_type=STRUCTURAL_ANALYSIS + "Model"):
|
||||
specs: ModelInfo = None
|
||||
nodes: List = None
|
||||
elements: List = None
|
||||
loads: List = None
|
||||
restraints: List = None
|
||||
properties: List = None
|
||||
materials: List = None
|
||||
layerDescription: str = None
|
||||
@@ -0,0 +1,8 @@
|
||||
from ..base import Base
|
||||
from ..geometry import Plane
|
||||
|
||||
|
||||
class Axis(Base, speckle_type="Objects.Structural.Geometry.Axis"):
|
||||
name: str = None
|
||||
axisType: str = None
|
||||
plane: Plane = None
|
||||
@@ -0,0 +1,109 @@
|
||||
from enum import Enum
|
||||
import enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from ..base import Base
|
||||
from ..geometry import *
|
||||
from .properties import *
|
||||
from .axis import Axis
|
||||
|
||||
STRUCTURAL_GEOMETRY = "Objects.Structural.Geometry"
|
||||
|
||||
|
||||
class ElementType1D(int, Enum):
|
||||
Beam = 0
|
||||
Brace = 1
|
||||
Bar = 2
|
||||
Column = 3
|
||||
Rod = 4
|
||||
Spring = 5
|
||||
Tie = 6
|
||||
Strut = 7
|
||||
Link = 8
|
||||
Damper = 9
|
||||
Cable = 10
|
||||
Spacer = 11
|
||||
Other = 12
|
||||
Null = 13
|
||||
|
||||
|
||||
class ElementType2D(int, Enum):
|
||||
Quad4 = 0
|
||||
Quad8 = 1
|
||||
Triangle3 = 2
|
||||
Triangle6 = 3
|
||||
|
||||
|
||||
class ElementType3D(int, Enum):
|
||||
Brick8 = 0
|
||||
Wedge6 = 1
|
||||
Pyramid5 = 2
|
||||
Tetra4 = 3
|
||||
|
||||
|
||||
class Restraint(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Restraint"):
|
||||
code: str = None
|
||||
stiffnessX: float = 0.0
|
||||
stiffnessY: float = 0.0
|
||||
stiffnessZ: float = 0.0
|
||||
stiffnessXX: float = 0.0
|
||||
stiffnessYY: float = 0.0
|
||||
stiffnessZZ: float = 0.0
|
||||
units: str = None
|
||||
|
||||
|
||||
class Node(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Node"):
|
||||
name: str = None
|
||||
basePoint: Point = None
|
||||
constraintAxis: Axis = None
|
||||
restraint: Restraint = None
|
||||
springProperty: PropertySpring = None
|
||||
massProperty: PropertyMass = None
|
||||
damperProperty: PropertyDamper = None
|
||||
units: str = None
|
||||
|
||||
|
||||
class Element1D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element1D"):
|
||||
name: str = None
|
||||
baseLine: Line = None
|
||||
property: Property1D = None
|
||||
type: ElementType1D = None
|
||||
end1Releases: Restraint = None
|
||||
end2Releases: Restraint = None
|
||||
end1Offset: Vector = None
|
||||
end2Offset: Vector = None
|
||||
orientationNode: Node = None
|
||||
orinetationAngle: float = 0.0
|
||||
localAxis: Plane = None
|
||||
parent: Base = None
|
||||
end1Node: Node = Node
|
||||
end2Node: Node = Node
|
||||
topology: List = None
|
||||
displayMesh: Mesh = None
|
||||
units: str = None
|
||||
|
||||
|
||||
class Element2D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element2D"):
|
||||
name: str = None
|
||||
property: Property2D = None
|
||||
type: ElementType2D = None
|
||||
offset: float = 0.0
|
||||
orientationAngle: float = 0.0
|
||||
parent: Base = None
|
||||
topology: List = None
|
||||
displayMesh: Mesh = None
|
||||
units: str = None
|
||||
|
||||
|
||||
class Element3D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element3D"):
|
||||
name: str = None
|
||||
baseMesh: Mesh = None
|
||||
property: Property3D = None
|
||||
type: ElementType3D = None
|
||||
orientationAngle: float = 0.0
|
||||
parent: Base = None
|
||||
topology: List
|
||||
units: str = None
|
||||
|
||||
|
||||
# class Storey needs ependency on built elements first
|
||||
@@ -0,0 +1,144 @@
|
||||
from enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from ..base import Base
|
||||
from .geometry import *
|
||||
|
||||
STRUCTURAL_LOADING = "Objects.Structural.Loading."
|
||||
|
||||
|
||||
class LoadType(int, Enum):
|
||||
|
||||
none = 0
|
||||
Dead = 1
|
||||
SuperDead = 2
|
||||
Soil = 3
|
||||
Live = 4
|
||||
LiveRoof = 5
|
||||
ReducibleLive = 6
|
||||
Wind = 7
|
||||
Snow = 8
|
||||
Rain = 9
|
||||
Thermal = 10
|
||||
Notional = 11
|
||||
Prestress = 12
|
||||
Equivalent = 13
|
||||
Accidental = 14
|
||||
SeismicRSA = 15
|
||||
SeismicAccTorsion = 16
|
||||
SeismicStatic = 17
|
||||
Other = 18
|
||||
|
||||
|
||||
class ActionType(int, Enum):
|
||||
|
||||
none = 0
|
||||
Permanent = 1
|
||||
Variable = 2
|
||||
Accidental = 3
|
||||
|
||||
|
||||
class BeamLoadType(int, Enum):
|
||||
|
||||
Point = 0
|
||||
Uniform = 1
|
||||
Linear = 2
|
||||
Patch = 3
|
||||
TriLinear = 4
|
||||
|
||||
|
||||
class FaceLoadType(int, Enum):
|
||||
|
||||
Constant = 0
|
||||
Variable = 1
|
||||
Point = 2
|
||||
|
||||
|
||||
class LoadDirection2D(int, Enum):
|
||||
|
||||
X = 0
|
||||
Y = 1
|
||||
Z = 2
|
||||
|
||||
|
||||
class LoadDirection(int, Enum):
|
||||
|
||||
X = 0
|
||||
Y = 1
|
||||
Z = 2
|
||||
XX = 3
|
||||
YY = 4
|
||||
ZZ = 5
|
||||
|
||||
|
||||
class LoadAxisType(int, Enum):
|
||||
Global = 0
|
||||
Local = 1 # local element axes
|
||||
DeformedLocal = (
|
||||
2 # element local axis that is embedded in the element as it deforms
|
||||
)
|
||||
|
||||
|
||||
class CombinationType(int, Enum):
|
||||
|
||||
LinearAdd = 0
|
||||
Envelope = 1
|
||||
AbsoluteAdd = 2
|
||||
SRSS = 3
|
||||
RangeAdd = 4
|
||||
|
||||
|
||||
class LoadCase(Base, speckle_type=STRUCTURAL_LOADING + "LoadCase"):
|
||||
name: str = None
|
||||
loadType: LoadType = None
|
||||
group: str = None
|
||||
actionType: ActionType = None
|
||||
description: str = None
|
||||
|
||||
|
||||
class Load(Base, speckle_type=STRUCTURAL_LOADING + "Load"):
|
||||
name: str = None
|
||||
units: str = None
|
||||
loadCase: LoadCase = None
|
||||
|
||||
|
||||
class LoadBeam(Load, speckle_type=STRUCTURAL_LOADING + "LoadBeam"):
|
||||
elements: List = None
|
||||
loadType: BeamLoadType = None
|
||||
direction: LoadDirection = None
|
||||
loadAxis: Axis = None
|
||||
loadAxisType: LoadAxisType = None
|
||||
isProjected: bool = None
|
||||
values: List = None
|
||||
positions: List = None
|
||||
|
||||
|
||||
class LoadCombinations(Base, speckle_type=STRUCTURAL_LOADING + "LoadCombination"):
|
||||
name: str = None
|
||||
loadCases: List
|
||||
loadFactors: List
|
||||
combinationType: CombinationType
|
||||
|
||||
|
||||
class LoadFace(Load, speckle_type=STRUCTURAL_LOADING + "LoadFace"):
|
||||
elements: List = None
|
||||
loadType: FaceLoadType = None
|
||||
direction: LoadDirection2D = None
|
||||
loadAxis: Axis = None
|
||||
loadAxisType: LoadAxisType = None
|
||||
isProjected: bool = None
|
||||
values: List = None
|
||||
positions: List = None
|
||||
|
||||
|
||||
class LoadGravity(Load, speckle_type=STRUCTURAL_LOADING + "LoadGravity"):
|
||||
elements: List = None
|
||||
nodes: List = None
|
||||
gravityFactors: Vector = None
|
||||
|
||||
|
||||
class LoadNode(Load, speckle_type=STRUCTURAL_LOADING + "LoadNode"):
|
||||
nodes: List = None
|
||||
loadAxis: Axis = None
|
||||
direction: LoadDirection = None
|
||||
value: float = 0.0
|
||||
@@ -0,0 +1,60 @@
|
||||
from enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from ..base import Base
|
||||
|
||||
|
||||
STRUCTURAL_MATERIALS = "Objects.Structural.Materials"
|
||||
|
||||
|
||||
class MaterialType(int, Enum):
|
||||
Concrete = 0
|
||||
Steel = 1
|
||||
Timber = 2
|
||||
Aluminium = 3
|
||||
Masonry = 4
|
||||
FRP = 5
|
||||
Glass = 6
|
||||
Fabric = 7
|
||||
Rebar = 8
|
||||
Tendon = 9
|
||||
ColdFormed = 10
|
||||
Other = 11
|
||||
|
||||
|
||||
class Material(Base, speckle_type=STRUCTURAL_MATERIALS):
|
||||
name: str = None
|
||||
grade: str = None
|
||||
materialType: MaterialType = None
|
||||
designCode: str = None
|
||||
codeYear: str = None
|
||||
strength: float = 0.0
|
||||
elasticModulus: float = 0.0
|
||||
poissonsRatio: float = 0.0
|
||||
shearModulus: float = 0.0
|
||||
density: float = 0.0
|
||||
thermalExpansivity: float = 0.0
|
||||
dampingRatio: float = 0.0
|
||||
cost: float = 0.0
|
||||
materialSafetyFactor: float = 0.0
|
||||
|
||||
|
||||
class Concrete(Material, speckle_type=STRUCTURAL_MATERIALS + ".Concrete"):
|
||||
compressiveStrength: float = 0.0
|
||||
tensileStrength: float = 0.0
|
||||
flexuralStrength: float = 0.0
|
||||
maxCompressiveStrength: float = 0.0
|
||||
maxTensileStrength: float = 0.0
|
||||
maxAggregateSize: float = 0.0
|
||||
lightweight: bool = None
|
||||
|
||||
|
||||
class Steel(Material, speckle_type=STRUCTURAL_MATERIALS + ".Steel"):
|
||||
yieldStrength: float = 0.0
|
||||
ultimateStrength: float = 0.0
|
||||
maxStrain: float = 0.0
|
||||
strainHardeningModulus: float = 0.0
|
||||
|
||||
|
||||
class Timber(Material, speckle_type=STRUCTURAL_MATERIALS + ".Timber"):
|
||||
species: str = None
|
||||
@@ -0,0 +1,214 @@
|
||||
from enum import Enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
|
||||
from ..base import Base
|
||||
|
||||
from .material import *
|
||||
from .axis import Axis
|
||||
|
||||
|
||||
STRUCTURAL_PROPERTY = "Objectives.Structural.Properties"
|
||||
|
||||
|
||||
class MemberType(int, Enum):
|
||||
Beam = 0
|
||||
Column = 1
|
||||
Generic1D = 2
|
||||
Slab = 3
|
||||
Wall = 4
|
||||
Generic2D = 5
|
||||
VoidCutter1D = 6
|
||||
VoidCutter2D = 7
|
||||
|
||||
|
||||
class BaseReferencePoint(int, Enum):
|
||||
Centroid = 0
|
||||
TopLeft = 1
|
||||
TopCentre = 2
|
||||
TopRight = 3
|
||||
MidLeft = 4
|
||||
MidRight = 5
|
||||
BotLeft = 6
|
||||
BotCentre = 7
|
||||
BotRight = 8
|
||||
|
||||
|
||||
class ReferenceSurface(int, Enum):
|
||||
Top = 0
|
||||
Middle = 1
|
||||
Bottom = 2
|
||||
|
||||
|
||||
class PropertyType2D(int, Enum):
|
||||
|
||||
Stress = 0
|
||||
Fabric = 1
|
||||
Plate = 2
|
||||
Shell = 3
|
||||
Curved = 4
|
||||
Wall = 5
|
||||
Strain = 6
|
||||
Axi = 7
|
||||
Load = 8
|
||||
|
||||
|
||||
class PropertyType3D(int, Enum):
|
||||
Solid = 0
|
||||
Infinite = 1
|
||||
|
||||
|
||||
class ShapeType(int, Enum):
|
||||
Rectangular = 0
|
||||
Circular = 1
|
||||
I = 2
|
||||
Tee = 3
|
||||
Angle = 4
|
||||
Channel = 5
|
||||
Perimeter = 6
|
||||
Box = 7
|
||||
Catalogue = 8
|
||||
Explicit = 9
|
||||
|
||||
|
||||
class PropertyTypeSpring(int, Enum):
|
||||
Axial = 0
|
||||
Torsional = 1
|
||||
General = 2
|
||||
Matrix = 3
|
||||
TensionOnly = 4
|
||||
CompressionOnly = 5
|
||||
Connector = 6
|
||||
LockUp = 7
|
||||
Gap = 8
|
||||
Friction = 9
|
||||
|
||||
|
||||
class PropertyTypeDamper(int, Enum):
|
||||
Axial = 0
|
||||
Torsional = 1
|
||||
General = 2
|
||||
|
||||
|
||||
class Property(Base, speckle_type=STRUCTURAL_PROPERTY):
|
||||
name: str = None
|
||||
|
||||
|
||||
class SectionProfile(Base, speckle_type=STRUCTURAL_PROPERTY + ".SectionProfile"):
|
||||
name: str = None
|
||||
shapeType: ShapeType = None
|
||||
area: float = 0.0
|
||||
Iyy: float = 0.0
|
||||
Izz: float = 0.0
|
||||
J: float = 0.0
|
||||
Ky: float = 0.0
|
||||
weight: float = 0.0
|
||||
units: str = None
|
||||
|
||||
|
||||
class Property1D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property1D"):
|
||||
memberType: MemberType = None
|
||||
Material: Material = None
|
||||
SectionProfile: SectionProfile = None
|
||||
BaseReferencePoint: BaseReferencePoint = None
|
||||
offsetY: float = 0.0
|
||||
offsetZ: float = 0.0
|
||||
|
||||
|
||||
class Property2D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property2D"):
|
||||
PropertyType2D: PropertyType2D = None
|
||||
thickness: float = 0.0
|
||||
Material: Material = None
|
||||
axis: Axis = None
|
||||
referenceSurface: ReferenceSurface = None
|
||||
zOffset: float = 0.0
|
||||
modifierInPlane: float = 0.0
|
||||
modifierBending: float = 0.0
|
||||
modifierShear: float = 0.0
|
||||
modifierVolume: float = 0.0
|
||||
|
||||
|
||||
class Property3D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property3D"):
|
||||
PropertyType3D: PropertyType3D = None
|
||||
Material: Material = None
|
||||
axis: Axis = None
|
||||
|
||||
|
||||
class PropertyDamper(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyDamper"):
|
||||
damperType: PropertyTypeDamper = None
|
||||
dampingX: float = 0.0
|
||||
dampingY: float = 0.0
|
||||
dampingZ: float = 0.0
|
||||
dampingXX: float = 0.0
|
||||
dampingYY: float = 0.0
|
||||
dampingZZ: float = 0.0
|
||||
|
||||
|
||||
class PropertyMass(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyMass"):
|
||||
mass: float = 0.0
|
||||
inertiaXX: float = 0.0
|
||||
inertiaYY: float = 0.0
|
||||
inertiaZZ: float = 0.0
|
||||
inertiaXY: float = 0.0
|
||||
inertiaYZ: float = 0.0
|
||||
inertiaZX: float = 0.0
|
||||
massModified: bool = None
|
||||
massModifierX: float = 0.0
|
||||
massModifierY: float = 0.0
|
||||
massModifierZ: float = 0.0
|
||||
|
||||
|
||||
class PropertySpring(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertySpring"):
|
||||
springType: PropertyTypeSpring = None
|
||||
springCurveX: float = 0.0
|
||||
stiffnessX: float = 0.0
|
||||
springCurveY: float = 0.0
|
||||
stiffnessY: float = 0.0
|
||||
springCurveZ: float = 0.0
|
||||
stiffnessZ: float = 0.0
|
||||
springCurveXX: float = 0.0
|
||||
stiffnessXX: float = 0.0
|
||||
springCurveYY: float = 0.0
|
||||
stiffnessYY: float = 0.0
|
||||
springCurveZZ: float = 0.0
|
||||
stiffnessZZ: float = 0.0
|
||||
dampingRatio: float = 0.0
|
||||
dampingX: float = 0.0
|
||||
dampingY: float = 0.0
|
||||
dampingZ: float = 0.0
|
||||
dampingXX: float = 0.0
|
||||
dampingYY: float = 0.0
|
||||
dampingZZ: float = 0.0
|
||||
matrix: float = 0.0
|
||||
postiveLockup: float = 0.0
|
||||
frictionCoefficient: float = 0.0
|
||||
|
||||
|
||||
class ReferenceSurfaceEnum(int, Enum):
|
||||
Concrete = 0
|
||||
Steel = 1
|
||||
Timber = 2
|
||||
Aluminium = 3
|
||||
Masonry = 4
|
||||
FRP = 5
|
||||
Glass = 6
|
||||
Fabric = 7
|
||||
Rebar = 8
|
||||
Tendon = 9
|
||||
ColdFormed = 10
|
||||
Other = 11
|
||||
|
||||
|
||||
class shapeType(int, Enum):
|
||||
Concrete = 0
|
||||
Steel = 1
|
||||
Timber = 2
|
||||
Aluminium = 3
|
||||
Masonry = 4
|
||||
FRP = 5
|
||||
Glass = 6
|
||||
Fabric = 7
|
||||
Rebar = 8
|
||||
Tendon = 9
|
||||
ColdFormed = 10
|
||||
Other = 11
|
||||
@@ -0,0 +1,176 @@
|
||||
from enum import Enum
|
||||
import enum
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from ..base import Base
|
||||
from ..geometry import *
|
||||
from .loading import *
|
||||
from .geometry import *
|
||||
from .analysis import Model
|
||||
|
||||
STRUCTURAL_RESULTS = "Objects.Structural.Results."
|
||||
|
||||
|
||||
class Result(Base, speckle_type=STRUCTURAL_RESULTS + "Result"):
|
||||
resultCase: Base = None
|
||||
permutation: str = None
|
||||
description: str = None
|
||||
|
||||
|
||||
class ResultSet1D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet1D"):
|
||||
results1D: List
|
||||
|
||||
|
||||
class Result1D(Result, speckle_type=STRUCTURAL_RESULTS + "Result1D"):
|
||||
element: Element1D = None
|
||||
position: float = 0.0
|
||||
dispX: float = 0.0
|
||||
dispY: float = 0.0
|
||||
dispZ: float = 0.0
|
||||
rotXX: float = 0.0
|
||||
rotYY: float = 0.0
|
||||
rotZZ: float = 0.0
|
||||
forceX: float = 0.0
|
||||
forceY: float = 0.0
|
||||
forceZ: float = 0.0
|
||||
momentXX: float = 0.0
|
||||
momentYY: float = 0.0
|
||||
momentZZ: float = 0.0
|
||||
axialStress: float = 0.0
|
||||
shearStressY: float = 0.0
|
||||
shearStressZ: float = 0.0
|
||||
bendingStressYPos: float = 0.0
|
||||
bendingStressYNeg: float = 0.0
|
||||
bendingStressZPos: float = 0.0
|
||||
bendingStressZNeg: float = 0.0
|
||||
combinedStressMax: float = 0.0
|
||||
combinedStressMin: float = 0.0
|
||||
|
||||
|
||||
class ResultSet2D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet2D"):
|
||||
results2D: List
|
||||
|
||||
|
||||
class Result2D(Result, speckle_type=STRUCTURAL_RESULTS + "Result2D"):
|
||||
element: Element2D = None
|
||||
position: List
|
||||
dispX: float = 0.0
|
||||
dispY: float = 0.0
|
||||
dispZ: float = 0.0
|
||||
forceXX: float = 0.0
|
||||
forceYY: float = 0.0
|
||||
forceXY: float = 0.0
|
||||
momentXX: float = 0.0
|
||||
momentYY: float = 0.0
|
||||
momentXY: float = 0.0
|
||||
shearX: float = 0.0
|
||||
shearY: float = 0.0
|
||||
stressTopXX: float = 0.0
|
||||
stressTopYY: float = 0.0
|
||||
stressTopZZ: float = 0.0
|
||||
stressTopXY: float = 0.0
|
||||
stressTopYZ: float = 0.0
|
||||
stressTopZX: float = 0.0
|
||||
stressMidXX: float = 0.0
|
||||
stressMidYY: float = 0.0
|
||||
stressMidZZ: float = 0.0
|
||||
stressMidXY: float = 0.0
|
||||
stressMidYZ: float = 0.0
|
||||
stressMidZX: float = 0.0
|
||||
stressBotXX: float = 0.0
|
||||
stressBotYY: float = 0.0
|
||||
stressBotZZ: float = 0.0
|
||||
stressBotXY: float = 0.0
|
||||
stressBotYZ: float = 0.0
|
||||
stressBotZX: float = 0.0
|
||||
|
||||
|
||||
class ResultSet3D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet3D"):
|
||||
results3D: List
|
||||
|
||||
|
||||
class Result3D(Result, speckle_type=STRUCTURAL_RESULTS + "Result3D"):
|
||||
element: Element3D = None
|
||||
position: List
|
||||
dispX: float = 0.0
|
||||
dispY: float = 0.0
|
||||
dispZ: float = 0.0
|
||||
stressXX: float = 0.0
|
||||
stressYY: float = 0.0
|
||||
stressZZ: float = 0.0
|
||||
stressXY: float = 0.0
|
||||
stressYZ: float = 0.0
|
||||
stressZX: float = 0.0
|
||||
|
||||
|
||||
class ResultGlobal(Result, speckle_type=STRUCTURAL_RESULTS + "ResultGlobal"):
|
||||
model: Model = None
|
||||
loadX: float = 0.0
|
||||
loadY: float = 0.0
|
||||
loadZ: float = 0.0
|
||||
loadXX: float = 0.0
|
||||
loadYY: float = 0.0
|
||||
loadZZ: float = 0.0
|
||||
reactionX: float = 0.0
|
||||
reactionY: float = 0.0
|
||||
reactionZ: float = 0.0
|
||||
reactionXX: float = 0.0
|
||||
reactionYY: float = 0.0
|
||||
reactionZZ: float = 0.0
|
||||
mode: float = 0.0
|
||||
frequency: float = 0.0
|
||||
loadFactor: float = 0.0
|
||||
modalStiffness: float = 0.0
|
||||
modalGeoStiffness: float = 0.0
|
||||
effMassX: float = 0.0
|
||||
effMassY: float = 0.0
|
||||
effMassZ: float = 0.0
|
||||
effMassXX: float = 0.0
|
||||
effMassYY: float = 0.0
|
||||
effMassZZ: float = 0.0
|
||||
|
||||
|
||||
class ResultSetNode(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSetNode"):
|
||||
resultsNode: List
|
||||
|
||||
|
||||
class ResultNode(Result, speckle_type=STRUCTURAL_RESULTS + " ResultNode"):
|
||||
node: Node = None
|
||||
dispX: float = 0.0
|
||||
dispY: float = 0.0
|
||||
dispZ: float = 0.0
|
||||
rotXX: float = 0.0
|
||||
rotYY: float = 0.0
|
||||
rotZZ: float = 0.0
|
||||
reactionX: float = 0.0
|
||||
reactionY: float = 0.0
|
||||
reactionZ: float = 0.0
|
||||
reactionXX: float = 0.0
|
||||
reactionYY: float = 0.0
|
||||
reactionZZ: float = 0.0
|
||||
constraintX: float = 0.0
|
||||
constraintY: float = 0.0
|
||||
constraintZ: float = 0.0
|
||||
constraintXX: float = 0.0
|
||||
constraintYY: float = 0.0
|
||||
constraintZZ: float = 0.0
|
||||
velX: float = 0.0
|
||||
velY: float = 0.0
|
||||
velZ: float = 0.0
|
||||
velXX: float = 0.0
|
||||
velYY: float = 0.0
|
||||
velZZ: float = 0.0
|
||||
accX: float = 0.0
|
||||
accY: float = 0.0
|
||||
accZ: float = 0.0
|
||||
accXX: float = 0.0
|
||||
accYY: float = 0.0
|
||||
accZZ: float = 0.0
|
||||
|
||||
|
||||
class ResultSetAll(Base, speckle_type=None):
|
||||
resultSet1D: ResultSet1D = None
|
||||
resultSet2D: ResultSet2D = None
|
||||
resultSet3D: ResultSet3D = None
|
||||
resultsGlobal: ResultGlobal = None
|
||||
resultsNode: ResultSetNode = None
|
||||
@@ -1,4 +1,5 @@
|
||||
from specklepy.logging.exceptions import SpeckleException
|
||||
from warnings import warn
|
||||
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning
|
||||
|
||||
UNITS = ["mm", "cm", "m", "in", "ft", "yd", "mi"]
|
||||
|
||||
@@ -28,6 +29,12 @@ UNITS_ENCODINGS = {
|
||||
|
||||
|
||||
def get_units_from_string(unit: str):
|
||||
if not isinstance(unit, str):
|
||||
warn(
|
||||
f"Invalid units: expected type str but received {type(unit)} ({unit}). Skipping - no units will be set.",
|
||||
SpeckleWarning,
|
||||
)
|
||||
return
|
||||
unit = str.lower(unit)
|
||||
for name, alternates in UNITS_STRINGS.items():
|
||||
if unit in alternates:
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import ujson
|
||||
import hashlib
|
||||
import re
|
||||
|
||||
from uuid import uuid4
|
||||
from warnings import warn
|
||||
from typing import Any, Dict, List, Tuple
|
||||
from specklepy.objects.base import Base, DataChunk
|
||||
from specklepy.logging.exceptions import SerializationException, SpeckleException
|
||||
from specklepy.logging.exceptions import (
|
||||
SerializationException,
|
||||
SpeckleException,
|
||||
SpeckleWarning,
|
||||
)
|
||||
from specklepy.transports.abstract_transport import AbstractTransport
|
||||
import specklepy.objects.geometry
|
||||
import specklepy.objects.other
|
||||
@@ -17,6 +21,19 @@ def hash_obj(obj: Any) -> str:
|
||||
return hashlib.sha256(ujson.dumps(obj).encode()).hexdigest()[:32]
|
||||
|
||||
|
||||
def safe_json_loads(obj: str, obj_id=None) -> Any:
|
||||
try:
|
||||
return ujson.loads(obj)
|
||||
except ValueError as err:
|
||||
import json
|
||||
|
||||
warn(
|
||||
f"Failed to deserialise object (id: {obj_id}). This is likely a ujson big int error - falling back to json. \nError: {err}",
|
||||
SpeckleWarning,
|
||||
)
|
||||
return json.loads(obj)
|
||||
|
||||
|
||||
class BaseObjectSerializer:
|
||||
read_transport: AbstractTransport
|
||||
write_transports: List[AbstractTransport]
|
||||
@@ -60,14 +77,19 @@ class BaseObjectSerializer:
|
||||
chunkable = False
|
||||
detach = False
|
||||
|
||||
# skip nulls or props marked to be ignored with "__" or "_"
|
||||
if value is None or prop.startswith(("__", "_")):
|
||||
# skip props marked to be ignored with "__" or "_"
|
||||
if prop.startswith(("__", "_")):
|
||||
continue
|
||||
|
||||
# don't prepopulate id as this will mess up hashing
|
||||
if prop == "id":
|
||||
continue
|
||||
|
||||
# allow serialisation of nulls
|
||||
if value is None:
|
||||
object_builder[prop] = value
|
||||
continue
|
||||
|
||||
# only bother with chunking and detaching if there is a write transport
|
||||
if self.write_transports:
|
||||
dynamic_chunk_match = prop.startswith("@") and re.match(
|
||||
@@ -238,7 +260,7 @@ class BaseObjectSerializer:
|
||||
"""
|
||||
if not obj_string:
|
||||
return None
|
||||
obj = ujson.loads(obj_string)
|
||||
obj = safe_json_loads(obj_string)
|
||||
return self.recompose_base(obj=obj)
|
||||
|
||||
def recompose_base(self, obj: dict) -> Base:
|
||||
@@ -254,7 +276,7 @@ class BaseObjectSerializer:
|
||||
if not obj:
|
||||
return
|
||||
if isinstance(obj, str):
|
||||
obj = ujson.loads(obj)
|
||||
obj = safe_json_loads(obj)
|
||||
|
||||
if "speckle_type" in obj and obj["speckle_type"] == "reference":
|
||||
obj = self.get_child(obj=obj)
|
||||
@@ -292,7 +314,7 @@ class BaseObjectSerializer:
|
||||
raise SpeckleException(
|
||||
f"Could not find the referenced child object of id `{ref_hash}` in the given read transport: {self.read_transport.name}"
|
||||
)
|
||||
ref_obj = ujson.loads(ref_obj_str)
|
||||
ref_obj = safe_json_loads(ref_obj_str, ref_hash)
|
||||
base.__setattr__(prop, self.recompose_base(obj=ref_obj))
|
||||
|
||||
# 3. handle all other cases (base objects, lists, and dicts)
|
||||
@@ -350,4 +372,5 @@ class BaseObjectSerializer:
|
||||
raise SpeckleException(
|
||||
f"Could not find the referenced child object of id `{ref_hash}` in the given read transport: {self.read_transport.name}"
|
||||
)
|
||||
return ujson.loads(ref_obj_str)
|
||||
|
||||
return safe_json_loads(ref_obj_str, ref_hash)
|
||||
|
||||
@@ -92,10 +92,15 @@ class BatchSender(object):
|
||||
|
||||
def _bg_send_batch(self, session, batch):
|
||||
object_ids = [obj[0] for obj in batch]
|
||||
server_has_object = session.post(
|
||||
url=f"{self.server_url}/api/diff/{self.stream_id}",
|
||||
data={"objects": json.dumps(object_ids)},
|
||||
).json()
|
||||
try:
|
||||
server_has_object = session.post(
|
||||
url=f"{self.server_url}/api/diff/{self.stream_id}",
|
||||
data={"objects": json.dumps(object_ids)},
|
||||
).json()
|
||||
except Exception as ex:
|
||||
raise SpeckleException(
|
||||
f"Invalid credentials - cannot send objects to server {self.server_url}"
|
||||
) from ex
|
||||
|
||||
new_object_ids = [x for x in object_ids if not server_has_object[x]]
|
||||
new_object_ids = set(new_object_ids)
|
||||
|
||||
@@ -77,6 +77,18 @@ def test_speckle_type_cannot_be_set(base: Base) -> None:
|
||||
assert base.speckle_type == "Base"
|
||||
|
||||
|
||||
def test_setting_units():
|
||||
b = Base(units="foot")
|
||||
assert b.units == "ft"
|
||||
|
||||
with pytest.raises(SpeckleException):
|
||||
b.units = "big"
|
||||
|
||||
b.units = None # invalid args are skipped
|
||||
b.units = 7
|
||||
assert b.units == "ft"
|
||||
|
||||
|
||||
def test_base_of_custom_speckle_type() -> None:
|
||||
b1 = Base.of_type("BirdHouse", name="Tweety's Crib")
|
||||
assert b1.speckle_type == "BirdHouse"
|
||||
|
||||
@@ -58,7 +58,7 @@ class TestBranch:
|
||||
assert isinstance(branches, list)
|
||||
assert len(branches) == 2
|
||||
assert isinstance(branches[0], Branch)
|
||||
assert branches[0].name == branch.name
|
||||
assert branches[1].name == branch.name
|
||||
|
||||
def test_branch_update(self, client, stream, branch, updated_branch):
|
||||
updated = client.branch.update(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import pytest
|
||||
from specklepy.api import operations
|
||||
from specklepy.api.client import SpeckleClient
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.transports.server import ServerTransport
|
||||
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning
|
||||
|
||||
|
||||
def test_invalid_authentication():
|
||||
client = SpeckleClient()
|
||||
|
||||
with pytest.warns(SpeckleWarning):
|
||||
client.authenticate("fake token")
|
||||
|
||||
|
||||
def test_invalid_send():
|
||||
client = SpeckleClient()
|
||||
client.me = {"token": "fake token"}
|
||||
transport = ServerTransport("3073b96e86", client)
|
||||
|
||||
with pytest.raises(SpeckleException):
|
||||
operations.send(Base(), [transport])
|
||||
|
||||
|
||||
def test_invalid_receive():
|
||||
client = SpeckleClient()
|
||||
client.me = {"token": "fake token"}
|
||||
transport = ServerTransport("fake stream", client)
|
||||
|
||||
with pytest.raises(SpeckleException):
|
||||
operations.receive("fake object", transport)
|
||||
@@ -3,6 +3,7 @@ from typing import Callable
|
||||
|
||||
import pytest
|
||||
from specklepy.api import operations
|
||||
from specklepy.logging.exceptions import SpeckleException
|
||||
from specklepy.objects.base import Base
|
||||
from specklepy.objects.encoding import CurveArray, ObjectArray
|
||||
from specklepy.objects.geometry import (
|
||||
@@ -450,3 +451,15 @@ def test_serialized_brep_attributes(brep: Brep):
|
||||
|
||||
for k in removed_keys:
|
||||
assert k not in serialized_dict.keys()
|
||||
|
||||
|
||||
def test_mesh_create():
|
||||
vertices = [2, 1, 2, 4, 77.3, 5, 33, 4, 2]
|
||||
faces = [1, 2, 3, 4, 5, 6, 7]
|
||||
mesh = Mesh.create(vertices, faces)
|
||||
|
||||
with pytest.raises(SpeckleException):
|
||||
bad_mesh = Mesh.create(vertices=7, faces=faces)
|
||||
|
||||
assert mesh.vertices == vertices
|
||||
assert mesh.textureCoordinates == []
|
||||
|
||||
@@ -89,3 +89,9 @@ class TestSerialization:
|
||||
deserialised = operations.deserialize(untyped)
|
||||
|
||||
assert deserialised == {"foo": "bar"}
|
||||
|
||||
def test_big_int(self):
|
||||
big_int = '{"big": ' + str(2 ** 64) + "}"
|
||||
deserialised = operations.deserialize(big_int)
|
||||
|
||||
assert deserialised == {"big": 2 ** 64}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
from typing import List
|
||||
import pytest
|
||||
from specklepy.api import operations
|
||||
from specklepy.objects.geometry import Point, Vector
|
||||
from specklepy.objects.other import (
|
||||
Transform,
|
||||
BlockInstance,
|
||||
BlockDefinition,
|
||||
IDENTITY_TRANSFORM,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def point():
|
||||
return Point(x=1, y=10, z=2)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def points():
|
||||
return [Point(x=1 + i, y=10 + i, z=2 + i) for i in range(5)]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def point_value():
|
||||
return [1, 10, 2]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def points_values():
|
||||
coords = []
|
||||
for i in range(5):
|
||||
coords.extend([1 + i, 10 + i, 2 + 1])
|
||||
return coords
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def vector():
|
||||
return Vector(x=1, y=10, z=2)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def vector_value():
|
||||
return [1, 1, 2]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def transform():
|
||||
"""Translates to [1, 2, 0] and scales z by 0.5"""
|
||||
return Transform.from_list(
|
||||
[
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
2.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.5,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_point_transform(point: Point, transform: Transform):
|
||||
new_point = transform.apply_to_point(point)
|
||||
|
||||
assert new_point.x == point.x + 1
|
||||
assert new_point.y == point.y + 2
|
||||
assert new_point.z == point.z * 0.5
|
||||
|
||||
|
||||
def test_points_transform(points: List[Point], transform: Transform):
|
||||
new_points = transform.apply_to_points(points)
|
||||
|
||||
for (i, new_point) in enumerate(new_points):
|
||||
assert new_point.x == points[i].x + 1
|
||||
assert new_point.y == points[i].y + 2
|
||||
assert new_point.z == points[i].z * 0.5
|
||||
|
||||
|
||||
def test_point_value_transform(point_value: List[float], transform: Transform):
|
||||
new_coords = transform.apply_to_point_value(point_value)
|
||||
|
||||
assert new_coords[0] == point_value[0] + 1
|
||||
assert new_coords[1] == point_value[1] + 2
|
||||
assert new_coords[2] == point_value[2] * 0.5
|
||||
|
||||
|
||||
def test_points_values_transform(points_values: List[float], transform: Transform):
|
||||
new_coords = transform.apply_to_points_values(points_values)
|
||||
|
||||
for i in range(0, len(points_values), 3):
|
||||
assert new_coords[i] == points_values[i] + 1
|
||||
assert new_coords[i + 1] == points_values[i + 1] + 2
|
||||
assert new_coords[i + 2] == points_values[i + 2] * 0.5
|
||||
|
||||
|
||||
def test_vector_transform(vector: Vector, transform: Transform):
|
||||
new_vector = transform.apply_to_vector(vector)
|
||||
|
||||
assert new_vector.x == vector.x
|
||||
assert new_vector.y == vector.y
|
||||
assert new_vector.z == vector.z * 0.5
|
||||
|
||||
|
||||
def test_vector_value_transform(vector_value: List[float], transform: Transform):
|
||||
new_coords = transform.apply_to_vector_value(vector_value)
|
||||
|
||||
assert new_coords[0] == vector_value[0]
|
||||
assert new_coords[1] == vector_value[1]
|
||||
assert new_coords[2] == vector_value[2] * 0.5
|
||||
|
||||
|
||||
def test_transform_fails_with_malformed_value():
|
||||
with pytest.raises(ValueError):
|
||||
Transform.from_list("asdf")
|
||||
with pytest.raises(ValueError):
|
||||
Transform.from_list([7, 8, 9])
|
||||
|
||||
|
||||
def test_transform_serialisation(transform: Transform):
|
||||
serialized = operations.serialize(transform)
|
||||
deserialized = operations.deserialize(serialized)
|
||||
|
||||
assert transform.get_id() == deserialized.get_id()
|
||||
@@ -18,6 +18,14 @@ class TestWrapper:
|
||||
assert wacky_wrap.branch_name == "🍕⬅🌟 you wat?"
|
||||
assert wrap.type == "branch"
|
||||
|
||||
def test_parse_nested_branch(self):
|
||||
wrap = StreamWrapper(
|
||||
"https://testing.speckle.dev/streams/4c3ce1459c/branches/izzy/dev"
|
||||
)
|
||||
|
||||
assert wrap.branch_name == "izzy/dev"
|
||||
assert wrap.type == "branch"
|
||||
|
||||
def test_parse_commit(self):
|
||||
wrap = StreamWrapper(
|
||||
"https://testing.speckle.dev/streams/4c3ce1459c/commits/8b9b831792"
|
||||
|
||||
Reference in New Issue
Block a user