smuod_common 0.9.0__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.
- smuod_common-0.9.0/.gitignore +23 -0
- smuod_common-0.9.0/.pre-commit-config.yaml +45 -0
- smuod_common-0.9.0/.python-version +1 -0
- smuod_common-0.9.0/Examples-Database.ipynb +108 -0
- smuod_common-0.9.0/Examples-LangChain.ipynb +153 -0
- smuod_common-0.9.0/Examples-Pydantic-AI.ipynb +488 -0
- smuod_common-0.9.0/LICENSE +20 -0
- smuod_common-0.9.0/PKG-INFO +174 -0
- smuod_common-0.9.0/README.md +138 -0
- smuod_common-0.9.0/pyproject.toml +127 -0
- smuod_common-0.9.0/snowflake_test1.py +29 -0
- smuod_common-0.9.0/snowflake_test2.py +32 -0
- smuod_common-0.9.0/src/smuod_common/__init__.py +7 -0
- smuod_common-0.9.0/src/smuod_common/database.py +96 -0
- smuod_common-0.9.0/src/smuod_common/db_helpers.py +99 -0
- smuod_common-0.9.0/src/smuod_common/langchain.py +33 -0
- smuod_common-0.9.0/src/smuod_common/logsetup.py +61 -0
- smuod_common-0.9.0/src/smuod_common/otelsetup.py +118 -0
- smuod_common-0.9.0/src/smuod_common/py.typed +0 -0
- smuod_common-0.9.0/src/smuod_common/pydantic_ai.py +60 -0
- smuod_common-0.9.0/src/smuod_common/pydantic_ai_client.py +63 -0
- smuod_common-0.9.0/src/smuod_common/settings.py +35 -0
- smuod_common-0.9.0/src/smuod_common/utils.py +32 -0
- smuod_common-0.9.0/tests/conftest.py +1 -0
- smuod_common-0.9.0/tests/test_azure_foundry_client.py +149 -0
- smuod_common-0.9.0/tests/test_db_engine.py +163 -0
- smuod_common-0.9.0/tests/test_logsetup.py +127 -0
- smuod_common-0.9.0/tests/test_pydantic_ai.py +121 -0
- smuod_common-0.9.0/uv.lock +4008 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Project
|
|
2
|
+
*.env
|
|
3
|
+
output*/
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
.venv/
|
|
7
|
+
__pycache__/
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.coverage
|
|
14
|
+
MANIFEST
|
|
15
|
+
|
|
16
|
+
# Jupyter Notebook
|
|
17
|
+
.ipynb_checkpoints/
|
|
18
|
+
|
|
19
|
+
# IDE
|
|
20
|
+
.vscode/settings.json
|
|
21
|
+
|
|
22
|
+
# Autogenerated docs
|
|
23
|
+
docs/site
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
3
|
+
rev: 0.13.5
|
|
4
|
+
hooks:
|
|
5
|
+
# Audit project dependencies for known vulnerabilities
|
|
6
|
+
- id: uv-audit
|
|
7
|
+
name: Dependency vulnerability audit
|
|
8
|
+
args: [--locked, --no-dev]
|
|
9
|
+
always_run: true
|
|
10
|
+
|
|
11
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
12
|
+
rev: v0.17.2
|
|
13
|
+
hooks:
|
|
14
|
+
# Run the linter, automatically fixing issues when possible.
|
|
15
|
+
- id: ruff
|
|
16
|
+
name: Ruff linting
|
|
17
|
+
types_or: [python, pyi, jupyter]
|
|
18
|
+
args: [--fix]
|
|
19
|
+
# Run the formatter.
|
|
20
|
+
- id: ruff-format
|
|
21
|
+
name: Ruff formatting
|
|
22
|
+
types_or: [python, pyi, jupyter]
|
|
23
|
+
|
|
24
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
25
|
+
rev: v2.4.0
|
|
26
|
+
hooks:
|
|
27
|
+
- id: mypy
|
|
28
|
+
name: Mypy static type checker
|
|
29
|
+
additional_dependencies:
|
|
30
|
+
- pydantic
|
|
31
|
+
|
|
32
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
33
|
+
rev: v6.0.0
|
|
34
|
+
hooks:
|
|
35
|
+
- id: check-merge-conflict
|
|
36
|
+
- id: check-added-large-files
|
|
37
|
+
- id: end-of-file-fixer
|
|
38
|
+
- id: mixed-line-ending
|
|
39
|
+
args: ["--fix", "lf"]
|
|
40
|
+
|
|
41
|
+
- repo: https://github.com/kynan/nbstripout
|
|
42
|
+
rev: 0.9.1
|
|
43
|
+
hooks:
|
|
44
|
+
- id: nbstripout
|
|
45
|
+
name: Strip output from Jupyter notebooks
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": null,
|
|
6
|
+
"id": "fe5d0ea1",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [],
|
|
9
|
+
"source": [
|
|
10
|
+
"%env AZURE_FOUNDRY_NAME=smuod-foundry-sweden\n",
|
|
11
|
+
"%env PYDANTIC_AI_NO_BANNER=1\n",
|
|
12
|
+
"%env OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:6317\n",
|
|
13
|
+
"\n",
|
|
14
|
+
"from smuod_common import configure_logging_console, configure_otel\n",
|
|
15
|
+
"\n",
|
|
16
|
+
"configure_logging_console(\"example\")\n",
|
|
17
|
+
"configure_otel()"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"cell_type": "code",
|
|
22
|
+
"execution_count": null,
|
|
23
|
+
"id": "cb3b0d20",
|
|
24
|
+
"metadata": {},
|
|
25
|
+
"outputs": [
|
|
26
|
+
{
|
|
27
|
+
"name": "stdout",
|
|
28
|
+
"output_type": "stream",
|
|
29
|
+
"text": [
|
|
30
|
+
"1\n"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"source": [
|
|
35
|
+
"from sqlalchemy import text\n",
|
|
36
|
+
"\n",
|
|
37
|
+
"from smuod_common.database import create_db_engine\n",
|
|
38
|
+
"\n",
|
|
39
|
+
"connstr = \"mssql+pyodbc://@sqldb-prodelasticpool01-srv.database.windows.net/MLDataStore?driver=ODBC+Driver+18+for+SQL+Server\"\n",
|
|
40
|
+
"engine = create_db_engine(connstr)\n",
|
|
41
|
+
"\n",
|
|
42
|
+
"try:\n",
|
|
43
|
+
" with engine.connect() as connection:\n",
|
|
44
|
+
" print(connection.execute(text(\"SELECT 1\")).scalar_one())\n",
|
|
45
|
+
"finally:\n",
|
|
46
|
+
" engine.dispose()\n"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"cell_type": "code",
|
|
51
|
+
"execution_count": 1,
|
|
52
|
+
"id": "e5dbf42f",
|
|
53
|
+
"metadata": {},
|
|
54
|
+
"outputs": [
|
|
55
|
+
{
|
|
56
|
+
"name": "stdout",
|
|
57
|
+
"output_type": "stream",
|
|
58
|
+
"text": [
|
|
59
|
+
"1\n"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"source": [
|
|
64
|
+
"from sqlalchemy import text\n",
|
|
65
|
+
"\n",
|
|
66
|
+
"from smuod_common.db_helpers import database_engine\n",
|
|
67
|
+
"\n",
|
|
68
|
+
"connstr = \"mssql+pyodbc://@sqldb-prodelasticpool01-srv.database.windows.net/MLDataStore?driver=ODBC+Driver+18+for+SQL+Server\"\n",
|
|
69
|
+
"engine = database_engine(connstr)\n",
|
|
70
|
+
"\n",
|
|
71
|
+
"try:\n",
|
|
72
|
+
" with engine.connect() as connection:\n",
|
|
73
|
+
" print(connection.execute(text(\"SELECT 1\")).scalar_one())\n",
|
|
74
|
+
"finally:\n",
|
|
75
|
+
" engine.dispose()\n"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"cell_type": "code",
|
|
80
|
+
"execution_count": null,
|
|
81
|
+
"id": "7b0115ad",
|
|
82
|
+
"metadata": {},
|
|
83
|
+
"outputs": [],
|
|
84
|
+
"source": []
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"metadata": {
|
|
88
|
+
"kernelspec": {
|
|
89
|
+
"display_name": "smuod-common (3.14.x)",
|
|
90
|
+
"language": "python",
|
|
91
|
+
"name": "python3"
|
|
92
|
+
},
|
|
93
|
+
"language_info": {
|
|
94
|
+
"codemirror_mode": {
|
|
95
|
+
"name": "ipython",
|
|
96
|
+
"version": 3
|
|
97
|
+
},
|
|
98
|
+
"file_extension": ".py",
|
|
99
|
+
"mimetype": "text/x-python",
|
|
100
|
+
"name": "python",
|
|
101
|
+
"nbconvert_exporter": "python",
|
|
102
|
+
"pygments_lexer": "ipython3",
|
|
103
|
+
"version": "3.14.9"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"nbformat": 4,
|
|
107
|
+
"nbformat_minor": 5
|
|
108
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": 1,
|
|
6
|
+
"id": "40e3c8d5",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [
|
|
9
|
+
{
|
|
10
|
+
"name": "stderr",
|
|
11
|
+
"output_type": "stream",
|
|
12
|
+
"text": [
|
|
13
|
+
"2026-10-25 15:16:05.702 | \u001b[32mINFO \u001b[0m | logsetup:configure_logging_console:59 - Logging to console with level: DEBUG\n",
|
|
14
|
+
"2026-10-25 15:16:05.702 | \u001b[32mINFO \u001b[0m | otelsetup:configure_otel:36 - Configuring OTeL, sending signals to the following endpoints:\n",
|
|
15
|
+
"2026-10-25 15:16:05.703 | \u001b[32mINFO \u001b[0m | otelsetup:configure_otel:37 - Logs: localhost:6317 (via gRPC)\n",
|
|
16
|
+
"2026-10-25 15:16:05.703 | \u001b[32mINFO \u001b[0m | otelsetup:configure_otel:38 - Metrics: http://localhost:6318/v1/metrics\n",
|
|
17
|
+
"2026-10-25 15:16:05.703 | \u001b[32mINFO \u001b[0m | otelsetup:configure_otel:39 - Traces: http://localhost:6318/v1/traces\n",
|
|
18
|
+
"2026-10-25 15:16:05.706 | \u001b[32mINFO \u001b[0m | otelsetup:add_otel_handler_to_logger:115 - Logging to OpenTelemetry is configured with log level: DEBUG\n"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "stdout",
|
|
23
|
+
"output_type": "stream",
|
|
24
|
+
"text": [
|
|
25
|
+
"env: AZURE_FOUNDRY_NAME=smuod-foundry-sweden\n",
|
|
26
|
+
"env: PYDANTIC_AI_NO_BANNER=1\n",
|
|
27
|
+
"env: OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:6317\n"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"source": [
|
|
32
|
+
"%env AZURE_FOUNDRY_NAME=smuod-foundry-sweden\n",
|
|
33
|
+
"%env PYDANTIC_AI_NO_BANNER=1\n",
|
|
34
|
+
"%env OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:6317\n",
|
|
35
|
+
"\n",
|
|
36
|
+
"from smuod_common import configure_logging_console, configure_otel\n",
|
|
37
|
+
"\n",
|
|
38
|
+
"configure_logging_console(\"example\")\n",
|
|
39
|
+
"configure_otel()"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"cell_type": "code",
|
|
44
|
+
"execution_count": 2,
|
|
45
|
+
"id": "369d6719",
|
|
46
|
+
"metadata": {},
|
|
47
|
+
"outputs": [
|
|
48
|
+
{
|
|
49
|
+
"data": {
|
|
50
|
+
"text/plain": [
|
|
51
|
+
"'Hello, world! 👋'"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"execution_count": 2,
|
|
55
|
+
"metadata": {},
|
|
56
|
+
"output_type": "execute_result"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"source": [
|
|
60
|
+
"from langchain_core.output_parsers import StrOutputParser\n",
|
|
61
|
+
"\n",
|
|
62
|
+
"from smuod_common.langchain import get_model\n",
|
|
63
|
+
"\n",
|
|
64
|
+
"llm = get_model(\"gpt-6-luna-2026-09-22\")\n",
|
|
65
|
+
"chain = llm | StrOutputParser()\n",
|
|
66
|
+
"chain.invoke(\"Hello, world!\")"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cell_type": "code",
|
|
71
|
+
"execution_count": 5,
|
|
72
|
+
"id": "62f6d7a1",
|
|
73
|
+
"metadata": {},
|
|
74
|
+
"outputs": [
|
|
75
|
+
{
|
|
76
|
+
"data": {
|
|
77
|
+
"text/plain": [
|
|
78
|
+
"'Hello, world! How can I help you today?'"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"execution_count": 5,
|
|
82
|
+
"metadata": {},
|
|
83
|
+
"output_type": "execute_result"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"source": [
|
|
87
|
+
"from langchain_core.output_parsers import StrOutputParser\n",
|
|
88
|
+
"\n",
|
|
89
|
+
"from smuod_common.langchain import get_model\n",
|
|
90
|
+
"\n",
|
|
91
|
+
"llm = get_model(\"grok-4.7\")\n",
|
|
92
|
+
"chain = llm | StrOutputParser()\n",
|
|
93
|
+
"chain.invoke(\"Hello, world!\")"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"cell_type": "code",
|
|
98
|
+
"execution_count": 4,
|
|
99
|
+
"id": "5e8fade8",
|
|
100
|
+
"metadata": {},
|
|
101
|
+
"outputs": [
|
|
102
|
+
{
|
|
103
|
+
"data": {
|
|
104
|
+
"text/plain": [
|
|
105
|
+
"[-0.1756591796875, -0.72705078125, -0.6640625]"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"execution_count": 4,
|
|
109
|
+
"metadata": {},
|
|
110
|
+
"output_type": "execute_result"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"source": [
|
|
114
|
+
"from smuod_common.langchain import get_embedder\n",
|
|
115
|
+
"\n",
|
|
116
|
+
"embedder = get_embedder(\n",
|
|
117
|
+
" \"text-embedding-3-large\",\n",
|
|
118
|
+
" dimensions=3,\n",
|
|
119
|
+
")\n",
|
|
120
|
+
"embedder.embed_query(\"Hello, world!\")"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"cell_type": "code",
|
|
125
|
+
"execution_count": null,
|
|
126
|
+
"id": "27e887fb",
|
|
127
|
+
"metadata": {},
|
|
128
|
+
"outputs": [],
|
|
129
|
+
"source": []
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"metadata": {
|
|
133
|
+
"kernelspec": {
|
|
134
|
+
"display_name": "smuod-common (3.14.x)",
|
|
135
|
+
"language": "python",
|
|
136
|
+
"name": "python3"
|
|
137
|
+
},
|
|
138
|
+
"language_info": {
|
|
139
|
+
"codemirror_mode": {
|
|
140
|
+
"name": "ipython",
|
|
141
|
+
"version": 3
|
|
142
|
+
},
|
|
143
|
+
"file_extension": ".py",
|
|
144
|
+
"mimetype": "text/x-python",
|
|
145
|
+
"name": "python",
|
|
146
|
+
"nbconvert_exporter": "python",
|
|
147
|
+
"pygments_lexer": "ipython3",
|
|
148
|
+
"version": "3.14.9"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"nbformat": 4,
|
|
152
|
+
"nbformat_minor": 5
|
|
153
|
+
}
|