Skip to content

Consent management component #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 33 additions & 36 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
name: Check
on:
push:
branches:
- main
pull_request:
push:
branches:
- main
pull_request:

env:
EDGEE_API_TOKEN: ${{ secrets.EDGEE_API_TOKEN }}

jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Install edgee
uses: edgee-cloud/[email protected]

- name: Build component
run: |
edgee component build

- name: Verify .wasm file exists
run: |
if [ ! -f "./dc_component.wasm" ]; then
echo "❌ Error: dc_component.wasm not found" >&2
exit 1
fi

- name: Test component
run: |
make test
full-ci:
name: Full CI (${{ matrix.dir }})
runs-on: ubuntu-latest
strategy:
matrix:
dir: [consent-management, data-collection]
defaults:
run:
working-directory: ${{ matrix.dir }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "${{ matrix.dir }}/pyproject.toml"

- name: Install Edgee CLI
uses: edgee-cloud/[email protected]

- name: Run edgee component wit
run: edgee component wit

- name: Build component
run: |
edgee component build
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore → consent-management/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# deps
.edgee/
# build output
dc_component.wasm
component.wasm
# world binding
edgee_world/
# python
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions consent-management/component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import edgee_world.consent_management.exports as exports
import edgee_world.consent_management.exports.consent_management as consent_management

from edgee_world.consent_management.types import *

class ConsentManagement(exports.ConsentManagement):
def map(self, cookies: List[Tuple[str, str]], settings: List[Tuple[str, str]]) -> Optional[consent_management.Consent]:
cookies_dict = dict(cookies)
settings_dict = dict(settings)

key = cookies_dict.get("key")
if key is None:
return None

if key == "granted":
return consent_management.Consent.GRANTED
elif key == "denied":
return consent_management.Consent.DENIED
else:
return consent_management.Consent.PENDING


raise NotImplementedError
21 changes: 21 additions & 0 deletions consent-management/edgee-component.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
manifest-version = 1

[component]
name = "example-py-consent-management-component"
version = "1.0.0"
category = "consent-management"
subcategory = "consent-mapping"
description = "Example Python component for consent management"
documentation = "https://github.com/edgee-cloud/example-py-component"
repository = "https://github.com/edgee-cloud/example-py-component"
language = "Python"
wit-version = "1.0.0"

[component.build]
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"
output_path = "./component.wasm"

[component.settings.example]
title = "Example Config Field"
type = "string"

File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions data-collection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# deps
.edgee/
# build output
component.wasm
# world binding
edgee_world/
# python
__pycache__/
29 changes: 29 additions & 0 deletions data-collection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div align="center">
<p align="center">
<a href="https://www.edgee.cloud">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.edgee.cloud/img/component-dark.svg">
<img src="https://cdn.edgee.cloud/img/component.svg" height="100" alt="Edgee">
</picture>
</a>
</p>
</div>

<h1 align="center">Example python component for Edgee</h1>

This is an example of a Python Edgee Component.

## Setup
Requirements:
- [edgee-cli](https://github.com/edgee-cloud/edgee)
- Python3
- uv

```shell
$ make setup
```
## Building

```shell
$ make build
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
manifest-version = 1

[component]
name = "example-py-component"
name = "example-py-data-collection-component"
version = "1.0.0"
category = "data-collection"
subcategory = "analytics"
Expand All @@ -12,8 +12,8 @@ language = "Python"
wit-version = "1.0.0"

[component.build]
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"
output_path = "./dc_component.wasm"
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"
output_path = "./component.wasm"

[component.settings.example]
title = "Example Config Field"
Expand Down
12 changes: 12 additions & 0 deletions data-collection/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = "example-py-component"
version = "0.1.0"
description = "Edgee python3 example for implementation of a data collection component"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []

[dependency-groups]
dev = [
"componentize-py>=0.16.0",
]
30 changes: 30 additions & 0 deletions data-collection/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.