diff --git a/.github/workflows/pub-tools-mec-pypi.yml b/.github/workflows/pub-tools-mec-pypi.yml new file mode 100644 index 00000000000..42f96ebb352 --- /dev/null +++ b/.github/workflows/pub-tools-mec-pypi.yml @@ -0,0 +1,34 @@ +name: Publish model-explorer-circle to pypi + +on: + workflow_dispatch: + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install build dependencies + run: python -m pip install -U setuptools wheel build + + - name: Build + run: | + cd tools/model_explorer_circle/ + python -m build . + + - name: Publish + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: tools/model_explorer_circle/dist/ + skip-existing: false + user: __token__ + password: ${{ secrets.MEC_PYPI_API }} diff --git a/.github/workflows/run-tools-mec-build.yml b/.github/workflows/run-tools-mec-build.yml new file mode 100644 index 00000000000..4c9f8eeaab3 --- /dev/null +++ b/.github/workflows/run-tools-mec-build.yml @@ -0,0 +1,49 @@ +name: Run tools/model-explorer-circle build + +on: + push: + branches: + - master + - release/* + paths: + - '.github/workflows/run-tools-mec-build.yml' + - 'tools/model_explorer_circle/**' + - '!**/*.md' + pull_request: + branches: + - master + - release/* + paths: + - '.github/workflows/run-tools-mec-build.yml' + - 'tools/model_explorer_circle/**' + - '!**/*.md' + +defaults: + run: + shell: bash + +jobs: + test: + strategy: + matrix: + python: ['3.10'] # ['3.10', '3.11', '3.12'] + platform: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.platform }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - name: Install test dependencies + run: python -m pip install --upgrade nox + + - name: Test + run: | + cd tools/model_explorer_circle + python -m nox -s tests-${{ matrix.python }} diff --git a/tools/model_explorer_circle/HOWTO.md b/tools/model_explorer_circle/HOWTO.md index a663a081f20..42f14ba2ffc 100644 --- a/tools/model_explorer_circle/HOWTO.md +++ b/tools/model_explorer_circle/HOWTO.md @@ -8,3 +8,27 @@ flatc -p --gen-onefile --gen-object-api circle_schema.fbs ``` * Note: For `--gen-onefile` option, you need to use the latest version of `flatc`. (tested version = v24.3.25) + +## How to local build with nox + +Use separate virtual-env: +``` +python3 -m venv venv +source venv/bin/activate +``` + +Install tools: +``` +python3 -m pip install --upgrade nox build +``` + +To run unit tests: +``` +python3 -m nox -s tests-3.xx +``` +- where `xx` is your python version, for example `10` + +To build package: +``` +python3 -m build . +``` diff --git a/tools/model_explorer_circle/noxfile.py b/tools/model_explorer_circle/noxfile.py index 3738621d64b..9db6b7b1ecf 100644 --- a/tools/model_explorer_circle/noxfile.py +++ b/tools/model_explorer_circle/noxfile.py @@ -15,10 +15,21 @@ import os import nox +nox.options.sessions = ["lint"] + # Define the minimal nox version required to run nox.options.needs_version = ">= 2024.3.2" +@nox.session +def lint(session): + # NOTE no need to run lint, as format checker runs with yapf including this project + session.install("yapf==0.40.2") + session.run("yapf", "--verbose", "--in-place", "--recursive", "--exclude", + "src/circle_adapter/circle_schema_generated.py", "noxfile.py", "./src", + "./tests") + + @nox.session def build_and_check_dists(session): session.install("build", "check-manifest >= 0.42", "twine", "ai-edge-model-explorer", diff --git a/tools/model_explorer_circle/pyproject.toml b/tools/model_explorer_circle/pyproject.toml index c866b49a9e9..95492b5317a 100644 --- a/tools/model_explorer_circle/pyproject.toml +++ b/tools/model_explorer_circle/pyproject.toml @@ -5,10 +5,14 @@ build-backend = "setuptools.build_meta" [project] name = "model-explorer-circle" version = "0.0.1" +maintainers = [ + { name="NNFW", email="nnfw@samsung.com" }, +] description = "Model Explorer Circle Adaptor" readme = "README.md" requires-python = ">=3.9" license = { text = "Apache Software License (Apache 2.0)" } +keywords = ["circle", "model-explorer", "visualization"] classifiers = [ "Intended Audience :: Developers", "Programming Language :: Python :: 3.9", @@ -24,3 +28,6 @@ dependencies = [ "flatbuffers" ] +[project.urls] +"Repository" = "https://github.com/Samsung/ONE/tree/master/tools/model_explorer_circle/" +"Bug Reports" = "https://github.com/Samsung/ONE/issues" diff --git a/tools/model_explorer_circle/src/circle_adapter/main.py b/tools/model_explorer_circle/src/circle_adapter/main.py index 2f8c6a16d8b..bd843beada9 100644 --- a/tools/model_explorer_circle/src/circle_adapter/main.py +++ b/tools/model_explorer_circle/src/circle_adapter/main.py @@ -17,7 +17,7 @@ from typing import Dict, Optional from model_explorer import Adapter, AdapterMetadata, ModelExplorerGraphs, graph_builder -from circle_adapter import circle_schema_generated as circle_schema +from . import circle_schema_generated as circle_schema class CircleAdapter(Adapter):