linkml 1.8.0rc2__tar.gz → 1.8.2__tar.gz

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.
Files changed (161) hide show
  1. {linkml-1.8.0rc2 → linkml-1.8.2}/PKG-INFO +2 -2
  2. linkml-1.8.2/linkml/cli/__main__.py +4 -0
  3. linkml-1.8.2/linkml/cli/main.py +126 -0
  4. linkml-1.8.2/linkml/generators/common/build.py +105 -0
  5. linkml-1.8.2/linkml/generators/common/lifecycle.py +124 -0
  6. linkml-1.8.2/linkml/generators/common/template.py +89 -0
  7. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/csvgen.py +1 -1
  8. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/slot.md.jinja2 +4 -0
  9. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen.py +1 -1
  10. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/dotgen.py +1 -1
  11. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/erdiagramgen.py +1 -1
  12. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/excelgen.py +1 -1
  13. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/golanggen.py +1 -1
  14. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/golrgen.py +1 -1
  15. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/graphqlgen.py +1 -1
  16. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/javagen.py +1 -1
  17. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/jsonldcontextgen.py +4 -4
  18. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/jsonldgen.py +1 -1
  19. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/jsonschemagen.py +80 -21
  20. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/linkmlgen.py +1 -1
  21. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/markdowngen.py +1 -1
  22. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/namespacegen.py +1 -1
  23. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/oocodegen.py +2 -1
  24. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/owlgen.py +1 -1
  25. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/plantumlgen.py +24 -7
  26. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/prefixmapgen.py +1 -1
  27. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/projectgen.py +1 -1
  28. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/protogen.py +1 -1
  29. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/__init__.py +9 -3
  30. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/array.py +114 -194
  31. linkml-1.8.2/linkml/generators/pydanticgen/build.py +118 -0
  32. linkml-1.8.2/linkml/generators/pydanticgen/includes.py +22 -0
  33. linkml-1.8.2/linkml/generators/pydanticgen/pydanticgen.py +1231 -0
  34. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/template.py +153 -180
  35. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/attribute.py.jinja +9 -7
  36. linkml-1.8.2/linkml/generators/pydanticgen/templates/base_model.py.jinja +16 -0
  37. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/class.py.jinja +2 -2
  38. linkml-1.8.2/linkml/generators/pydanticgen/templates/footer.py.jinja +5 -0
  39. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/module.py.jinja +3 -3
  40. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/validator.py.jinja +0 -4
  41. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pythongen.py +12 -2
  42. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/rdfgen.py +1 -1
  43. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/shaclgen.py +6 -2
  44. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/shexgen.py +1 -1
  45. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sparqlgen.py +1 -1
  46. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sqlalchemygen.py +1 -1
  47. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sqltablegen.py +1 -1
  48. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sssomgen.py +1 -1
  49. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/summarygen.py +1 -1
  50. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/terminusdbgen.py +7 -4
  51. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/typescriptgen.py +1 -1
  52. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/yamlgen.py +1 -1
  53. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/yumlgen.py +1 -1
  54. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/cli.py +1 -1
  55. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/transformers/logical_model_transformer.py +117 -18
  56. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/converter.py +1 -1
  57. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/execute_tutorial.py +2 -0
  58. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/logictools.py +142 -29
  59. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/schema_builder.py +7 -6
  60. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/schema_fixer.py +1 -1
  61. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/sqlutils.py +1 -1
  62. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/cli.py +4 -1
  63. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validators/jsonschemavalidator.py +1 -1
  64. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validators/sparqlvalidator.py +1 -1
  65. linkml-1.8.2/linkml/workspaces/datamodel/__init__.py +0 -0
  66. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/workspaces/example_runner.py +1 -1
  67. {linkml-1.8.0rc2 → linkml-1.8.2}/pyproject.toml +17 -4
  68. {linkml-1.8.0rc2 → linkml-1.8.2}/setup.py +4 -3
  69. linkml-1.8.0rc2/linkml/generators/pydanticgen/build.py +0 -79
  70. linkml-1.8.0rc2/linkml/generators/pydanticgen/includes.py +0 -46
  71. linkml-1.8.0rc2/linkml/generators/pydanticgen/pydanticgen.py +0 -879
  72. linkml-1.8.0rc2/linkml/generators/pydanticgen/templates/base_model.py.jinja +0 -29
  73. linkml-1.8.0rc2/linkml/generators/pydanticgen/templates/footer.py.jinja +0 -13
  74. {linkml-1.8.0rc2 → linkml-1.8.2}/LICENSE +0 -0
  75. {linkml-1.8.0rc2 → linkml-1.8.2}/README.md +0 -0
  76. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/__init__.py +0 -0
  77. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/_version.py +0 -0
  78. {linkml-1.8.0rc2/linkml/generators/common → linkml-1.8.2/linkml/cli}/__init__.py +0 -0
  79. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/PythonGenNotes.md +0 -0
  80. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/README.md +0 -0
  81. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/__init__.py +0 -0
  82. {linkml-1.8.0rc2/linkml/generators/legacy → linkml-1.8.2/linkml/generators/common}/__init__.py +0 -0
  83. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/common/type_designators.py +0 -0
  84. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/class.md.jinja2 +0 -0
  85. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/class_diagram.md.jinja2 +0 -0
  86. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/common_metadata.md.jinja2 +0 -0
  87. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/enum.md.jinja2 +0 -0
  88. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/index.md.jinja2 +0 -0
  89. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/index.tex.jinja2 +0 -0
  90. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/schema.md.jinja2 +0 -0
  91. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/subset.md.jinja2 +0 -0
  92. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/docgen/type.md.jinja2 +0 -0
  93. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/javagen/example_template.java.jinja2 +0 -0
  94. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/javagen/java_record_template.jinja2 +0 -0
  95. {linkml-1.8.0rc2/linkml/linter → linkml-1.8.2/linkml/generators/legacy}/__init__.py +0 -0
  96. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/black.py +0 -0
  97. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/conditional_import.py.jinja +0 -0
  98. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/enum.py.jinja +0 -0
  99. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/imports.py.jinja +0 -0
  100. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/shacl/__init__.py +0 -0
  101. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/shacl/ifabsent_processor.py +0 -0
  102. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/shacl/shacl_data_type.py +0 -0
  103. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sqlalchemy/__init__.py +0 -0
  104. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sqlalchemy/sqlalchemy_declarative_template.py +0 -0
  105. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/sqlalchemy/sqlalchemy_imperative_template.py +0 -0
  106. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/generators/string_template.md +0 -0
  107. {linkml-1.8.0rc2/linkml/linter/config/datamodel → linkml-1.8.2/linkml/linter}/__init__.py +0 -0
  108. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/config/datamodel/.linkmllint.yaml +0 -0
  109. {linkml-1.8.0rc2/linkml/transformers → linkml-1.8.2/linkml/linter/config/datamodel}/__init__.py +0 -0
  110. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/config/datamodel/config.py +0 -0
  111. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/config/datamodel/config.yaml +0 -0
  112. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/config/default.yaml +0 -0
  113. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/config/recommended.yaml +0 -0
  114. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/formatters/__init__.py +0 -0
  115. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/formatters/formatter.py +0 -0
  116. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/formatters/json_formatter.py +0 -0
  117. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/formatters/markdown_formatter.py +0 -0
  118. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/formatters/terminal_formatter.py +0 -0
  119. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/formatters/tsv_formatter.py +0 -0
  120. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/linter.py +0 -0
  121. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/linter/rules.py +0 -0
  122. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/reporting/__init__.py +0 -0
  123. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/reporting/model.py +0 -0
  124. {linkml-1.8.0rc2/linkml/workspaces → linkml-1.8.2/linkml/transformers}/__init__.py +0 -0
  125. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/transformers/model_transformer.py +0 -0
  126. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/transformers/relmodel_transformer.py +0 -0
  127. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/transformers/schema_renamer.py +0 -0
  128. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/__init__.py +0 -0
  129. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/cli_utils.py +0 -0
  130. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/datautils.py +0 -0
  131. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/datavalidator.py +0 -0
  132. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/deprecation.py +0 -0
  133. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/generator.py +0 -0
  134. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/helpers.py +0 -0
  135. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/ifabsent_functions.py +0 -0
  136. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/mergeutils.py +0 -0
  137. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/rawloader.py +0 -0
  138. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/schemaloader.py +0 -0
  139. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/schemasynopsis.py +0 -0
  140. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/typereferences.py +0 -0
  141. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/utils/validation.py +0 -0
  142. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/__init__.py +0 -0
  143. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/loaders/__init__.py +0 -0
  144. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/loaders/delimited_file_loader.py +0 -0
  145. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/loaders/json_loader.py +0 -0
  146. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/loaders/loader.py +0 -0
  147. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/loaders/passthrough_loader.py +0 -0
  148. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/loaders/yaml_loader.py +0 -0
  149. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/plugins/__init__.py +0 -0
  150. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/plugins/jsonschema_validation_plugin.py +0 -0
  151. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/plugins/pydantic_validation_plugin.py +0 -0
  152. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/plugins/recommended_slots_plugin.py +0 -0
  153. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/plugins/shacl_validation_plugin.py +0 -0
  154. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/plugins/validation_plugin.py +0 -0
  155. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/report.py +0 -0
  156. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/validation_context.py +0 -0
  157. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validator/validator.py +0 -0
  158. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/validators/__init__.py +0 -0
  159. {linkml-1.8.0rc2/linkml/workspaces/datamodel → linkml-1.8.2/linkml/workspaces}/__init__.py +0 -0
  160. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/workspaces/datamodel/workspaces.py +0 -0
  161. {linkml-1.8.0rc2 → linkml-1.8.2}/linkml/workspaces/datamodel/workspaces.yaml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linkml
