linkml 1.8.1__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.
- {linkml-1.8.1 → linkml-1.8.2}/PKG-INFO +2 -2
- linkml-1.8.2/linkml/cli/__main__.py +4 -0
- linkml-1.8.2/linkml/cli/main.py +126 -0
- linkml-1.8.2/linkml/generators/common/build.py +105 -0
- linkml-1.8.2/linkml/generators/common/lifecycle.py +124 -0
- linkml-1.8.2/linkml/generators/common/template.py +89 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/csvgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/slot.md.jinja2 +4 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/dotgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/erdiagramgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/excelgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/golanggen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/golrgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/graphqlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/javagen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/jsonldcontextgen.py +4 -4
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/jsonldgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/jsonschemagen.py +69 -22
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/linkmlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/markdowngen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/namespacegen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/oocodegen.py +2 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/owlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/plantumlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/prefixmapgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/projectgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/protogen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/__init__.py +8 -3
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/array.py +114 -194
- linkml-1.8.2/linkml/generators/pydanticgen/build.py +118 -0
- linkml-1.8.2/linkml/generators/pydanticgen/includes.py +22 -0
- linkml-1.8.2/linkml/generators/pydanticgen/pydanticgen.py +1231 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/template.py +152 -184
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/attribute.py.jinja +9 -7
- linkml-1.8.2/linkml/generators/pydanticgen/templates/base_model.py.jinja +16 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/class.py.jinja +2 -2
- linkml-1.8.2/linkml/generators/pydanticgen/templates/footer.py.jinja +5 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/module.py.jinja +2 -2
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/validator.py.jinja +0 -4
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pythongen.py +12 -2
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/rdfgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/shaclgen.py +6 -2
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/shexgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sparqlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sqlalchemygen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sqltablegen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sssomgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/summarygen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/terminusdbgen.py +7 -4
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/typescriptgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/yamlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/yumlgen.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/cli.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/transformers/logical_model_transformer.py +117 -18
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/converter.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/execute_tutorial.py +2 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/logictools.py +142 -29
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/schema_builder.py +7 -6
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/schema_fixer.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/sqlutils.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/cli.py +4 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validators/jsonschemavalidator.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validators/sparqlvalidator.py +1 -1
- linkml-1.8.2/linkml/workspaces/datamodel/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/workspaces/example_runner.py +1 -1
- {linkml-1.8.1 → linkml-1.8.2}/pyproject.toml +17 -4
- {linkml-1.8.1 → linkml-1.8.2}/setup.py +4 -3
- linkml-1.8.1/linkml/generators/pydanticgen/build.py +0 -79
- linkml-1.8.1/linkml/generators/pydanticgen/includes.py +0 -52
- linkml-1.8.1/linkml/generators/pydanticgen/pydanticgen.py +0 -889
- linkml-1.8.1/linkml/generators/pydanticgen/templates/base_model.py.jinja +0 -29
- linkml-1.8.1/linkml/generators/pydanticgen/templates/footer.py.jinja +0 -13
- {linkml-1.8.1 → linkml-1.8.2}/LICENSE +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/README.md +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/_version.py +0 -0
- {linkml-1.8.1/linkml/generators/common → linkml-1.8.2/linkml/cli}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/PythonGenNotes.md +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/README.md +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/__init__.py +0 -0
- {linkml-1.8.1/linkml/generators/legacy → linkml-1.8.2/linkml/generators/common}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/common/type_designators.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/class.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/class_diagram.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/common_metadata.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/enum.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/index.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/index.tex.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/schema.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/subset.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/docgen/type.md.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/javagen/example_template.java.jinja2 +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/javagen/java_record_template.jinja2 +0 -0
- {linkml-1.8.1/linkml/linter → linkml-1.8.2/linkml/generators/legacy}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/black.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/conditional_import.py.jinja +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/enum.py.jinja +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/pydanticgen/templates/imports.py.jinja +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/shacl/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/shacl/ifabsent_processor.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/shacl/shacl_data_type.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sqlalchemy/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sqlalchemy/sqlalchemy_declarative_template.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/sqlalchemy/sqlalchemy_imperative_template.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/generators/string_template.md +0 -0
- {linkml-1.8.1/linkml/linter/config/datamodel → linkml-1.8.2/linkml/linter}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/config/datamodel/.linkmllint.yaml +0 -0
- {linkml-1.8.1/linkml/transformers → linkml-1.8.2/linkml/linter/config/datamodel}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/config/datamodel/config.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/config/datamodel/config.yaml +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/config/default.yaml +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/config/recommended.yaml +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/formatters/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/formatters/formatter.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/formatters/json_formatter.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/formatters/markdown_formatter.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/formatters/terminal_formatter.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/formatters/tsv_formatter.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/linter.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/linter/rules.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/reporting/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/reporting/model.py +0 -0
- {linkml-1.8.1/linkml/workspaces → linkml-1.8.2/linkml/transformers}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/transformers/model_transformer.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/transformers/relmodel_transformer.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/transformers/schema_renamer.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/cli_utils.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/datautils.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/datavalidator.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/deprecation.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/generator.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/helpers.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/ifabsent_functions.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/mergeutils.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/rawloader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/schemaloader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/schemasynopsis.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/typereferences.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/utils/validation.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/loaders/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/loaders/delimited_file_loader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/loaders/json_loader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/loaders/loader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/loaders/passthrough_loader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/loaders/yaml_loader.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/plugins/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/plugins/jsonschema_validation_plugin.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/plugins/pydantic_validation_plugin.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/plugins/recommended_slots_plugin.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/plugins/shacl_validation_plugin.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/plugins/validation_plugin.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/report.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/validation_context.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validator/validator.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/validators/__init__.py +0 -0
- {linkml-1.8.1/linkml/workspaces/datamodel → linkml-1.8.2/linkml/workspaces}/__init__.py +0 -0
- {linkml-1.8.1 → linkml-1.8.2}/linkml/workspaces/datamodel/workspaces.py +0 -0
- {linkml-1.8.1 → 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.
|
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 (
|
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,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):
|
@@ -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],
|
@@ -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 = (
|
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",
|