Skip to content

Commit b072100

Browse files
Consent management component (#14)
* move data-collection to its own folder * consent-mapping: initial import * check.yml: test full CI * fixup! move data-collection to its own folder * fixup! consent-mapping: initial import * fixup! consent-mapping: initial import * fixup! move data-collection to its own folder * fixup! check.yml: test full CI * fix * update gitiginre and component file naming
1 parent 71f63c9 commit b072100

File tree

15 files changed

+160
-55
lines changed

15 files changed

+160
-55
lines changed

.github/workflows/check.yml

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,40 @@
11
name: Check
22
on:
3-
push:
4-
branches:
5-
- main
6-
pull_request:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
77

88
env:
99
EDGEE_API_TOKEN: ${{ secrets.EDGEE_API_TOKEN }}
1010

1111
jobs:
12-
test:
13-
name: test
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
19-
- name: Install uv
20-
uses: astral-sh/setup-uv@v5
21-
22-
- name: "Set up Python"
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version-file: "pyproject.toml"
26-
27-
- name: Install edgee
28-
uses: edgee-cloud/[email protected]
29-
30-
- name: Build component
31-
run: |
32-
edgee component build
33-
34-
- name: Verify .wasm file exists
35-
run: |
36-
if [ ! -f "./dc_component.wasm" ]; then
37-
echo "❌ Error: dc_component.wasm not found" >&2
38-
exit 1
39-
fi
40-
41-
- name: Test component
42-
run: |
43-
make test
12+
full-ci:
13+
name: Full CI (${{ matrix.dir }})
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
dir: [consent-management, data-collection]
18+
defaults:
19+
run:
20+
working-directory: ${{ matrix.dir }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
27+
- name: "Set up Python"
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version-file: "${{ matrix.dir }}/pyproject.toml"
31+
32+
- name: Install Edgee CLI
33+
uses: edgee-cloud/[email protected]
34+
35+
- name: Run edgee component wit
36+
run: edgee component wit
37+
38+
- name: Build component
39+
run: |
40+
edgee component build

Makefile

Lines changed: 0 additions & 15 deletions
This file was deleted.

.gitignore renamed to consent-management/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# deps
22
.edgee/
33
# build output
4-
dc_component.wasm
4+
component.wasm
55
# world binding
66
edgee_world/
77
# python
File renamed without changes.

consent-management/component.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import edgee_world.consent_management.exports as exports
2+
import edgee_world.consent_management.exports.consent_management as consent_management
3+
4+
from edgee_world.consent_management.types import *
5+
6+
class ConsentManagement(exports.ConsentManagement):
7+
def map(self, cookies: List[Tuple[str, str]], settings: List[Tuple[str, str]]) -> Optional[consent_management.Consent]:
8+
cookies_dict = dict(cookies)
9+
settings_dict = dict(settings)
10+
11+
key = cookies_dict.get("key")
12+
if key is None:
13+
return None
14+
15+
if key == "granted":
16+
return consent_management.Consent.GRANTED
17+
elif key == "denied":
18+
return consent_management.Consent.DENIED
19+
else:
20+
return consent_management.Consent.PENDING
21+
22+
23+
raise NotImplementedError
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
manifest-version = 1
2+
3+
[component]
4+
name = "example-py-consent-management-component"
5+
version = "1.0.0"
6+
category = "consent-management"
7+
subcategory = "consent-mapping"
8+
description = "Example Python component for consent management"
9+
documentation = "https://github.com/edgee-cloud/example-py-component"
10+
repository = "https://github.com/edgee-cloud/example-py-component"
11+
language = "Python"
12+
wit-version = "1.0.0"
13+
14+
[component.build]
15+
command = "uv sync && rm -rf edgee_world && uv run componentize-py --wit-path .edgee/wit/ bindings edgee_world && uv run componentize-py --wit-path .edgee/wit/ --world consent-management componentize component -o component.wasm"
16+
output_path = "./component.wasm"
17+
18+
[component.settings.example]
19+
title = "Example Config Field"
20+
type = "string"
21+
File renamed without changes.
File renamed without changes.

data-collection/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# deps
2+
.edgee/
3+
# build output
4+
component.wasm
5+
# world binding
6+
edgee_world/
7+
# python
8+
__pycache__/

data-collection/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div align="center">
2+
<p align="center">
3+
<a href="https://www.edgee.cloud">
4+
<picture>
5+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.edgee.cloud/img/component-dark.svg">
6+
<img src="https://cdn.edgee.cloud/img/component.svg" height="100" alt="Edgee">
7+
</picture>
8+
</a>
9+
</p>
10+
</div>
11+
12+
<h1 align="center">Example python component for Edgee</h1>
13+
14+
This is an example of a Python Edgee Component.
15+
16+
## Setup
17+
Requirements:
18+
- [edgee-cli](https://github.com/edgee-cloud/edgee)
19+
- Python3
20+
- uv
21+
22+
```shell
23+
$ make setup
24+
```
25+
## Building
26+
27+
```shell
28+
$ make build
29+
```
File renamed without changes.
File renamed without changes.

edgee-component.toml renamed to data-collection/edgee-component.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
manifest-version = 1
22

33
[component]
4-
name = "example-py-component"
4+
name = "example-py-data-collection-component"
55
version = "1.0.0"
66
category = "data-collection"
77
subcategory = "analytics"
@@ -12,8 +12,8 @@ language = "Python"
1212
wit-version = "1.0.0"
1313

1414
[component.build]
15-
command = "uv sync && rm -rf edgee_world && uv run componentize-py --wit-path .edgee/wit/ bindings edgee_world && uv run componentize-py --wit-path .edgee/wit/ --world data-collection componentize dc_component -o dc_component.wasm"
16-
output_path = "./dc_component.wasm"
15+
command = "uv sync && rm -rf edgee_world && uv run componentize-py --wit-path .edgee/wit/ bindings edgee_world && uv run componentize-py --wit-path .edgee/wit/ --world data-collection componentize component -o component.wasm"
16+
output_path = "./component.wasm"
1717

1818
[component.settings.example]
1919
title = "Example Config Field"

data-collection/pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[project]
2+
name = "example-py-component"
3+
version = "0.1.0"
4+
description = "Edgee python3 example for implementation of a data collection component"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = []
8+
9+
[dependency-groups]
10+
dev = [
11+
"componentize-py>=0.16.0",
12+
]

data-collection/uv.lock

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)