3
- Version: 1.8.0rc2
3
+ Version: 1.8.2
4
4
  Summary: Linked Open Data Modeling Language
5
5
  Home-page: https://linkml.io/linkml/
6
6
  Keywords: schema,linked data,data modeling,rdf,owl,biolink
@@ -36,7 +36,7 @@ Requires-Dist: jinja2 (>=3.1.0)
36
36
  Requires-Dist: jsonasobj2 (>=1.0.3,<2.0.0)
37
37
  Requires-Dist: jsonschema[format] (>=4.0.0)
38
38
  Requires-Dist: linkml-dataops
39
- Requires-Dist: linkml-runtime (==1.8.0rc2)
39
+ Requires-Dist: linkml-runtime (>=1.8.1,<2.0.0)
40
40
  Requires-Dist: openpyxl
41
41
  Requires-Dist: parse
42
42
  Requires-Dist: prefixcommons (>=0.1.7)
@@ -0,0 +1,4 @@
1
+ from linkml.cli.main import linkml as cli
2
+
3
+ if __name__ == "__main__":
4
+ cli()
@@ -0,0 +1,126 @@
1
+ """
2
+ Main ``linkml`` entrypoint
3
+
4
+ Gathers all the other linkml click entrypoints and puts them under ``linkml`` :)
5
+ """
6
+
7
+ import click
8
+
9
+ from linkml.generators.csvgen import cli as gen_csv
10
+ from linkml.generators.docgen import cli as gen_doc
11
+ from linkml.generators.dotgen import cli as gen_graphviz
12
+ from linkml.generators.erdiagramgen import cli as gen_erdiagram
13
+ from linkml.generators.excelgen import cli as gen_excel
14
+ from linkml.generators.golanggen import cli as gen_golang
15
+ from linkml.generators.golrgen import cli as gen_golr_views
16
+ from linkml.generators.graphqlgen import cli as gen_graphql
17
+ from linkml.generators.javagen import cli as gen_java
18
+ from linkml.generators.jsonldcontextgen import cli as gen_jsonld_context
19
+ from linkml.generators.jsonldgen import cli as gen_jsonld
20
+ from linkml.generators.jsonschemagen import cli as gen_json_schema
21
+ from linkml.generators.linkmlgen import cli as gen_linkml
22
+ from linkml.generators.markdowngen import cli as gen_markdown
23
+ from linkml.generators.namespacegen import cli as gen_namespaces
24
+ from linkml.generators.owlgen import cli as gen_owl
25
+ from linkml.generators.plantumlgen import cli as gen_plantuml
26
+ from linkml.generators.prefixmapgen import cli as gen_prefix_map
27
+ from linkml.generators.projectgen import cli as gen_project
28
+ from linkml.generators.protogen import cli as gen_proto
29
+ from linkml.generators.pydanticgen import cli as gen_pydantic
30
+ from linkml.generators.pythongen import cli as gen_python
31
+ from linkml.generators.rdfgen import cli as gen_rdf
32
+ from linkml.generators.shaclgen import cli as gen_shacl
33
+ from linkml.generators.shexgen import cli as gen_shex
34
+ from linkml.generators.sparqlgen import cli as gen_sparql
35
+ from linkml.generators.sqlalchemygen import cli as gen_sqla
36
+ from linkml.generators.sqltablegen import cli as gen_sqltables
37
+ from linkml.generators.sssomgen import cli as gen_sssom
38
+ from linkml.generators.summarygen import cli as gen_summary
39
+ from linkml.generators.terminusdbgen import cli as gen_terminusdb
40
+ from linkml.generators.typescriptgen import cli as gen_typescript
41
+ from linkml.generators.yamlgen import cli as gen_yaml
42
+ from linkml.generators.yumlgen import cli as gen_yuml
43
+ from linkml.linter.cli import main as linkml_lint
44
+ from linkml.utils.converter import cli as linkml_convert
45
+ from linkml.utils.execute_tutorial import cli as run_tutorial
46
+ from linkml.utils.schema_fixer import main as linkml_schema_fixer
47
+ from linkml.utils.sqlutils import main as linkml_sqldb
48
+ from linkml.validator.cli import cli as linkml_validate
49
+ from linkml.workspaces.example_runner import cli as linkml_run_examples
50
+
51
+ # --------------------------------------------------
52
+ # Command groups
53
+ # --------------------------------------------------
54
+
55
+
56
+ @click.group()
57
+ def linkml():
58
+ """
59
+ LinkML: A flexible linked data modeling language
60
+ """
61
+
62
+
63
+ @linkml.group()
64
+ def generate():
65
+ """
66
+ Generate formats from a LinkML schema
67
+ """
68
+
69
+
70
+ @linkml.group()
71
+ def dev():
72
+ """
73
+ Helper tools for linkml development
74
+ """
75
+
76
+
77
+ # --------------------------------------------------
78
+ # Add commands to groups
79
+ # --------------------------------------------------
80
+
81
+ # Top-level linkml commands
82
+ linkml.add_command(linkml_convert, name="convert")
83
+ linkml.add_command(linkml_lint, name="lint")
84
+ linkml.add_command(linkml_sqldb, name="sqldb")
85
+ linkml.add_command(linkml_schema_fixer, name="fix")
86
+ linkml.add_command(linkml_run_examples, name="examples")
87
+ linkml.add_command(linkml_validate, name="validate")
88
+
89
+ # Generators
90
+ generate.add_command(gen_jsonld_context, name="jsonld-context")
91
+ generate.add_command(gen_prefix_map, name="prefix-map")
92
+ generate.add_command(gen_csv, name="csv")
93
+ generate.add_command(gen_graphviz, name="graphviz")
94
+ generate.add_command(gen_golang, name="golang")
95
+ generate.add_command(gen_golr_views, name="golr-views")
96
+ generate.add_command(gen_graphql, name="graphql")
97
+ generate.add_command(gen_java, name="java")
98
+ generate.add_command(gen_jsonld, name="jsonld")
99
+ generate.add_command(gen_json_schema, name="json-schema")
100
+ generate.add_command(gen_markdown, name="markdown")
101
+ generate.add_command(gen_doc, name="doc")
102
+ generate.add_command(gen_namespaces, name="namespaces")
103
+ generate.add_command(gen_owl, name="owl")
104
+ generate.add_command(gen_plantuml, name="plantuml")
105
+ generate.add_command(gen_proto, name="proto")
106
+ generate.add_command(gen_python, name="python")
107
+ generate.add_command(gen_pydantic, name="pydantic")
108
+ generate.add_command(gen_rdf, name="rdf")
109
+ generate.add_command(gen_shex, name="shex")
110
+ generate.add_command(gen_shacl, name="shacl")
111
+ generate.add_command(gen_sparql, name="sparql")
112
+ generate.add_command(gen_typescript, name="typescript")
113
+ generate.add_command(gen_terminusdb, name="terminusdb")
114
+ generate.add_command(gen_yuml, name="yuml")
115
+ generate.add_command(gen_yaml, name="yaml")
116
+ generate.add_command(gen_erdiagram, name="erdiagram")
117
+ generate.add_command(gen_sqla, name="sqla")
118
+ generate.add_command(gen_sqltables, name="sqltables")
119
+ generate.add_command(gen_summary, name="summary")
120
+ generate.add_command(gen_project, name="project")
121
+ generate.add_command(gen_excel, name="excel")
122
+ generate.add_command(gen_sssom, name="sssom")
123
+ generate.add_command(gen_linkml, name="linkml")
124
+
125
+ # Dev helpers
126
+ dev.add_command(run_tutorial, name="tutorial")
@@ -0,0 +1,105 @@
1
+ """
2
+ Models for intermediate build results
3
+
4
+ (see PydanticGenerator for example implementation and use)
5
+ """
6
+
7
+ import dataclasses
8
+ from abc import abstractmethod
9
+ from typing import Any, TypeVar
10
+
11
+ try:
12
+ from typing import Annotated
13
+ except ImportError:
14
+ from typing_extensions import Annotated
15
+
16
+
17
+ from linkml_runtime.linkml_model import (
18
+ ClassDefinition,
19
+ EnumDefinition,
20
+ SchemaDefinition,
21
+ SlotDefinition,
22
+ TypeDefinition,
23
+ )
24
+ from pydantic import BaseModel, ConfigDict, GetCoreSchemaHandler
25
+ from pydantic_core import core_schema
26
+
27
+ T = TypeVar("T", bound="BuildResult", covariant=True)
28
+
29
+
30
+ @dataclasses.dataclass()
31
+ class SkipValidation:
32
+ """
33
+ A version of :class:`pydantic.SkipValidation` that actually skips generating the
34
+ schema for the field entirely - useful for including types that don't need to be validated
35
+ like the metamodel dataclasses
36
+ """
37
+
38
+ def __class_getitem__(cls, item: Any) -> Any:
39
+ return Annotated[item, SkipValidation()]
40
+
41
+ @classmethod
42
+ def __get_pydantic_core_schema__(cls, source: Any, handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
43
+ return core_schema.any_schema()
44
+
45
+ __hash__ = object.__hash__
46
+
47
+
48
+ class BuildResult(BaseModel):
49
+ """
50
+ The result of any build phase for any linkML object
51
+
52
+ BuildResults are merged in the serialization process, and are used
53
+ to keep track of not only the particular representation
54
+ of the thing in question, but any "side effects" that need to happen
55
+ elsewhere in the generation process (like adding imports, injecting classes, etc.)
56
+ """
57
+
58
+ model_config = ConfigDict(arbitrary_types_allowed=True)
59
+
60
+ @abstractmethod
61
+ def merge(self, other: T) -> T:
62
+ """
63
+ Build results should have some means of merging results of a like kind
64
+ """
65
+
66
+
67
+ class SchemaResult(BuildResult):
68
+ """Abstract results container for built schemas"""
69
+
70
+ source: SkipValidation[SchemaDefinition]
71
+
72
+ def merge(self, other: T) -> T:
73
+ """
74
+ SchemaResults are special and don't need a merge method, since generating
75
+ multiple schemas at once is not common or expected behavior for a generator.
76
+ """
77
+ raise NotImplementedError("SchemaResult doesn't need a merge method, and none has been defined")
78
+
79
+
80
+ class ClassResult(BuildResult):
81
+ """Abstract results container for built classes"""
82
+
83
+ source: SkipValidation[ClassDefinition]
84
+
85
+
86
+ class SlotResult(BuildResult):
87
+ """Abstract results container for built slots"""
88
+
89
+ source: SkipValidation[SlotDefinition]
90
+
91
+
92
+ class TypeResult(BuildResult):
93
+ """Abstract results container for built types"""
94
+
95
+ source: SkipValidation[TypeDefinition]
96
+
97
+
98
+ class EnumResult(BuildResult):
99
+ """Abstract results container for built enums"""
100
+
101
+ source: SkipValidation[EnumDefinition]
102
+
103
+
104
+ class RangeResult(BuildResult):
105
+ """Abstract results container for just the range part of a slot"""
@@ -0,0 +1,124 @@
1
+ """
2
+ Lifestyle methods mixin
3
+ """
4
+
5
+ from typing import Iterable, TypeVar
6
+
7
+ from linkml_runtime import SchemaView
8
+ from linkml_runtime.linkml_model.meta import (
9
+ ClassDefinition,
10
+ EnumDefinition,
11
+ SchemaDefinition,
12
+ SlotDefinition,
13
+ TypeDefinition,
14
+ )
15
+
16
+ from linkml.generators.common.build import ClassResult, RangeResult, SchemaResult, SlotResult, TypeResult
17
+ from linkml.generators.common.template import TemplateModel
18
+
19
+ TSchema = TypeVar("TSchema", bound=SchemaResult)
20
+ TClass = TypeVar("TClass", bound=ClassResult)
21
+ TSlot = TypeVar("TSlot", bound=SlotResult)
22
+ TRange = TypeVar("TRange", bound=RangeResult)
23
+ TType = TypeVar("TType", bound=TypeResult)
24
+ TEnum = TypeVar("TEnum", bound=EnumDefinition)
25
+ TTemplate = TypeVar("TTemplate", bound=TemplateModel)
26
+
27
+
28
+ class LifecycleMixin:
29
+ """
30
+ Mixin class for implementing lifecycle methods to modify the generation process
31
+ without needing messy overrides and tiptoeing around parent generator classes.
32
+
33
+ Not all classes that inherit from the mixin will be able to implement all of the lifecycle methods.
34
+ The generator class should make it clear which methods are supported in its documentation -
35
+ no programmatic checking for lifecycle method support is available on first implementation.
36
+
37
+ Generators should **not** define any of the lifecycle methods themselves - the purpose is
38
+ to allow downstream modification of the generation process with clear entrypoints and without
39
+ needing to copy/paste code from the generator/call ``super()`` methods - if the Generator
40
+ is also using the lifecycle method, the point of the mixin is lost.
41
+
42
+ The order that these methods are called may vary in different generators, but in general, if
43
+ slots are generated hierarchically within classes as in the pydantic generator...
44
+
45
+ * :meth:`.before_generate_schema`
46
+ * :meth:`.before_generate_classes`
47
+ * :meth:`.before_generate_class`
48
+ * :meth:`.before_generate_slots`
49
+ * :meth:`.before_generate_slot`
50
+ * :meth:`.after_generate_slot`
51
+ * :meth:`.after_generate_slots`
52
+ * :meth:`.after_generate_class`
53
+ * :meth:`.after_generate_classes`
54
+ * :meth:`.after_generate_schema`
55
+ * :meth:`.before_render_template`
56
+ * :meth:`.after_render_template`
57
+
58
+ (Add other examples of ordering from other generators as implemented)
59
+
60
+ Each method should receive a :class:`.SchemaView` to get perspective on the current schema
61
+ being built. The ``before_`` methods should receive and return a single or list of ``Definitions``
62
+ and the ``after_`` methods should receive and return a single or list of the appropriate :class:`.BuildResult`
63
+ type.
64
+ """
65
+
66
+ def before_generate_schema(self, schema: SchemaDefinition, sv: SchemaView) -> SchemaDefinition:
67
+ return schema
68
+
69
+ def after_generate_schema(self, schema: TSchema, sv: SchemaView) -> TSchema:
70
+ return schema
71
+
72
+ def before_generate_class(self, cls: ClassDefinition, sv: SchemaView) -> ClassDefinition:
73
+ return cls
74
+
75
+ def after_generate_class(self, cls: TClass, sv: SchemaView) -> TClass:
76
+ return cls
77
+
78
+ def before_generate_classes(self, cls: Iterable[ClassDefinition], sv: SchemaView) -> Iterable[ClassDefinition]:
79
+ return cls
80
+
81
+ def after_generate_classes(self, cls: Iterable[TClass], sv: SchemaView) -> Iterable[TClass]:
82
+ return cls
83
+
84
+ def before_generate_slot(self, slot: SlotDefinition, sv: SchemaView) -> SlotDefinition:
85
+ return slot
86
+
87
+ def after_generate_slot(self, slot: TSlot, sv: SchemaView) -> TSlot:
88
+ return slot
89
+
90
+ def before_generate_slots(self, slot: Iterable[SlotDefinition], sv: SchemaView) -> Iterable[SlotDefinition]:
91
+ return slot
92
+
93
+ def after_generate_slots(self, slot: Iterable[TSlot], sv: SchemaView) -> Iterable[TSlot]:
94
+ return slot
95
+
96
+ def before_generate_type(self, typ: TypeDefinition, sv: SchemaView) -> TypeDefinition:
97
+ return typ
98
+
99
+ def after_generate_type(self, typ: TType, sv: SchemaView) -> TType:
100
+ return typ
101
+
102
+ def before_generate_types(self, typ: Iterable[TypeDefinition], sv: SchemaView) -> Iterable[TypeDefinition]:
103
+ return typ
104
+
105
+ def after_generate_types(self, typ: Iterable[TType], sv: SchemaView) -> Iterable[TType]:
106
+ return typ
107
+
108
+ def before_generate_enum(self, enum: EnumDefinition, sv: SchemaView) -> EnumDefinition:
109
+ return enum
110
+
111
+ def after_generate_enum(self, enum: TEnum, sv: SchemaView) -> TEnum:
112
+ return enum
113
+
114
+ def before_generate_enums(self, enum: Iterable[EnumDefinition], sv: SchemaView) -> Iterable[EnumDefinition]:
115
+ return enum
116
+
117
+ def after_generate_enums(self, enum: Iterable[TEnum], sv: SchemaView) -> Iterable[TEnum]:
118
+ return enum
119
+
120
+ def before_render_template(self, template: TTemplate, sv: SchemaView) -> TTemplate:
121
+ return template
122
+
123
+ def after_render_template(self, template: str, sv: SchemaView) -> str:
124
+ return template
@@ -0,0 +1,89 @@
1
+ """
2
+ Base classes for jinja template handling classes.
3
+
4
+ See :mod:`.linkml.generators.pydanticgen.template` for example implementation
5
+ """
6
+
7
+ from copy import copy
8
+ from typing import Any, ClassVar, Dict, List, Optional, Union
9
+
10
+ from jinja2 import Environment
11
+ from pydantic import BaseModel
12
+
13
+
14
+ class TemplateModel(BaseModel):
15
+ """
16
+ Metaclass to render model results with jinja templates.
17
+
18
+ Each subclass needs to declare a :class:`typing.ClassVar` for a
19
+ jinja template within the `templates` directory.
20
+
21
+ Templates are written expecting each of the other TemplateModels
22
+ to already be rendered to strings - ie. rather than the ``class.py.jinja``
23
+ template receiving a full :class:`.PydanticAttribute` object or dictionary,
24
+ it receives it having already been rendered to a string. See the :meth:`.render` method.
25
+ """
26
+
27
+ template: ClassVar[str]
28
+ _environment: ClassVar[Environment]
29
+
30
+ meta_exclude: ClassVar[List[str]] = None
31
+
32
+ def render(self, environment: Optional[Environment] = None, **kwargs) -> str:
33
+ """
34
+ Recursively render a template model to a string.
35
+
36
+ For each field in the model, recurse through, rendering each :class:`.TemplateModel`
37
+ using the template set in :attr:`.TemplateModel.template` , but preserving the structure
38
+ of lists and dictionaries. Regular :class:`.BaseModel` s are rendered to dictionaries.
39
+ Any other value is passed through unchanged.
40
+
41
+ Args:
42
+ environment (:class:`jinja2.Environment`): Template environment - see :meth:`.environment`
43
+ """
44
+ if environment is None:
45
+ environment = TemplateModel.environment()
46
+
47
+ fields = {**self.model_fields, **self.model_computed_fields}
48
+
49
+ data = {k: _render(getattr(self, k, None), environment) for k in fields}
50
+ template = environment.get_template(self.template)
51
+ rendered = template.render(**data)
52
+ return rendered
53
+
54
+ @classmethod
55
+ def environment(cls) -> Environment:
56
+ """
57
+ Default environment for Template models.
58
+ uses a :class:`jinja2.PackageLoader` for the templates directory within this module
59
+ with the ``trim_blocks`` and ``lstrip_blocks`` parameters set to ``True`` so that the
60
+ default templates could be written in a more readable way.
61
+ """
62
+ return copy(cls._environment)
63
+
64
+ @classmethod
65
+ def exclude_from_meta(cls: "TemplateModel") -> List[str]:
66
+ """
67
+ Attributes in the source definition to exclude from linkml_meta
68
+ """
69
+ ret = [*cls.model_fields.keys()]
70
+ if cls.meta_exclude is not None:
71
+ ret = ret + cls.meta_exclude
72
+ return ret
73
+
74
+
75
+ def _render(
76
+ item: Union[TemplateModel, Any, List[Union[Any, TemplateModel]], Dict[str, Union[Any, TemplateModel]]],
77
+ environment: Environment,
78
+ ) -> Union[str, List[str], Dict[str, str]]:
79
+ if isinstance(item, TemplateModel):
80
+ return item.render(environment)
81
+ elif isinstance(item, list):
82
+ return [_render(i, environment) for i in item]
83
+ elif isinstance(item, dict):
84
+ return {k: _render(v, environment) for k, v in item.items()}
85
+ elif isinstance(item, BaseModel):
86
+ fields = item.model_fields
87
+ return {k: _render(getattr(item, k, None), environment) for k in fields.keys()}
88
+ else:
89
+ return item
@@ -95,7 +95,7 @@ class CsvGenerator(Generator):
95
95
 
96
96
 
97
97
  @shared_arguments(CsvGenerator)
98
- @click.command()
98
+ @click.command(name="csv")
99
99
  @click.version_option(__version__, "-V", "--version")
100
100
  @click.option("--root", "-r", multiple=True, help="Class(es) to transform")
101
101
  def cli(yamlfile, root=None, **args):
@@ -34,6 +34,10 @@ _{{ element_description_line }}_
34
34
  {% endfor %}
35
35
  {% endif %}
36
36
 
37
+ {% if element.abstract %}
38
+ * __NOTE__: this is an abstract slot and should not be populated directly
39
+ {% endif %}
40
+
37
41
  URI: {{ gen.uri_link(element) }}
38
42
 
39
43
 
@@ -978,7 +978,7 @@ YAML, and including it when necessary but not by default (e.g. in documentation
978
978
  """,
979
979
  )
980
980
  @click.version_option(__version__, "-V", "--version")
981
- @click.command()
981
+ @click.command(name="doc")
982
982
  def cli(
983
983
  yamlfile,
984
984
  directory,
@@ -136,7 +136,7 @@ class DotGenerator(Generator):
136
136
 
137
137
 
138
138
  @shared_arguments(DotGenerator)
139
- @click.command()
139
+ @click.command(name="graphviz")
140
140
  @click.option(
141
141
  "--directory",
142
142
  "-d",
@@ -312,7 +312,7 @@ class ERDiagramGenerator(Generator):
312
312
  @click.option("--classes", "-c", multiple=True, help="List of classes to serialize")
313
313
  @click.option("--include-upstream", is_flag=True, help="Include upstream classes")
314
314
  @click.version_option(__version__, "-V", "--version")
315
- @click.command()
315
+ @click.command(name="erdiagram")
316
316
  def cli(
317
317
  yamlfile,
318
318
  classes: List[str],
@@ -167,7 +167,7 @@ class ExcelGenerator(Generator):
167
167
 
168
168
 
169
169
  @shared_arguments(ExcelGenerator)
170
- @click.command()
170
+ @click.command(name="excel")
171
171
  @click.option(
172
172
  "--split-workbook-by-class",
173
173
  is_flag=True,
@@ -189,7 +189,7 @@ class GolangGenerator(Generator):
189
189
 
190
190
  @shared_arguments(GolangGenerator)
191
191
  @click.version_option(__version__, "-V", "--version")
192
- @click.command()
192
+ @click.command(name="golang")
193
193
  def cli(yamlfile, **args):
194
194
  """Generate Golang types
195
195
 
@@ -101,7 +101,7 @@ class GolrSchemaGenerator(Generator):
101
101
 
102
102
 
103
103
  @shared_arguments(GolrSchemaGenerator)
104
- @click.command()
104
+ @click.command(name="golr-views")
105
105
  @click.option("--dir", "-d", default="golr-views", show_default=True, help="Output directory")
106
106
  @click.version_option(__version__, "-V", "--version")
107
107
  def cli(yamlfile, dir=None, **args):
@@ -52,7 +52,7 @@ class GraphqlGenerator(Generator):
52
52
 
53
53
 
54
54
  @shared_arguments(GraphqlGenerator)
55
- @click.command()
55
+ @click.command(name="graphql")
56
56
  @click.version_option(__version__, "-V", "--version")
57
57
  def cli(yamlfile, **args):
58
58
  """Generate graphql representation of a LinkML model"""
@@ -146,7 +146,7 @@ class JavaGenerator(OOCodeGenerator):
146
146
  help="Optional Java 17 record implementation",
147
147
  )
148
148
  @click.version_option(__version__, "-V", "--version")
149
- @click.command()
149
+ @click.command(name="java")
150
150
  def cli(
151
151
  yamlfile,
152
152
  output_directory=None,
@@ -18,8 +18,7 @@ from rdflib import SKOS, XSD, Namespace
18
18
  from linkml._version import __version__
19
19
  from linkml.utils.generator import Generator, shared_arguments
20
20
 
21
- URI_RANGES = (XSD.anyURI, SHEX.nonliteral, SHEX.bnode, SHEX.iri)
22
-
21
+ URI_RANGES = (SHEX.nonliteral, SHEX.bnode, SHEX.iri)
23
22
 
24
23
  ENUM_CONTEXT = {
25
24
  "@vocab": "@null",
@@ -99,7 +98,7 @@ class ContextGenerator(Generator):
99
98
  comments.generation_date = self.schema.generation_date
100
99
  comments.source = self.schema.source_file
101
100
  context.comments = comments
102
- context_content = {}
101
+ context_content = {"xsd": "http://www.w3.org/2001/XMLSchema#"}
103
102
  if base:
104
103
  base = str(base)
105
104
  if "://" not in base:
@@ -193,6 +192,7 @@ class ContextGenerator(Generator):
193
192
  elif not uri_prefix or is_default_namespace:
194
193
  definition["@id"] = uri_suffix
195
194
  else:
195
+
196
196
  definition["@id"] = (uri_prefix + ":" + uri_suffix) if uri_prefix else uri
197
197
 
198
198
  if uri_prefix and not is_default_namespace:
@@ -203,7 +203,7 @@ class ContextGenerator(Generator):
203
203
 
204
204
 
205
205
  @shared_arguments(ContextGenerator)
206
- @click.command()
206
+ @click.command(name="jsonld-context")
207
207
  @click.option("--base", help="Base URI for model")
208
208
  @click.option(
209
209
  "--prefixes/--no-prefixes",
@@ -192,7 +192,7 @@ class JSONLDGenerator(Generator):
192
192
 
193
193
 
194
194
  @shared_arguments(JSONLDGenerator)
195
- @click.command()
195
+ @click.command(name="jsonld")
196
196
  @click.option(
197
197
  "--context",
198
198
  multiple=True,