cognite-function-apps 0.14.1__tar.gz → 0.15.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.
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.pre-commit-config.yaml +2 -3
- cognite_function_apps-0.15.0/.release-please-manifest.json +3 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/CHANGELOG.md +18 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/PKG-INFO +2 -1
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/dev-server.md +52 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/pyproject.toml +2 -0
- cognite_function_apps-0.15.0/src/cognite_function_apps/_version.py +1 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/cli.py +28 -1
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/devserver/asgi.py +7 -3
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/devserver/swagger.py +23 -8
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_asgi.py +42 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_cli.py +103 -6
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_swagger.py +62 -6
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/uv.lock +38 -1
- cognite_function_apps-0.14.1/.release-please-manifest.json +0 -3
- cognite_function_apps-0.14.1/src/cognite_function_apps/_version.py +0 -1
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.claude/settings.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.gemini/config.yaml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.gitattributes +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/agents/agentic-workflows.agent.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/aw/actions-lock.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/renovate.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/conventional-pr-title.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/copilot-setup-steps.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/deploy-docs.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/python-package.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/python-publish.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/release-please.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.gitignore +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.nojekyll +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.python-version +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/AGENTS.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/CLAUDE.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/CODEOWNERS +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/LICENSE +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/README.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/RELEASING.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/Terminology.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/adr/response-customization.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/codecov.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/api-reference.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/app-composition.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/architecture.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/async-support.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/contributing.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/dependency-injection.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/error-handling.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/function-client.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/index.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/introspection.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/logging.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/mcp.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/release-process.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/response-customization.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/stylesheets/extra.css +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/tracing.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/type-safety.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs-src/error-handling.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs-src/function-client.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs-src/introspection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs-src/logging.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs-src/tracing.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs-src/type-safety.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/examples/dev.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/examples/handler.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/examples/requirements.txt +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/justfile +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/mkdocs.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/release-please-config.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/_type_utils.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/app.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/base_client.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/client.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/client_generation.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/convert.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/dependency_registry.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/devserver/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/devserver/auth.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/formatting.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/introspection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/logger.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/mcp.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/models.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/py.typed +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/routing.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/schema.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/service.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/templates/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/templates/client_template.jinja2 +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/tracer.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/conftest.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/conftest_pep563.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/conftest_type_checking.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_app.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_async_handlers.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_client_generation.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_convert.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_convert_edge_cases.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_convert_property_based.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_dependency_injection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_error_handling.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_formatting.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_handle_function.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_introspection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_logger.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_mcp.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_models.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_routing.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_schema.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_trace_propagation.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_tracer.py +0 -0
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.15.0](https://github.com/cognitedata/cognite-function-apps/compare/cognite-function-apps-v0.14.1...cognite-function-apps-v0.15.0) (2026-09-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add injectable devserver client ([#226](https://github.com/cognitedata/cognite-function-apps/issues/226)) ([98d0792](https://github.com/cognitedata/cognite-function-apps/commit/98d0792f656c3e55403867bf255ff237a5862394))
|
|
9
|
+
* add VS Code debugger attach mode ([#227](https://github.com/cognitedata/cognite-function-apps/issues/227)) ([85a29c8](https://github.com/cognitedata/cognite-function-apps/commit/85a29c8399ad307924eaf43bcfb539e58f099a95))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* run pyright hook in project environment ([#230](https://github.com/cognitedata/cognite-function-apps/issues/230)) ([1d15bbd](https://github.com/cognitedata/cognite-function-apps/commit/1d15bbd5b38e1ee762a7f37625ccec1e80a49137))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Documentation
|
|
18
|
+
|
|
19
|
+
* add local debugger launch configuration ([#231](https://github.com/cognitedata/cognite-function-apps/issues/231)) ([1bc068f](https://github.com/cognitedata/cognite-function-apps/commit/1bc068f5ce3b66ff6d51611141f216c68ae0f07e))
|
|
20
|
+
|
|
3
21
|
## [0.14.1](https://github.com/cognitedata/cognite-function-apps/compare/cognite-function-apps-v0.14.0...cognite-function-apps-v0.14.1) (2026-09-15)
|
|
4
22
|
|
|
5
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cognite-function-apps
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.15.0
|
|
4
4
|
Summary: FastAPI-style framework for building composable Function Apps for Cognite Functions with automatic OpenAPI schema generation and MCP integration
|
|
5
5
|
Project-URL: Repository, https://github.com/cognitedata/cognite-function-apps
|
|
6
6
|
Project-URL: Changelog, https://github.com/cognitedata/cognite-function-apps/releases
|
|
@@ -10,6 +10,7 @@ Requires-Dist: cognite-sdk>=7.87.0
|
|
|
10
10
|
Requires-Dist: pydantic>=2.10.5
|
|
11
11
|
Requires-Dist: typing-extensions>=4.11.0
|
|
12
12
|
Provides-Extra: cli
|
|
13
|
+
Requires-Dist: debugpy>=1.8.0; extra == 'cli'
|
|
13
14
|
Requires-Dist: pydantic-settings>=2.0.0; extra == 'cli'
|
|
14
15
|
Requires-Dist: typer>=0.9.0; extra == 'cli'
|
|
15
16
|
Requires-Dist: uvicorn>=0.37.0; extra == 'cli'
|
|
@@ -88,10 +88,52 @@ fun serve . --no-reload
|
|
|
88
88
|
# Adjust log level
|
|
89
89
|
fun serve . --log-level debug
|
|
90
90
|
|
|
91
|
+
# Wait for a debugger to attach on 127.0.0.1:5678 (disables auto-reload)
|
|
92
|
+
fun serve . --debugpy
|
|
93
|
+
|
|
94
|
+
# Use a different debugger port
|
|
95
|
+
fun serve . --debugpy --debugpy-port 5679
|
|
96
|
+
|
|
91
97
|
# Combine options
|
|
92
98
|
fun serve . --port 3000 --log-level debug
|
|
93
99
|
```
|
|
94
100
|
|
|
101
|
+
### Attaching a Debugger
|
|
102
|
+
|
|
103
|
+
To start and debug the local server from an IDE that uses `launch.json`, add this launch configuration. It prompts for the Function App directory, opens Swagger UI when Uvicorn is ready, and lets breakpoints in handler code pause execution.
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"version": "0.2.0",
|
|
108
|
+
"configurations": [
|
|
109
|
+
{
|
|
110
|
+
"name": "Debug Function App",
|
|
111
|
+
"type": "debugpy",
|
|
112
|
+
"request": "launch",
|
|
113
|
+
"module": "cognite_function_apps.cli",
|
|
114
|
+
"args": ["serve", "${input:appPath}"],
|
|
115
|
+
"console": "internalConsole",
|
|
116
|
+
"serverReadyAction": {
|
|
117
|
+
"action": "openExternally",
|
|
118
|
+
"pattern": "Uvicorn running on (http://\\S+)",
|
|
119
|
+
"uriFormat": "%s/docs"
|
|
120
|
+
},
|
|
121
|
+
"justMyCode": true
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"inputs": [
|
|
125
|
+
{
|
|
126
|
+
"id": "appPath",
|
|
127
|
+
"type": "promptString",
|
|
128
|
+
"description": "Path to Function App folder or file",
|
|
129
|
+
"default": "."
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Select **Debug Function App** in the IDE, enter the Function App directory, and start debugging.
|
|
136
|
+
|
|
95
137
|
#### Option B: Manual Setup
|
|
96
138
|
|
|
97
139
|
If you prefer more control, create a `dev.py` file next to your handler:
|
|
@@ -249,6 +291,16 @@ fun serve . --log-level debug
|
|
|
249
291
|
fun serve . --no-reload
|
|
250
292
|
```
|
|
251
293
|
|
|
294
|
+
### Supplying a client
|
|
295
|
+
|
|
296
|
+
The dev server warns by default that Swagger calls use real CDF credentials, including the configured project and cluster. When embedding it, provide a client factory instead of replacing internal client creation.
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
from cognite_function_apps.devserver import create_asgi_app
|
|
300
|
+
|
|
301
|
+
app = create_asgi_app(handle, client_factory=create_local_client)
|
|
302
|
+
```
|
|
303
|
+
|
|
252
304
|
### Using uvicorn directly
|
|
253
305
|
|
|
254
306
|
If you're using the manual setup with `dev.py`:
|
|
@@ -22,6 +22,7 @@ Changelog = "https://github.com/cognitedata/cognite-function-apps/releases"
|
|
|
22
22
|
|
|
23
23
|
[project.optional-dependencies]
|
|
24
24
|
cli = [
|
|
25
|
+
"debugpy>=1.8.0",
|
|
25
26
|
"uvicorn>=0.37.0",
|
|
26
27
|
"typer>=0.9.0",
|
|
27
28
|
"pydantic-settings>=2.0.0",
|
|
@@ -51,6 +52,7 @@ dev = [
|
|
|
51
52
|
"pyright>=1.1.410",
|
|
52
53
|
"ruff>=0.14.1",
|
|
53
54
|
"hypothesis>=6.138.15",
|
|
55
|
+
"debugpy>=1.8.0",
|
|
54
56
|
"uvicorn>=0.37.0",
|
|
55
57
|
"pydantic-settings>=2.0.0",
|
|
56
58
|
"httpx>=0.27.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.15.0" # x-release-please-version
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/cli.py
RENAMED
|
@@ -21,6 +21,21 @@ from cognite_function_apps.service import FunctionService
|
|
|
21
21
|
logger = logging.getLogger(__name__)
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
def _wait_for_debugger(port: int) -> None:
|
|
25
|
+
"""Listen for a local debugpy client before starting the server."""
|
|
26
|
+
try:
|
|
27
|
+
import debugpy # noqa: PLC0415, T100
|
|
28
|
+
except ImportError as e:
|
|
29
|
+
msg = "debugpy is not installed; reinstall with: pip install cognite-function-apps[cli]"
|
|
30
|
+
raise RuntimeError(msg) from e
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
debugpy.listen(("127.0.0.1", port)) # noqa: T100
|
|
34
|
+
except Exception as e:
|
|
35
|
+
raise RuntimeError(f"Failed to start debugger listener on 127.0.0.1:{port}: {e}") from e
|
|
36
|
+
debugpy.wait_for_client() # noqa: T100
|
|
37
|
+
|
|
38
|
+
|
|
24
39
|
def _load_handler_from_path(handler_path: Path) -> FunctionService:
|
|
25
40
|
"""Load the handle object from a handler.py file.
|
|
26
41
|
|
|
@@ -321,6 +336,8 @@ app = create_asgi_app(handler_module.handle)
|
|
|
321
336
|
host: Annotated[str, typer.Option(help="Host to bind to")] = "127.0.0.1", # pyright: ignore[reportUnknownMemberType]
|
|
322
337
|
port: Annotated[int, typer.Option(help="Port to bind to")] = 8000, # pyright: ignore[reportUnknownMemberType]
|
|
323
338
|
reload: Annotated[bool, typer.Option(help="Enable auto-reload on code changes")] = True, # pyright: ignore[reportUnknownMemberType]
|
|
339
|
+
debugpy: Annotated[bool, typer.Option(help="Wait for a debugger to attach")] = False, # pyright: ignore[reportUnknownMemberType]
|
|
340
|
+
debugpy_port: Annotated[int, typer.Option(help="Port for debugger attachment")] = 5678, # pyright: ignore[reportUnknownMemberType]
|
|
324
341
|
log_level: Annotated[
|
|
325
342
|
str,
|
|
326
343
|
typer.Option(help="Log level"), # pyright: ignore[reportUnknownMemberType]
|
|
@@ -329,15 +346,25 @@ app = create_asgi_app(handler_module.handle)
|
|
|
329
346
|
"""Start a development server for local testing.
|
|
330
347
|
|
|
331
348
|
This command loads your handler.py file and starts a local development server
|
|
332
|
-
using uvicorn. It automatically detects code changes and reloads the server.
|
|
349
|
+
using uvicorn. It automatically detects code changes and reloads the server unless debugging is enabled.
|
|
333
350
|
|
|
334
351
|
Example:
|
|
335
352
|
fun serve examples/
|
|
336
353
|
fun serve . --port 3000 --log-level debug
|
|
354
|
+
fun serve . --debugpy
|
|
337
355
|
"""
|
|
338
356
|
handler_path = path.resolve()
|
|
339
357
|
_validate_handler_directory(handler_path)
|
|
340
358
|
|
|
359
|
+
if debugpy:
|
|
360
|
+
typer.secho(f"Waiting for debugger attach on 127.0.0.1:{debugpy_port}...", fg=typer.colors.YELLOW)
|
|
361
|
+
try:
|
|
362
|
+
_wait_for_debugger(debugpy_port)
|
|
363
|
+
except RuntimeError as e:
|
|
364
|
+
typer.secho(f"Error: {e}", fg=typer.colors.RED, err=True)
|
|
365
|
+
raise typer.Exit(code=1) from e
|
|
366
|
+
reload = False
|
|
367
|
+
|
|
341
368
|
# Print startup information
|
|
342
369
|
typer.secho(f"\nStarting server at http://{host}:{port}", fg=typer.colors.GREEN, bold=True)
|
|
343
370
|
if reload:
|
|
@@ -167,7 +167,10 @@ def create_synthetic_function_call_info(path: str) -> FunctionCallInfo:
|
|
|
167
167
|
)
|
|
168
168
|
|
|
169
169
|
|
|
170
|
-
def create_asgi_app(
|
|
170
|
+
def create_asgi_app(
|
|
171
|
+
handle: FunctionService,
|
|
172
|
+
client_factory: Callable[[], CogniteClient] | None = None,
|
|
173
|
+
) -> ASGIApp:
|
|
171
174
|
"""Create an ASGI application from a Cognite Functions handle.
|
|
172
175
|
|
|
173
176
|
This adapter automatically includes interactive documentation endpoints:
|
|
@@ -178,7 +181,8 @@ def create_asgi_app(handle: FunctionService) -> ASGIApp:
|
|
|
178
181
|
and are not deployed to production Cognite Functions.
|
|
179
182
|
|
|
180
183
|
Args:
|
|
181
|
-
handle: The FunctionService instance created by create_function_service()
|
|
184
|
+
handle: The FunctionService instance created by create_function_service().
|
|
185
|
+
client_factory: Optional factory for the Cognite client. Defaults to environment-based authentication.
|
|
182
186
|
|
|
183
187
|
Returns:
|
|
184
188
|
ASGI application compatible with uvicorn, hypercorn, etc.
|
|
@@ -197,7 +201,7 @@ def create_asgi_app(handle: FunctionService) -> ASGIApp:
|
|
|
197
201
|
from .swagger import SwaggerMiddleware # noqa: PLC0415
|
|
198
202
|
|
|
199
203
|
# Create Cognite client once at startup
|
|
200
|
-
client = get_cognite_client_from_env()
|
|
204
|
+
client = (client_factory or get_cognite_client_from_env)()
|
|
201
205
|
logger.info("🚀 ASGI app created successfully")
|
|
202
206
|
logger.info("⚡ Using optimized async handle")
|
|
203
207
|
logger.info("📚 Interactive docs available at /docs")
|
|
@@ -5,6 +5,7 @@ Swagger UI and the OpenAPI specification. All other requests are passed
|
|
|
5
5
|
through to the next app in the ASGI middleware chain.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import html
|
|
8
9
|
import json
|
|
9
10
|
from http import HTTPStatus
|
|
10
11
|
|
|
@@ -50,13 +51,27 @@ async def _send_html_response(send: ASGISend, html: str, status: HTTPStatus = HT
|
|
|
50
51
|
)
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
def _create_development_notice(client: CogniteClient) -> str:
|
|
55
|
+
"""Create the default local-development warning."""
|
|
56
|
+
project = html.escape(client.config.project or "unknown")
|
|
57
|
+
cluster = html.escape(client.config.cdf_cluster or "unknown")
|
|
58
|
+
return (
|
|
59
|
+
'<div style="background:#b91c1c;color:#fff;padding:10px 16px;font-family:sans-serif;font-size:14px;">'
|
|
60
|
+
f"Authenticated against CDF project <b>{project}</b> in cluster <b>{cluster}</b> — calling routes below "
|
|
61
|
+
"uses your real, authenticated CDF credentials and may create, update, or delete data in this project.</div>"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async def _serve_swagger_ui(send: ASGISend, client: CogniteClient) -> None:
|
|
54
66
|
"""Serve Swagger UI HTML that loads the OpenAPI spec from /openapi.json.
|
|
55
67
|
|
|
56
68
|
Args:
|
|
57
|
-
send: ASGI send callable
|
|
69
|
+
send: ASGI send callable.
|
|
70
|
+
client: Cognite client used to generate the default notice.
|
|
58
71
|
"""
|
|
59
|
-
|
|
72
|
+
notice = _create_development_notice(client)
|
|
73
|
+
|
|
74
|
+
document = """
|
|
60
75
|
<!DOCTYPE html>
|
|
61
76
|
<html lang="en">
|
|
62
77
|
<head>
|
|
@@ -81,7 +96,7 @@ async def _serve_swagger_ui(send: ASGISend) -> None:
|
|
|
81
96
|
}
|
|
82
97
|
</style>
|
|
83
98
|
</head>
|
|
84
|
-
<body>
|
|
99
|
+
<body>__DEVELOPMENT_NOTICE__
|
|
85
100
|
<div id="swagger-ui"></div>
|
|
86
101
|
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.29.4/swagger-ui-bundle.js"
|
|
87
102
|
integrity="sha384-eGAqzBSdqmAnsjFjrz0Ua2nJFnpAzDMmRg4mr6jwRwzcjSmL9FMmXAhMwX+mTFfs"
|
|
@@ -111,8 +126,8 @@ async def _serve_swagger_ui(send: ASGISend) -> None:
|
|
|
111
126
|
</script>
|
|
112
127
|
</body>
|
|
113
128
|
</html>
|
|
114
|
-
"""
|
|
115
|
-
await _send_html_response(send,
|
|
129
|
+
""".replace("__DEVELOPMENT_NOTICE__", notice)
|
|
130
|
+
await _send_html_response(send, document)
|
|
116
131
|
|
|
117
132
|
|
|
118
133
|
async def _serve_openapi_json(send: ASGISend, handle: FunctionService, client: "CogniteClient") -> None:
|
|
@@ -251,7 +266,7 @@ class SwaggerMiddleware:
|
|
|
251
266
|
Args:
|
|
252
267
|
app: The next ASGI app in the middleware chain
|
|
253
268
|
handle: FunctionService instance for accessing the OpenAPI schema
|
|
254
|
-
client: CogniteClient instance for making API calls
|
|
269
|
+
client: CogniteClient instance for making API calls.
|
|
255
270
|
"""
|
|
256
271
|
self.app = app
|
|
257
272
|
self.handle = handle
|
|
@@ -270,7 +285,7 @@ class SwaggerMiddleware:
|
|
|
270
285
|
|
|
271
286
|
# Intercept documentation endpoints (GET only)
|
|
272
287
|
if path == "/docs":
|
|
273
|
-
await _serve_swagger_ui(send)
|
|
288
|
+
await _serve_swagger_ui(send, self.client)
|
|
274
289
|
return
|
|
275
290
|
elif path == "/openapi.json" and scope["method"] == "GET":
|
|
276
291
|
await _serve_openapi_json(send, self.handle, self.client)
|
|
@@ -330,6 +330,22 @@ class TestCreateAsgiApp:
|
|
|
330
330
|
# Verify the app is callable
|
|
331
331
|
assert callable(asgi_app)
|
|
332
332
|
|
|
333
|
+
def test_create_asgi_app_uses_custom_client_factory(self, monkeypatch: MonkeyPatch) -> None:
|
|
334
|
+
"""Test that a custom client factory replaces environment authentication."""
|
|
335
|
+
mock_client = Mock(spec=CogniteClient)
|
|
336
|
+
factory = Mock(return_value=mock_client)
|
|
337
|
+
monkeypatch.setattr(
|
|
338
|
+
"cognite_function_apps.devserver.asgi.get_cognite_client_from_env",
|
|
339
|
+
Mock(side_effect=AssertionError("environment factory should not be called")),
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
app = FunctionApp(title="Test App", version="1.0.0")
|
|
343
|
+
handle = create_function_service(app)
|
|
344
|
+
|
|
345
|
+
create_asgi_app(handle, client_factory=factory)
|
|
346
|
+
|
|
347
|
+
factory.assert_called_once_with()
|
|
348
|
+
|
|
333
349
|
@pytest.mark.asyncio
|
|
334
350
|
async def test_options_request_cors_preflight(self, monkeypatch: MonkeyPatch) -> None:
|
|
335
351
|
"""Test that OPTIONS requests return proper CORS headers."""
|
|
@@ -475,6 +491,32 @@ class TestAsgiIntegration:
|
|
|
475
491
|
assert body["response"]["statusCode"] < 400
|
|
476
492
|
assert body["response"]["data"]["id"] == 123
|
|
477
493
|
|
|
494
|
+
@pytest.mark.asyncio
|
|
495
|
+
async def test_root_route_passes_through_swagger_middleware(self) -> None:
|
|
496
|
+
"""Test that an application-defined root route remains reachable."""
|
|
497
|
+
mock_client = Mock(spec=CogniteClient)
|
|
498
|
+
app = FunctionApp(title="Test App", version="1.0.0")
|
|
499
|
+
|
|
500
|
+
@app.get("/")
|
|
501
|
+
def root(client: CogniteClient) -> dict[str, str]:
|
|
502
|
+
return {"message": "root route"}
|
|
503
|
+
|
|
504
|
+
asgi_app = create_asgi_app(create_function_service(app), client_factory=lambda: mock_client)
|
|
505
|
+
messages: list[ASGIHttpResponseStartMessage | ASGIHttpResponseBodyMessage] = []
|
|
506
|
+
|
|
507
|
+
async def send(message: ASGIHttpResponseStartMessage | ASGIHttpResponseBodyMessage) -> None:
|
|
508
|
+
messages.append(message)
|
|
509
|
+
|
|
510
|
+
async def receive() -> ASGIHttpRequestMessage:
|
|
511
|
+
return ASGIHttpRequestMessage(type="http.request", body=b"", more_body=False)
|
|
512
|
+
|
|
513
|
+
await asgi_app(_create_http_scope("/"), receive, send)
|
|
514
|
+
|
|
515
|
+
response = messages[-1]
|
|
516
|
+
assert response["type"] == "http.response.body"
|
|
517
|
+
body = json.loads(response["body"])
|
|
518
|
+
assert body["response"]["data"] == {"message": "root route"}
|
|
519
|
+
|
|
478
520
|
@pytest.mark.asyncio
|
|
479
521
|
async def test_post_request_integration(self, monkeypatch: MonkeyPatch) -> None:
|
|
480
522
|
"""Test a complete POST request through the ASGI app."""
|
|
@@ -2,26 +2,123 @@
|
|
|
2
2
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
import sys
|
|
5
|
+
from collections.abc import Callable
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import Any, cast
|
|
7
|
-
from unittest.mock import Mock
|
|
8
|
+
from unittest.mock import Mock, patch
|
|
8
9
|
|
|
9
10
|
import pytest
|
|
10
11
|
import typer
|
|
11
12
|
from cognite.client import CogniteClient
|
|
12
13
|
|
|
13
|
-
from cognite_function_apps
|
|
14
|
+
from cognite_function_apps import cli
|
|
15
|
+
from cognite_function_apps.cli import _load_handler_from_path, _wait_for_debugger # pyright: ignore[reportPrivateUsage]
|
|
14
16
|
from cognite_function_apps.service import FunctionService
|
|
15
17
|
|
|
16
18
|
|
|
19
|
+
def test_wait_for_debugger_listens_on_loopback(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
20
|
+
"""The debugger accepts local connections before startup."""
|
|
21
|
+
debugpy = Mock()
|
|
22
|
+
monkeypatch.setitem(sys.modules, "debugpy", debugpy)
|
|
23
|
+
|
|
24
|
+
_wait_for_debugger(1234)
|
|
25
|
+
|
|
26
|
+
debugpy.listen.assert_called_once_with(("127.0.0.1", 1234))
|
|
27
|
+
debugpy.wait_for_client.assert_called_once_with()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_wait_for_debugger_reports_missing_dependency(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
31
|
+
"""The debugger reports when debugpy is unavailable."""
|
|
32
|
+
monkeypatch.setitem(sys.modules, "debugpy", None)
|
|
33
|
+
|
|
34
|
+
with pytest.raises(RuntimeError, match="debugpy is not installed"):
|
|
35
|
+
_wait_for_debugger(5678)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_wait_for_debugger_reports_listener_failure(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
39
|
+
"""The debugger reports listener setup failures clearly."""
|
|
40
|
+
debugpy = Mock()
|
|
41
|
+
debugpy.listen.side_effect = OSError("Address already in use")
|
|
42
|
+
monkeypatch.setitem(sys.modules, "debugpy", debugpy)
|
|
43
|
+
|
|
44
|
+
with pytest.raises(RuntimeError, match=r"Failed to start debugger listener on 127\.0\.0\.1:5678"):
|
|
45
|
+
_wait_for_debugger(5678)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_debugpy_disables_reload(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
49
|
+
"""Debugger attachment uses Uvicorn's stable single-process mode."""
|
|
50
|
+
handler_path = tmp_path / "function_app"
|
|
51
|
+
handler_path.mkdir()
|
|
52
|
+
(handler_path / "handler.py").write_text("")
|
|
53
|
+
command = Mock()
|
|
54
|
+
|
|
55
|
+
def register_command(func: Callable[..., None]) -> Callable[..., None]:
|
|
56
|
+
command.callback = func
|
|
57
|
+
return func
|
|
58
|
+
|
|
59
|
+
def register_callback(func: Callable[..., None]) -> Callable[..., None]:
|
|
60
|
+
return func
|
|
61
|
+
|
|
62
|
+
typer_module = Mock()
|
|
63
|
+
typer_module.Typer.return_value.command.return_value = register_command
|
|
64
|
+
typer_module.Typer.return_value.callback.return_value = register_callback
|
|
65
|
+
typer_module.colors.YELLOW = "yellow"
|
|
66
|
+
monkeypatch.setitem(sys.modules, "typer", typer_module)
|
|
67
|
+
monkeypatch.setitem(sys.modules, "uvicorn", Mock())
|
|
68
|
+
monkeypatch.setattr("cognite_function_apps.devserver.create_asgi_app", Mock())
|
|
69
|
+
|
|
70
|
+
with (
|
|
71
|
+
patch.object(cli, "_wait_for_debugger"),
|
|
72
|
+
patch.object(cli, "_load_handler_from_path", return_value=Mock()),
|
|
73
|
+
patch("uvicorn.run") as uvicorn_run,
|
|
74
|
+
):
|
|
75
|
+
cli.main()
|
|
76
|
+
command.callback(handler_path, debugpy=True)
|
|
77
|
+
|
|
78
|
+
uvicorn_run.assert_called_once()
|
|
79
|
+
assert uvicorn_run.call_args.kwargs["reload"] is False
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_debugpy_reports_startup_failure(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
83
|
+
"""Debugger startup failures exit cleanly before loading the handler."""
|
|
84
|
+
handler_path = tmp_path / "function_app"
|
|
85
|
+
handler_path.mkdir()
|
|
86
|
+
command = Mock()
|
|
87
|
+
|
|
88
|
+
def register_command(func: Callable[..., None]) -> Callable[..., None]:
|
|
89
|
+
command.callback = func
|
|
90
|
+
return func
|
|
91
|
+
|
|
92
|
+
def register_callback(func: Callable[..., None]) -> Callable[..., None]:
|
|
93
|
+
return func
|
|
94
|
+
|
|
95
|
+
typer_module = Mock()
|
|
96
|
+
typer_module.Typer.return_value.command.return_value = register_command
|
|
97
|
+
typer_module.Typer.return_value.callback.return_value = register_callback
|
|
98
|
+
typer_module.colors.YELLOW = "yellow"
|
|
99
|
+
typer_module.colors.RED = "red"
|
|
100
|
+
typer_module.Exit = typer.Exit
|
|
101
|
+
monkeypatch.setitem(sys.modules, "typer", typer_module)
|
|
102
|
+
monkeypatch.setitem(sys.modules, "uvicorn", Mock())
|
|
103
|
+
monkeypatch.setattr("cognite_function_apps.devserver.create_asgi_app", Mock())
|
|
104
|
+
|
|
105
|
+
with patch.object(cli, "_wait_for_debugger", side_effect=RuntimeError("Address already in use")):
|
|
106
|
+
cli.main()
|
|
107
|
+
with pytest.raises(typer.Exit) as exc_info:
|
|
108
|
+
command.callback(handler_path, debugpy=True)
|
|
109
|
+
|
|
110
|
+
assert exc_info.value.exit_code == 1
|
|
111
|
+
|
|
112
|
+
|
|
17
113
|
def test_cli_extra_declares_pydantic_settings() -> None:
|
|
18
114
|
"""The cli extra must install pydantic-settings; AuthConfig imports it at load time."""
|
|
19
115
|
requirements = importlib.metadata.requires("cognite-function-apps")
|
|
20
116
|
assert requirements is not None
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
117
|
+
for dependency in ("debugpy", "pydantic-settings"):
|
|
118
|
+
assert any(
|
|
119
|
+
requirement.startswith(dependency) and "extra ==" in requirement and "cli" in requirement
|
|
120
|
+
for requirement in requirements
|
|
121
|
+
), requirements
|
|
25
122
|
|
|
26
123
|
|
|
27
124
|
class TestCLIHandlerLoading:
|
|
@@ -10,11 +10,16 @@ import pytest
|
|
|
10
10
|
from cognite.client import CogniteClient
|
|
11
11
|
|
|
12
12
|
from cognite_function_apps import FunctionApp, create_function_service
|
|
13
|
-
from cognite_function_apps.devserver.asgi import
|
|
13
|
+
from cognite_function_apps.devserver.asgi import (
|
|
14
|
+
ASGIHttpResponseBodyMessage,
|
|
15
|
+
ASGIHttpResponseStartMessage,
|
|
16
|
+
ASGIHttpScope,
|
|
17
|
+
)
|
|
14
18
|
|
|
15
19
|
# Import private functions for testing
|
|
16
20
|
from cognite_function_apps.devserver.swagger import (
|
|
17
21
|
SwaggerMiddleware,
|
|
22
|
+
_create_development_notice,
|
|
18
23
|
_send_html_response,
|
|
19
24
|
_send_json_response,
|
|
20
25
|
_serve_openapi_json,
|
|
@@ -70,6 +75,7 @@ class TestSwaggerHelperFunctions:
|
|
|
70
75
|
assert start["type"] == "http.response.start"
|
|
71
76
|
assert start["status"] == HTTPStatus.OK
|
|
72
77
|
assert (b"content-type", b"text/html; charset=utf-8") in start["headers"]
|
|
78
|
+
assert (b"content-length", str(len(html_content.encode("utf-8"))).encode("utf-8")) in start["headers"]
|
|
73
79
|
assert (b"access-control-allow-origin", b"*") in start["headers"]
|
|
74
80
|
|
|
75
81
|
# Check body message
|
|
@@ -142,23 +148,73 @@ class TestSwaggerUIServing:
|
|
|
142
148
|
|
|
143
149
|
@pytest.mark.asyncio
|
|
144
150
|
async def test_serve_swagger_ui(self) -> None:
|
|
145
|
-
"""Test serving Swagger UI
|
|
146
|
-
|
|
151
|
+
"""Test serving Swagger UI with the default credential warning."""
|
|
152
|
+
client = Mock(spec=CogniteClient)
|
|
153
|
+
client.config.project = "project"
|
|
154
|
+
client.config.cdf_cluster = "cluster"
|
|
155
|
+
messages: list[ASGIHttpResponseStartMessage | ASGIHttpResponseBodyMessage] = []
|
|
147
156
|
|
|
148
|
-
async def mock_send(message:
|
|
157
|
+
async def mock_send(message: ASGIHttpResponseStartMessage | ASGIHttpResponseBodyMessage) -> None:
|
|
149
158
|
messages.append(message)
|
|
150
159
|
|
|
151
|
-
await _serve_swagger_ui(mock_send)
|
|
160
|
+
await _serve_swagger_ui(mock_send, client)
|
|
152
161
|
|
|
153
162
|
# Should send HTML response
|
|
154
163
|
assert len(messages) == 2
|
|
155
164
|
|
|
156
165
|
# Check body contains Swagger UI components
|
|
157
|
-
|
|
166
|
+
response = messages[1]
|
|
167
|
+
assert response["type"] == "http.response.body"
|
|
168
|
+
body = response["body"].decode("utf-8")
|
|
158
169
|
assert "swagger-ui" in body
|
|
159
170
|
assert "SwaggerUIBundle" in body
|
|
160
171
|
assert "/openapi.json" in body
|
|
161
172
|
assert "<!DOCTYPE html>" in body
|
|
173
|
+
assert "Authenticated against CDF project <b>project</b> in cluster <b>cluster</b>" in body
|
|
174
|
+
|
|
175
|
+
def test_create_development_notice_escapes_client_configuration(self) -> None:
|
|
176
|
+
"""Test the default notice includes escaped project and cluster values."""
|
|
177
|
+
client = Mock(spec=CogniteClient)
|
|
178
|
+
client.config.project = "project<script>"
|
|
179
|
+
client.config.cdf_cluster = "cluster<script>"
|
|
180
|
+
|
|
181
|
+
notice = _create_development_notice(client)
|
|
182
|
+
|
|
183
|
+
assert "project<script>" in notice
|
|
184
|
+
assert "cluster<script>" in notice
|
|
185
|
+
assert "<script>" not in notice
|
|
186
|
+
|
|
187
|
+
def test_create_development_notice_uses_unknown_for_missing_configuration(self) -> None:
|
|
188
|
+
"""Test the default notice handles incomplete client configuration."""
|
|
189
|
+
client = Mock(spec=CogniteClient)
|
|
190
|
+
client.config.project = None
|
|
191
|
+
client.config.cdf_cluster = None
|
|
192
|
+
|
|
193
|
+
notice = _create_development_notice(client)
|
|
194
|
+
|
|
195
|
+
assert "<b>unknown</b>" in notice
|
|
196
|
+
|
|
197
|
+
@pytest.mark.asyncio
|
|
198
|
+
async def test_serve_swagger_ui_escapes_configuration_and_sets_content_length(self) -> None:
|
|
199
|
+
"""Test that the default notice is escaped with byte-accurate length."""
|
|
200
|
+
client = Mock(spec=CogniteClient)
|
|
201
|
+
client.config.project = 'project<script>alert("x")</script>'
|
|
202
|
+
client.config.cdf_cluster = "cluster"
|
|
203
|
+
messages: list[ASGIHttpResponseStartMessage | ASGIHttpResponseBodyMessage] = []
|
|
204
|
+
|
|
205
|
+
async def mock_send(message: ASGIHttpResponseStartMessage | ASGIHttpResponseBodyMessage) -> None:
|
|
206
|
+
messages.append(message)
|
|
207
|
+
|
|
208
|
+
await _serve_swagger_ui(mock_send, client)
|
|
209
|
+
|
|
210
|
+
response = messages[1]
|
|
211
|
+
assert response["type"] == "http.response.body"
|
|
212
|
+
body = response["body"]
|
|
213
|
+
assert b'<script>alert("x")</script>' not in body
|
|
214
|
+
assert b"<script>alert("x")</script>" in body
|
|
215
|
+
headers = messages[0]
|
|
216
|
+
assert headers["type"] == "http.response.start"
|
|
217
|
+
assert dict(headers["headers"])[b"content-length"] == str(len(body)).encode("utf-8")
|
|
162
218
|
|
|
163
219
|
|
|
164
220
|
class TestOpenAPIJSONServing:
|
|
@@ -329,6 +329,7 @@ dependencies = [
|
|
|
329
329
|
|
|
330
330
|
[package.optional-dependencies]
|
|
331
331
|
cli = [
|
|
332
|
+
{ name = "debugpy" },
|
|
332
333
|
{ name = "pydantic-settings" },
|
|
333
334
|
{ name = "typer" },
|
|
334
335
|
{ name = "uvicorn" },
|
|
@@ -345,6 +346,7 @@ client = [
|
|
|
345
346
|
{ name = "jinja2" },
|
|
346
347
|
]
|
|
347
348
|
dev = [
|
|
349
|
+
{ name = "debugpy" },
|
|
348
350
|
{ name = "httpx" },
|
|
349
351
|
{ name = "hypothesis" },
|
|
350
352
|
{ name = "jinja2" },
|
|
@@ -372,6 +374,7 @@ dev = [
|
|
|
372
374
|
[package.metadata]
|
|
373
375
|
requires-dist = [
|
|
374
376
|
{ name = "cognite-sdk", specifier = ">=7.87.0" },
|
|
377
|
+
{ name = "debugpy", marker = "extra == 'cli'", specifier = ">=1.8.0" },
|
|
375
378
|
{ name = "opentelemetry-api", marker = "extra == 'tracing'", specifier = ">=1.20.0" },
|
|
376
379
|
{ name = "opentelemetry-exporter-otlp", marker = "extra == 'tracing'", specifier = ">=1.20.0" },
|
|
377
380
|
{ name = "opentelemetry-sdk", marker = "extra == 'tracing'", specifier = ">=1.20.0" },
|
|
@@ -389,6 +392,7 @@ client = [
|
|
|
389
392
|
{ name = "jinja2", specifier = ">=3.0.0" },
|
|
390
393
|
]
|
|
391
394
|
dev = [
|
|
395
|
+
{ name = "debugpy", specifier = ">=1.8.0" },
|
|
392
396
|
{ name = "httpx", specifier = ">=0.27.0" },
|
|
393
397
|
{ name = "hypothesis", specifier = ">=6.138.15" },
|
|
394
398
|
{ name = "jinja2", specifier = ">=3.0.0" },
|
|
@@ -614,6 +618,39 @@ wheels = [
|
|
|
614
618
|
{ url = "https://files.pythonhosted.org/packages/8e/b5/c2c5fce26f0ee40d21bafe7f191d29a34b35a65ac4fe8a1191d1983612e9/cryptography-50.0.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:c99c003e088647b8a5b7c145d6f78c335f6348332b62e142d411c4b63d1460b9", size = 3813796, upload-time = "2026-07-31T14:25:02.298Z" },
|
|
615
619
|
]
|
|
616
620
|
|
|
621
|
+
[[package]]
|
|
622
|
+
name = "debugpy"
|
|
623
|
+
version = "1.8.22"
|
|
624
|
+
source = { registry = "https://pypi.org/simple" }
|
|
625
|
+
sdist = { url = "https://files.pythonhosted.org/packages/44/9d/3cb6693342acf96802dba89934a5b8da43c201d764ebd1f2c0514a3d42bd/debugpy-1.8.22.tar.gz", hash = "sha256:e489c7268e1c7b41e13b438d9c533d2a7af73fb59bf8cd30fead8286c1c39c4e", size = 1710877, upload-time = "2026-09-15T21:44:02.578Z" }
|
|
626
|
+
wheels = [
|
|
627
|
+
{ url = "https://files.pythonhosted.org/packages/1a/e9/ced401ba1088e1d2b3228dbbcae33e15aa8c08a1368433bedebfa8efcb02/debugpy-1.8.22-cp310-cp310-macosx_15_0_x86_64.whl", hash = "sha256:fa47099176d1d612bef69e9f74658a5687a9f05bd80fb5710f99959bace85735", size = 2128369, upload-time = "2026-09-15T21:44:04.775Z" },
|
|
628
|
+
{ url = "https://files.pythonhosted.org/packages/4f/97/5c8e839a7f73e92cd4a733408bb85bb764e829e52a9fb097f99d6e2cbbc0/debugpy-1.8.22-cp310-cp310-manylinux_2_34_x86_64.whl", hash = "sha256:7bf29e0d8ce80b100d37fb333e1b193b790d962739f3067796c2b03ffdc9afee", size = 3022081, upload-time = "2026-09-15T21:44:06.382Z" },
|
|
629
|
+
{ url = "https://files.pythonhosted.org/packages/11/ed/fbb045d18a8b733a798bb834a03a20cd64f1446206d844b674bb638da6c3/debugpy-1.8.22-cp310-cp310-win32.whl", hash = "sha256:56b877b37ed73f0bf53ba7afc394816ff1eb5d701bae24a24ed9e1ea6f7ce34f", size = 5325298, upload-time = "2026-09-15T21:44:08.267Z" },
|
|
630
|
+
{ url = "https://files.pythonhosted.org/packages/82/7f/633160132b80b424c6816391f239682435c6b77cdd58288d04b3443b9f80/debugpy-1.8.22-cp310-cp310-win_amd64.whl", hash = "sha256:1bd0c6df3c68c0a3f71db8baa3780a953abb65537ec4b3bc6b935ad5b3b3d45c", size = 5353598, upload-time = "2026-09-15T21:44:10.125Z" },
|
|
631
|
+
{ url = "https://files.pythonhosted.org/packages/26/4a/8c24c588088c622df6dacdc0110e9cc81b44781fe7a408113441e76aa955/debugpy-1.8.22-cp311-cp311-macosx_15_0_universal2.whl", hash = "sha256:66e4ac3d6e7026e83e7d93d7ee2f51dd4a4e8dff673578d424e60796893e5b2c", size = 2217799, upload-time = "2026-09-15T21:44:11.57Z" },
|
|
632
|
+
{ url = "https://files.pythonhosted.org/packages/c7/14/1c9ff33eba51da70a8dfe2277cc13153bb3ffec79282b9acfcdbe1641d30/debugpy-1.8.22-cp311-cp311-manylinux_2_34_x86_64.whl", hash = "sha256:192b73e8d53bbd60225220c0943627bf249ac93d0ea3090e23c45f3e0ceb6a35", size = 3074375, upload-time = "2026-09-15T21:44:13.349Z" },
|
|
633
|
+
{ url = "https://files.pythonhosted.org/packages/10/e8/1fa16a94af7d8b86c3ca336d7d32b78cb2c475266d0bb889732d2bc50310/debugpy-1.8.22-cp311-cp311-win32.whl", hash = "sha256:745e1800ec2961e5660c1a317c0a20e28c0fef4de36c04f17a21c33f2b37a92a", size = 5258392, upload-time = "2026-09-15T21:44:15.182Z" },
|
|
634
|
+
{ url = "https://files.pythonhosted.org/packages/32/1a/c086b883a4561017bfdd83c1bc70bf2b05ab6540ff767dedf207cadab938/debugpy-1.8.22-cp311-cp311-win_amd64.whl", hash = "sha256:1e76339d5510bc17e9181dba9577508afcb21aad5728f1a55ef74d7d97d255f3", size = 5277955, upload-time = "2026-09-15T21:44:16.986Z" },
|
|
635
|
+
{ url = "https://files.pythonhosted.org/packages/73/21/5c7f5c66eaeee57c9dadb0bbff22efddc8d99cdbd3d036c806175f1828cc/debugpy-1.8.22-cp312-cp312-macosx_15_0_universal2.whl", hash = "sha256:4ad076f4f66cb8acb79e4384d48b1ea60a0b1957aa0b1112d4887ea3a4df60e0", size = 2499375, upload-time = "2026-09-15T21:44:18.478Z" },
|
|
636
|
+
{ url = "https://files.pythonhosted.org/packages/7e/ec/7389798843643ea5bc6a08480ba1b855377c70e2ed90189c0a03594e401e/debugpy-1.8.22-cp312-cp312-manylinux_2_34_x86_64.whl", hash = "sha256:8a697acec45dbc70d17fb5d9f4f61989fc294d273c69de487fd10cb35fdd75eb", size = 4000941, upload-time = "2026-09-15T21:44:20.245Z" },
|
|
637
|
+
{ url = "https://files.pythonhosted.org/packages/20/f4/64ce7a2499550929e08654360b270409eeda3e321b7c27027d9c919aa36b/debugpy-1.8.22-cp312-cp312-win32.whl", hash = "sha256:12bc7f368182b517cf26c76a2393fff65354e365fa1552b6241e66edff17997b", size = 5359040, upload-time = "2026-09-15T21:44:22.218Z" },
|
|
638
|
+
{ url = "https://files.pythonhosted.org/packages/4b/fe/e7d3b72874cdd327bda295d1995a01e426857ae9cbaaba74fd997bc3afbc/debugpy-1.8.22-cp312-cp312-win_amd64.whl", hash = "sha256:371a4ba4a5975eb958393903f3254cf983da7b1c7c178b3f987ee427f42515e3", size = 5398304, upload-time = "2026-09-15T21:44:24.119Z" },
|
|
639
|
+
{ url = "https://files.pythonhosted.org/packages/6b/f4/fee6d40f5865aa84e1100c9df1a0f2cf8991776b61f11f433ff277df4415/debugpy-1.8.22-cp313-cp313-macosx_15_0_universal2.whl", hash = "sha256:c21dd7e1ec22556bb41dc3bf6b86c603e440ec889c4acb27d7206354b2106c54", size = 2493531, upload-time = "2026-09-15T21:44:25.835Z" },
|
|
640
|
+
{ url = "https://files.pythonhosted.org/packages/bc/4f/8df91270afbf61fc5ab202951f28451194a7eb093704b26da11cb0ecd308/debugpy-1.8.22-cp313-cp313-manylinux_2_34_x86_64.whl", hash = "sha256:c1ffb9953708b648ecf6acd2e5ad2c002bf68785ed618197dd4463a2a7226f39", size = 3994351, upload-time = "2026-09-15T21:44:27.31Z" },
|
|
641
|
+
{ url = "https://files.pythonhosted.org/packages/4f/11/2e34a4f21d6155b0c58003fd6fca9819df7d6fe7d7acd83b146b648a57ee/debugpy-1.8.22-cp313-cp313-win32.whl", hash = "sha256:ba810a66b437e3c43ca0ce0892404f010338286263ca8e5108442d76a9485337", size = 5359071, upload-time = "2026-09-15T21:44:29.064Z" },
|
|
642
|
+
{ url = "https://files.pythonhosted.org/packages/d0/f5/c2b3e8260388d7b76bc4e5a3a29648a0ca47dca6a2721d6549ff2d944eee/debugpy-1.8.22-cp313-cp313-win_amd64.whl", hash = "sha256:f49b1d6cecf326b63c06d7f517e4a6642777f758c58cb799e7bc5a6dd74721c2", size = 5400362, upload-time = "2026-09-15T21:44:30.857Z" },
|
|
643
|
+
{ url = "https://files.pythonhosted.org/packages/ea/95/d97240bb68b86db8d0a07602be068aae9e50f17063d696a4c6f619975311/debugpy-1.8.22-cp314-cp314-macosx_15_0_universal2.whl", hash = "sha256:e6744ac1850c73c2ba7b29a126cf9ab74efd1831190720e8fee17ef5389c8f5d", size = 2493148, upload-time = "2026-09-15T21:44:32.518Z" },
|
|
644
|
+
{ url = "https://files.pythonhosted.org/packages/70/9e/994fe1fb23dd4a5a8d059a0dc95da4b0821907200a61c2d5a4fdc21b6cf8/debugpy-1.8.22-cp314-cp314-manylinux_2_34_x86_64.whl", hash = "sha256:0c1104233340196e5cbf5514e7dfdbb98968e730cfd7fdd6f3d72a082be838a9", size = 3961025, upload-time = "2026-09-15T21:44:34.387Z" },
|
|
645
|
+
{ url = "https://files.pythonhosted.org/packages/37/e0/66319918883cf6dd6dea3805210c3cafd9e65dfaa6f8b852482cff10a026/debugpy-1.8.22-cp314-cp314-win32.whl", hash = "sha256:feea785c7bbeb8cfd5b01a63f9061c899dc468c8be81671141a29305774fa294", size = 5359408, upload-time = "2026-09-15T21:44:36.128Z" },
|
|
646
|
+
{ url = "https://files.pythonhosted.org/packages/94/53/5b4d91f7fffb9393ac907133201d1da0c070d57e463ee8e2ec1db3cb63b6/debugpy-1.8.22-cp314-cp314-win_amd64.whl", hash = "sha256:d593a330297332ec435f3965c448b6d500e03f33675cf2063178bc76377a788e", size = 5397429, upload-time = "2026-09-15T21:44:38.429Z" },
|
|
647
|
+
{ url = "https://files.pythonhosted.org/packages/24/71/580df4aed96c9b23c9cbb049907d8ac1347050afdb8f450df20649d51578/debugpy-1.8.22-cp315-cp315-macosx_15_0_universal2.whl", hash = "sha256:a9eca6ab09a61534e923064400081e016f7e1d8430cc6e8b7a9cecd2f59e2b07", size = 2493380, upload-time = "2026-09-15T21:44:40.074Z" },
|
|
648
|
+
{ url = "https://files.pythonhosted.org/packages/b0/10/a323945b0966e560c40fe48470d2847bfc7692a8f550d7086e9a28f5b623/debugpy-1.8.22-cp315-cp315-manylinux_2_34_x86_64.whl", hash = "sha256:b7dbde1fb822d100802d505b2aed6d0813b1a0a2015d495cb8798b2215d5d1e5", size = 3975456, upload-time = "2026-09-15T21:44:41.623Z" },
|
|
649
|
+
{ url = "https://files.pythonhosted.org/packages/ef/f9/4383635281999c3eaa44bf327de523ba42240b35eb87c1130adac4a829c6/debugpy-1.8.22-cp315-cp315-win32.whl", hash = "sha256:225d063f81708c2546999e7edfac0198b2d5c2f144797dc64858f867948633e0", size = 5359469, upload-time = "2026-09-15T21:44:43.234Z" },
|
|
650
|
+
{ url = "https://files.pythonhosted.org/packages/7b/14/4fe9f46a9c825c8cbc6dc4aebc2a885b0bceb37ce2a37699c170482e7a40/debugpy-1.8.22-cp315-cp315-win_amd64.whl", hash = "sha256:b17a4896520f1c6da09ce76ec8215df0b85b0b6f3617526a4c65c2315340875a", size = 5397869, upload-time = "2026-09-15T21:44:44.783Z" },
|
|
651
|
+
{ url = "https://files.pythonhosted.org/packages/56/3d/c7dc9f35bc9e22cdb53679f844bee40fd5cff871862f60595869a433400d/debugpy-1.8.22-py2.py3-none-any.whl", hash = "sha256:a9e9d3550e15ca479c59333e90845029190531f0cacfedab3b815a57bd913947", size = 5374857, upload-time = "2026-09-15T21:44:54.454Z" },
|
|
652
|
+
]
|
|
653
|
+
|
|
617
654
|
[[package]]
|
|
618
655
|
name = "distlib"
|
|
619
656
|
version = "0.4.0"
|
|
@@ -628,7 +665,7 @@ name = "exceptiongroup"
|
|
|
628
665
|
version = "1.3.1"
|
|
629
666
|
source = { registry = "https://pypi.org/simple" }
|
|
630
667
|
dependencies = [
|
|
631
|
-
{ name = "typing-extensions" },
|
|
668
|
+
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
|
632
669
|
]
|
|
633
670
|
sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" }
|
|
634
671
|
wheels = [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.14.1" # x-release-please-version
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/deploy-docs.yml
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/python-package.yml
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/python-publish.yml
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/.github/workflows/release-please.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/docs/response-customization.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/app.py
RENAMED
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/client.py
RENAMED
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/convert.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/logger.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/mcp.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/models.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/py.typed
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/routing.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/schema.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/src/cognite_function_apps/tracer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/conftest_type_checking.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_client_generation.py
RENAMED
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_convert_edge_cases.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_convert_property_based.py
RENAMED
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_dependency_injection.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.15.0}/tests/test_trace_propagation.py
RENAMED
|
File without changes
|
|
File without changes
|