dsw-models 4.25.1__py2.py3-none-any.whl → 4.26.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,229 @@
1
+ import typing
2
+ from uuid import UUID
3
+
4
+ import pydantic
5
+
6
+ from .common import (BaseModel, TAnnotations, TQuestionValueType, THeaders,
7
+ MetricMeasure, QuestionValidation, TypeHintExchange)
8
+
9
+
10
+ class BaseKMFlatEntity(BaseModel):
11
+ uuid: UUID
12
+ annotations: TAnnotations
13
+
14
+
15
+ class Answer(BaseKMFlatEntity):
16
+ label: str
17
+ advice: str | None
18
+ metric_measures: list[MetricMeasure]
19
+ follow_up_uuids: list[UUID]
20
+
21
+
22
+ class Chapter(BaseKMFlatEntity):
23
+ title: str
24
+ text: str | None
25
+ question_uuids: list[UUID]
26
+
27
+
28
+ class Choice(BaseKMFlatEntity):
29
+ label: str
30
+
31
+
32
+ class Expert(BaseKMFlatEntity):
33
+ name: str
34
+ email: str
35
+
36
+
37
+ class ApiIntegration(BaseKMFlatEntity):
38
+ integration_type: typing.Literal['ApiIntegration'] = 'ApiIntegration'
39
+ name: str
40
+ variables: list[str]
41
+ allow_custom_reply: bool
42
+ request_method: str
43
+ request_url: str
44
+ request_headers: THeaders
45
+ request_body: str | None
46
+ request_allow_empty_search: bool
47
+ response_list_field: str | None
48
+ response_item_template: str
49
+ response_item_template_for_selection: str | None
50
+ test_q: str
51
+ test_variables: dict[str, str]
52
+ test_response: TypeHintExchange | None
53
+
54
+
55
+ class ApiLegacyIntegration(BaseKMFlatEntity):
56
+ integration_type: typing.Literal['ApiLegacyIntegration'] = 'ApiLegacyIntegration'
57
+ id: str
58
+ name: str
59
+ variables: list[str]
60
+ logo: str | None
61
+ request_method: str
62
+ request_url: str
63
+ request_headers: THeaders
64
+ request_body: str | None
65
+ request_empty_search: bool
66
+ response_list_field: str | None
67
+ response_item_id: str | None
68
+ response_item_template: str | None
69
+ item_url: str | None
70
+
71
+
72
+ class WidgetIntegration(BaseKMFlatEntity):
73
+ integration_type: typing.Literal['WidgetIntegration'] = 'WidgetIntegration'
74
+ id: str
75
+ name: str
76
+ variables: list[str]
77
+ logo: str | None
78
+ widget_url: str
79
+ item_url: str | None
80
+
81
+
82
+ Integration = typing.Annotated[
83
+ typing.Union[
84
+ ApiIntegration,
85
+ ApiLegacyIntegration,
86
+ WidgetIntegration,
87
+ ],
88
+ pydantic.Field(discriminator='integration_type'),
89
+ ]
90
+
91
+
92
+ class Metric(BaseKMFlatEntity):
93
+ title: str
94
+ abbreviation: str | None
95
+ description: str | None
96
+
97
+
98
+ class Phase(BaseKMFlatEntity):
99
+ title: str
100
+ description: str | None
101
+
102
+
103
+ class QuestionBase(BaseKMFlatEntity):
104
+ title: str
105
+ text: str | None
106
+ required_phase_uuid: UUID | None
107
+ expert_uuids: list[UUID]
108
+ reference_uuids: list[UUID]
109
+ tag_uuids: list[UUID]
110
+
111
+
112
+ class OptionsQuestion(QuestionBase):
113
+ question_type: typing.Literal['OptionsQuestion'] = 'OptionsQuestion'
114
+ answer_uuids: list[UUID]
115
+
116
+
117
+ class MultiChoiceQuestion(QuestionBase):
118
+ question_type: typing.Literal['MultiChoiceQuestion'] = 'MultiChoiceQuestion'
119
+ choice_uuids: list[UUID]
120
+
121
+
122
+ class ListQuestion(QuestionBase):
123
+ question_type: typing.Literal['ListQuestion'] = 'ListQuestion'
124
+ item_template_question_uuids: list[UUID]
125
+
126
+
127
+ class ValueQuestion(QuestionBase):
128
+ question_type: typing.Literal['ValueQuestion'] = 'ValueQuestion'
129
+ value_type: TQuestionValueType
130
+ validations: list[QuestionValidation]
131
+
132
+
133
+ class IntegrationQuestion(QuestionBase):
134
+ question_type: typing.Literal['IntegrationQuestion'] = 'IntegrationQuestion'
135
+ integration_uuid: UUID
136
+ variables: dict[str, str]
137
+
138
+
139
+ class ItemSelectQuestion(QuestionBase):
140
+ question_type: typing.Literal['ItemSelectQuestion'] = 'ItemSelectQuestion'
141
+ list_question_uuid: UUID
142
+
143
+
144
+ class FileQuestion(QuestionBase):
145
+ question_type: typing.Literal['FileQuestion'] = 'FileQuestion'
146
+ max_size: int
147
+ file_types: str | None
148
+
149
+
150
+ Question = typing.Annotated[
151
+ typing.Union[
152
+ OptionsQuestion,
153
+ MultiChoiceQuestion,
154
+ ListQuestion,
155
+ ValueQuestion,
156
+ IntegrationQuestion,
157
+ ItemSelectQuestion,
158
+ FileQuestion,
159
+ ],
160
+ pydantic.Field(discriminator='question_type'),
161
+ ]
162
+
163
+
164
+ class ResourcePageReference(BaseKMFlatEntity):
165
+ reference_type: typing.Literal['ResourcePageReference'] = 'ResourcePageReference'
166
+ resource_page_uuid: UUID
167
+
168
+
169
+ class URLReference(BaseKMFlatEntity):
170
+ reference_type: typing.Literal['URLReference'] = 'URLReference'
171
+ url: str
172
+ label: str
173
+
174
+
175
+ class CrossReference(BaseKMFlatEntity):
176
+ reference_type: typing.Literal['CrossReference'] = 'CrossReference'
177
+ target_uuid: UUID
178
+ description: str
179
+
180
+
181
+ Reference = typing.Annotated[
182
+ typing.Union[
183
+ ResourcePageReference,
184
+ URLReference,
185
+ CrossReference,
186
+ ],
187
+ pydantic.Field(discriminator='reference_type'),
188
+ ]
189
+
190
+
191
+ class ResourceCollection(BaseKMFlatEntity):
192
+ title: str
193
+ resource_page_uuids: list[UUID]
194
+
195
+
196
+ class ResourcePage(BaseKMFlatEntity):
197
+ title: str
198
+ content: str
199
+
200
+
201
+ class Tag(BaseKMFlatEntity):
202
+ name: str
203
+ description: str | None
204
+ color: str
205
+
206
+
207
+ class KnowledgeModelEntities(BaseModel):
208
+ answers: dict[UUID, Answer]
209
+ chapters: dict[UUID, Chapter]
210
+ choices: dict[UUID, Choice]
211
+ experts: dict[UUID, Expert]
212
+ integrations: dict[UUID, Integration]
213
+ metrics: dict[UUID, Metric]
214
+ phases: dict[UUID, Phase]
215
+ questions: dict[UUID, Question]
216
+ references: dict[UUID, Reference]
217
+ resource_collections: dict[UUID, ResourceCollection]
218
+ resource_pages: dict[UUID, ResourcePage]
219
+ tags: dict[UUID, Tag]
220
+
221
+
222
+ class KnowledgeModel(BaseKMFlatEntity):
223
+ entities: KnowledgeModelEntities
224
+ chapter_uuids: list[UUID]
225
+ integration_uuids: list[UUID]
226
+ metric_uuids: list[UUID]
227
+ phase_uuids: list[UUID]
228
+ resource_collection_uuids: list[UUID]
229
+ tag_uuids: list[UUID]
@@ -0,0 +1,34 @@
1
+ # pylint: disable=too-many-arguments, too-many-locals, too-many-lines
2
+ import datetime
3
+
4
+ from .common import BaseModel
5
+ from .events import Event
6
+
7
+
8
+ class KnowledgeModelPackage(BaseModel):
9
+ id: str
10
+ km_id: str
11
+ organization_id: str
12
+ version: str
13
+ name: str
14
+ metamodel_version: int
15
+ description: str
16
+ license: str
17
+ readme: str
18
+ created_at: datetime.datetime
19
+ fork_of_package_id: str | None
20
+ merge_checkpoint_package_id: str | None
21
+ previous_package_id: str | None
22
+ events: list[Event]
23
+ non_editable: bool = False
24
+ phase: str
25
+
26
+
27
+ class KnowledgeModelPackageBundle(BaseModel):
28
+ id: str
29
+ km_id: str
30
+ organization_id: str
31
+ version: str
32
+ metamodel_version: int
33
+ name: str
34
+ packages: list[KnowledgeModelPackage]
@@ -0,0 +1,172 @@
1
+ from uuid import UUID
2
+
3
+ import pydantic
4
+
5
+ from .common import (BaseModel, TAnnotations, TQuestionValueType,
6
+ QuestionValidation, TypeHintExchange)
7
+
8
+
9
+ class BaseKMTreeEntity(BaseModel):
10
+ uuid: UUID
11
+ annotations: TAnnotations
12
+
13
+
14
+ class MetricMeasure(BaseModel):
15
+ metric: 'Metric'
16
+ measure: float = pydantic.Field(ge=0.0, le=1.0)
17
+ weight: float = pydantic.Field(ge=0.0, le=1.0)
18
+
19
+
20
+ class Answer(BaseKMTreeEntity):
21
+ label: str
22
+ advice: str | None
23
+ metric_measures: list[MetricMeasure]
24
+ follow_ups: list['Question']
25
+
26
+
27
+ class Choice(BaseKMTreeEntity):
28
+ label: str
29
+
30
+
31
+ class Expert(BaseKMTreeEntity):
32
+ name: str
33
+ email: str
34
+
35
+
36
+ class Tag(BaseKMTreeEntity):
37
+ title: str
38
+ description: str | None
39
+ color: str
40
+
41
+
42
+ class Phase(BaseKMTreeEntity):
43
+ name: str
44
+ description: str | None
45
+
46
+
47
+ class Metric(BaseKMTreeEntity):
48
+ title: str
49
+ abbreviation: str | None
50
+ description: str | None
51
+
52
+
53
+ class ResourcePage(BaseKMTreeEntity):
54
+ title: str
55
+ content: str
56
+
57
+
58
+ class ResourceCollection(BaseKMTreeEntity):
59
+ title: str
60
+ resource_pages: list[ResourcePage]
61
+
62
+
63
+ class Integration(BaseKMTreeEntity):
64
+ name: str
65
+ variables: list[str]
66
+
67
+
68
+ class ApiIntegration(Integration):
69
+ allow_custom_reply: bool
70
+ request_method: str
71
+ request_url: str
72
+ request_body: str | None
73
+ request_allow_empty_search: bool
74
+ response_list_field: str
75
+ response_item_template: str
76
+ response_item_template_for_selection: str | None
77
+ test_q: str
78
+ test_variables: dict[str, str]
79
+ test_response: TypeHintExchange | None
80
+
81
+
82
+ class ApiLegacyIntegration(Integration):
83
+ id: str
84
+ logo: str | None
85
+ request_method: str
86
+ request_url: str
87
+ request_body: str | None
88
+ request_empty_search: bool
89
+ response_list_field: str | None
90
+ response_item_id: str | None
91
+ response_item_template: str | None
92
+ item_url: str | None
93
+
94
+
95
+ class WidgetIntegration(Integration):
96
+ id: str
97
+ logo: str | None
98
+ widget_url: str
99
+ item_url: str | None
100
+
101
+
102
+ class Reference(BaseKMTreeEntity):
103
+ pass
104
+
105
+
106
+ class ResourcePageReference(Reference):
107
+ resource_page: ResourcePage
108
+
109
+
110
+ class URLReference(Reference):
111
+ url: str
112
+ label: str
113
+
114
+
115
+ class CrossReference(Reference):
116
+ target: BaseKMTreeEntity
117
+ description: str
118
+
119
+
120
+ class Question(BaseKMTreeEntity):
121
+ title: str
122
+ text: str
123
+ required_phase: Phase | None
124
+ experts: list[Expert]
125
+ references: list[Reference]
126
+ tags: list[Tag]
127
+
128
+
129
+ class OptionsQuestion(Question):
130
+ answers: list[Answer]
131
+
132
+
133
+ class ChoiceQuestion(Question):
134
+ choices: list[Choice]
135
+
136
+
137
+ class ListQuestion(Question):
138
+ item_template_questions: list[Question]
139
+
140
+
141
+ class ValueQuestion(Question):
142
+ value_type: TQuestionValueType
143
+ validations: list[QuestionValidation]
144
+
145
+
146
+ class IntegrationQuestion(Question):
147
+ integration: Integration
148
+ variables: dict[str, str]
149
+
150
+
151
+ class ItemSelectQuestion(Question):
152
+ list_question: ListQuestion
153
+
154
+
155
+ class FileQuestion(Question):
156
+ max_size: int
157
+ file_types: str | None
158
+
159
+
160
+ class Chapter(BaseKMTreeEntity):
161
+ title: str
162
+ description: str
163
+ questions: list[Question]
164
+
165
+
166
+ class KnowledgeModel(BaseKMTreeEntity):
167
+ chapters: list[Chapter]
168
+ tags: list[Tag]
169
+ phases: list[Phase]
170
+ metrics: list[Metric]
171
+ integrations: list[Integration]
172
+ resource_collections: list[ResourceCollection]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dsw-models
3
- Version: 4.25.1
3
+ Version: 4.26.0
4
4
  Summary: Library with DSW models and basic IO operations
