diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1fc612d..91c37f3 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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/install-edgee-cli@v0.2.0 - - - 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/install-edgee-cli@v0.2.0 + + - name: Run edgee component wit + run: edgee component wit + + - name: Build component + run: | + edgee component build diff --git a/Makefile b/Makefile deleted file mode 100644 index 7f3d81d..0000000 --- a/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -.PHONY: all -MAKEFLAGS += --silent - -all: help - -help: - @grep -E '^[a-zA-Z1-9\._-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | sort \ - | sed -e "s/^Makefile://" -e "s///" \ - | awk 'BEGIN { FS = ":.*?## " }; { printf "\033[36m%-30s\033[0m %s\n", $$1, $$2 }' -build: - edgee components build - -test: ## test the component functions - python -m unittest dc_component_test.py diff --git a/.gitignore b/consent-management/.gitignore similarity index 81% rename from .gitignore rename to consent-management/.gitignore index 8351d0b..734088c 100644 --- a/.gitignore +++ b/consent-management/.gitignore @@ -1,7 +1,7 @@ # deps .edgee/ # build output -dc_component.wasm +component.wasm # world binding edgee_world/ # python diff --git a/README.md b/consent-management/README.md similarity index 100% rename from README.md rename to consent-management/README.md diff --git a/consent-management/component.py b/consent-management/component.py new file mode 100644 index 0000000..e1f2ba7 --- /dev/null +++ b/consent-management/component.py @@ -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 diff --git a/consent-management/edgee-component.toml b/consent-management/edgee-component.toml new file mode 100644 index 0000000..244f1f5 --- /dev/null +++ b/consent-management/edgee-component.toml @@ -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" + diff --git a/pyproject.toml b/consent-management/pyproject.toml similarity index 100% rename from pyproject.toml rename to consent-management/pyproject.toml diff --git a/uv.lock b/consent-management/uv.lock similarity index 100% rename from uv.lock rename to consent-management/uv.lock diff --git a/data-collection/.gitignore b/data-collection/.gitignore new file mode 100644 index 0000000..734088c --- /dev/null +++ b/data-collection/.gitignore @@ -0,0 +1,8 @@ +# deps +.edgee/ +# build output +component.wasm +# world binding +edgee_world/ +# python +__pycache__/ diff --git a/data-collection/README.md b/data-collection/README.md new file mode 100644 index 0000000..9248bcb --- /dev/null +++ b/data-collection/README.md @@ -0,0 +1,29 @@ +
+

+ + + + Edgee + + +

+
+ +

Example python component for Edgee

+ +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 +``` diff --git a/dc_component.py b/data-collection/component.py similarity index 100% rename from dc_component.py rename to data-collection/component.py diff --git a/dc_component_test.py b/data-collection/component_test.py similarity index 100% rename from dc_component_test.py rename to data-collection/component_test.py diff --git a/edgee-component.toml b/data-collection/edgee-component.toml similarity index 84% rename from edgee-component.toml rename to data-collection/edgee-component.toml index 8ddb418..c4464a8 100644 --- a/edgee-component.toml +++ b/data-collection/edgee-component.toml @@ -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" @@ -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" diff --git a/data-collection/pyproject.toml b/data-collection/pyproject.toml new file mode 100644 index 0000000..6f74ab1 --- /dev/null +++ b/data-collection/pyproject.toml @@ -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", +] diff --git a/data-collection/uv.lock b/data-collection/uv.lock new file mode 100644 index 0000000..5f12039 --- /dev/null +++ b/data-collection/uv.lock @@ -0,0 +1,30 @@ +version = 1 +requires-python = ">=3.12" + +[[package]] +name = "componentize-py" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d1/64/d64b0cbf596b4624f941199c943cf4547612807f125c25d26d6c7dfa7e03/componentize_py-0.16.0.tar.gz", hash = "sha256:2823e5f3abf7a4eaf993d0841d8e7888f13d3b46a8e42230e044d64b49311e57", size = 156307 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/39/55db339c8d2a3de3f9b57e94763308eaa1ea4691b671606b90595cbcef3f/componentize_py-0.16.0-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:a67f378aada7d4652c14abfb922be915c6383192416d0fe75aef33c4fd8ed6f0", size = 18121079 }, + { url = "https://files.pythonhosted.org/packages/59/c0/7721d5d3f8e6d716309fc0da466856695b699a6a55d557dfcc841b088730/componentize_py-0.16.0-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:0728eb5c584651a21c7fde39e9c4c21d0b469b37e07e5e32b2d72e7ac5047083", size = 17763273 }, + { url = "https://files.pythonhosted.org/packages/47/4b/8e70d5526073825a791dc2a4a1d02ef255034203d3fb4ff6450b06c927f5/componentize_py-0.16.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:46bc31b4d3e93d556174827aeef326f644e7de4b85f3c1f8e05769aa3f522a08", size = 18544158 }, + { url = "https://files.pythonhosted.org/packages/dc/78/368da5fdc97e8c56ee5d59a1c3f452233aa91f6c2e89fc8cde532612c6a3/componentize_py-0.16.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:95644bf551b8e93f56049a623307bbc1d982ebfa3ebb1ef45b3e631bfd65b798", size = 19050720 }, + { url = "https://files.pythonhosted.org/packages/12/47/55d85805686da60018b1f3d32c1025e46f9c2fe18a9c7e369912fa65998b/componentize_py-0.16.0-cp39-abi3-win_amd64.whl", hash = "sha256:8b0571f7a081dac86c9ab1b7ed0e0a5b5d5c9107f3d33db29f0764f261d7c1b8", size = 17282010 }, +] + +[[package]] +name = "example-py-component" +version = "0.1.0" +source = { virtual = "." } + +[package.dev-dependencies] +dev = [ + { name = "componentize-py" }, +] + +[package.metadata] + +[package.metadata.requires-dev] +dev = [{ name = "componentize-py", specifier = ">=0.16.0" }]