Skip to content

Commit

Permalink
Merge branch 'main' of github.com:specklesystems/specklepy into v3-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
gjedlicska committed Dec 11, 2024
2 parents 92732e3 + d71b616 commit 118fa07
Show file tree
Hide file tree
Showing 23 changed files with 914 additions and 747 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
hooks:
- id: ruff
rev: v0.1.6
rev: v0.8.2

- repo: https://github.com/commitizen-tools/commitizen
hooks:
Expand All @@ -13,12 +13,12 @@ repos:
rev: v3.13.0

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.10.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
Expand Down
1,422 changes: 732 additions & 690 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ httpx = "^0.25.0"
pydantic-settings = "^2.6.1"

[tool.poetry.group.dev.dependencies]
black = "23.11.0"
isort = "^5.7.0"
black = "24.10.0"
isort = "^5.13.2"
pytest = "^7.1.3"
pytest-asyncio = "^0.23.0"
pytest-ordering = "^0.6"
pytest-cov = "^3.0.0"
devtools = "^0.8.0"
pylint = "^2.14.4"
pylint = "^3.3.2"
pydantic-settings = "^2.3.0"
mypy = "^0.982"
pre-commit = "^2.20.0"
commitizen = "^2.38.0"
ruff = "^0.4.4"
commitizen = "^3.13.0"
ruff = "^0.8.2"
types-deprecated = "^1.2.9"
types-ujson = "^5.6.0.0"
types-requests = "^2.28.11.5"
Expand All @@ -61,8 +61,7 @@ exclude = '''
'''
include = '\.pyi?$'
line-length = 88
target-version = ["py37", "py38", "py39", "py310", "py311"]

target-version = ["py39", "py310", "py311", "py312", "py313"]

