Skip to content

Commit

Permalink
Merge pull request #241 from specklesystems/speckle_type_sync_with_core
Browse files Browse the repository at this point in the history
speckle type sync with core
  • Loading branch information
gjedlicska authored Dec 21, 2022
2 parents 67499ab + 59a6950 commit f36d63a
Show file tree
Hide file tree
Showing 64 changed files with 1,051 additions and 585 deletions.
13 changes: 7 additions & 6 deletions example/many_children.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import random
import string
import time
from pathlib import Path
from typing import List
from specklepy.objects import Base

from specklepy.api import operations
from specklepy.objects import Base
from specklepy.transports.sqlite import SQLiteTransport
import time
from pathlib import Path
import os
import string
import random


class Sub(Base):
Expand Down
7 changes: 4 additions & 3 deletions example/stream_objects.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import random
import string
from typing import List

from specklepy.api import operations
from specklepy.api.wrapper import StreamWrapper
from specklepy.objects import Base
from specklepy.api import operations
import string
import random


class Sub(Base):
Expand Down
5 changes: 3 additions & 2 deletions example/using_speckle_base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""This is an example showcasing the usage of speckle `Base` class."""

# the speckle.objects module exposes all speckle provided classes
from specklepy.objects import Base
from specklepy.api import operations
from devtools import debug

from specklepy.api import operations
from specklepy.objects import Base


class ExampleSub(Base):
"""
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ target-version = ["py37", "py38", "py39", "py310"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"
26 changes: 12 additions & 14 deletions src/specklepy/api/client.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import re
from typing import Dict
from warnings import warn

from deprecated import deprecated
from specklepy.api.credentials import Account, get_account_from_token
from specklepy.logging import metrics
from specklepy.logging.exceptions import (
SpeckleException,
SpeckleWarning,
)
from typing import Dict
from gql import Client
from gql.transport.requests import RequestsHTTPTransport
from gql.transport.websockets import WebsocketsTransport

from specklepy.api import resources
from specklepy.api.credentials import Account, get_account_from_token
from specklepy.api.resources import (
active_user,
branch,
commit,
stream,
object,
other_user,
server,
user,
stream,
subscriptions,
other_user,
active_user
user,
)
from gql import Client
from gql.transport.requests import RequestsHTTPTransport
from gql.transport.websockets import WebsocketsTransport
from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning


class SpeckleClient:
Expand Down
12 changes: 7 additions & 5 deletions src/specklepy/api/credentials.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
from pydantic import BaseModel, Field # pylint: disable=no-name-in-module
from typing import List, Optional
from specklepy.logging import metrics

from pydantic import BaseModel, Field # pylint: disable=no-name-in-module

from specklepy import paths
from specklepy.api.models import ServerInfo
from specklepy.transports.sqlite import SQLiteTransport
from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException
from specklepy import paths
from specklepy.transports.sqlite import SQLiteTransport


class UserInfo(BaseModel):
Expand Down Expand Up @@ -64,7 +66,7 @@ def get_local_accounts(base_path: Optional[str] = None) -> List[Account]:
json_acct_files.extend(
file for file in os.listdir(json_path) if file.endswith(".json")
)

except Exception:
# cannot find or get the json account paths
pass
Expand Down
2 changes: 1 addition & 1 deletion src/specklepy/api/host_applications.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from dataclasses import dataclass
from enum import Enum
from unicodedata import name


Expand Down
19 changes: 9 additions & 10 deletions src/specklepy/api/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime
from typing import List, Optional


from pydantic import BaseModel, Field


Expand Down Expand Up @@ -60,20 +59,20 @@ class Branches(BaseModel):


class Stream(BaseModel):
id: Optional[str] = None
id: Optional[str] = None
name: Optional[str]
role: Optional[str] = None
isPublic: Optional[bool] = None
description: Optional[str] = None
createdAt: Optional[datetime] = None
updatedAt: Optional[datetime] = None
createdAt: Optional[datetime] = None
updatedAt: Optional[datetime] = None
collaborators: List[Collaborator] = Field(default_factory=list)
branches: Optional[Branches] = None
commit: Optional[Commit] = None
object: Optional[Object] = None
commentCount: Optional[int] = None
favoritedDate: Optional[datetime] = None
favoritesCount: Optional[int] = None
branches: Optional[Branches] = None
commit: Optional[Commit] = None
object: Optional[Object] = None
commentCount: Optional[int] = None
favoritedDate: Optional[datetime] = None
favoritesCount: Optional[int] = None

def __repr__(self):
return f"Stream( id: {self.id}, name: {self.name}, description: {self.description}, isPublic: {self.isPublic})"
Expand Down
7 changes: 4 additions & 3 deletions src/specklepy/api/operations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import List, Optional

from specklepy.logging import metrics
from specklepy.objects.base import Base
from specklepy.transports.sqlite import SQLiteTransport
from specklepy.logging.exceptions import SpeckleException
from specklepy.transports.abstract_transport import AbstractTransport
from specklepy.objects.base import Base
from specklepy.serialization.base_object_serializer import BaseObjectSerializer
from specklepy.transports.abstract_transport import AbstractTransport
from specklepy.transports.sqlite import SQLiteTransport


def send(
Expand Down
8 changes: 5 additions & 3 deletions src/specklepy/api/resource.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from graphql import DocumentNode
from specklepy.api.credentials import Account
from specklepy.transports.sqlite import SQLiteTransport
from typing import Any, Dict, List, Optional, Tuple, Type, Union

from gql.client import Client
from gql.transport.exceptions import TransportQueryError
from graphql import DocumentNode

from specklepy.api.credentials import Account
from specklepy.logging.exceptions import (
GraphQLException,
SpeckleException,
UnsupportedException,
)
from specklepy.serialization.base_object_serializer import BaseObjectSerializer
from specklepy.transports.sqlite import SQLiteTransport


class ResourceBase(object):
Expand Down
4 changes: 1 addition & 3 deletions src/specklepy/api/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from pathlib import Path
import sys
import pkgutil
import sys
from importlib import import_module


for (_, name, _) in pkgutil.iter_modules(__path__):

imported_module = import_module("." + name, package=__name__)
Expand Down
9 changes: 5 additions & 4 deletions src/specklepy/api/resources/active_user.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import List, Optional
from datetime import datetime, timezone
from typing import List, Optional

from gql import gql

from specklepy.api.models import ActivityCollection, PendingStreamCollaborator, User
from specklepy.api.resource import ResourceBase
from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException
from specklepy.api.resource import ResourceBase
from specklepy.api.models import ActivityCollection, PendingStreamCollaborator, User


NAME = "active_user"

Expand Down
3 changes: 2 additions & 1 deletion src/specklepy/api/resources/branch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from gql import gql
from specklepy.api.resource import ResourceBase

from specklepy.api.models import Branch
from specklepy.api.resource import ResourceBase
from specklepy.logging import metrics

NAME = "branch"
Expand Down
7 changes: 4 additions & 3 deletions src/specklepy/api/resources/commit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import Optional, List
from typing import List, Optional

from gql import gql
from specklepy.api.resource import ResourceBase

from specklepy.api.models import Commit
from specklepy.api.resource import ResourceBase
from specklepy.logging import metrics


NAME = "commit"


Expand Down
2 changes: 2 additions & 0 deletions src/specklepy/api/resources/object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Dict, List

from gql import gql

from specklepy.api.resource import ResourceBase
from specklepy.objects.base import Base

Expand Down
11 changes: 5 additions & 6 deletions src/specklepy/api/resources/other_user.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import List, Optional, Union
from datetime import datetime, timezone
from typing import List, Optional, Union

from gql import gql

from specklepy.api.models import ActivityCollection, LimitedUser
from specklepy.api.resource import ResourceBase
from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException
from specklepy.api.resource import ResourceBase
from specklepy.api.models import (
ActivityCollection,
LimitedUser,
)

NAME = "other_user"

Expand Down
3 changes: 2 additions & 1 deletion src/specklepy/api/resources/server.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import re
from typing import Any, Dict, List, Tuple

from gql import gql

from specklepy.api.models import ServerInfo
from specklepy.api.resource import ResourceBase
from specklepy.logging import metrics
from specklepy.logging.exceptions import GraphQLException


NAME = "server"


Expand Down
7 changes: 4 additions & 3 deletions src/specklepy/api/resources/stream.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from datetime import datetime, timezone
from typing import List, Optional

from deprecated import deprecated
from gql import gql
from specklepy.logging import metrics

from specklepy.api.models import ActivityCollection, PendingStreamCollaborator, Stream
from specklepy.api.resource import ResourceBase
from specklepy.logging.exceptions import UnsupportedException, SpeckleException

from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException, UnsupportedException

NAME = "stream"

Expand Down
4 changes: 3 additions & 1 deletion src/specklepy/api/resources/subscriptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Callable, Dict, List, Union
from functools import wraps
from typing import Callable, Dict, List, Union

from gql import gql
from graphql import DocumentNode

from specklepy.api.resource import ResourceBase
from specklepy.api.resources.stream import Stream
from specklepy.logging.exceptions import SpeckleException
Expand Down
11 changes: 6 additions & 5 deletions src/specklepy/api/resources/user.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from typing import List, Optional, Union
from datetime import datetime, timezone
from typing import List, Optional, Union

from deprecated import deprecated
from gql import gql

from specklepy.api.models import ActivityCollection, PendingStreamCollaborator, User
from specklepy.api.resource import ResourceBase
from specklepy.logging import metrics
from specklepy.logging.exceptions import SpeckleException
from specklepy.api.resource import ResourceBase
from specklepy.api.models import ActivityCollection, PendingStreamCollaborator, User
from deprecated import deprecated


NAME = "user"

Expand Down
7 changes: 4 additions & 3 deletions src/specklepy/api/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from urllib.parse import unquote, urlparse
from warnings import warn
from urllib.parse import urlparse, unquote

from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import (
Account,
get_account_from_token,
get_local_accounts,
)
from specklepy.logging import metrics
from specklepy.api.client import SpeckleClient
from specklepy.transports.server.server import ServerTransport
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning
from specklepy.transports.server.server import ServerTransport


class StreamWrapper:
Expand Down
14 changes: 7 additions & 7 deletions src/specklepy/logging/metrics.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys
import queue
import hashlib
import contextlib
import getpass
import hashlib
import logging
from typing import Optional
import requests
import threading
import platform
import contextlib
import queue
import sys
import threading
from typing import Optional

import requests

"""
Anonymous telemetry to help us understand how to make a better Speckle.
Expand Down
3 changes: 2 additions & 1 deletion src/specklepy/objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Builtin Speckle object kit."""

from specklepy.objects import encoding, geometry, other, primitive, structural, units
from specklepy.objects.base import Base

__all__ = ["Base"]
__all__ = ["Base", "encoding", "geometry", "other", "units", "structural", "primitive"]
Loading

0 comments on commit f36d63a

Please sign in to comment.