mdmodels 0.2.4__tar.gz → 0.3.1__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 (174) hide show
  1. mdmodels-0.3.1/.github/scripts/start_ollama.sh +16 -0
  2. mdmodels-0.3.1/.github/workflows/lint.yml +24 -0
  3. mdmodels-0.3.1/.github/workflows/publish.yml +23 -0
  4. mdmodels-0.3.1/.github/workflows/test-publish.yml +25 -0
  5. mdmodels-0.3.1/.github/workflows/test.yml +69 -0
  6. mdmodels-0.3.1/.gitignore +172 -0
  7. mdmodels-0.3.1/Dockerfile +23 -0
  8. mdmodels-0.3.1/PKG-INFO +162 -0
  9. mdmodels-0.3.1/README.md +106 -0
  10. mdmodels-0.3.1/docs/.gitignore +21 -0
  11. mdmodels-0.3.1/docs/README.md +49 -0
  12. mdmodels-0.3.1/docs/astro.config.mjs +88 -0
  13. mdmodels-0.3.1/docs/package-lock.json +8414 -0
  14. mdmodels-0.3.1/docs/package.json +28 -0
  15. mdmodels-0.3.1/docs/public/favicon.svg +1 -0
  16. mdmodels-0.3.1/docs/src/assets/houston.webp +0 -0
  17. mdmodels-0.3.1/docs/src/assets/logo.svg +6 -0
  18. mdmodels-0.3.1/docs/src/content/config.ts +11 -0
  19. mdmodels-0.3.1/docs/src/content/docs/basic/converting-formats.mdx +55 -0
  20. mdmodels-0.3.1/docs/src/content/docs/basic/creating-data.mdx +66 -0
  21. mdmodels-0.3.1/docs/src/content/docs/basic/index.mdx +65 -0
  22. mdmodels-0.3.1/docs/src/content/docs/basic/library.mdx +120 -0
  23. mdmodels-0.3.1/docs/src/content/docs/basic/multiple-models.mdx +51 -0
  24. mdmodels-0.3.1/docs/src/content/docs/basic/parsing.mdx +95 -0
  25. mdmodels-0.3.1/docs/src/content/docs/basic/querying.mdx +57 -0
  26. mdmodels-0.3.1/docs/src/content/docs/basic/serialization.mdx +41 -0
  27. mdmodels-0.3.1/docs/src/content/docs/basic/validation.mdx +60 -0
  28. mdmodels-0.3.1/docs/src/content/docs/databases/graphdb.mdx +232 -0
  29. mdmodels-0.3.1/docs/src/content/docs/databases/sql.mdx +360 -0
  30. mdmodels-0.3.1/docs/src/content/docs/databases/vector.mdx +221 -0
  31. mdmodels-0.3.1/docs/src/content/docs/installation.mdx +59 -0
  32. mdmodels-0.3.1/docs/src/content/docs/integrations/cli.mdx +398 -0
  33. mdmodels-0.3.1/docs/src/content/docs/integrations/fastapi.mdx +317 -0
  34. mdmodels-0.3.1/docs/src/content/docs/integrations/fastmcp.mdx +208 -0
  35. mdmodels-0.3.1/docs/src/content/docs/integrations/graphql.mdx +173 -0
  36. mdmodels-0.3.1/docs/src/content.config.ts +7 -0
  37. mdmodels-0.3.1/docs/src/styles/styles.css +41 -0
  38. mdmodels-0.3.1/docs/tsconfig.json +5 -0
  39. mdmodels-0.3.1/examples/basic/BasicExample.ipynb +622 -0
  40. mdmodels-0.3.1/examples/basic/model.jl +151 -0
  41. mdmodels-0.3.1/examples/basic/model.md +131 -0
  42. mdmodels-0.3.1/examples/basic/model.rs +130 -0
  43. mdmodels-0.3.1/examples/basic/model.xsd +205 -0
  44. mdmodels-0.3.1/examples/basic/uml_diagram.md +48 -0
  45. mdmodels-0.3.1/examples/graph/Neo4JExample.ipynb +320 -0
  46. mdmodels-0.3.1/examples/graph/model.md +86 -0
  47. mdmodels-0.2.4/mdmodels/llm/__init__.py → mdmodels-0.3.1/examples/graph/startn4j.sh +15 -14
  48. mdmodels-0.3.1/examples/sql/basic/SQLDatabaseExample.ipynb +515 -0
  49. mdmodels-0.3.1/examples/sql/basic/model.md +182 -0
  50. mdmodels-0.3.1/examples/sql/basic/projects.json +117 -0
  51. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/__init__.py +1 -1
  52. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/adder_method.py +9 -8
  53. mdmodels-0.3.1/mdmodels/cli.py +420 -0
  54. mdmodels-0.3.1/mdmodels/config.py +159 -0
  55. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/create.py +33 -16
  56. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/datamodel.py +61 -9
  57. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/git_utils.py +15 -4
  58. {mdmodels-0.2.4/mdmodels/sql → mdmodels-0.3.1/mdmodels/graph}/__init__.py +3 -5
  59. mdmodels-0.2.4/mdmodels/graph/__init__.py → mdmodels-0.3.1/mdmodels/graph/connector.py +25 -14
  60. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/graph/create.py +78 -27
  61. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/graph/relation.py +7 -7
  62. mdmodels-0.3.1/mdmodels/graphql/__init__.py +3 -0
  63. mdmodels-0.3.1/mdmodels/graphql/create.py +488 -0
  64. mdmodels-0.3.1/mdmodels/library.py +698 -0
  65. {mdmodels-0.2.4/mdmodels/llm/templates → mdmodels-0.3.1/mdmodels/llm}/__init__.py +5 -1
  66. mdmodels-0.3.1/mdmodels/llm/handler.py +240 -0
  67. mdmodels-0.3.1/mdmodels/mcp/__init__.py +13 -0
  68. mdmodels-0.3.1/mdmodels/mcp/auth.py +104 -0
  69. mdmodels-0.3.1/mdmodels/mcp/config.py +74 -0
  70. mdmodels-0.3.1/mdmodels/mcp/create.py +100 -0
  71. mdmodels-0.3.1/mdmodels/mcp/sql/__init__.py +8 -0
  72. mdmodels-0.3.1/mdmodels/mcp/sql/annotation.py +39 -0
  73. mdmodels-0.3.1/mdmodels/mcp/sql/constants.py +90 -0
  74. mdmodels-0.3.1/mdmodels/mcp/sql/create.py +135 -0
  75. mdmodels-0.3.1/mdmodels/mcp/sql/embedding.py +22 -0
  76. mdmodels-0.3.1/mdmodels/mcp/sql/middleware.py +66 -0
  77. mdmodels-0.3.1/mdmodels/mcp/sql/naming.py +27 -0
  78. mdmodels-0.3.1/mdmodels/mcp/sql/ownership.py +261 -0
  79. mdmodels-0.3.1/mdmodels/mcp/sql/relationships_types.py +23 -0
  80. mdmodels-0.3.1/mdmodels/mcp/sql/runtime.py +80 -0
  81. mdmodels-0.3.1/mdmodels/mcp/sql/tools/__init__.py +1 -0
  82. mdmodels-0.3.1/mdmodels/mcp/sql/tools/_assets.py +9 -0
  83. mdmodels-0.3.1/mdmodels/mcp/sql/tools/aggregate.py +140 -0
  84. mdmodels-0.3.1/mdmodels/mcp/sql/tools/annotate.py +197 -0
  85. mdmodels-0.3.1/mdmodels/mcp/sql/tools/assets/data_entry_form.html +947 -0
  86. mdmodels-0.3.1/mdmodels/mcp/sql/tools/assets/downloader.html +208 -0
  87. mdmodels-0.3.1/mdmodels/mcp/sql/tools/assets/plot_viewer.html +989 -0
  88. mdmodels-0.3.1/mdmodels/mcp/sql/tools/assets/tabular_upload.html +0 -0
  89. mdmodels-0.3.1/mdmodels/mcp/sql/tools/download.py +96 -0
  90. mdmodels-0.3.1/mdmodels/mcp/sql/tools/form.py +390 -0
  91. mdmodels-0.3.1/mdmodels/mcp/sql/tools/form_store.py +99 -0
  92. mdmodels-0.3.1/mdmodels/mcp/sql/tools/plot.py +834 -0
  93. mdmodels-0.3.1/mdmodels/mcp/sql/tools/relationships.py +73 -0
  94. mdmodels-0.3.1/mdmodels/mcp/sql/tools/schema.py +36 -0
  95. mdmodels-0.3.1/mdmodels/mcp/sql/tools/select.py +149 -0
  96. mdmodels-0.3.1/mdmodels/mcp/sql/tools/tabular.py +0 -0
  97. mdmodels-0.3.1/mdmodels/mcp/sql/tools/upsert.py +192 -0
  98. mdmodels-0.3.1/mdmodels/mcp/sql/tools/vector_search.py +191 -0
  99. mdmodels-0.3.1/mdmodels/mcp/types.py +4 -0
  100. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/meta.py +1 -1
  101. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/path.py +20 -18
  102. mdmodels-0.3.1/mdmodels/relations.py +227 -0
  103. mdmodels-0.3.1/mdmodels/rest/__init__.py +21 -0
  104. mdmodels-0.3.1/mdmodels/rest/config.py +114 -0
  105. mdmodels-0.3.1/mdmodels/rest/create.py +675 -0
  106. mdmodels-0.3.1/mdmodels/rest/search.py +44 -0
  107. mdmodels-0.3.1/mdmodels/sql/__init__.py +47 -0
  108. mdmodels-0.3.1/mdmodels/sql/aggregation.py +241 -0
  109. mdmodels-0.3.1/mdmodels/sql/base.py +109 -0
  110. mdmodels-0.3.1/mdmodels/sql/childref.py +125 -0
  111. mdmodels-0.3.1/mdmodels/sql/config.py +268 -0
  112. mdmodels-0.3.1/mdmodels/sql/connector.py +469 -0
  113. mdmodels-0.3.1/mdmodels/sql/create.py +838 -0
  114. mdmodels-0.3.1/mdmodels/sql/filter.py +185 -0
  115. mdmodels-0.3.1/mdmodels/sql/groupby.py +0 -0
  116. mdmodels-0.3.1/mdmodels/sql/insert.py +378 -0
  117. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/sql/linked_type.py +4 -4
  118. mdmodels-0.3.1/mdmodels/sql/migrations.py +159 -0
  119. mdmodels-0.3.1/mdmodels/sql/upsert.py +210 -0
  120. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/sql/utils.py +96 -80
  121. mdmodels-0.3.1/mdmodels/sql/vector.py +400 -0
  122. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/units/converter.py +26 -23
  123. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/units/unit_definition.py +1 -1
  124. mdmodels-0.3.1/pyproject.toml +79 -0
  125. mdmodels-0.3.1/run-tests.sh +31 -0
  126. mdmodels-0.3.1/tests/__init__.py +0 -0
  127. mdmodels-0.3.1/tests/fixtures/expected_json.json +26 -0
  128. mdmodels-0.3.1/tests/fixtures/expected_units.json +46 -0
  129. mdmodels-0.3.1/tests/fixtures/expected_units_complex.json +33 -0
  130. mdmodels-0.3.1/tests/fixtures/expected_wrapped_xml.xml +16 -0
  131. mdmodels-0.3.1/tests/fixtures/expected_xml.xml +15 -0
  132. mdmodels-0.3.1/tests/fixtures/model.md +62 -0
  133. mdmodels-0.3.1/tests/fixtures/model_database.md +33 -0
  134. mdmodels-0.3.1/tests/fixtures/model_graph.md +18 -0
  135. mdmodels-0.3.1/tests/fixtures/model_json_schema.json +89 -0
  136. mdmodels-0.3.1/tests/fixtures/model_multiple_types.md +32 -0
  137. mdmodels-0.3.1/tests/fixtures/model_recursion.md +4 -0
  138. mdmodels-0.3.1/tests/fixtures/model_units.md +6 -0
  139. mdmodels-0.3.1/tests/fixtures/model_wrapped_xml.md +17 -0
  140. mdmodels-0.3.1/tests/integration/__init__.py +0 -0
  141. mdmodels-0.3.1/tests/integration/conftest.py +51 -0
  142. mdmodels-0.3.1/tests/integration/test_conversion.py +21 -0
  143. mdmodels-0.3.1/tests/integration/test_db.py +243 -0
  144. mdmodels-0.3.1/tests/integration/test_from_json_schema.py +105 -0
  145. mdmodels-0.3.1/tests/integration/test_graph.py +75 -0
  146. mdmodels-0.3.1/tests/integration/test_llm.py +30 -0
  147. mdmodels-0.3.1/tests/integration/test_parse.py +156 -0
  148. mdmodels-0.3.1/tests/unit/__init__.py +0 -0
  149. mdmodels-0.3.1/tests/unit/test_create.py +36 -0
  150. mdmodels-0.3.1/tests/unit/test_datamodel.py +135 -0
  151. mdmodels-0.3.1/tests/unit/test_git_utils.py +87 -0
  152. mdmodels-0.3.1/tests/unit/test_unit_definition.py +53 -0
  153. mdmodels-0.3.1/uv.lock +3919 -0
  154. mdmodels-0.2.4/PKG-INFO +0 -122
  155. mdmodels-0.2.4/README.md +0 -86
  156. mdmodels-0.2.4/mdmodels/library.py +0 -257
  157. mdmodels-0.2.4/mdmodels/llm/embed.py +0 -81
  158. mdmodels-0.2.4/mdmodels/llm/fetcher.py +0 -141
  159. mdmodels-0.2.4/mdmodels/llm/handler.py +0 -137
  160. mdmodels-0.2.4/mdmodels/llm/prompts.py +0 -157
  161. mdmodels-0.2.4/mdmodels/llm/response.py +0 -87
  162. mdmodels-0.2.4/mdmodels/llm/templates/dataset_query.py +0 -231
  163. mdmodels-0.2.4/mdmodels/sql/base.py +0 -43
  164. mdmodels-0.2.4/mdmodels/sql/connector.py +0 -215
  165. mdmodels-0.2.4/mdmodels/sql/create.py +0 -424
  166. mdmodels-0.2.4/mdmodels/sql/insert.py +0 -240
  167. mdmodels-0.2.4/pyproject.toml +0 -57
  168. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/graph/basenode.py +0 -0
  169. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/reference.py +0 -0
  170. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/templates.py +0 -0
  171. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/units/__init__.py +0 -0
  172. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/units/annotation.py +0 -0
  173. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/units/mappings.py +0 -0
  174. {mdmodels-0.2.4 → mdmodels-0.3.1}/mdmodels/utils.py +0 -0
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ # Start Ollama in the background.
4
+ /bin/ollama serve &
5
+ # Record Process ID.
6
+ pid=$!
7
+
8
+ # Pause for Ollama to start.
9
+ sleep 5
10
+
11
+ echo "🔴 Retrieve GEMMA2 model..."
12
+ ollama pull gemma2:2b
13
+ echo "🟢 Done!"
14
+
15
+ # Wait for Ollama process to finish.
16
+ wait $pid
@@ -0,0 +1,24 @@
1
+ name: Ruff
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - "mdmodels/**"
7
+ - "tests/**"
8
+ - "pyproject.toml"
9
+ pull_request:
10
+ paths:
11
+ - "mdmodels/**"
12
+ - "tests/**"
13
+ - "pyproject.toml"
14
+
15
+ jobs:
16
+ ruff:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: astral-sh/ruff-action@v2
21
+ with:
22
+ src: >-
23
+ mdmodels/
24
+ tests/
@@ -0,0 +1,23 @@
1
+ name: Build and publish
2
+
3
+ on:
4
+ release:
5
+ types: [released]
6
+
7
+ jobs:
8
+ deploy:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - name: Checkout
13
+ uses: actions/checkout@v5
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v6
17
+
18
+ - name: Build and publish to PyPi
19
+ env:
20
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
21
+ run: |
22
+ uv build
23
+ uv publish
@@ -0,0 +1,25 @@
1
+ name: Publish to TestPyPi
2
+
3
+ on: workflow_dispatch
4
+
5
+ jobs:
6
+ deploy:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+
12
+ - name: Set up Python
13
+ uses: actions/setup-python@v4
14
+ with:
15
+ python-version: "3.11"
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v6
19
+
20
+ - name: Publish Package
21
+ env:
22
+ UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
23
+ run: |
24
+ uv build
25
+ uv publish --index testpypi
@@ -0,0 +1,69 @@
1
+ name: Library Tests
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - "mdmodels/**"
7
+ - "tests/**"
8
+ - "pyproject.toml"
9
+ pull_request:
10
+ paths:
11
+ - "mdmodels/**"
12
+ - "tests/**"
13
+ - "pyproject.toml"
14
+
15
+ jobs:
16
+ build:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ max-parallel: 4
20
+ matrix:
21
+ python-version: ["3.11", "3.12", "3.13"]
22
+ steps:
23
+ - name: "Checkout"
24
+ uses: "actions/checkout@v4"
25
+ - name: Set up Python ${{ matrix.python-version }}
26
+ uses: actions/setup-python@v4
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+ - name: Pull Ollama model
30
+ run: |
31
+ curl http://localhost:11434/api/pull -d '{
32
+ "model": "gemma2:2b"
33
+ }'
34
+
35
+ - name: Install uv
36
+ uses: astral-sh/setup-uv@v6
37
+ - name: Install dependencies
38
+ run: |
39
+ python3 -m pip install --upgrade pip
40
+ uv sync --all-extras --group dev --python ${{ matrix.python-version }}
41
+ - name: Wait for Neo4j service to be ready
42
+ run: |
43
+ until curl -s http://localhost:7474; do
44
+ echo "Waiting for Neo4j service to be ready..."
45
+ sleep 5
46
+ done
47
+ - name: Test with pytest
48
+ env:
49
+ NEO4J_USER: neo4j
50
+ NEO4J_PASSWORD: your_password
51
+ NEO4J_HOST: localhost
52
+ NEO4J_PORT: 7687
53
+ OLLAMA_HOST: "http://localhost:11434/v1"
54
+ OLLAMA_MODEL: "gemma2:2b"
55
+ run: |
56
+ uv run pytest -v
57
+
58
+ services:
59
+ neo4j:
60
+ image: neo4j:latest
61
+ ports:
62
+ - 7474:7474
63
+ - 7687:7687
64
+ env:
65
+ NEO4J_AUTH: neo4j/your_password
66
+ ollama:
67
+ image: ollama/ollama:latest
68
+ ports:
69
+ - 11434:11434
@@ -0,0 +1,172 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+ *.pyc
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a data_model or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ .idea/
164
+
165
+ # MacOs
166
+ .DS_Store
167
+ **/.DS_Store
168
+
169
+ .ruff_cache/
170
+ .vscode/
171
+ app.py
172
+ poetry.lock
@@ -0,0 +1,23 @@
1
+ ARG PYTHON_VERSION=3.11
2
+ FROM python:${PYTHON_VERSION}-slim
3
+
4
+ ENV PYTHONDONTWRITEBYTECODE=1 \
5
+ PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1
7
+
8
+ WORKDIR /app
9
+
10
+ RUN apt-get update && \
11
+ apt-get install -y --no-install-recommends build-essential pkg-config && \
12
+ rm -rf /var/lib/apt/lists/*
13
+
14
+ COPY pyproject.toml README.md /app/
15
+ COPY mdmodels /app/mdmodels
16
+ COPY tests /app/tests
17
+
18
+ RUN python3 -m pip install --upgrade pip && \
19
+ python3 -m pip install uv && \
20
+ uv sync --all-extras --group dev --python ${PYTHON_VERSION}
21
+
22
+ # Run tests by default.
23
+ CMD ["uv", "run", "pytest", "-v", "-m", "not expensive"]
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: mdmodels
3
+ Version: 0.3.1
4
+ Summary: Python package for the MDModels Rust crate
5
+ Author-email: Jan Range <range.jan@web.de>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: astropy>=6.1.7
9
+ Requires-Dist: bigtree<0.22,>=0.21.1
10
+ Requires-Dist: dotenv>=0.9.9
11
+ Requires-Dist: dotted-dict<2,>=1.1.3
12
+ Requires-Dist: fastexcel>=0.19.0
13
+ Requires-Dist: httpx<0.29,>=0.28
14
+ Requires-Dist: mdmodels-core<0.3,>=0.2.9
15
+ Requires-Dist: nest-asyncio<2,>=1.6.0
16
+ Requires-Dist: pandas>=2.2.3
17
+ Requires-Dist: polars>=1.39.3
18
+ Requires-Dist: pydantic-xml<3,>=2.12.1
19
+ Requires-Dist: python-forge<19,>=18.6.0
20
+ Requires-Dist: python-jsonpath<2,>=1.2.0
21
+ Requires-Dist: rich<14,>=13.9.4
22
+ Requires-Dist: toml>=0.10.2
23
+ Requires-Dist: typer>=0.20.0
24
+ Requires-Dist: validators<0.35,>=0.34.0
25
+ Provides-Extra: chat
26
+ Requires-Dist: openai<2,>=1.57.0; extra == 'chat'
27
+ Requires-Dist: tabulate<0.10,>=0.9.0; extra == 'chat'
28
+ Provides-Extra: graph
29
+ Requires-Dist: neomodel<6,>=5.4.0; extra == 'graph'
30
+ Provides-Extra: graphql
31
+ Requires-Dist: strawberry-graphql>=0.296.0; extra == 'graphql'
32
+ Requires-Dist: uvicorn>=0.38.0; extra == 'graphql'
33
+ Provides-Extra: mcp
34
+ Requires-Dist: fastmcp[apps]>=3.2.0; extra == 'mcp'
35
+ Requires-Dist: toon-format==0.9.0b1; extra == 'mcp'
36
+ Provides-Extra: mysql
37
+ Requires-Dist: pymysql>=1.1.2; extra == 'mysql'
38
+ Requires-Dist: sqlmodel>=0.0.22; extra == 'mysql'
39
+ Provides-Extra: pgvector
40
+ Requires-Dist: fastembed>=0.7.3; extra == 'pgvector'
41
+ Requires-Dist: pgvector>=0.4.1; extra == 'pgvector'
42
+ Requires-Dist: psycopg2-binary>=2.9.11; extra == 'pgvector'
43
+ Requires-Dist: sentence-transformers<3,>=2.2.2; extra == 'pgvector'
44
+ Requires-Dist: sqlmodel<0.0.23,>=0.0.22; extra == 'pgvector'
45
+ Provides-Extra: postgres
46
+ Requires-Dist: psycopg2-binary>=2.9.11; extra == 'postgres'
47
+ Requires-Dist: sqlmodel<0.0.23,>=0.0.22; extra == 'postgres'
48
+ Provides-Extra: rest
49
+ Requires-Dist: fastapi>=0.123.8; extra == 'rest'
50
+ Requires-Dist: pyyaml>=6.0.3; extra == 'rest'
51
+ Requires-Dist: uvicorn>=0.38.0; extra == 'rest'
52
+ Provides-Extra: sqlserver
53
+ Requires-Dist: pyodbc>=5.3.0; extra == 'sqlserver'
54
+ Requires-Dist: sqlmodel>=0.0.22; extra == 'sqlserver'
55
+ Description-Content-Type: text/markdown
56
+
57
+ # Python MD-Models
58
+
59
+ ![Tests](https://github.com/FairCHemistry/py-mdmodels/actions/workflows/test.yml/badge.svg)
60
+ ![PyPI - Version](https://img.shields.io/pypi/v/mdmodels)
61
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mdmodels)
62
+
63
+ Build metadata-first Python apps from Markdown-defined models. `mdmodels` is the Python package for the [MDModels Rust crate](https://github.com/FairCHemistry/md-models), with batteries included for data modeling, AI workflows, SQL/graph backends, and API generation. 🚀
64
+
65
+ ## Why MD-Models?
66
+
67
+ - 🧩 **Model once** in Markdown, then generate strongly typed Python models
68
+ - 🤖 **Work with AI** for extraction, mapping, Q&A, and similarity search
69
+ - 🗃️ **Persist and query** with SQL, vectors, and graph databases
70
+ - 🌐 **Ship interfaces fast** via REST, GraphQL, and MCP helpers
71
+
72
+ ## What's in the bag? 🎒
73
+
74
+ - 🧱 **Core model tooling** - Load, inspect, and work with metadata models
75
+ - 🐍 **Pydantic generation** - Generate rich Python model classes from MD-Models
76
+ - 🤖 **LLM workflows** - Extract, map, search, and answer questions over metadata
77
+ - 🗄️ **SQL and vector search** - Build SQL-backed stores and pgvector-style embedding workflows
78
+ - 🕸️ **Graph databases** - Build and query graph representations of your models
79
+ - 🌐 **API generation** - Expose model-backed services through REST and GraphQL helpers
80
+ - 🔌 **MCP integrations** - Create MCP-compatible interfaces for model and SQL workflows
81
+
82
+ > **Note:** This package is actively evolving and APIs may change. Feedback and contributions are welcome. 🙌
83
+
84
+ ## Installation
85
+
86
+ We recommend using `uv` for a fast, reproducible Python workflow.
87
+
88
+ Install `uv` (if needed):
89
+
90
+ ```bash
91
+ curl -LsSf https://astral.sh/uv/install.sh | sh
92
+ ```
93
+
94
+ Install the base package:
95
+
96
+ ```bash
97
+ uv pip install mdmodels
98
+ ```
99
+
100
+ Install optional feature sets:
101
+
102
+ ```bash
103
+ # LLM tools
104
+ uv pip install "mdmodels[chat]"
105
+
106
+ # Graph database tools
107
+ uv pip install "mdmodels[graph]"
108
+
109
+ # SQL backends
110
+ uv pip install "mdmodels[postgres]"
111
+ uv pip install "mdmodels[mysql]"
112
+ uv pip install "mdmodels[sqlserver]"
113
+
114
+ # Vector search (pgvector + embeddings)
115
+ uv pip install "mdmodels[pgvector]"
116
+
117
+ # API integrations
118
+ uv pip install "mdmodels[rest]"
119
+ uv pip install "mdmodels[graphql]"
120
+
121
+ # MCP integration
122
+ uv pip install "mdmodels[mcp]"
123
+ ```
124
+
125
+ ## Documentation 📚
126
+
127
+ Guides, tutorials, and API usage:
128
+
129
+ - [py-mdmodels.vercel.app](https://py-mdmodels.vercel.app/)
130
+
131
+ ## Development
132
+
133
+ Run all tests:
134
+
135
+ ```bash
136
+ uv run pytest
137
+ ```
138
+
139
+ Run tests with coverage report:
140
+
141
+ ```bash
142
+ uv run pytest --cov=mdmodels --cov-report=html
143
+ ```
144
+
145
+ Run tests in Docker:
146
+
147
+ ```bash
148
+ docker build --build-arg PYTHON_VERSION=3.12 -t mdmodels .
149
+ docker run -v $(pwd):/app mdmodels
150
+ ```
151
+
152
+ Use the helper script:
153
+
154
+ ```bash
155
+ ./run-tests.sh --python=3.12
156
+ ```
157
+
158
+ Skip expensive tests:
159
+
160
+ ```bash
161
+ uv run pytest -m "not expensive"
162
+ ```
@@ -0,0 +1,106 @@
1
+ # Python MD-Models
2
+
3
+ ![Tests](https://github.com/FairCHemistry/py-mdmodels/actions/workflows/test.yml/badge.svg)
4
+ ![PyPI - Version](https://img.shields.io/pypi/v/mdmodels)
5
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mdmodels)
6
+
7
+ Build metadata-first Python apps from Markdown-defined models. `mdmodels` is the Python package for the [MDModels Rust crate](https://github.com/FairCHemistry/md-models), with batteries included for data modeling, AI workflows, SQL/graph backends, and API generation. 🚀
8
+
9
+ ## Why MD-Models?
10
+
11
+ - 🧩 **Model once** in Markdown, then generate strongly typed Python models
12
+ - 🤖 **Work with AI** for extraction, mapping, Q&A, and similarity search
13
+ - 🗃️ **Persist and query** with SQL, vectors, and graph databases
14
+ - 🌐 **Ship interfaces fast** via REST, GraphQL, and MCP helpers
15
+
16
+ ## What's in the bag? 🎒
17
+
18
+ - 🧱 **Core model tooling** - Load, inspect, and work with metadata models
19
+ - 🐍 **Pydantic generation** - Generate rich Python model classes from MD-Models
20
+ - 🤖 **LLM workflows** - Extract, map, search, and answer questions over metadata
21
+ - 🗄️ **SQL and vector search** - Build SQL-backed stores and pgvector-style embedding workflows
22
+ - 🕸️ **Graph databases** - Build and query graph representations of your models
23
+ - 🌐 **API generation** - Expose model-backed services through REST and GraphQL helpers
24
+ - 🔌 **MCP integrations** - Create MCP-compatible interfaces for model and SQL workflows
25
+
26
+ > **Note:** This package is actively evolving and APIs may change. Feedback and contributions are welcome. 🙌
27
+
28
+ ## Installation
29
+
30
+ We recommend using `uv` for a fast, reproducible Python workflow.
31
+
32
+ Install `uv` (if needed):
33
+
34
+ ```bash
35
+ curl -LsSf https://astral.sh/uv/install.sh | sh
36
+ ```
37
+
38
+ Install the base package:
39
+
40
+ ```bash
41
+ uv pip install mdmodels
42
+ ```
43
+
44
+ Install optional feature sets:
45
+
46
+ ```bash
47
+ # LLM tools
48
+ uv pip install "mdmodels[chat]"
49
+
50
+ # Graph database tools
51
+ uv pip install "mdmodels[graph]"
52
+
53
+ # SQL backends
54
+ uv pip install "mdmodels[postgres]"
55
+ uv pip install "mdmodels[mysql]"
56
+ uv pip install "mdmodels[sqlserver]"
57
+
58
+ # Vector search (pgvector + embeddings)
59
+ uv pip install "mdmodels[pgvector]"
60
+
61
+ # API integrations
62
+ uv pip install "mdmodels[rest]"
63
+ uv pip install "mdmodels[graphql]"
64
+
65
+ # MCP integration
66
+ uv pip install "mdmodels[mcp]"
67
+ ```
68
+
69
+ ## Documentation 📚
70
+
71
+ Guides, tutorials, and API usage:
72
+
73
+ - [py-mdmodels.vercel.app](https://py-mdmodels.vercel.app/)
74
+
75
+ ## Development
76
+
77
+ Run all tests:
78
+
79
+ ```bash
80
+ uv run pytest
81
+ ```
82
+
83
+ Run tests with coverage report:
84
+
85
+ ```bash
86
+ uv run pytest --cov=mdmodels --cov-report=html
87
+ ```
88
+
89
+ Run tests in Docker:
90
+
91
+ ```bash
92
+ docker build --build-arg PYTHON_VERSION=3.12 -t mdmodels .
93
+ docker run -v $(pwd):/app mdmodels
94
+ ```
95
+
96
+ Use the helper script:
97
+
98
+ ```bash
99
+ ./run-tests.sh --python=3.12
100
+ ```
101
+
102
+ Skip expensive tests:
103
+
104
+ ```bash
105
+ uv run pytest -m "not expensive"
106
+ ```
@@ -0,0 +1,21 @@
1
+ # build output
2
+ dist/
3
+ # generated types
4
+ .astro/
5
+
6
+ # dependencies
7
+ node_modules/
8
+
9
+ # logs
10
+ npm-debug.log*
11
+ yarn-debug.log*
12
+ yarn-error.log*
13
+ pnpm-debug.log*
14
+
15
+
16
+ # environment variables
17
+ .env
18
+ .env.production
19
+
20
+ # macOS-specific files
21
+ .DS_Store
@@ -0,0 +1,49 @@
1
+ # Starlight Starter Kit: Basics
2
+
3
+ [![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
4
+
5
+ ```
6
+ npm create astro@latest -- --template starlight
7
+ ```
8
+
9
+ > 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
10
+
11
+ ## 🚀 Project Structure
12
+
13
+ Inside of your Astro + Starlight project, you'll see the following folders and files:
14
+
15
+ ```
16
+ .
17
+ ├── public/
18
+ ├── src/
19
+ │ ├── assets/
20
+ │ ├── content/
21
+ │ │ └── docs/
22
+ │ └── content.config.ts
23
+ ├── astro.config.mjs
24
+ ├── package.json
25
+ └── tsconfig.json
26
+ ```
27
+
28
+ Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
29
+
30
+ Images can be added to `src/assets/` and embedded in Markdown with a relative link.
31
+
32
+ Static assets, like favicons, can be placed in the `public/` directory.
33
+
34
+ ## 🧞 Commands
35
+
36
+ All commands are run from the root of the project, from a terminal:
37
+
38
+ | Command | Action |
39
+ | :------------------------ | :----------------------------------------------- |
40
+ | `npm install` | Installs dependencies |
41
+ | `npm run dev` | Starts local dev server at `localhost:4321` |
42
+ | `npm run build` | Build your production site to `./dist/` |
43
+ | `npm run preview` | Preview your build locally, before deploying |
44
+ | `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
45
+ | `npm run astro -- --help` | Get help using the Astro CLI |
46
+
47
+ ## 👀 Want to learn more?
48
+
49
+ Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).