[tool.commitizen]
name = "cz_conventional_commits"
Expand Down
1 change: 1 addition & 0 deletions src/speckle_automate/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Some useful helpers for working with automation data."""

import secrets
import string

Expand Down
12 changes: 4 additions & 8 deletions src/speckle_automate/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ class FunctionRunData(AutomateBase):
def execute_automate_function(
automate_function: AutomateFunction[T],
input_schema: type[T],
) -> None:
...
) -> None: ...


@overload
def execute_automate_function(
automate_function: AutomateFunctionWithoutInputs,
) -> None:
...
) -> None: ...


class AutomateGenerateJsonSchema(GenerateJsonSchema):
Expand Down Expand Up @@ -146,16 +144,14 @@ def run_function(
automation_context: AutomationContext,
automate_function: AutomateFunction[T],
inputs: T,
) -> AutomationContext:
...
) -> AutomationContext: ...


@overload
def run_function(
automation_context: AutomationContext,
automate_function: AutomateFunctionWithoutInputs,
) -> AutomationContext:
...
) -> AutomationContext: ...


def run_function(
Expand Down
4 changes: 2 additions & 2 deletions src/specklepy/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
OtherUserResource,
ProjectInviteResource,
ProjectResource,
ServerResource,
SubscriptionResource,
VersionResource,
branch,
commit,
object,
server,
stream,
subscriptions,
user,
Expand Down Expand Up @@ -69,7 +69,7 @@ def __init__(
self.account = Account()

def _init_resources(self) -> None:
self.server = server.Resource(
self.server = ServerResource(
account=self.account, basepath=self.url, client=self.httpclient
)

Expand Down
9 changes: 3 additions & 6 deletions src/specklepy/api/resources/current/active_user_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from deprecated import deprecated

from specklepy.core.api.inputs.project_inputs import UserProjectsFilter
from specklepy.core.api.inputs.user_inputs import UserUpdateInput
from specklepy.core.api.inputs.user_inputs import UserProjectsFilter, UserUpdateInput
from specklepy.core.api.models import (
PendingStreamCollaborator,
Project,
Expand Down Expand Up @@ -44,12 +43,10 @@ def update(
company: Optional[str] = None,
bio: Optional[str] = None,
avatar: Optional[str] = None,
) -> User:
...
) -> User: ...

@overload
def update(self, *, input: UserUpdateInput) -> User:
...
def update(self, *, input: UserUpdateInput) -> User: ...

def update(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/specklepy/api/resources/deprecated/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from specklepy.core.api.models.deprecated import FE1_DEPRECATION_VERSION


@deprecated(reason="Renamed to ActiveUserResource", version=FE1_DEPRECATION_VERSION)
@deprecated(reason="Renamed to ServerResource", version=FE1_DEPRECATION_VERSION)
class Resource(ServerResource):
"""Renamed to ServerResource"""
42 changes: 42 additions & 0 deletions src/specklepy/core/api/inputs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from specklepy.core.api.inputs.model_inputs import (
CreateModelInput,
DeleteModelInput,
ModelVersionsFilter,
UpdateModelInput,
)
from specklepy.core.api.inputs.project_inputs import (
ProjectCreateInput,
ProjectInviteCreateInput,
ProjectInviteUseInput,
ProjectModelsFilter,
ProjectUpdateInput,
ProjectUpdateRoleInput,
)
from specklepy.core.api.inputs.user_inputs import UserProjectsFilter, UserUpdateInput
from specklepy.core.api.inputs.version_inputs import (
CreateVersionInput,
DeleteVersionsInput,
MarkReceivedVersionInput,
MoveVersionsInput,
UpdateVersionInput,
)

__all__ = [
"CreateModelInput",
"DeleteModelInput",
"UpdateModelInput",
"ModelVersionsFilter",
"ProjectCreateInput",
"ProjectInviteCreateInput",
"ProjectInviteUseInput",
"ProjectModelsFilter",
"ProjectUpdateInput",
"ProjectUpdateRoleInput",
"UserProjectsFilter",
"UserUpdateInput",
"UpdateVersionInput",
"MoveVersionsInput",
"DeleteVersionsInput",
"CreateVersionInput",
"MarkReceivedVersionInput",
]
5 changes: 0 additions & 5 deletions src/specklepy/core/api/inputs/project_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,3 @@ class ProjectUpdateRoleInput(BaseModel):
userId: str
projectId: str
role: Optional[str]


class UserProjectsFilter(BaseModel):
search: str
onlyWithRole: Optional[Sequence[str]] = None
7 changes: 6 additions & 1 deletion src/specklepy/core/api/inputs/user_inputs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Sequence

from pydantic import BaseModel

Expand All @@ -8,3 +8,8 @@ class UserUpdateInput(BaseModel):
bio: Optional[str] = None
company: Optional[str] = None
name: Optional[str] = None


class UserProjectsFilter(BaseModel):
search: str
onlyWithRoles: Optional[Sequence[str]] = None
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from deprecated import deprecated
from gql import gql

from specklepy.core.api.inputs.project_inputs import UserProjectsFilter
from specklepy.core.api.inputs.user_inputs import UserUpdateInput
from specklepy.core.api.inputs.user_inputs import UserProjectsFilter, UserUpdateInput
from specklepy.core.api.models import (
ActivityCollection,
PendingStreamCollaborator,
Expand Down Expand Up @@ -100,12 +99,10 @@ def update(
company: Optional[str] = None,
bio: Optional[str] = None,
avatar: Optional[str] = None,
) -> User:
...
) -> User: ...

@overload
def update(self, *, input: UserUpdateInput) -> User:
...
def update(self, *, input: UserUpdateInput) -> User: ...

def update(
self,
Expand Down
14 changes: 8 additions & 6 deletions src/specklepy/core/api/resources/current/model_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def get_with_versions(
"modelId": model_id,
"versionsLimit": versions_limit,
"versionsCursor": versions_cursor,
"versionsFilter": versions_filter.model_dump(warnings="error")
if versions_filter
else None,
"versionsFilter": (
versions_filter.model_dump(warnings="error")
if versions_filter
else None
),
}

return self.make_request_and_parse_response(
Expand Down Expand Up @@ -179,9 +181,9 @@ def get_models(
"projectId": project_id,
"modelsLimit": models_limit,
"modelsCursor": models_cursor,
"modelsFilter": models_filter.model_dump(warnings="error")
if models_filter
else None,
"modelsFilter": (
models_filter.model_dump(warnings="error") if models_filter else None
),
}

return self.make_request_and_parse_response(
Expand Down
6 changes: 3 additions & 3 deletions src/specklepy/core/api/resources/current/project_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def get_with_models(
"projectId": project_id,
"modelsLimit": models_limit,
"modelsCursor": models_cursor,
"modelsFilter": models_filter.model_dump(warnings="error")
if models_filter
else None,
"modelsFilter": (
models_filter.model_dump(warnings="error") if models_filter else None
),
}

return self.make_request_and_parse_response(
Expand Down
4 changes: 2 additions & 2 deletions src/specklepy/core/api/resources/deprecated/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def list(self, stream_limit: int = 10) -> List[Stream]:
query = gql(
"""
query User($stream_limit: Int!) {
user {
activeUser {
id
bio
name
Expand Down Expand Up @@ -149,7 +149,7 @@ def list(self, stream_limit: int = 10) -> List[Stream]:
params = {"stream_limit": stream_limit}

return self.make_request(
query=query, params=params, return_type=["user", "streams", "items"]
query=query, params=params, return_type=["activeUser", "streams", "items"]
)

@deprecated(reason=FE1_DEPRECATION_REASON, version=FE1_DEPRECATION_VERSION)
Expand Down
1 change: 1 addition & 0 deletions src/specklepy/core/helpers/speckle_path_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Provides uniform and consistent path helpers for `specklepy`
"""

import os
import sys
from pathlib import Path
Expand Down
6 changes: 3 additions & 3 deletions src/specklepy/objects/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ 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
Expand Down
20 changes: 19 additions & 1 deletion tests/integration/client/current/test_active_user_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from specklepy.api.client import SpeckleClient
from specklepy.core.api.inputs.project_inputs import ProjectCreateInput
from specklepy.core.api.inputs.user_inputs import UserUpdateInput
from specklepy.core.api.inputs.user_inputs import UserProjectsFilter, UserUpdateInput
from specklepy.core.api.models import ResourceCollection, User


Expand Down Expand Up @@ -42,3 +42,21 @@ def test_active_user_get_projects(self, client: SpeckleClient):
assert len(res.items) == len(existing.items) + 2
assert any(project.id == p1.id for project in res.items)
assert any(project.id == p2.id for project in res.items)

def test_active_user_get_projects_with_filter(self, client: SpeckleClient):
# Since the client may be reused for other tests,
# this test does rely on no other test creating a project with "Search for me" in its name
p1 = client.project.create(
ProjectCreateInput(name="Search for me!", description=None, visibility=None)
)
_ = client.project.create(
ProjectCreateInput(name="But not me!", description=None, visibility=None)
)
filter = UserProjectsFilter(search="Search for me")

res = client.active_user.get_projects(filter=filter)

assert isinstance(res, ResourceCollection)
assert len(res.items) == 1
assert res.totalCount == 1
assert res.items[0].id == p1.id
Loading

0 comments on commit 118fa07

Please sign in to comment.