cognite-function-apps 0.15.0__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.16.0/.release-please-manifest.json +3 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/CHANGELOG.md +25 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/PKG-INFO +1 -1
- {cognite_function_apps-0.15.0 → 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.15.0 → cognite_function_apps-0.16.0}/docs/dev-server.md +4 -23
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/mkdocs.yml +1 -0
- cognite_function_apps-0.16.0/src/cognite_function_apps/_version.py +1 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/app.py +6 -2
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/cli.py +2 -17
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/convert.py +7 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/__init__.py +2 -0
- cognite_function_apps-0.16.0/src/cognite_function_apps/devserver/debug.py +26 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/routing.py +5 -2
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/schema.py +8 -2
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/tracer.py +171 -35
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_cli.py +43 -60
- {cognite_function_apps-0.15.0 → 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.15.0 → cognite_function_apps-0.16.0}/tests/test_handle_function.py +64 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_routing.py +24 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_schema.py +75 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_tracer.py +239 -10
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/uv.lock +140 -78
- cognite_function_apps-0.15.0/.release-please-manifest.json +0 -3
- cognite_function_apps-0.15.0/src/cognite_function_apps/_version.py +0 -1
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.claude/settings.json +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.gemini/config.yaml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.gitattributes +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/agents/agentic-workflows.agent.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/aw/actions-lock.json +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/renovate.json +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/workflows/conventional-pr-title.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/workflows/copilot-setup-steps.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/workflows/deploy-docs.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/workflows/python-package.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/workflows/python-publish.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.github/workflows/release-please.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.gitignore +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.nojekyll +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.pre-commit-config.yaml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/.python-version +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/AGENTS.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/CLAUDE.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/CODEOWNERS +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/LICENSE +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/README.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/RELEASING.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/Terminology.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/adr/response-customization.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/codecov.yml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/app-composition.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/architecture.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/async-support.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/contributing.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/dependency-injection.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/error-handling.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/function-client.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/index.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/introspection.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/logging.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/mcp.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/release-process.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/response-customization.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/stylesheets/extra.css +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/tracing.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs/type-safety.md +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs-src/error-handling.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs-src/function-client.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs-src/introspection.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs-src/logging.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs-src/tracing.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/docs-src/type-safety.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/examples/dev.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/examples/handler.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/examples/requirements.txt +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/justfile +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/pyproject.toml +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/release-please-config.json +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/__init__.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/_type_utils.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/base_client.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/client.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/client_generation.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/dependency_registry.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/asgi.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/auth.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/devserver/swagger.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/formatting.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/introspection.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/logger.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/mcp.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/models.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/py.typed +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/service.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/templates/__init__.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/templates/client_template.jinja2 +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/__init__.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/conftest.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/conftest_pep563.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/conftest_type_checking.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_app.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_asgi.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_async_handlers.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_client_generation.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_convert_edge_cases.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_convert_property_based.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_dependency_injection.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_error_handling.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_formatting.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_introspection.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_logger.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_mcp.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_models.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_swagger.py +0 -0
- {cognite_function_apps-0.15.0 → cognite_function_apps-0.16.0}/tests/test_trace_propagation.py +0 -0
|
@@ -1,5 +1,30 @@
|
|
|
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
|
+
|
|
3
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)
|
|
4
29
|
|
|
5
30
|
|
|
@@ -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
|
|
@@ -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
|
+
```
|
|
@@ -98,9 +98,9 @@ fun serve . --debugpy --debugpy-port 5679
|
|
|
98
98
|
fun serve . --port 3000 --log-level debug
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
###
|
|
101
|
+
### Debugging in VS Code
|
|
102
102
|
|
|
103
|
-
|
|
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
104
|
|
|
105
105
|
```json
|
|
106
106
|
{
|
|
@@ -132,28 +132,9 @@ To start and debug the local server from an IDE that uses `launch.json`, add thi
|
|
|
132
132
|
}
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
Select **Debug Function App
|
|
135
|
+
Select **Debug Function App**, enter the Function App directory, and set breakpoints in handler code.
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
If you prefer more control, create a `dev.py` file next to your handler:
|
|
140
|
-
|
|
141
|
-
```python
|
|
142
|
-
from cognite_function_apps.devserver import create_asgi_app
|
|
143
|
-
from handler import handle
|
|
144
|
-
|
|
145
|
-
app = create_asgi_app(handle)
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Then run with uvicorn:
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
uv run uvicorn dev:app --reload
|
|
152
|
-
# or without uv
|
|
153
|
-
uvicorn dev:app --reload
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
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.
|
|
157
138
|
|
|
158
139
|
## Interactive API Documentation
|
|
159
140
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.16.0" # x-release-please-version
|
{cognite_function_apps-0.15.0 → 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.15.0 → cognite_function_apps-0.16.0}/src/cognite_function_apps/cli.py
RENAMED
|
@@ -21,21 +21,6 @@ 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
|
-
|
|
39
24
|
def _load_handler_from_path(handler_path: Path) -> FunctionService:
|
|
40
25
|
"""Load the handle object from a handler.py file.
|
|
41
26
|
|
|
@@ -136,7 +121,7 @@ def main() -> None:
|
|
|
136
121
|
import typer # noqa: PLC0415
|
|
137
122
|
import uvicorn # noqa: PLC0415
|
|
138
123
|
|
|
139
|
-
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
|
|
140
125
|
except ImportError as e:
|
|
141
126
|
logger.error(
|
|
142
127
|
"""Error: CLI dependencies not installed. Missing: %s
|
|
@@ -359,7 +344,7 @@ app = create_asgi_app(handler_module.handle)
|
|
|
359
344
|
if debugpy:
|
|
360
345
|
typer.secho(f"Waiting for debugger attach on 127.0.0.1:{debugpy_port}...", fg=typer.colors.YELLOW)
|
|
361
346
|
try:
|
|
362
|
-
|
|
347
|
+
wait_for_debugger(debugpy_port)
|
|
363
348
|
except RuntimeError as e:
|
|
364
349
|
typer.secho(f"Error: {e}", fg=typer.colors.RED, err=True)
|
|
365
350
|
raise typer.Exit(code=1) from e
|
{cognite_function_apps-0.15.0 → 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
|
]
|
|
@@ -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
|
{cognite_function_apps-0.15.0 → 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.15.0 → 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
|