cognite-function-apps 0.14.1__tar.gz → 0.16.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.16.0}/.pre-commit-config.yaml +2 -3
- cognite_function_apps-0.16.0/.release-please-manifest.json +3 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/CHANGELOG.md +43 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/PKG-INFO +2 -1
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/api-reference.md +7 -0
- cognite_function_apps-0.16.0/docs/deployment.md +160 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/dev-server.md +50 -17
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/mkdocs.yml +1 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/pyproject.toml +2 -0
- cognite_function_apps-0.16.0/src/cognite_function_apps/_version.py +1 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/app.py +6 -2
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/cli.py +14 -2
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/convert.py +7 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/__init__.py +2 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/asgi.py +7 -3
- cognite_function_apps-0.16.0/src/cognite_function_apps/devserver/debug.py +26 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/swagger.py +23 -8
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/routing.py +5 -2
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/schema.py +8 -2
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/tracer.py +171 -35
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_asgi.py +42 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_cli.py +85 -5
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_convert.py +27 -0
- cognite_function_apps-0.16.0/tests/test_debug.py +45 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_handle_function.py +64 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_routing.py +24 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_schema.py +75 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_swagger.py +62 -6
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_tracer.py +239 -10
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/uv.lock +177 -78
- 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.16.0}/.claude/settings.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.gemini/config.yaml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.gitattributes +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/agents/agentic-workflows.agent.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/aw/actions-lock.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/renovate.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/workflows/conventional-pr-title.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/workflows/copilot-setup-steps.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/workflows/deploy-docs.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/workflows/python-package.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/workflows/python-publish.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.github/workflows/release-please.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.gitignore +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.nojekyll +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/.python-version +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/AGENTS.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/CLAUDE.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/CODEOWNERS +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/LICENSE +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/README.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/RELEASING.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/Terminology.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/adr/response-customization.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/codecov.yml +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/app-composition.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/architecture.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/async-support.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/contributing.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/dependency-injection.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/error-handling.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/function-client.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/index.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/introspection.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/logging.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/mcp.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/release-process.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/response-customization.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/stylesheets/extra.css +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/tracing.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs/type-safety.md +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs-src/error-handling.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs-src/function-client.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs-src/introspection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs-src/logging.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs-src/tracing.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/docs-src/type-safety.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/examples/dev.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/examples/handler.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/examples/requirements.txt +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/justfile +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/release-please-config.json +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/_type_utils.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/base_client.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/client.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/client_generation.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/dependency_registry.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/auth.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/formatting.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/introspection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/logger.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/mcp.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/models.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/py.typed +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/service.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/templates/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/templates/client_template.jinja2 +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/__init__.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/conftest.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/conftest_pep563.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/conftest_type_checking.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_app.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_async_handlers.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_client_generation.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_convert_edge_cases.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_convert_property_based.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_dependency_injection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_error_handling.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_formatting.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_introspection.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_logger.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_mcp.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_models.py +0 -0
- {cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/tests/test_trace_propagation.py +0 -0
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.16.0](https://github.com/cognitedata/cognite-function-apps/compare/cognite-function-apps-v0.15.0...cognite-function-apps-v0.16.0) (2026-11-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* expose debugpy setup for embedded servers ([#233](https://github.com/cognitedata/cognite-function-apps/issues/233)) ([84023c5](https://github.com/cognitedata/cognite-function-apps/commit/84023c569c71494749529d7b1a5462b4211683c6))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* generate array schema for Sequence[T] return types in OpenAPI response ([#211](https://github.com/cognitedata/cognite-function-apps/issues/211)) ([9fed26a](https://github.com/cognitedata/cognite-function-apps/commit/9fed26aa34e2e7edf709f50c90046d8827129ac8))
|
|
14
|
+
* stop test_cli debugpy tests from blocking on a real debugger ([#239](https://github.com/cognitedata/cognite-function-apps/issues/239)) ([f28b577](https://github.com/cognitedata/cognite-function-apps/commit/f28b5778679dc4d9959d25a2701c9a1a5696444a))
|
|
15
|
+
* **tests:** count only tracer logger warnings in exporter failure test ([#249](https://github.com/cognitedata/cognite-function-apps/issues/249)) ([a5a36c4](https://github.com/cognitedata/cognite-function-apps/commit/a5a36c432422d545eb7a63a9ca46be6e5cd06c9c))
|
|
16
|
+
* wrap single string value as one-element list for sequence-type query params [Repo Assist] ([#203](https://github.com/cognitedata/cognite-function-apps/issues/203)) ([e658753](https://github.com/cognitedata/cognite-function-apps/commit/e6587538749b3ece9dd337f8c94f075ad7939001))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Performance Improvements
|
|
20
|
+
|
|
21
|
+
* cache is_coroutine flag on RouteInfo ([#244](https://github.com/cognitedata/cognite-function-apps/issues/244)) ([de0ddd2](https://github.com/cognitedata/cognite-function-apps/commit/de0ddd2effcb7508686c128f7f1f7834fb4adec0))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
|
|
26
|
+
* add deployment guide with Toolkit, schedules, and workflow payloads ([#245](https://github.com/cognitedata/cognite-function-apps/issues/245)) ([c0049c3](https://github.com/cognitedata/cognite-function-apps/commit/c0049c3f69a5d90cf15edbba6064d6daee25c325))
|
|
27
|
+
|
|
28
|
+
## [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)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* add injectable devserver client ([#226](https://github.com/cognitedata/cognite-function-apps/issues/226)) ([98d0792](https://github.com/cognitedata/cognite-function-apps/commit/98d0792f656c3e55403867bf255ff237a5862394))
|
|
34
|
+
* 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))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* 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))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Documentation
|
|
43
|
+
|
|
44
|
+
* 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))
|
|
45
|
+
|
|
3
46
|
## [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
47
|
|
|
5
48
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cognite-function-apps
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.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'
|
|
@@ -267,6 +267,13 @@ See [Response Customization](response-customization.md) for complete documentati
|
|
|
267
267
|
show_root_heading: true
|
|
268
268
|
show_source: false
|
|
269
269
|
|
|
270
|
+
#### wait_for_debugger
|
|
271
|
+
|
|
272
|
+
::: cognite_function_apps.devserver.wait_for_debugger
|
|
273
|
+
options:
|
|
274
|
+
show_root_heading: true
|
|
275
|
+
show_source: false
|
|
276
|
+
|
|
270
277
|
### Models and Types
|
|
271
278
|
|
|
272
279
|
#### FunctionCallInfo
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Deployment Guide
|
|
2
|
+
|
|
3
|
+
This guide shows how to deploy a Function App to CDF and call its routes from the SDK,
|
|
4
|
+
schedules, and workflows.
|
|
5
|
+
|
|
6
|
+
## The `data` Payload
|
|
7
|
+
|
|
8
|
+
A Function App is one Cognite Function. Each call selects a route through the `data` payload:
|
|
9
|
+
|
|
10
|
+
| Field | Type | Default | Description |
|
|
11
|
+
|-------|------|---------|-------------|
|
|
12
|
+
| `path` | `str` | `"/"` | Route path, optionally with a query string |
|
|
13
|
+
| `method` | `str` | `"POST"` | HTTP method: `GET`, `POST`, `PUT`, `DELETE`, `PATCH` |
|
|
14
|
+
| `body` | `dict` or `list` | `{}` | Request body |
|
|
15
|
+
| `headers` | `dict` | `{}` | Request headers, for example for trace propagation |
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
# GET /items/42?include_tax=true
|
|
19
|
+
data = {"path": "/items/42?include_tax=true", "method": "GET"}
|
|
20
|
+
|
|
21
|
+
# POST /items/ with a body
|
|
22
|
+
data = {"path": "/items/", "method": "POST", "body": {"name": "Widget", "price": 29.99}}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
!!! tip "The default method is POST"
|
|
26
|
+
Always set `"method": "GET"` when calling a `GET` route.
|
|
27
|
+
|
|
28
|
+
Query parameters are parsed from `path` and passed to the handler as typed arguments:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
@app.get("/items/{item_id}")
|
|
32
|
+
def get_item(client: CogniteClient, item_id: int, include_tax: bool = False) -> ItemResponse:
|
|
33
|
+
...
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Calling from the Cognite SDK
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from cognite.client import CogniteClient
|
|
40
|
+
|
|
41
|
+
client = CogniteClient()
|
|
42
|
+
|
|
43
|
+
response = client.functions.call(
|
|
44
|
+
external_id="my-function-app",
|
|
45
|
+
data={"path": "/items/42", "method": "GET"},
|
|
46
|
+
).get_response()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The response is the framework envelope, with the handler result under `data`:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
{"statusCode": 200, "data": {"id": 42, "name": "Widget"}, "headers": {"content-type": "application/json"}}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Errors use the same envelope with an error status code. See [Error Handling](error-handling.md).
|
|
56
|
+
For typed calls from Python, use the [Function Client](function-client.md).
|
|
57
|
+
|
|
58
|
+
## Discovering Routes
|
|
59
|
+
|
|
60
|
+
`create_function_service()` adds the introspection endpoints automatically, so a deployed
|
|
61
|
+
function can describe itself:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
client.functions.call(external_id="my-function-app", data={"path": "/__routes__", "method": "GET"})
|
|
65
|
+
client.functions.call(external_id="my-function-app", data={"path": "/__schema__", "method": "GET"})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
See [Introspection](introspection.md) for the full list.
|
|
69
|
+
|
|
70
|
+
## Deploying with Cognite Toolkit
|
|
71
|
+
|
|
72
|
+
[Cognite Toolkit](https://docs.cognite.com/cdf/deploy/cdf_toolkit/) deploys the function
|
|
73
|
+
code from a folder named after the function's external ID:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
modules/my_module/functions/
|
|
77
|
+
├── my-function-app/
|
|
78
|
+
│ ├── handler.py
|
|
79
|
+
│ └── requirements.txt
|
|
80
|
+
├── my-function-app.Function.yaml
|
|
81
|
+
└── my-function-app.Schedule.yaml
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`handler.py` exposes the service as `handle`:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from cognite_function_apps import FunctionApp, create_function_service
|
|
88
|
+
|
|
89
|
+
app = FunctionApp(title="Asset API", version="1.0.0")
|
|
90
|
+
|
|
91
|
+
# ... routes ...
|
|
92
|
+
|
|
93
|
+
handle = create_function_service(app)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Add `cognite-function-apps` to `requirements.txt`, then describe the function:
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
# my-function-app.Function.yaml
|
|
100
|
+
externalId: my-function-app
|
|
101
|
+
name: My Function App
|
|
102
|
+
runtime: py311
|
|
103
|
+
functionPath: handler.py
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Schedules
|
|
107
|
+
|
|
108
|
+
A schedule calls one route on a cron interval. Put the route in `data`:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
# my-function-app.Schedule.yaml
|
|
112
|
+
- name: sync-assets-hourly
|
|
113
|
+
functionExternalId: my-function-app
|
|
114
|
+
cronExpression: "0 * * * *"
|
|
115
|
+
data:
|
|
116
|
+
path: /sync/assets
|
|
117
|
+
method: POST
|
|
118
|
+
body:
|
|
119
|
+
dry_run: false
|
|
120
|
+
authentication:
|
|
121
|
+
clientId: "{{ function_client_id }}"
|
|
122
|
+
clientSecret: "{{ function_client_secret }}"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Add one schedule entry per route you want to run on a timer.
|
|
126
|
+
|
|
127
|
+
### Workflows
|
|
128
|
+
|
|
129
|
+
A workflow function task passes `data` the same way, so each task can call a different route
|
|
130
|
+
of the same function:
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
# modules/my_module/workflows/asset-pipeline.WorkflowVersion.yaml
|
|
134
|
+
workflowExternalId: asset-pipeline
|
|
135
|
+
version: v1
|
|
136
|
+
workflowDefinition:
|
|
137
|
+
tasks:
|
|
138
|
+
- externalId: validate-assets
|
|
139
|
+
type: function
|
|
140
|
+
parameters:
|
|
141
|
+
function:
|
|
142
|
+
externalId: my-function-app
|
|
143
|
+
data:
|
|
144
|
+
path: /assets/validate
|
|
145
|
+
method: POST
|
|
146
|
+
body:
|
|
147
|
+
strict: true
|
|
148
|
+
- externalId: ingest-assets
|
|
149
|
+
type: function
|
|
150
|
+
dependsOn:
|
|
151
|
+
- externalId: validate-assets
|
|
152
|
+
parameters:
|
|
153
|
+
function:
|
|
154
|
+
externalId: my-function-app
|
|
155
|
+
data:
|
|
156
|
+
path: /assets/ingest
|
|
157
|
+
method: POST
|
|
158
|
+
body:
|
|
159
|
+
batch_size: 500
|
|
160
|
+
```
|
|
@@ -88,30 +88,53 @@ 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
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
### Debugging in VS Code
|
|
102
|
+
|
|
103
|
+
Use this configuration to launch the local server and debug handler code in one step. It starts `fun serve` under VS Code's debugger, opens Swagger UI when Uvicorn is ready, and lets breakpoints 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
|
+
}
|
|
104
133
|
```
|
|
105
134
|
|
|
106
|
-
|
|
135
|
+
Select **Debug Function App**, enter the Function App directory, and set breakpoints in handler code.
|
|
107
136
|
|
|
108
|
-
|
|
109
|
-
uv run uvicorn dev:app --reload
|
|
110
|
-
# or without uv
|
|
111
|
-
uvicorn dev:app --reload
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
The server will start on `http://localhost:8000` by default.
|
|
137
|
+
For other debugpy-compatible IDEs, run `fun serve . --debugpy`; it listens only on `127.0.0.1:5678`, waits for the debugger before startup, and disables auto-reload. Use `--debugpy-port` to select a different local port.
|
|
115
138
|
|
|
116
139
|
## Interactive API Documentation
|
|
117
140
|
|
|
@@ -249,6 +272,16 @@ fun serve . --log-level debug
|
|
|
249
272
|
fun serve . --no-reload
|
|
250
273
|
```
|
|
251
274
|
|
|
275
|
+
### Supplying a client
|
|
276
|
+
|
|
277
|
+
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.
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from cognite_function_apps.devserver import create_asgi_app
|
|
281
|
+
|
|
282
|
+
app = create_asgi_app(handle, client_factory=create_local_client)
|
|
283
|
+
```
|
|
284
|
+
|
|
252
285
|
### Using uvicorn directly
|
|
253
286
|
|
|
254
287
|
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.16.0" # x-release-please-version
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/app.py
RENAMED
|
@@ -875,11 +875,15 @@ async def execute_function_and_format_response(
|
|
|
875
875
|
) -> DataDict:
|
|
876
876
|
"""Execute the function and format the response.
|
|
877
877
|
|
|
878
|
-
|
|
878
|
+
Async endpoints are awaited directly and sync endpoints run on a thread pool,
|
|
879
|
+
using the flag cached on RouteInfo at registration.
|
|
879
880
|
Detects Response[T] wrappers and extracts data with custom status/headers.
|
|
880
881
|
"""
|
|
881
882
|
func = route_match.endpoint
|
|
882
|
-
|
|
883
|
+
if route_match.is_coroutine:
|
|
884
|
+
result = await cast(Coroutine[Any, Any, TypedResponse], func(**kwargs))
|
|
885
|
+
else:
|
|
886
|
+
result = await asyncio.to_thread(func, **kwargs)
|
|
883
887
|
|
|
884
888
|
# Check if result is a Response wrapper
|
|
885
889
|
response_status_code: int | None = None
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/cli.py
RENAMED
|
@@ -121,7 +121,7 @@ def main() -> None:
|
|
|
121
121
|
import typer # noqa: PLC0415
|
|
122
122
|
import uvicorn # noqa: PLC0415
|
|
123
123
|
|
|
124
|
-
from cognite_function_apps.devserver import create_asgi_app # noqa: PLC0415
|
|
124
|
+
from cognite_function_apps.devserver import create_asgi_app, wait_for_debugger # noqa: PLC0415
|
|
125
125
|
except ImportError as e:
|
|
126
126
|
logger.error(
|
|
127
127
|
"""Error: CLI dependencies not installed. Missing: %s
|
|
@@ -321,6 +321,8 @@ app = create_asgi_app(handler_module.handle)
|
|
|
321
321
|
host: Annotated[str, typer.Option(help="Host to bind to")] = "127.0.0.1", # pyright: ignore[reportUnknownMemberType]
|
|
322
322
|
port: Annotated[int, typer.Option(help="Port to bind to")] = 8000, # pyright: ignore[reportUnknownMemberType]
|
|
323
323
|
reload: Annotated[bool, typer.Option(help="Enable auto-reload on code changes")] = True, # pyright: ignore[reportUnknownMemberType]
|
|
324
|
+
debugpy: Annotated[bool, typer.Option(help="Wait for a debugger to attach")] = False, # pyright: ignore[reportUnknownMemberType]
|
|
325
|
+
debugpy_port: Annotated[int, typer.Option(help="Port for debugger attachment")] = 5678, # pyright: ignore[reportUnknownMemberType]
|
|
324
326
|
log_level: Annotated[
|
|
325
327
|
str,
|
|
326
328
|
typer.Option(help="Log level"), # pyright: ignore[reportUnknownMemberType]
|
|
@@ -329,15 +331,25 @@ app = create_asgi_app(handler_module.handle)
|
|
|
329
331
|
"""Start a development server for local testing.
|
|
330
332
|
|
|
331
333
|
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.
|
|
334
|
+
using uvicorn. It automatically detects code changes and reloads the server unless debugging is enabled.
|
|
333
335
|
|
|
334
336
|
Example:
|
|
335
337
|
fun serve examples/
|
|
336
338
|
fun serve . --port 3000 --log-level debug
|
|
339
|
+
fun serve . --debugpy
|
|
337
340
|
"""
|
|
338
341
|
handler_path = path.resolve()
|
|
339
342
|
_validate_handler_directory(handler_path)
|
|
340
343
|
|
|
344
|
+
if debugpy:
|
|
345
|
+
typer.secho(f"Waiting for debugger attach on 127.0.0.1:{debugpy_port}...", fg=typer.colors.YELLOW)
|
|
346
|
+
try:
|
|
347
|
+
wait_for_debugger(debugpy_port)
|
|
348
|
+
except RuntimeError as e:
|
|
349
|
+
typer.secho(f"Error: {e}", fg=typer.colors.RED, err=True)
|
|
350
|
+
raise typer.Exit(code=1) from e
|
|
351
|
+
reload = False
|
|
352
|
+
|
|
341
353
|
# Print startup information
|
|
342
354
|
typer.secho(f"\nStarting server at http://{host}:{port}", fg=typer.colors.GREEN, bold=True)
|
|
343
355
|
if reload:
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/convert.py
RENAMED
|
@@ -198,6 +198,13 @@ def convert_value_to_type(value: Any, target_type: Any, param_path: str = "") ->
|
|
|
198
198
|
inspect.isclass(origin) and issubclass(origin, Sequence) and not issubclass(origin, (str, bytes))
|
|
199
199
|
)
|
|
200
200
|
if is_sequence_type:
|
|
201
|
+
if isinstance(value, str):
|
|
202
|
+
# A bare string for a sequence parameter is treated as a single-element
|
|
203
|
+
# list. This is the standard HTTP convention: a query parameter that
|
|
204
|
+
# appears only once (e.g. ?ids=1) arrives as a string, but the handler
|
|
205
|
+
# may declare it as list[int]. Wrapping avoids a confusing ConvertError
|
|
206
|
+
# for what is clearly a valid single-item request.
|
|
207
|
+
value = [value]
|
|
201
208
|
if not isinstance(value, (list, tuple)):
|
|
202
209
|
raise ConvertError(
|
|
203
210
|
f"Unsupported sequence type {type(value).__name__} at {param_path}, supported types are: (list, tuple)."
|
|
@@ -16,10 +16,12 @@ Example:
|
|
|
16
16
|
|
|
17
17
|
from .asgi import create_asgi_app
|
|
18
18
|
from .auth import AuthConfig, get_cognite_client_from_auth_config, get_cognite_client_from_env
|
|
19
|
+
from .debug import wait_for_debugger
|
|
19
20
|
|
|
20
21
|
__all__ = [
|
|
21
22
|
"AuthConfig",
|
|
22
23
|
"create_asgi_app",
|
|
23
24
|
"get_cognite_client_from_auth_config",
|
|
24
25
|
"get_cognite_client_from_env",
|
|
26
|
+
"wait_for_debugger",
|
|
25
27
|
]
|
|
@@ -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")
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Debugpy setup helpers for local development."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def wait_for_debugger(port: int = 5678) -> None:
|
|
5
|
+
"""Listen locally and wait for a debugpy client to attach.
|
|
6
|
+
|
|
7
|
+
The listener binds only to ``127.0.0.1`` and blocks until a client attaches.
|
|
8
|
+
Install the ``cli`` extra to make ``debugpy`` available.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
port: Local debugger port. Defaults to 5678.
|
|
12
|
+
|
|
13
|
+
Raises:
|
|
14
|
+
RuntimeError: If debugpy is unavailable or its listener cannot start.
|
|
15
|
+
"""
|
|
16
|
+
try:
|
|
17
|
+
import debugpy # noqa: PLC0415, T100
|
|
18
|
+
except ImportError as e:
|
|
19
|
+
msg = "debugpy is not installed; reinstall with: pip install cognite-function-apps[cli]"
|
|
20
|
+
raise RuntimeError(msg) from e
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
debugpy.listen(("127.0.0.1", port)) # noqa: T100
|
|
24
|
+
except Exception as e:
|
|
25
|
+
raise RuntimeError(f"Failed to start debugger listener on 127.0.0.1:{port}: {e}") from e
|
|
26
|
+
debugpy.wait_for_client() # noqa: T100
|
|
@@ -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)
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/routing.py
RENAMED
|
@@ -93,13 +93,16 @@ class RouteInfo:
|
|
|
93
93
|
extra_headers: Mapping[str, str] | None = None
|
|
94
94
|
"""Additional custom response headers"""
|
|
95
95
|
|
|
96
|
-
# Derived
|
|
96
|
+
# Derived fields: computed once at route registration
|
|
97
97
|
has_var_keyword: bool = field(init=False, repr=False)
|
|
98
98
|
"""True if the endpoint accepts **kwargs (VAR_KEYWORD parameter)"""
|
|
99
|
+
is_coroutine: bool = field(init=False, repr=False)
|
|
100
|
+
"""True if the endpoint is an async function"""
|
|
99
101
|
|
|
100
102
|
def __post_init__(self) -> None:
|
|
101
|
-
"""Compute derived fields from the endpoint signature."""
|
|
103
|
+
"""Compute derived fields from the endpoint and its signature."""
|
|
102
104
|
self.has_var_keyword = any(p.kind == inspect.Parameter.VAR_KEYWORD for p in self.signature.parameters.values())
|
|
105
|
+
self.is_coroutine = inspect.iscoroutinefunction(self.endpoint)
|
|
103
106
|
|
|
104
107
|
|
|
105
108
|
# NewType for type-safe sorted routes - ensures find_matching_route only accepts properly sorted routes
|
{cognite_function_apps-0.14.1 → cognite_function_apps-0.16.0}/src/cognite_function_apps/schema.py
RENAMED
|
@@ -633,8 +633,14 @@ class SchemaGenerator:
|
|
|
633
633
|
if return_type in (int, float, bool, str):
|
|
634
634
|
return OpenAPISchema(type=SchemaGenerator._python_type_to_openapi(return_type))
|
|
635
635
|
|
|
636
|
-
# Handle
|
|
637
|
-
|
|
636
|
+
# Handle list and sequence types (list[T], Sequence[T], tuple[T, ...], etc.)
|
|
637
|
+
_seq_origin = get_origin(return_type)
|
|
638
|
+
if (
|
|
639
|
+
_seq_origin is not None
|
|
640
|
+
and inspect.isclass(_seq_origin)
|
|
641
|
+
and issubclass(_seq_origin, Sequence)
|
|
642
|
+
and not issubclass(_seq_origin, (str, bytes))
|
|
643
|
+
):
|
|
638
644
|
return SchemaGenerator._handle_list_type_schema(return_type, component_schemas)
|
|
639
645
|
|
|
640
646
|
# Handle dictionaries
|