overture-schema-codegen 0.1.1.dev0__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.
- overture/schema/codegen/__init__.py +1 -0
- overture/schema/codegen/cli.py +228 -0
- overture/schema/codegen/extraction/__init__.py +0 -0
- overture/schema/codegen/extraction/docstring.py +46 -0
- overture/schema/codegen/extraction/enum_extraction.py +40 -0
- overture/schema/codegen/extraction/examples.py +367 -0
- overture/schema/codegen/extraction/field.py +172 -0
- overture/schema/codegen/extraction/field_constraints.py +185 -0
- overture/schema/codegen/extraction/field_walk.py +275 -0
- overture/schema/codegen/extraction/length_constraints.py +49 -0
- overture/schema/codegen/extraction/literal_alternatives.py +26 -0
- overture/schema/codegen/extraction/model_constraints.py +252 -0
- overture/schema/codegen/extraction/model_extraction.py +240 -0
- overture/schema/codegen/extraction/newtype_extraction.py +73 -0
- overture/schema/codegen/extraction/numeric_extraction.py +74 -0
- overture/schema/codegen/extraction/pydantic_extraction.py +33 -0
- overture/schema/codegen/extraction/specs.py +295 -0
- overture/schema/codegen/extraction/type_analyzer.py +693 -0
- overture/schema/codegen/extraction/type_registry.py +137 -0
- overture/schema/codegen/extraction/union_extraction.py +270 -0
- overture/schema/codegen/layout/__init__.py +0 -0
- overture/schema/codegen/layout/module_layout.py +139 -0
- overture/schema/codegen/layout/type_collection.py +122 -0
- overture/schema/codegen/markdown/__init__.py +0 -0
- overture/schema/codegen/markdown/link_computation.py +70 -0
- overture/schema/codegen/markdown/path_assignment.py +114 -0
- overture/schema/codegen/markdown/pipeline.py +198 -0
- overture/schema/codegen/markdown/renderer.py +641 -0
- overture/schema/codegen/markdown/reverse_references.py +169 -0
- overture/schema/codegen/markdown/templates/_used_by.md.jinja2 +10 -0
- overture/schema/codegen/markdown/templates/enum.md.jinja2 +13 -0
- overture/schema/codegen/markdown/templates/feature.md.jinja2 +45 -0
- overture/schema/codegen/markdown/templates/geometric.md.jinja2 +11 -0
- overture/schema/codegen/markdown/templates/newtype.md.jinja2 +17 -0
- overture/schema/codegen/markdown/templates/numeric.md.jinja2 +27 -0
- overture/schema/codegen/markdown/templates/pydantic_type.md.jinja2 +8 -0
- overture/schema/codegen/markdown/type_format.py +383 -0
- overture/schema/codegen/py.typed +0 -0
- overture/schema/codegen/pyspark/__init__.py +1 -0
- overture/schema/codegen/pyspark/_primitive_fill.py +23 -0
- overture/schema/codegen/pyspark/_render_common.py +477 -0
- overture/schema/codegen/pyspark/check_builder.py +961 -0
- overture/schema/codegen/pyspark/check_ir.py +223 -0
- overture/schema/codegen/pyspark/constraint_dispatch.py +753 -0
- overture/schema/codegen/pyspark/pipeline.py +220 -0
- overture/schema/codegen/pyspark/renderer.py +816 -0
- overture/schema/codegen/pyspark/schema_builder.py +187 -0
- overture/schema/codegen/pyspark/templates/_check_function.py.jinja2 +10 -0
- overture/schema/codegen/pyspark/templates/model_module.py.jinja2 +83 -0
- overture/schema/codegen/pyspark/templates/test_module.py.jinja2 +129 -0
- overture/schema/codegen/pyspark/test_data/__init__.py +9 -0
- overture/schema/codegen/pyspark/test_data/base_row.py +835 -0
- overture/schema/codegen/pyspark/test_data/constraint_values.py +203 -0
- overture/schema/codegen/pyspark/test_data/invalid_value.py +105 -0
- overture/schema/codegen/pyspark/test_data/scaffold.py +390 -0
- overture/schema/codegen/pyspark/test_renderer.py +708 -0
- overture/schema/codegen/spec_discovery.py +66 -0
- overture_schema_codegen-0.1.1.dev0.dist-info/METADATA +13 -0
- overture_schema_codegen-0.1.1.dev0.dist-info/RECORD +61 -0
- overture_schema_codegen-0.1.1.dev0.dist-info/WHEEL +4 -0
- overture_schema_codegen-0.1.1.dev0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Bridge discovered models to extracted specs.
|
|
2
|
+
|
|
3
|
+
`discover_models` yields `(ModelKey, entry)` pairs where each entry is either
|
|
4
|
+
a concrete Pydantic model class, a discriminated-union type alias, or a
|
|
5
|
+
`RootModel`. This module turns one such pair into a spec, splitting by output:
|
|
6
|
+
`extract_model_spec` yields the feature/union `ModelSpec` the pipelines
|
|
7
|
+
generate from, while `extract_alias_spec` documents a `RootModel` as a named
|
|
8
|
+
alias for markdown. It sits at the orchestration tier (alongside `cli`),
|
|
9
|
+
importing downward into extraction and layout.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from overture.schema.system.discovery import ModelKey
|
|
15
|
+
|
|
16
|
+
from .extraction.model_extraction import extract_model
|
|
17
|
+
from .extraction.newtype_extraction import extract_rootmodel_alias
|
|
18
|
+
from .extraction.specs import (
|
|
19
|
+
ModelSpec,
|
|
20
|
+
NewTypeSpec,
|
|
21
|
+
is_model_class,
|
|
22
|
+
is_rootmodel,
|
|
23
|
+
is_union_alias,
|
|
24
|
+
partitions_from_tags,
|
|
25
|
+
)
|
|
26
|
+
from .extraction.union_extraction import extract_union
|
|
27
|
+
from .layout.module_layout import entry_point_class
|
|
28
|
+
|
|
29
|
+
__all__ = ["extract_alias_spec", "extract_model_spec"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def extract_model_spec(key: ModelKey, entry: object) -> ModelSpec | None:
|
|
33
|
+
"""Extract the feature/union `ModelSpec` for a discovered `(key, entry)`.
|
|
34
|
+
|
|
35
|
+
Returns None when `entry` generates no feature or union spec: a
|
|
36
|
+
non-model, non-union entry, or a `RootModel`. A RootModel serializes as
|
|
37
|
+
its bare root value and has no record structure, so extracting it as a
|
|
38
|
+
top-level `RecordSpec` would invent a spurious `root` column;
|
|
39
|
+
`extract_alias_spec` documents it instead. Wherever a RootModel is used
|
|
40
|
+
as a field, `analyze_type` unwraps it to that bare shape.
|
|
41
|
+
"""
|
|
42
|
+
if is_rootmodel(entry):
|
|
43
|
+
return None
|
|
44
|
+
partitions = partitions_from_tags(key.tags)
|
|
45
|
+
if is_model_class(entry):
|
|
46
|
+
return extract_model(entry, entry_point=key.entry_point, partitions=partitions)
|
|
47
|
+
if is_union_alias(entry):
|
|
48
|
+
return extract_union(
|
|
49
|
+
entry_point_class(key.entry_point),
|
|
50
|
+
entry,
|
|
51
|
+
entry_point=key.entry_point,
|
|
52
|
+
partitions=partitions,
|
|
53
|
+
)
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def extract_alias_spec(entry: object) -> NewTypeSpec | None:
|
|
58
|
+
"""Extract the markdown alias spec for a `RootModel` entry point.
|
|
59
|
+
|
|
60
|
+
A RootModel is a named alias over its bare root value -- like a NewType
|
|
61
|
+
-- so it documents as a `NewTypeSpec`. Returns None for any other entry;
|
|
62
|
+
only RootModels contribute a standalone alias page.
|
|
63
|
+
"""
|
|
64
|
+
if is_rootmodel(entry):
|
|
65
|
+
return extract_rootmodel_alias(entry)
|
|
66
|
+
return None
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: overture-schema-codegen
|
|
3
|
+
Version: 0.1.1.dev0
|
|
4
|
+
Summary: Code generator that produces documentation and code from Pydantic models
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Dist: click>=8.1
|
|
7
|
+
Requires-Dist: jinja2>=3.0
|
|
8
|
+
Requires-Dist: overture-schema-cli>=0.1.1
|
|
9
|
+
Requires-Dist: overture-schema-common>=0.1.1
|
|
10
|
+
Requires-Dist: overture-schema-system>=0.1.1
|
|
11
|
+
Requires-Dist: tomli>=2.0 ; python_full_version < '3.11'
|
|
12
|
+
Requires-Dist: typing-extensions>=4.0
|
|
13
|
+
Requires-Python: >=3.10
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
overture/schema/codegen/__init__.py,sha256=OTcZrypy__DDDKAzA5H6ifRbUgofOZDP3zuvTV4ZYVA,58
|
|
2
|
+
overture/schema/codegen/cli.py,sha256=CBC7sHhflqu9s8reRzQmXoSJ87dj2G60K1YxI5gN5v4,7282
|
|
3
|
+
overture/schema/codegen/extraction/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
overture/schema/codegen/extraction/docstring.py,sha256=ZqLITnoOl3j6tibyZ1k69OT3rja6ykOKEzKF46Cvxpg,1438
|
|
5
|
+
overture/schema/codegen/extraction/enum_extraction.py,sha256=CAKo0AYvPgVAtOiE2d4cy29zzzpGJMGYF7atpoHezbY,1145
|
|
6
|
+
overture/schema/codegen/extraction/examples.py,sha256=gg5h1Nan-5M6Uj6mAS6vELER_Z9knhuc7S6mQgQkFyc,12117
|
|
7
|
+
overture/schema/codegen/extraction/field.py,sha256=wrp1ZfxqXiRrJ0ANLzjvHzBLd0KszUHHoqgxQFBN4Uo,4765
|
|
8
|
+
overture/schema/codegen/extraction/field_constraints.py,sha256=605KlCY_aLshk2loFfS5mz-M3u2e9oJzBzU56XtKAQE,7015
|
|
9
|
+
overture/schema/codegen/extraction/field_walk.py,sha256=VqhQV3DtHh7YBWU8AgYkQ-fFB8svGH74VWIDuWvMRJ0,8710
|
|
10
|
+
overture/schema/codegen/extraction/length_constraints.py,sha256=Z1QmaK78TMqYdzrU1222UfAR4maxTrIjtTbtJdhtVQk,1463
|
|
11
|
+
overture/schema/codegen/extraction/literal_alternatives.py,sha256=6gEXJlbV8jWOnzJotfBbimJXdR9zQ8Yz6j7swSUh-wY,1038
|
|
12
|
+
overture/schema/codegen/extraction/model_constraints.py,sha256=jc1Y_8VGjCBGb59O5IB9jx9d6LqTHK8iMzTUpvoXm_k,9250
|
|
13
|
+
overture/schema/codegen/extraction/model_extraction.py,sha256=TEW5pRQrqQc-wIcRLMbss4jV5SpRmndTNckvxxXAKYo,8474
|
|
14
|
+
overture/schema/codegen/extraction/newtype_extraction.py,sha256=tYp4KO---24PhkzR3Bx5AcJ3wMBvvCRkfM_bVCeEw_U,2793
|
|
15
|
+
overture/schema/codegen/extraction/numeric_extraction.py,sha256=07cbS0J6iKWBadOcsTcag_gjNkrH5paJ-_yHXQ5h65o,2353
|
|
16
|
+
overture/schema/codegen/extraction/pydantic_extraction.py,sha256=IcVJhudq6fCDji9Z5PzZ4H4ye41AkmXzYhva_rLq_N8,1088
|
|
17
|
+
overture/schema/codegen/extraction/specs.py,sha256=6IZOFHLYB_UfIZL20u2yjnP7QX2juEpekr10dVKQvYg,9041
|
|
18
|
+
overture/schema/codegen/extraction/type_analyzer.py,sha256=Rf6tgxITZewGXrSOMxnVRHEt3oF73BcF0gLCSuJzlNE,27210
|
|
19
|
+
overture/schema/codegen/extraction/type_registry.py,sha256=lewqdzb9gNMvCE_3F8LurKp9slbbpkdSnZTPQ6SkMCk,4813
|
|
20
|
+
overture/schema/codegen/extraction/union_extraction.py,sha256=IVuSaCi9gp_MKJrcFglpKPG4e3ocg3A5nDcGbdrLnac,10107
|
|
21
|
+
overture/schema/codegen/layout/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
overture/schema/codegen/layout/module_layout.py,sha256=y95L3jDtIpMp-LIWmoJndLahW5KpxKXS_yIC0NkvzM0,3939
|
|
23
|
+
overture/schema/codegen/layout/type_collection.py,sha256=oNeYYEeNyADYyv1EmdPAB-RAUtrlsCK3FpCGr6LHMgc,4603
|
|
24
|
+
overture/schema/codegen/markdown/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
+
overture/schema/codegen/markdown/link_computation.py,sha256=dJi5KMXE_XIMo4fvEjeQ-xgXl1nUUuiUfqrKeyoDs30,2405
|
|
26
|
+
overture/schema/codegen/markdown/path_assignment.py,sha256=ag35ErlpANIN8J99o63tIQsi3nThc8o-X6G5VJ2ydUE,3804
|
|
27
|
+
overture/schema/codegen/markdown/pipeline.py,sha256=PRGtMY8i9v1NfT7QW4tA5CQztqxVaOrVQe6YPDqLBAI,6611
|
|
28
|
+
overture/schema/codegen/markdown/renderer.py,sha256=hTosab2LiMx9pISOwh6wK2z69wUOPeeb1qvaDA3DntI,20442
|
|
29
|
+
overture/schema/codegen/markdown/reverse_references.py,sha256=mZpBtH9gVV-7ALp0Rf_v90sufQThWKTkZMB4tj2baiQ,5872
|
|
30
|
+
overture/schema/codegen/markdown/templates/_used_by.md.jinja2,sha256=vXrfGooK-Wt7sN1e-CEwOp-1iNM9JvYfuhDa7iDDW14,186
|
|
31
|
+
overture/schema/codegen/markdown/templates/enum.md.jinja2,sha256=e3omybgyMjh91fcAQYi531hZLE-XvhLl9yC5rlOOExc,278
|
|
32
|
+
overture/schema/codegen/markdown/templates/feature.md.jinja2,sha256=Z1Eul2ZjVgEzROufnLAlS2R65LAouRqvgfRfEK8tkcQ,944
|
|
33
|
+
overture/schema/codegen/markdown/templates/geometric.md.jinja2,sha256=r-pGKMLzmDBsO_jcDXYz-bca2uClz5CQt8GcCQzAIWY,419
|
|
34
|
+
overture/schema/codegen/markdown/templates/newtype.md.jinja2,sha256=bOwA3DRNpWNRXenv70mMJ1Opu6gPjIoN829QtazfwbI,369
|
|
35
|
+
overture/schema/codegen/markdown/templates/numeric.md.jinja2,sha256=y5de8WDMLVjKWEuRvKtlRjY5cr7Uy6cZ7IkZ3wNR53c,646
|
|
36
|
+
overture/schema/codegen/markdown/templates/pydantic_type.md.jinja2,sha256=9XQjs5OzGV6anffWZLD7q2D3w7eF7jxTbxhKuwbCdgA,209
|
|
37
|
+
overture/schema/codegen/markdown/type_format.py,sha256=0PgSp66k2HrPX8bbdbTjande_lcj6QT8G9GMmOb3WGQ,14309
|
|
38
|
+
overture/schema/codegen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
+
overture/schema/codegen/pyspark/__init__.py,sha256=xEiYueRMlf49YJJcBs1vtWdNchyv8HDzrCIG7dGFZYs,74
|
|
40
|
+
overture/schema/codegen/pyspark/_primitive_fill.py,sha256=AygbBOZGkjCBpYWwAacoB5V4JsZrVCcNwlKoIOuWnXI,814
|
|
41
|
+
overture/schema/codegen/pyspark/_render_common.py,sha256=JwoI2hmiOz1GOlgeyZyl_TaMb2QapbDyZPaaIC8bIrI,17920
|
|
42
|
+
overture/schema/codegen/pyspark/check_builder.py,sha256=1z-u_D9UrgTIo7hir7t5FOSL3Tb7n5sNtnRH25dK2_k,38363
|
|
43
|
+
overture/schema/codegen/pyspark/check_ir.py,sha256=kThtGCwqN2upZskCHAmYtFAIQo0u29Qb3H9WNnsBCD8,8459
|
|
44
|
+
overture/schema/codegen/pyspark/constraint_dispatch.py,sha256=WtG6XzwAeGjvvBG6i8EtYpI_ewXhCBHiS46Hcz1YQGs,28597
|
|
45
|
+
overture/schema/codegen/pyspark/pipeline.py,sha256=gmZHFtAQceqHfAf3VBW1--jyljMhBqAx6uiESyWJaD4,7226
|
|
46
|
+
overture/schema/codegen/pyspark/renderer.py,sha256=kjdGzIOWSbtuN_wyV-UIpuHvEwwo0oTrDYjJ0T2wdfQ,30201
|
|
47
|
+
overture/schema/codegen/pyspark/schema_builder.py,sha256=aRThzAXpxPkHhbn2iQ2opIwp0kStQI4XgoqJANHbm50,6586
|
|
48
|
+
overture/schema/codegen/pyspark/templates/_check_function.py.jinja2,sha256=bKvhewfX-T23ggWWJKAYjGUrZShTx8KNs_vX9BFIHxM,316
|
|
49
|
+
overture/schema/codegen/pyspark/templates/model_module.py.jinja2,sha256=5p1xLfdm3kKON3Ow7nyFMCtb1z0u-FdF4trOCuGVL4I,1962
|
|
50
|
+
overture/schema/codegen/pyspark/templates/test_module.py.jinja2,sha256=ST3E_qkZH1kkiGg2PujIB3Stc2U7peL7Ai0bzJ7y97U,3852
|
|
51
|
+
overture/schema/codegen/pyspark/test_data/__init__.py,sha256=-kADuoPLDav7mEWvmtkuENmJaC-59tL626qU8G4O9Z0,378
|
|
52
|
+
overture/schema/codegen/pyspark/test_data/base_row.py,sha256=b6Xitha4c5kCYY11VHA4ugti8jXXyto8YTQNvhbxW_k,31810
|
|
53
|
+
overture/schema/codegen/pyspark/test_data/constraint_values.py,sha256=JTe4YIdQuUBQ-rH3o4lYqGj59Nb-22X4k22hqKTa0dY,7696
|
|
54
|
+
overture/schema/codegen/pyspark/test_data/invalid_value.py,sha256=UbhWDGk8JMDr7FaROg3S_WZmFQ8pqlPojmz4KpdKZcM,4165
|
|
55
|
+
overture/schema/codegen/pyspark/test_data/scaffold.py,sha256=zpU6dd4CS61m5dfOejhPsxeluGtA1L0-a1gbwDiCNx0,15314
|
|
56
|
+
overture/schema/codegen/pyspark/test_renderer.py,sha256=XKD4-7h3jxSU9qLyAU9Me_UL_b1OFaKRbUV1I_Zv-Vc,28412
|
|
57
|
+
overture/schema/codegen/spec_discovery.py,sha256=7kW8AHh7W1RLPSOzIhCng-BQ2BIjopAupBbeBLaPvYA,2548
|
|
58
|
+
overture_schema_codegen-0.1.1.dev0.dist-info/WHEEL,sha256=Lkz__M3n3EKWmzMwHnFILNW2SHO43bOxmbqnBjwb--4,80
|
|
59
|
+
overture_schema_codegen-0.1.1.dev0.dist-info/entry_points.txt,sha256=CvJI-Tq_UhjwIqq8COr4w4LwN29ds11wLGJj8tamlJs,71
|
|
60
|
+
overture_schema_codegen-0.1.1.dev0.dist-info/METADATA,sha256=5t8B4BnmPbrxL9fXdrA2bLA2gVhun_4p0GgdO5jTS08,482
|
|
61
|
+
overture_schema_codegen-0.1.1.dev0.dist-info/RECORD,,
|