5
5
  Author-email: Marek Suchánek <marek.suchanek@ds-wizard.org>
6
6
  License: Apache License 2.0
@@ -13,11 +13,13 @@ Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
16
17
  Classifier: Topic :: Text Processing
17
18
  Classifier: Topic :: Utilities
18
19
  Requires-Python: <4,>=3.12
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
22
+ Requires-Dist: pydantic
21
23
  Dynamic: license-file
22
24
 
23
25
  # Data Stewardship Wizard: Models
@@ -28,7 +30,7 @@ Dynamic: license-file
28
30
  [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4975/badge)](https://bestpractices.coreinfrastructure.org/projects/4975)
29
31
  [![Python Version](https://img.shields.io/badge/Python-%E2%89%A5%203.7-blue)](https://python.org)
30
32
 
31
- *Library with DSW models and its basic IO*
33
+ *Library with DSW models and relevant transformations*
32
34
 
33
35
  ## Usage
34
36
 
@@ -0,0 +1,16 @@
1
+ dsw/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ dsw/models/build_info.py,sha256=GYhJZrBL07xEDAD6WxxqOSpaG023814LTEI12UTSb7U,381
3
+ dsw/models/common.py,sha256=vAP-zMKPs9Y4XHeqIwPhpQ5Sfb8jQRx4xpH1lCJMRtc,394
4
+ dsw/models/document_template/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ dsw/models/document_template/metadata.py,sha256=x2YeD3LqXi5sKb8d9Ufeph-OxGldRVUxc0OAJJP9tlE,922
6
+ dsw/models/knowledge_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ dsw/models/knowledge_model/common.py,sha256=TFPcM7qvPKRyurivDEoJD7XDN8sOC52mQvpijS8b5IU,4825
8
+ dsw/models/knowledge_model/events.py,sha256=r0IJS_43Yztoeq3SBT6KhS0BhwQf1ZoNPbuHMvpyz04,19430
9
+ dsw/models/knowledge_model/flat.py,sha256=Vxx5OBBdSBt0_EZ8yoiqx0TMDiuqG0zLGKWC3vE64H8,5519
10
+ dsw/models/knowledge_model/package.py,sha256=4sm2tJvlGWfhw0UnYX9CmUPA-z17xccmaaaJfVzf0Nk,768
11
+ dsw/models/knowledge_model/tree.py,sha256=cdN4-8FS086F-LQSo8ib-syK1eltpggWIC48XXWu6GY,3322
12
+ dsw_models-4.26.0.dist-info/licenses/LICENSE,sha256=rDtJ4LdsXvf_euOpGD0Q86P78K4JyM5m4yfYz9wZ750,11346
13
+ dsw_models-4.26.0.dist-info/METADATA,sha256=xWQFJWZFeGMDQpZMmrp6i_GhIF0nzIPOnbpYxST8Ey8,1854
14
+ dsw_models-4.26.0.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
15
+ dsw_models-4.26.0.dist-info/top_level.txt,sha256=7SfbsHFoJ_vlAgG6C-xzETETwYO71dBrGnod8uMFnjw,4
16
+ dsw_models-4.26.0.dist-info/RECORD,,
dsw/models/io.py DELETED
@@ -1,10 +0,0 @@
1
- import json
2
- import typing
3
-
4
-
5
- class WizardJSONEncoder(json.JSONEncoder):
6
-
7
- def default(self, o: typing.Any) -> typing.Any:
8
- if hasattr(o, 'to_dict') and callable(o.to_dict):
9
- return o.to_dict()
10
- return super().default(o)