Skip to content

Commit 9e078fa

Browse files
author
Jens Kürten
committed
Merge branch 'main' of github.com:cslab/functions-sdk-python into ec_status_changeevent
2 parents 47eb973 + c0bd6a2 commit 9e078fa

25 files changed

+354
-317
lines changed

csfunctions/devserver.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import os
3636
import time
3737
from collections.abc import Iterable
38-
from wsgiref.types import StartResponse, WSGIEnvironment
3938

4039
from werkzeug.serving import run_simple
4140
from werkzeug.wrappers import Request, Response
@@ -128,7 +127,7 @@ def handle_request(request: Request) -> Response:
128127
return Response(response, content_type="application/json")
129128

130129

131-
def application(environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]:
130+
def application(environ, start_response) -> Iterable[bytes]:
132131
request = Request(environ)
133132
response = handle_request(request)
134133
return response(environ, start_response)

csfunctions/events/__init__.py

+21-23
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
from pydantic import Field
44

5-
from .dialog_data import DocumentReleaseDialogData, PartReleaseDialogData
5+
from .dialog_data import DocumentReleasedDialogData, PartReleasedDialogData
66
from .document_create_check import DocumentCreateCheckData, DocumentCreateCheckEvent
77
from .document_field_calculation import DocumentFieldCalculationData, DocumentFieldCalculationEvent
88
from .document_modify_check import DocumentModifyCheckData, DocumentModifyCheckEvent
9-
from .document_release import DocumentReleaseData, DocumentReleaseEvent
109
from .document_release_check import DocumentReleaseCheckData, DocumentReleaseCheckEvent
10+
from .document_released import DocumentReleasedData, DocumentReleasedEvent
1111
from .dummy import DummyEvent, DummyEventData
12-
from .engineering_change_release import EngineeringChangeRelease, EngineeringChangeReleaseData
13-
from .engineering_change_release_check import EngineeringChangeReleaseCheck, EngineeringChangeReleaseCheckData
12+
from .engineering_change_release_check import EngineeringChangeReleaseCheckData, EngineeringChangeReleaseCheckEvent
13+
from .engineering_change_released import EngineeringChangeReleasedData, EngineeringChangeReleasedEvent
1414
from .engineering_change_status_change_check import (
1515
EngineeringChangeStatusChangeCheck,
1616
EngineeringChangeStatusChangeCheckData,
@@ -20,22 +20,22 @@
2020
from .part_create_check import PartCreateCheckData, PartCreateCheckEvent
2121
from .part_field_calculation import PartFieldCalculationData, PartFieldCalculationEvent
2222
from .part_modify_check import PartModifyCheckData, PartModifyCheckEvent
23-
from .part_release import PartReleaseData, PartReleaseEvent
2423
from .part_release_check import PartReleaseCheckData, PartReleaseCheckEvent
24+
from .part_released import PartReleasedData, PartReleasedEvent
2525
from .workflow_task_trigger import WorkflowTaskTriggerEvent, WorkflowTaskTriggerEventData
2626

2727
Event = Annotated[
2828
Union[
29-
DocumentReleaseEvent,
29+
DocumentReleasedEvent,
3030
DocumentReleaseCheckEvent,
3131
DocumentFieldCalculationEvent,
32-
PartReleaseEvent,
32+
PartReleasedEvent,
3333
PartReleaseCheckEvent,
3434
PartFieldCalculationEvent,
3535
FieldValueCalculationEvent,
3636
DummyEvent,
37-
EngineeringChangeRelease,
38-
EngineeringChangeReleaseCheck,
37+
EngineeringChangeReleasedEvent,
38+
EngineeringChangeReleaseCheckEvent,
3939
EngineeringChangeStatusChanged,
4040
EngineeringChangeStatusChangeCheck,
4141
WorkflowTaskTriggerEvent,
@@ -47,15 +47,15 @@
4747
Field(discriminator="name"),
4848
]
4949
EventData = Union[
50-
DocumentReleaseData,
50+
DocumentReleasedData,
5151
DocumentReleaseCheckData,
5252
DocumentFieldCalculationData,
53-
PartReleaseData,
53+
PartReleasedData,
5454
PartReleaseCheckData,
5555
PartFieldCalculationData,
5656
FieldValueCalculationData,
5757
DummyEventData,
58-
EngineeringChangeReleaseData,
58+
EngineeringChangeReleasedData,
5959
EngineeringChangeReleaseCheckData,
6060
EngineeringChangeStatusChangedData,
6161
EngineeringChangeStatusChangeCheckData,
@@ -67,33 +67,31 @@
6767
]
6868

6969
__all__ = [
70-
"DocumentReleaseEvent",
70+
"DocumentReleasedEvent",
7171
"DocumentReleaseCheckEvent",
7272
"DocumentFieldCalculationEvent",
73-
"PartReleaseEvent",
73+
"PartReleasedEvent",
7474
"PartReleaseCheckEvent",
7575
"PartFieldCalculationEvent",
7676
"FieldValueCalculationEvent",
7777
"DummyEvent",
78-
"EngineeringChangeRelease",
79-
"EngineeringChangeReleaseCheck",
80-
"EngineeringChangeStatusChanged",
81-
"EngineeringChangeStatusChangeCheck",
78+
"EngineeringChangeReleasedEvent",
79+
"EngineeringChangeReleaseCheckEvent",
8280
"WorkflowTaskTriggerEvent",
83-
"DocumentReleaseData",
81+
"DocumentReleasedData",
8482
"DocumentReleaseCheckData",
8583
"DocumentFieldCalculationData",
86-
"PartReleaseData",
84+
"PartReleasedData",
8785
"PartReleaseCheckData",
8886
"FieldValueCalculationData",
8987
"DummyEventData",
90-
"EngineeringChangeReleaseData",
88+
"EngineeringChangeReleasedData",
9189
"EngineeringChangeReleaseCheckData",
9290
"EngineeringChangeStatusChangedData",
9391
"EngineeringChangeStatusChangeCheckData",
9492
"WorkflowTaskTriggerEventData",
95-
"DocumentReleaseDialogData",
96-
"PartReleaseDialogData",
93+
"DocumentReleasedDialogData",
94+
"PartReleasedDialogData",
9795
"PartFieldCalculationData",
9896
"DocumentCreateCheckData",
9997
"DocumentCreateCheckEvent",

csfunctions/events/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
class EventNames(str, Enum):
77
DUMMY = "dummy"
8-
DOCUMENT_RELEASE = "document_release"
8+
DOCUMENT_RELEASED = "document_released"
99
DOCUMENT_RELEASE_CHECK = "document_release_check"
1010
DOCUMENT_FIELD_CALCULATION = "document_field_calculation"
11-
PART_RELEASE = "part_release"
11+
PART_RELEASED = "part_released"
1212
PART_RELEASE_CHECK = "part_release_check"
1313
PART_FIELD_CALCULATION = "part_field_calculation"
14-
ENGINEERING_CHANGE_RELEASE = "engineering_change_release"
14+
ENGINEERING_CHANGE_RELEASED = "engineering_change_released"
1515
ENGINEERING_CHANGE_RELEASE_CHECK = "engineering_change_release_check"
1616
FIELD_VALUE_CALCULATION = "field_value_calculation"
1717
WORKFLOW_TASK_TRIGGER = "workflow_task_trigger"

csfunctions/events/dialog_data.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from pydantic import BaseModel, Field
44

55

6-
class DocumentReleaseDialogData(BaseModel):
6+
class DocumentReleasedDialogData(BaseModel):
77
dialog_type: Literal["document_release"] = "document_release"
88
cdbprot_remark: str | None = Field(None, description="remark")
99
cdb_ec_id: str | None = Field(None, description="Engineering Change ID")
1010

1111

12-
class PartReleaseDialogData(BaseModel):
12+
class PartReleasedDialogData(BaseModel):
1313
dialog_type: Literal["part_release"] = "part_release"
1414
cdbprot_remark: str | None = Field("", description="remark")
1515
cdb_ec_id: str | None = Field("", description="Engineering Change ID")

csfunctions/events/document_create_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class DocumentCreateCheckData(BaseModel):
1111
documents: list[Document] = Field(..., description="List of documents that are about to be created")
12-
linked_parts: list[Part] = Field(..., description="List of parts that belong to the documents")
12+
parts: list[Part] = Field(..., description="List of parts that belong to the documents")
1313

1414

1515
class DocumentCreateCheckEvent(BaseEvent):

csfunctions/events/document_field_calculation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class DocumentFieldCalculationData(BaseModel):
1111
document: Document = Field(..., description="Current state of the document")
1212
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")
13-
linked_parts: list[Part] = Field(..., description="Parts that belong to the document")
13+
parts: list[Part] = Field(..., description="Parts that belong to the document")
1414

1515

1616
class DocumentFieldCalculationEvent(BaseEvent):

csfunctions/events/document_modify_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class DocumentModifyCheckData(BaseModel):
1111
documents: list[Document] = Field(..., description="List of documents that are about to be modified")
12-
linked_parts: list[Part] = Field(..., description="List of parts that belong to the documents")
12+
parts: list[Part] = Field(..., description="List of parts that belong to the documents")
1313

1414

1515
class DocumentModifyCheckEvent(BaseEvent):

csfunctions/events/document_release_check.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from csfunctions.objects import Document, Part
66

77
from .base import BaseEvent, EventNames
8-
from .dialog_data import DocumentReleaseDialogData
8+
from .dialog_data import DocumentReleasedDialogData
99

1010

1111
class DocumentReleaseCheckData(BaseModel):
1212
documents: list[Document] = Field(..., description="List of documents that will be released.")
13-
attached_parts: list[Part] = Field(..., description="List of parts that belong to the documents")
14-
dialog_data: DocumentReleaseDialogData
13+
parts: list[Part] = Field(..., description="List of parts that belong to the documents")
14+
dialog_data: DocumentReleasedDialogData
1515

1616

1717
class DocumentReleaseCheckEvent(BaseEvent):

csfunctions/events/document_release.py renamed to csfunctions/events/document_released.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from csfunctions.objects import Document, Part
66

77
from .base import BaseEvent, EventNames
8-
from .dialog_data import DocumentReleaseDialogData
8+
from .dialog_data import DocumentReleasedDialogData
99

1010

11-
class DocumentReleaseData(BaseModel):
11+
class DocumentReleasedData(BaseModel):
1212
documents: list[Document] = Field(..., description="List of documents that were released.")
1313
parts: list[Part] = Field(..., description="List of parts that belong to the released documents")
14-
dialog_data: DocumentReleaseDialogData
14+
dialog_data: DocumentReleasedDialogData
1515

1616

17-
class DocumentReleaseEvent(BaseEvent):
18-
name: Literal[EventNames.DOCUMENT_RELEASE] = EventNames.DOCUMENT_RELEASE
19-
data: DocumentReleaseData
17+
class DocumentReleasedEvent(BaseEvent):
18+
name: Literal[EventNames.DOCUMENT_RELEASED] = EventNames.DOCUMENT_RELEASED
19+
data: DocumentReleasedData

csfunctions/events/engineering_change_release_check.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99

1010
class EngineeringChangeReleaseCheckData(BaseModel):
11-
attached_documents: list[Document] = Field(..., description="List of included documents.")
12-
attached_parts: list[Part] = Field(..., description="List of included parts.")
11+
documents: list[Document] = Field(..., description="List of included documents.")
12+
parts: list[Part] = Field(..., description="List of included parts.")
1313
engineering_changes: list[EngineeringChange] = Field(
1414
..., description="List of engineering changes that will be released."
1515
)
1616

1717

18-
class EngineeringChangeReleaseCheck(BaseEvent):
18+
class EngineeringChangeReleaseCheckEvent(BaseEvent):
1919
name: Literal[EventNames.ENGINEERING_CHANGE_RELEASE_CHECK] = EventNames.ENGINEERING_CHANGE_RELEASE_CHECK
2020
data: EngineeringChangeReleaseCheckData

csfunctions/events/engineering_change_release.py renamed to csfunctions/events/engineering_change_released.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from .base import BaseEvent, EventNames
88

99

10-
class EngineeringChangeReleaseData(BaseModel):
10+
class EngineeringChangeReleasedData(BaseModel):
1111
documents: list[Document] = Field(..., description="List of included documents.")
1212
parts: list[Part] = Field(..., description="List of included parts.")
1313
engineering_changes: list[EngineeringChange] = Field(
1414
..., description="List of engineering changes that were released."
1515
)
1616

1717

18-
class EngineeringChangeRelease(BaseEvent):
19-
name: Literal[EventNames.ENGINEERING_CHANGE_RELEASE] = EventNames.ENGINEERING_CHANGE_RELEASE
20-
data: EngineeringChangeReleaseData
18+
class EngineeringChangeReleasedEvent(BaseEvent):
19+
name: Literal[EventNames.ENGINEERING_CHANGE_RELEASED] = EventNames.ENGINEERING_CHANGE_RELEASED
20+
data: EngineeringChangeReleasedData

csfunctions/events/part_create_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class PartCreateCheckData(BaseModel):
1111
parts: list[Part] = Field(..., description="List of parts that are about to be created")
12-
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
12+
documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
1313

1414

1515
class PartCreateCheckEvent(BaseEvent):

csfunctions/events/part_field_calculation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PartFieldCalculationData(BaseModel):
1111
part: Part = Field(..., description="Current state of the part")
1212
action: Literal["create", "modify", "copy", "index"] = Field(..., description="Action being performed")
1313

14-
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
14+
documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
1515

1616

1717
class PartFieldCalculationEvent(BaseEvent):

csfunctions/events/part_modify_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class PartModifyCheckData(BaseModel):
1111
parts: list[Part] = Field(..., description="List of parts that are about to be modified")
12-
linked_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
12+
documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
1313

1414

1515
class PartModifyCheckEvent(BaseEvent):

csfunctions/events/part_release_check.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from csfunctions.objects import Document, Part
66

77
from .base import BaseEvent, EventNames
8-
from .dialog_data import PartReleaseDialogData
8+
from .dialog_data import PartReleasedDialogData
99

1010

1111
class PartReleaseCheckData(BaseModel):
1212
parts: list[Part] = Field(..., description="List of parts that will be released.")
13-
attached_documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
14-
dialog_data: PartReleaseDialogData
13+
documents: list[Document] = Field(..., description="List of documents that are referenced by the parts.")
14+
dialog_data: PartReleasedDialogData
1515

1616

1717
class PartReleaseCheckEvent(BaseEvent):

csfunctions/events/part_release.py renamed to csfunctions/events/part_released.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from csfunctions.objects import Document, Part
66

77
from .base import BaseEvent, EventNames
8-
from .dialog_data import PartReleaseDialogData
8+
from .dialog_data import PartReleasedDialogData
99

1010

11-
class PartReleaseData(BaseModel):
11+
class PartReleasedData(BaseModel):
1212
parts: list[Part] = Field(..., description="List if parts that were released.")
1313
documents: list[Document] = Field(..., description="List if documents that are referenced by the released part.")
14-
dialog_data: PartReleaseDialogData
14+
dialog_data: PartReleasedDialogData
1515

1616

17-
class PartReleaseEvent(BaseEvent):
18-
name: Literal[EventNames.PART_RELEASE] = EventNames.PART_RELEASE
19-
data: PartReleaseData
17+
class PartReleasedEvent(BaseEvent):
18+
name: Literal[EventNames.PART_RELEASED] = EventNames.PART_RELEASED
19+
data: PartReleasedData

csfunctions/objects/document.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from contextlib import suppress
21
from datetime import date, datetime
32
from typing import TYPE_CHECKING, Literal, Optional
43

@@ -8,9 +7,7 @@
87

98
from .base import BaseObject, ObjectType
109
from .file import File
11-
12-
with suppress(ImportError):
13-
from .part import Part
10+
from .part import Part
1411

1512
if TYPE_CHECKING:
1613
from csfunctions.events import EventData
@@ -99,3 +96,6 @@ class CADDocument(Document):
9996
"""
10097

10198
object_type: Literal[ObjectType.CAD_DOCUMENT] = ObjectType.CAD_DOCUMENT # type: ignore[assignment]
99+
100+
101+
Part.model_rebuild()

csfunctions/objects/part.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from contextlib import suppress
21
from datetime import date, datetime
32
from typing import TYPE_CHECKING, Literal, Optional
43

@@ -11,7 +10,6 @@
1110
if TYPE_CHECKING:
1211
from csfunctions.events import EventData
1312

14-
with suppress(ImportError):
1513
from .document import Document
1614

1715

0 commit comments

Comments
 (0)