linkml 1.7.5__tar.gz → 1.7.7__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.7.5 → linkml-1.7.7}/PKG-INFO +9 -4
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/__init__.py +2 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/class.md.jinja2 +15 -2
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/slot.md.jinja2 +18 -4
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen.py +17 -3
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/jsonldcontextgen.py +40 -17
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/jsonldgen.py +3 -1
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/owlgen.py +16 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/prefixmapgen.py +5 -4
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/projectgen.py +14 -2
- linkml-1.7.7/linkml/generators/pydanticgen/__init__.py +29 -0
- linkml-1.7.7/linkml/generators/pydanticgen/array.py +457 -0
- linkml-1.7.7/linkml/generators/pydanticgen/black.py +29 -0
- linkml-1.7.7/linkml/generators/pydanticgen/build.py +79 -0
- {linkml-1.7.5/linkml/generators → linkml-1.7.7/linkml/generators/pydanticgen}/pydanticgen.py +252 -304
- linkml-1.7.7/linkml/generators/pydanticgen/template.py +577 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/attribute.py.jinja +10 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/base_model.py.jinja +29 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/class.py.jinja +21 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/conditional_import.py.jinja +9 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/enum.py.jinja +16 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/footer.py.jinja +13 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/imports.py.jinja +31 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/module.py.jinja +27 -0
- linkml-1.7.7/linkml/generators/pydanticgen/templates/validator.py.jinja +15 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/pythongen.py +13 -7
- linkml-1.7.7/linkml/generators/shacl/__init__.py +3 -0
- linkml-1.7.7/linkml/generators/shacl/ifabsent_processor.py +59 -0
- linkml-1.7.7/linkml/generators/shacl/shacl_data_type.py +40 -0
- linkml-1.7.7/linkml/generators/shaclgen.py +229 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/shexgen.py +1 -1
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sqlalchemygen.py +1 -1
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sqltablegen.py +32 -22
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/terminusdbgen.py +7 -1
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/config/datamodel/config.py +8 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/rules.py +11 -2
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/generator.py +7 -6
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/ifabsent_functions.py +7 -9
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/schemaloader.py +1 -9
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/sqlutils.py +39 -25
- {linkml-1.7.5 → linkml-1.7.7}/pyproject.toml +19 -8
- {linkml-1.7.5 → linkml-1.7.7}/setup.py +9 -4
- linkml-1.7.5/linkml/generators/shaclgen.py +0 -206
- {linkml-1.7.5 → linkml-1.7.7}/LICENSE +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/README.md +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/_version.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/PythonGenNotes.md +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/README.md +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/common/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/common/type_designators.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/csvgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/class_diagram.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/common_metadata.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/enum.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/index.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/index.tex.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/schema.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/subset.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/docgen/type.md.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/dotgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/erdiagramgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/excelgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/golanggen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/golrgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/graphqlgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/javagen/example_template.java.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/javagen/java_record_template.jinja2 +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/javagen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/jsonschemagen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/legacy/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/linkmlgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/markdowngen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/namespacegen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/oocodegen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/plantumlgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/protogen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/rdfgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sparqlgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sqlalchemy/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sqlalchemy/sqlalchemy_declarative_template.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sqlalchemy/sqlalchemy_imperative_template.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/sssomgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/string_template.md +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/summarygen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/typescriptgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/yamlgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/generators/yumlgen.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/cli.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/config/datamodel/.linkmllint.yaml +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/config/datamodel/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/config/datamodel/config.yaml +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/config/default.yaml +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/config/recommended.yaml +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/formatters/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/formatters/formatter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/formatters/json_formatter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/formatters/markdown_formatter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/formatters/terminal_formatter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/formatters/tsv_formatter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/linter/linter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/reporting/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/reporting/model.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/transformers/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/transformers/logical_model_transformer.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/transformers/model_transformer.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/transformers/relmodel_transformer.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/transformers/schema_renamer.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/cli_utils.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/converter.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/datautils.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/datavalidator.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/execute_tutorial.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/helpers.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/logictools.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/mergeutils.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/rawloader.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/schema_builder.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/schema_fixer.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/schemasynopsis.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/typereferences.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/utils/validation.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/cli.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/loaders/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/loaders/delimited_file_loader.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/loaders/json_loader.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/loaders/loader.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/loaders/passthrough_loader.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/loaders/yaml_loader.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/plugins/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/plugins/jsonschema_validation_plugin.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/plugins/pydantic_validation_plugin.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/plugins/recommended_slots_plugin.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/plugins/shacl_validation_plugin.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/plugins/validation_plugin.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/report.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/validation_context.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validator/validator.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validators/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validators/jsonschemavalidator.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/validators/sparqlvalidator.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/workspaces/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/workspaces/datamodel/__init__.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/workspaces/datamodel/workspaces.py +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/workspaces/datamodel/workspaces.yaml +0 -0
- {linkml-1.7.5 → linkml-1.7.7}/linkml/workspaces/example_runner.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: linkml
|
3
|
-
Version: 1.7.
|
3
|
+
Version: 1.7.7
|
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
|
@@ -19,10 +19,15 @@ Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
22
23
|
Classifier: Programming Language :: Python :: 3.8
|
23
24
|
Classifier: Programming Language :: Python :: 3.9
|
24
25
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
26
|
+
Provides-Extra: black
|
27
|
+
Provides-Extra: shacl
|
28
|
+
Provides-Extra: tests
|
25
29
|
Requires-Dist: antlr4-python3-runtime (>=4.9.0,<4.10)
|
30
|
+
Requires-Dist: black (>=24.0.0) ; extra == "black" or extra == "tests"
|
26
31
|
Requires-Dist: click (>=7.0)
|
27
32
|
Requires-Dist: graphviz (>=0.10.1)
|
28
33
|
Requires-Dist: hbreader
|
@@ -31,13 +36,14 @@ Requires-Dist: jinja2 (>=3.1.0)
|
|
31
36
|
Requires-Dist: jsonasobj2 (>=1.0.3,<2.0.0)
|
32
37
|
Requires-Dist: jsonschema[format] (>=4.0.0)
|
33
38
|
Requires-Dist: linkml-dataops
|
34
|
-
Requires-Dist: linkml-runtime (>=1.7.
|
39
|
+
Requires-Dist: linkml-runtime (>=1.7.4)
|
35
40
|
Requires-Dist: openpyxl
|
36
41
|
Requires-Dist: parse
|
37
42
|
Requires-Dist: prefixcommons (>=0.1.7)
|
38
|
-
Requires-Dist: prefixmaps (>=0.
|
43
|
+
Requires-Dist: prefixmaps (>=0.2.2)
|
39
44
|
Requires-Dist: pydantic (>=1.0.0,<3.0.0)
|
40
45
|
Requires-Dist: pyjsg (>=0.11.6)
|
46
|
+
Requires-Dist: pyshacl (>=0.25.0,<0.26.0) ; extra == "shacl" or extra == "tests"
|
41
47
|
Requires-Dist: pyshex (>=0.7.20)
|
42
48
|
Requires-Dist: pyshexc (>=0.8.3)
|
43
49
|
Requires-Dist: python-dateutil
|
@@ -45,7 +51,6 @@ Requires-Dist: pyyaml
|
|
45
51
|
Requires-Dist: rdflib (>=6.0.0)
|
46
52
|
Requires-Dist: requests (>=2.22)
|
47
53
|
Requires-Dist: sqlalchemy (>=1.4.31)
|
48
|
-
Requires-Dist: typing-extensions (>=4.5.0,<5.0.0) ; python_version == "3.7"
|
49
54
|
Requires-Dist: watchdog (>=0.9.0)
|
50
55
|
Project-URL: Documentation, https://linkml.io/linkml/
|
51
56
|
Project-URL: Repository, https://github.com/linkml/linkml
|
@@ -5,6 +5,7 @@ representation such as JsonSchema
|
|
5
5
|
|
6
6
|
from linkml.generators.javagen import JavaGenerator
|
7
7
|
from linkml.generators.jsonldcontextgen import ContextGenerator
|
8
|
+
from linkml.generators.jsonldgen import JSONLDGenerator
|
8
9
|
from linkml.generators.jsonschemagen import JsonSchemaGenerator
|
9
10
|
from linkml.generators.owlgen import OwlSchemaGenerator
|
10
11
|
from linkml.generators.pydanticgen import PydanticGenerator
|
@@ -43,6 +44,7 @@ __all__ = [
|
|
43
44
|
"PythonGenerator",
|
44
45
|
"JavaGenerator",
|
45
46
|
"ContextGenerator",
|
47
|
+
"JSONLDGenerator",
|
46
48
|
"JsonSchemaGenerator",
|
47
49
|
"ShaclGenerator",
|
48
50
|
"ShExGenerator",
|
@@ -8,6 +8,19 @@
|
|
8
8
|
{%- endif -%}
|
9
9
|
{%- endif -%}
|
10
10
|
|
11
|
+
{% macro compute_range(slot) -%}
|
12
|
+
{%- if slot.any_of or slot.exactly_one_of -%}
|
13
|
+
{%- for subslot_range in schemaview.slot_range_as_union(slot) -%}
|
14
|
+
{{ gen.link(subslot_range) }}
|
15
|
+
{%- if not loop.last -%}
|
16
|
+
or <br />
|
17
|
+
{%- endif -%}
|
18
|
+
{%- endfor -%}
|
19
|
+
{%- else -%}
|
20
|
+
{{ gen.link(slot.range) }}
|
21
|
+
{%- endif -%}
|
22
|
+
{% endmacro %}
|
23
|
+
|
11
24
|
# Class: {{ title }}
|
12
25
|
|
13
26
|
{%- if header -%}
|
@@ -55,12 +68,12 @@ URI: {{ gen.uri_link(element) }}
|
|
55
68
|
| --- | --- | --- | --- |
|
56
69
|
{% if gen.get_direct_slots(element)|length > 0 %}
|
57
70
|
{%- for slot in gen.get_direct_slots(element) -%}
|
58
|
-
| {{ gen.link(slot) }} | {{ gen.cardinality(slot) }} <br/> {{
|
71
|
+
| {{ gen.link(slot) }} | {{ gen.cardinality(slot) }} <br/> {{ compute_range(slot) }} | {{ slot.description|enshorten }} | direct |
|
59
72
|
{% endfor -%}
|
60
73
|
{% endif -%}
|
61
74
|
{% if gen.get_indirect_slots(element)|length > 0 %}
|
62
75
|
{%- for slot in gen.get_indirect_slots(element) -%}
|
63
|
-
| {{ gen.link(slot) }} | {{ gen.cardinality(slot) }} <br/> {{
|
76
|
+
| {{ gen.link(slot) }} | {{ gen.cardinality(slot) }} <br/> {{ compute_range(slot) }} | {{ slot.description|enshorten }} | {{ gen.links(gen.get_slot_inherited_from(element.name, slot.name))|join(', ') }} |
|
64
77
|
{% endfor -%}
|
65
78
|
{% endif %}
|
66
79
|
|
@@ -8,6 +8,19 @@
|
|
8
8
|
{%- endif -%}
|
9
9
|
{%- endif -%}
|
10
10
|
|
11
|
+
{% macro compute_range(slot) -%}
|
12
|
+
{%- if slot.any_of or slot.exactly_one_of -%}
|
13
|
+
{%- for subslot_range in schemaview.slot_range_as_union(slot) -%}
|
14
|
+
{{ gen.link(subslot_range) }}
|
15
|
+
{%- if not loop.last -%}
|
16
|
+
or <br />
|
17
|
+
{%- endif -%}
|
18
|
+
{%- endfor -%}
|
19
|
+
{%- else -%}
|
20
|
+
{{ gen.link(slot.range) }}
|
21
|
+
{%- endif -%}
|
22
|
+
{% endmacro %}
|
23
|
+
|
11
24
|
# Slot: {{ title }}
|
12
25
|
|
13
26
|
{%- if header -%}
|
@@ -33,14 +46,15 @@ URI: {{ gen.uri_link(element) }}
|
|
33
46
|
<!-- no inheritance hierarchy -->
|
34
47
|
{% endif %}
|
35
48
|
|
36
|
-
{%
|
49
|
+
{% set classes_by_slot = schemaview.get_classes_by_slot(element, include_induced=True) %}
|
50
|
+
{% if classes_by_slot %}
|
37
51
|
|
38
52
|
## Applicable Classes
|
39
53
|
|
40
54
|
| Name | Description | Modifies Slot |
|
41
55
|
| --- | --- | --- |
|
42
|
-
{% for c in
|
43
|
-
{{ gen.link(c) }} | {{ schemaview.get_class(c).description|enshorten }} | {% if c in schemaview.get_classes_modifying_slot(element) %} yes {% else %} no {% endif %} |
|
56
|
+
{% for c in classes_by_slot -%}
|
57
|
+
| {{ gen.link(c) }} | {{ schemaview.get_class(c).description|enshorten }} | {% if c in schemaview.get_classes_modifying_slot(element) %} yes {% else %} no {% endif %} |
|
44
58
|
{% endfor %}
|
45
59
|
|
46
60
|
{% endif %}
|
@@ -58,7 +72,7 @@ URI: {{ gen.uri_link(element) }}
|
|
58
72
|
|
59
73
|
## Properties
|
60
74
|
|
61
|
-
* Range: {{
|
75
|
+
* Range: {{ compute_range(element) }}
|
62
76
|
{% if element.multivalued %}
|
63
77
|
* Multivalued: {{ element.multivalued }}
|
64
78
|
{% endif -%}
|
@@ -192,52 +192,65 @@ class DocGenerator(Generator):
|
|
192
192
|
"diagram_type": self.diagram_type.value if self.diagram_type else None,
|
193
193
|
"include_top_level_diagram": self.include_top_level_diagram,
|
194
194
|
}
|
195
|
+
self.logger.debug("Processing Index")
|
195
196
|
template = self._get_template("index")
|
196
197
|
out_str = template.render(gen=self, schema=sv.schema, schemaview=sv, **template_vars)
|
197
198
|
self._write(out_str, directory, self.index_name)
|
198
199
|
if self._is_single_file_format(self.format):
|
199
|
-
|
200
|
+
self.logger.info(f"{self.format} is a single-page format, skipping non-index elements")
|
200
201
|
return
|
202
|
+
self.logger.debug("Processing Schemas...")
|
201
203
|
template = self._get_template("schema")
|
202
204
|
for schema_name in sv.imports_closure():
|
205
|
+
self.logger.debug(f" Generating doc for {schema_name}")
|
203
206
|
imported_schema = sv.schema_map.get(schema_name)
|
204
207
|
out_str = template.render(gen=self, schema=imported_schema, schemaview=sv, **template_vars)
|
205
208
|
self._write(out_str, directory, imported_schema.name)
|
209
|
+
self.logger.debug("Processing Classes...")
|
206
210
|
template = self._get_template("class")
|
207
211
|
for cn, c in sv.all_classes().items():
|
208
212
|
if self._is_external(c):
|
209
213
|
continue
|
210
214
|
n = self.name(c)
|
215
|
+
self.logger.debug(f" Generating doc for {n}")
|
211
216
|
out_str = template.render(gen=self, element=c, schemaview=sv, **template_vars)
|
212
217
|
self._write(out_str, directory, n)
|
218
|
+
self.logger.debug("Processing Slots...")
|
213
219
|
template = self._get_template("slot")
|
214
220
|
for sn, s in sv.all_slots().items():
|
215
221
|
if self._is_external(s):
|
216
222
|
continue
|
217
223
|
n = self.name(s)
|
224
|
+
self.logger.debug(f" Generating doc for {n}")
|
218
225
|
s = sv.induced_slot(sn)
|
219
226
|
out_str = template.render(gen=self, element=s, schemaview=sv, **template_vars)
|
220
227
|
self._write(out_str, directory, n)
|
228
|
+
self.logger.debug("Processing Enums...")
|
221
229
|
template = self._get_template("enum")
|
222
230
|
for en, e in sv.all_enums().items():
|
223
231
|
if self._is_external(e):
|
224
232
|
continue
|
225
233
|
n = self.name(e)
|
234
|
+
self.logger.debug(f" Generating doc for {n}")
|
226
235
|
out_str = template.render(gen=self, element=e, schemaview=sv, **template_vars)
|
227
236
|
self._write(out_str, directory, n)
|
237
|
+
self.logger.debug("Processing Types...")
|
228
238
|
template = self._get_template("type")
|
229
239
|
for tn, t in sv.all_types().items():
|
230
240
|
if self._exclude_type(t):
|
231
241
|
continue
|
232
242
|
n = self.name(t)
|
243
|
+
self.logger.debug(f" Generating doc for {n}")
|
233
244
|
t = sv.induced_type(tn)
|
234
245
|
out_str = template.render(gen=self, element=t, schemaview=sv, **template_vars)
|
235
246
|
self._write(out_str, directory, n)
|
247
|
+
self.logger.debug("Processing Subsets...")
|
236
248
|
template = self._get_template("subset")
|
237
249
|
for _, s in sv.all_subsets().items():
|
238
250
|
if self._is_external(c):
|
239
251
|
continue
|
240
252
|
n = self.name(s)
|
253
|
+
self.logger.debug(f" Generating doc for {n}")
|
241
254
|
out_str = template.render(gen=self, element=s, schemaview=sv, **template_vars)
|
242
255
|
self._write(out_str, directory, n)
|
243
256
|
|
@@ -253,6 +266,7 @@ class DocGenerator(Generator):
|
|
253
266
|
path = Path(directory)
|
254
267
|
path.mkdir(parents=True, exist_ok=True)
|
255
268
|
file_name = f"{name}.{self._file_suffix()}"
|
269
|
+
self.logger.debug(f" Writing file: {file_name}")
|
256
270
|
with open(path / file_name, "w", encoding="UTF-8") as stream:
|
257
271
|
stream.write(out_str)
|
258
272
|
|
@@ -294,7 +308,7 @@ class DocGenerator(Generator):
|
|
294
308
|
if p.is_file():
|
295
309
|
folder = self.template_directory
|
296
310
|
else:
|
297
|
-
|
311
|
+
self.logger.info(
|
298
312
|
f"Could not find {base_file_name} in {self.template_directory} - falling back to default"
|
299
313
|
)
|
300
314
|
if not folder:
|
@@ -325,7 +339,7 @@ class DocGenerator(Generator):
|
|
325
339
|
|
326
340
|
:param element: SchemaView element definition
|
327
341
|
:return: slot name or numeric portion of CURIE prefixed
|
328
|
-
|
342
|
+
slot_uri
|
329
343
|
"""
|
330
344
|
if type(element).class_name == "slot_definition":
|
331
345
|
if self.use_slot_uris:
|
@@ -6,14 +6,14 @@ Generate JSON-LD contexts
|
|
6
6
|
import os
|
7
7
|
import re
|
8
8
|
from dataclasses import dataclass, field
|
9
|
-
from typing import Dict, Optional, Set
|
9
|
+
from typing import Any, Dict, Optional, Set, Union
|
10
10
|
|
11
11
|
import click
|
12
12
|
from jsonasobj2 import JsonObj, as_json
|
13
13
|
from linkml_runtime.linkml_model.meta import ClassDefinition, SlotDefinition
|
14
14
|
from linkml_runtime.linkml_model.types import SHEX
|
15
15
|
from linkml_runtime.utils.formatutils import camelcase, underscore
|
16
|
-
from rdflib import SKOS, XSD
|
16
|
+
from rdflib import SKOS, XSD, Namespace
|
17
17
|
|
18
18
|
from linkml._version import __version__
|
19
19
|
from linkml.utils.generator import Generator, shared_arguments
|
@@ -47,7 +47,7 @@ class ContextGenerator(Generator):
|
|
47
47
|
slot_class_maps: Dict = field(default_factory=lambda: dict())
|
48
48
|
emit_metadata: bool = False
|
49
49
|
model: Optional[bool] = True
|
50
|
-
base: Optional[str] = None
|
50
|
+
base: Optional[Union[str, Namespace]] = None
|
51
51
|
output: Optional[str] = None
|
52
52
|
prefixes: Optional[bool] = True
|
53
53
|
flatprefixes: Optional[bool] = False
|
@@ -57,7 +57,7 @@ class ContextGenerator(Generator):
|
|
57
57
|
if self.namespaces is None:
|
58
58
|
raise TypeError("Schema text must be supplied to context generator. Preparsed schema will not work")
|
59
59
|
|
60
|
-
def visit_schema(self, base: Optional[str] = None, output: Optional[str] = None, **_):
|
60
|
+
def visit_schema(self, base: Optional[Union[str, Namespace]] = None, output: Optional[str] = None, **_):
|
61
61
|
# Add any explicitly declared prefixes
|
62
62
|
for prefix in self.schema.prefixes.values():
|
63
63
|
self.emit_prefixes.add(prefix.prefix_prefix)
|
@@ -80,11 +80,10 @@ class ContextGenerator(Generator):
|
|
80
80
|
self.namespaces[self.schema.name] = default_uri
|
81
81
|
self.emit_prefixes.add(self.schema.name)
|
82
82
|
self.context_body["@vocab"] = default_uri
|
83
|
-
# self.context_body['@base'] = self.base_dir
|
84
83
|
|
85
84
|
def end_schema(
|
86
85
|
self,
|
87
|
-
base: Optional[str] = None,
|
86
|
+
base: Optional[Union[str, Namespace]] = None,
|
88
87
|
output: Optional[str] = None,
|
89
88
|
prefixes: Optional[bool] = True,
|
90
89
|
flatprefixes: Optional[bool] = False,
|
@@ -102,6 +101,7 @@ class ContextGenerator(Generator):
|
|
102
101
|
context.comments = comments
|
103
102
|
context_content = {}
|
104
103
|
if base:
|
104
|
+
base = str(base)
|
105
105
|
if "://" not in base:
|
106
106
|
self.context_body["@base"] = os.path.relpath(base, os.path.dirname(self.schema.source_file))
|
107
107
|
else:
|
@@ -133,16 +133,13 @@ class ContextGenerator(Generator):
|
|
133
133
|
class_def = {}
|
134
134
|
cn = camelcase(cls.name)
|
135
135
|
self.add_mappings(cls)
|
136
|
-
|
137
|
-
|
138
|
-
class_def["@id"] = (cls_uri_prefix + ":" + cls_uri_suffix) if cls_uri_prefix else cls.class_uri
|
139
|
-
if cls_uri_prefix:
|
140
|
-
self.add_prefix(cls_uri_prefix)
|
136
|
+
|
137
|
+
self._build_element_id(class_def, cls.class_uri)
|
141
138
|
if class_def:
|
142
139
|
self.slot_class_maps[cn] = class_def
|
143
140
|
|
144
141
|
# We don't bother to visit class slots - just all slots
|
145
|
-
return
|
142
|
+
return True
|
146
143
|
|
147
144
|
def visit_slot(self, aliased_slot_name: str, slot: SlotDefinition) -> None:
|
148
145
|
if slot.identifier:
|
@@ -169,15 +166,41 @@ class ContextGenerator(Generator):
|
|
169
166
|
slot_def["@type"] = "@id"
|
170
167
|
else:
|
171
168
|
slot_def["@type"] = range_type.uri
|
172
|
-
|
173
|
-
|
174
|
-
slot_def["@id"] = slot.slot_uri
|
175
|
-
if slot_prefix:
|
176
|
-
self.add_prefix(slot_prefix)
|
169
|
+
|
170
|
+
self._build_element_id(slot_def, slot.slot_uri)
|
177
171
|
self.add_mappings(slot)
|
178
172
|
if slot_def:
|
179
173
|
self.context_body[underscore(aliased_slot_name)] = slot_def
|
180
174
|
|
175
|
+
def _build_element_id(self, definition: Any, uri: str) -> None:
|
176
|
+
"""
|
177
|
+
Defines the elements @id attribute according to the default namespace prefix of the schema.
|
178
|
+
|
179
|
+
The @id namespace prefix is added only if it doesn't correspond to the default schema namespace prefix
|
180
|
+
whether it is in URI format or as an alias.
|
181
|
+
|
182
|
+
@param definition: the element (class or slot) definition
|
183
|
+
@param uri: the uri of the element (class or slot)
|
184
|
+
@return: None
|
185
|
+
"""
|
186
|
+
uri_prefix, uri_suffix = self.namespaces.prefix_suffix(uri)
|
187
|
+
is_default_namespace = uri_prefix == self.context_body["@vocab"] or uri_prefix == self.namespaces.prefix_for(
|
188
|
+
self.context_body["@vocab"]
|
189
|
+
)
|
190
|
+
|
191
|
+
if not uri_prefix and not uri_suffix:
|
192
|
+
definition["@id"] = uri
|
193
|
+
elif not uri_prefix or is_default_namespace:
|
194
|
+
definition["@id"] = uri_suffix
|
195
|
+
else:
|
196
|
+
definition["@id"] = (uri_prefix + ":" + uri_suffix) if uri_prefix else uri
|
197
|
+
|
198
|
+
if uri_prefix and not is_default_namespace:
|
199
|
+
self.add_prefix(uri_prefix)
|
200
|
+
|
201
|
+
def serialize(self, base: Optional[Union[str, Namespace]] = None, **kwargs) -> str:
|
202
|
+
return super().serialize(base=base, **kwargs)
|
203
|
+
|
181
204
|
|
182
205
|
@shared_arguments(ContextGenerator)
|
183
206
|
@click.command()
|
@@ -37,7 +37,8 @@ class JSONLDGenerator(Generator):
|
|
37
37
|
|
38
38
|
Status: incompletely implemented
|
39
39
|
|
40
|
-
Note: this is distinct from
|
40
|
+
Note: this is distinct from
|
41
|
+
:class:`~linkml.generators.jsonldcontextgen.ContextGenerator`, which generates a JSON-LD context
|
41
42
|
"""
|
42
43
|
|
43
44
|
# ClassVars
|
@@ -49,6 +50,7 @@ class JSONLDGenerator(Generator):
|
|
49
50
|
] # jsonld includes @type and @context. json is pure JSON
|
50
51
|
uses_schemaloader = True
|
51
52
|
requires_metamodel = True
|
53
|
+
file_extension = "jsonld"
|
52
54
|
|
53
55
|
# ObjectVars
|
54
56
|
original_schema: SchemaDefinition = None
|
@@ -22,6 +22,7 @@ from linkml_runtime.linkml_model.meta import (
|
|
22
22
|
EnumDefinition,
|
23
23
|
EnumDefinitionName,
|
24
24
|
PermissibleValue,
|
25
|
+
SchemaDefinitionName,
|
25
26
|
SlotDefinition,
|
26
27
|
SlotDefinitionName,
|
27
28
|
TypeDefinition,
|
@@ -199,6 +200,12 @@ class OwlSchemaGenerator(Generator):
|
|
199
200
|
for enm in sv.all_enums(imports=mergeimports).values():
|
200
201
|
self.add_enum(enm)
|
201
202
|
|
203
|
+
if not mergeimports:
|
204
|
+
for imp in schema.imports:
|
205
|
+
if imp == "linkml:types":
|
206
|
+
continue
|
207
|
+
graph.add((base, OWL.imports, self._schema_uri(imp)))
|
208
|
+
|
202
209
|
# Add metadata as annotation properties
|
203
210
|
self.add_metadata(schema, base)
|
204
211
|
return graph
|
@@ -267,6 +274,8 @@ class OwlSchemaGenerator(Generator):
|
|
267
274
|
self.graph.add((uri, metaslot_uri, obj))
|
268
275
|
|
269
276
|
for k, v in e.annotations.items():
|
277
|
+
if isinstance(v, dict) or isinstance(v, list):
|
278
|
+
continue
|
270
279
|
if ":" not in k:
|
271
280
|
default_prefix = this_sv.schema.default_prefix
|
272
281
|
if default_prefix in this_sv.schema.prefixes:
|
@@ -1129,6 +1138,13 @@ class OwlSchemaGenerator(Generator):
|
|
1129
1138
|
default_prefix = self.schemaview.schema.default_prefix or ""
|
1130
1139
|
return URIRef(self.schemaview.expand_curie(f"{default_prefix}:{underscore(p.name)}"))
|
1131
1140
|
|
1141
|
+
def _schema_uri(self, scn: Union[str, SchemaDefinitionName]) -> URIRef:
|
1142
|
+
if ":" in scn:
|
1143
|
+
return URIRef(self.schemaview.expand_curie(scn))
|
1144
|
+
else:
|
1145
|
+
default_prefix = self.schemaview.schema.default_prefix or ""
|
1146
|
+
return URIRef(self.schemaview.expand_curie(f"{default_prefix}:{scn}"))
|
1147
|
+
|
1132
1148
|
def _type_uri(self, tn: TypeDefinitionName, native: bool = None) -> URIRef:
|
1133
1149
|
if native is None:
|
1134
1150
|
# never use native unless type shadowing with objects is enabled
|
@@ -6,14 +6,14 @@ Generate JSON-LD contexts
|
|
6
6
|
import csv
|
7
7
|
import os
|
8
8
|
from dataclasses import dataclass, field
|
9
|
-
from typing import Dict, Optional, Set
|
9
|
+
from typing import Dict, Optional, Set, Union
|
10
10
|
|
11
11
|
import click
|
12
12
|
from jsonasobj2 import JsonObj, as_json
|
13
13
|
from linkml_runtime.linkml_model.meta import ClassDefinition, SlotDefinition
|
14
14
|
from linkml_runtime.linkml_model.types import SHEX
|
15
15
|
from linkml_runtime.utils.formatutils import camelcase
|
16
|
-
from rdflib import XSD
|
16
|
+
from rdflib import XSD, Namespace
|
17
17
|
|
18
18
|
from linkml._version import __version__
|
19
19
|
from linkml.utils.generator import Generator, shared_arguments
|
@@ -35,7 +35,7 @@ class PrefixGenerator(Generator):
|
|
35
35
|
default_ns: str = None
|
36
36
|
context_body: Dict = field(default_factory=lambda: dict())
|
37
37
|
slot_class_maps: Dict = field(default_factory=lambda: dict())
|
38
|
-
base: str = None
|
38
|
+
base: Optional[Union[str, Namespace]] = None
|
39
39
|
|
40
40
|
def __post_init__(self):
|
41
41
|
super().__post_init__()
|
@@ -59,9 +59,10 @@ class PrefixGenerator(Generator):
|
|
59
59
|
if self.default_ns:
|
60
60
|
self.emit_prefixes.add(self.default_ns)
|
61
61
|
|
62
|
-
def end_schema(self, base: Optional[str] = None, output: Optional[str] = None, **_) -> None:
|
62
|
+
def end_schema(self, base: Optional[Union[str, Namespace]] = None, output: Optional[str] = None, **_) -> None:
|
63
63
|
context = JsonObj()
|
64
64
|
if base:
|
65
|
+
base = str(base)
|
65
66
|
if "://" not in base:
|
66
67
|
self.context_body["@base"] = os.path.relpath(base, os.path.dirname(self.schema.source_file))
|
67
68
|
else:
|
@@ -198,26 +198,38 @@ def cli(
|
|
198
198
|
|
199
199
|
Generate all downstream artefacts using default configuration:
|
200
200
|
|
201
|
-
|
201
|
+
.. code-block: bash
|
202
|
+
|
203
|
+
gen-project -d . personinfo.yaml
|
202
204
|
|
203
205
|
Exclusion lists: all except ShEx:
|
204
206
|
|
205
|
-
|
207
|
+
.. code-block: bash
|
208
|
+
|
209
|
+
gen-project --exclude shex -d . personinfo.yaml
|
206
210
|
|
207
211
|
Inclusion lists: only jsonschema and python:
|
208
212
|
|
213
|
+
.. code-block: bash
|
214
|
+
|
209
215
|
gen-project -I python -I jsonschema -d . personinfo.yaml
|
210
216
|
|
211
217
|
Configuration, on command line:
|
212
218
|
|
219
|
+
.. code-block: bash
|
220
|
+
|
213
221
|
gen-project -A 'jsonschema: {top_class: Container}' -d . personinfo.yaml
|
214
222
|
|
215
223
|
Configuration, via yaml file:
|
216
224
|
|
225
|
+
.. code-block: bash
|
226
|
+
|
217
227
|
gen-project --config config.yaml personinfo.yaml
|
218
228
|
|
219
229
|
config.yaml:
|
220
230
|
|
231
|
+
.. code-block: yaml
|
232
|
+
|
221
233
|
directory: .
|
222
234
|
generator_args:
|
223
235
|
json_schema:
|
@@ -0,0 +1,29 @@
|
|
1
|
+
from linkml.generators.pydanticgen.pydanticgen import DEFAULT_IMPORTS, PydanticGenerator, cli
|
2
|
+
from linkml.generators.pydanticgen.template import (
|
3
|
+
ConditionalImport,
|
4
|
+
Import,
|
5
|
+
Imports,
|
6
|
+
PydanticAttribute,
|
7
|
+
PydanticBaseModel,
|
8
|
+
PydanticClass,
|
9
|
+
PydanticEnum,
|
10
|
+
PydanticModule,
|
11
|
+
PydanticValidator,
|
12
|
+
TemplateModel,
|
13
|
+
)
|
14
|
+
|
15
|
+
__all__ = [
|
16
|
+
"cli",
|
17
|
+
"ConditionalImport",
|
18
|
+
"DEFAULT_IMPORTS",
|
19
|
+
"Import",
|
20
|
+
"Imports",
|
21
|
+
"PydanticAttribute",
|
22
|
+
"PydanticBaseModel",
|
23
|
+
"PydanticClass",
|
24
|
+
"PydanticEnum",
|
25
|
+
"PydanticGenerator",
|
26
|
+
"PydanticModule",
|
27
|
+
"PydanticValidator",
|
28
|
+
"TemplateModel",
|
29
|
+
]
|