diff --git a/.forgejo/workflows/docker.yml b/.forgejo/workflows/docker.yml new file mode 100644 index 0000000..2ff9932 --- /dev/null +++ b/.forgejo/workflows/docker.yml @@ -0,0 +1,57 @@ +name: Publish on DockerHub + +on: + push: + tags: ['*'] + workflow_dispatch: + +jobs: + publish: + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v4 + + # The `docker` runner image is node-based and may not ship the docker CLI + # that the docker/* actions below drive; install it idempotently, as the + # sibling repos do for their Docker jobs. + - name: Ensure Docker CLI + run: | + set -eux + if ! command -v docker >/dev/null 2>&1; then + ARCH=$(uname -m) + curl -fsSL --retry 3 --retry-connrefused \ + "https://download.docker.com/linux/static/stable/${ARCH}/docker-27.5.1.tgz" \ + | tar xz --strip-components=1 -C /usr/local/bin docker/docker + fi + docker --version + + # Marketplace actions must be referenced by full URL: this instance's + # DEFAULT_ACTIONS_URL points at code.forgejo.org, so only bare `actions/*` + # names resolve to GitHub automatically. + - name: Set up QEMU + uses: https://github.com/docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: https://github.com/docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: https://github.com/docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata for the Docker image + id: meta + uses: https://github.com/docker/metadata-action@v5 + with: + images: schmelczera/great-ai + + - name: Build and push + uses: https://github.com/docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/.forgejo/workflows/docs.yml b/.forgejo/workflows/docs.yml new file mode 100644 index 0000000..973ab3a --- /dev/null +++ b/.forgejo/workflows/docs.yml @@ -0,0 +1,52 @@ +name: Publish documentation + +on: + push: + branches: [main] + paths: + - 'docs/**' + - 'great_ai/**' + - 'mkdocs.yaml' + - '.forgejo/workflows/docs.yml' + workflow_dispatch: + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + publish: + runs-on: docker + steps: + - uses: actions/checkout@v4 + with: + # The mkdocs git-revision-date plugin reads each page's git history. + fetch-depth: 0 + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Set up Python + run: uv python install 3.10 + + - name: Install dependencies + run: | + uv venv --python 3.10 + uv pip install '.[dev]' + + - name: Build documentation + run: | + . .venv/bin/activate + mkdocs build + + # The old workflow ran `mkdocs gh-deploy` (GitHub Pages); on this instance + # built sites are rsynced into the host /pages mount that nginx serves, + # via the shared ci-actions/deploy-pages action — same as photos/reconcile. + - name: Deploy to pages mount + if: github.ref == 'refs/heads/main' + uses: http://forgejo:3000/andras/ci-actions/deploy-pages@main + with: + source: site + target: great-ai diff --git a/.forgejo/workflows/publish.yml b/.forgejo/workflows/publish.yml new file mode 100644 index 0000000..8042684 --- /dev/null +++ b/.forgejo/workflows/publish.yml @@ -0,0 +1,28 @@ +name: Publish on PyPI + +on: + push: + tags: ['*'] + workflow_dispatch: + +jobs: + publish: + runs-on: docker + steps: + - uses: actions/checkout@v4 + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Set up Python + run: uv python install 3.10 + + # Forgejo cannot use PyPI trusted publishing (OIDC), so authenticate with + # an API token, the same way the sibling repos publish their packages. + - name: Build and publish + env: + FLIT_USERNAME: __token__ + FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: uvx flit publish diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml new file mode 100644 index 0000000..bc632df --- /dev/null +++ b/.forgejo/workflows/test.yml @@ -0,0 +1,73 @@ +name: Check + +on: + push: + branches: [main, dev] + pull_request: + branches: [main, dev] + workflow_dispatch: + +concurrency: + group: ${{ gitea.workflow }}-${{ gitea.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Lint, format & type checks + runs-on: docker + steps: + - uses: actions/checkout@v4 + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Set up Python + run: uv python install 3.10 + + - name: Install dependencies + # --seed gives the venv its own pip, which scripts/check-python.sh shells + # out to for its linters; '.[dev]' provides the rest (mypy resolves the + # package's own imports against the installed tree). + run: | + uv venv --seed --python 3.10 + uv pip install '.[dev]' + + - name: Check code and formatting + run: | + . .venv/bin/activate + scripts/check-python.sh great_ai tests + + test: + name: Test on Python ${{ matrix.python-version }} + runs-on: docker + strategy: + fail-fast: false + matrix: + # pyproject declares >= 3.7, but uv's standalone CPython and the current + # dependency floors (scikit-learn/numpy now require >= 3.9) no longer + # build on 3.7/3.8. Re-add those rows if the constraints are relaxed. + # The windows leg of the old GitHub matrix is dropped: this Forgejo + # instance only has a Linux `docker` runner. + python-version: ['3.9', '3.10'] + steps: + - uses: actions/checkout@v4 + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: | + uv venv --python ${{ matrix.python-version }} + uv pip install '.[dev]' + + - name: Run tests + run: | + . .venv/bin/activate + pytest --doctest-modules --asyncio-mode=strict diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 1230149..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 46492bc..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: analyse with CodeQL - -on: - push: - branches: - - main - pull_request: - branches: - - main - schedule: - - cron: '45 13 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: - - python - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index ef488e2..0000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: publish on DockerHub - -on: - push: - tags: - - '*' - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Checkout - uses: actions/checkout@v3 - - - name: Extract metadata for the Docker image - id: meta - uses: docker/metadata-action@v4 - with: - images: schmelczera/great-ai - - - name: Build and push - uses: docker/build-push-action@v3 - with: - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml deleted file mode 100644 index 1f26dd0..0000000 --- a/.github/workflows/docs.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: publish documentation - -on: - workflow_dispatch: - push: - branches: - - main - - dev - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - name: Install dependencies - run: pip install --upgrade './[dev]' - - - name: Build documentation - run: mkdocs gh-deploy diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index aa13970..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: publish on PyPI - -on: - push: - tags: - - '*' - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - name: Install Flit - run: pip install --upgrade flit --user - - - name: Build and publish - run: flit publish --setup-py - env: - FLIT_USERNAME: __token__ - FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index dab6f73..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: tests - -on: - workflow_dispatch: - push: - branches: - - main - - dev - -jobs: - test: - name: Build and test on ${{ matrix.operating-system }} with Python ${{ matrix.python-version }} - - strategy: - matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] - operating-system: [windows-latest, ubuntu-latest] - - runs-on: ${{ matrix.operating-system }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - pip install --upgrade './[dev]' - - - name: Check code and formatting - run: scripts/check-python.sh great_ai tests - - - name: Run tests - run: python3 -m pytest --doctest-modules --cov=. --cov-report=xml --junit-xml pytest.xml --asyncio-mode=strict || true - - - name: Upload results - if: always() - uses: actions/upload-artifact@v3 - with: - name: Unit test coverage (Python ${{ matrix.python-version }} - ${{ matrix.operating-system }}) - path: "*.xml" - - sonar: - name: Analyse Python project with SonarQube - needs: test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --upgrade . - rm -rf build - - - name: Download test results - uses: actions/download-artifact@v3 - with: - path: artifacts - - - uses: sonarsource/sonarqube-scan-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - with: - args: > - -Dsonar.projectKey=great-ai - -Dsonar.login=${{ secrets.SONAR_TOKEN }} - -Dsonar.verbose=true - -Dsonar.python.coverage.reportPaths=artifacts/*/coverage.xml - -Dsonar.coverage.exclusions=**/external/**/* - -Dsonar.exclusions=**/external/**/*,artifacts/**/* - - publish-test-results: - name: Publish unit test results - needs: test - runs-on: ubuntu-latest - if: always() - steps: - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Publish results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - files: artifacts/*/pytest.xml diff --git a/great_ai/utilities/parallel_map/parallel_map.py b/great_ai/utilities/parallel_map/parallel_map.py index bb4dd0d..fa109a5 100644 --- a/great_ai/utilities/parallel_map/parallel_map.py +++ b/great_ai/utilities/parallel_map/parallel_map.py @@ -147,7 +147,7 @@ def parallel_map( serialized_map_function = dill.dumps(func, byref=True, recurse=False) processes = [ - ctx.Process( # type: ignore + ctx.Process( name=f"parallel_map_{config.function_name}_{i}", target=mapper_function, daemon=True,