Skip to content

Use CUDA_VISIBLE_DEVICES by default #2899

Use CUDA_VISIBLE_DEVICES by default

Use CUDA_VISIBLE_DEVICES by default #2899

Workflow file for this run

name: build package & server
on:
pull_request:
push:
branches: [master]
jobs:
python-test:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.9", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch==1.13.0 hatchling==1.25.0
- name: Test package
run: |
hatch run +py=${{ matrix.python-version }} test:package
build-conda:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
- name: set version
run: |
python3 .github/pyproject_versions.py --replace True
- name: Build conda package
uses: prefix-dev/rattler-build-action@v0.2.16
with:
build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld
recipe-path: .conda/recipe.yaml
upload-artifact: false
test-conda:
runs-on: ubuntu-24.04
needs: [ build-conda ]
steps:
# Checkout needed to get github.sha
- uses: actions/checkout@v4
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: codecarbon
miniforge-version: latest
python-version: 3.12
use-mamba: true
- name: Restore build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
fail-on-cache-miss: true
- name: Install package
shell: bash -l {0}
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
- name: Test conda package
shell: bash -l {0}
run: codecarbon --help
build_server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Clean pip cache
run: pip cache purge
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Unit tests on api
run: |
pip install hatch==1.13.0 hatchling==1.25.0
# hatch run api:test-unit
test_api_server:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:16
# Provide the password for postgres
env:
POSTGRES_DB: codecarbon_db
POSTGRES_PASSWORD: supersecret
POSTGRES_USER: codecarbon-user
POSTGRES_HOST: localhost
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5480:5432
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v4
# Performs a clean installation of all dependencies
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch==1.13.0 hatchling==1.25.0
- name: Setup PostgreSQL
# Runs a script that creates a PostgreSQL table, populates
# the table with data, and then retrieves the data.
run: hatch run api:setup-db
env:
# The hostname used to communicate with the PostgreSQL service container
DATABASE_URL: postgresql://codecarbon-user:supersecret@localhost:5480/codecarbon_db
- name: Run API tests
env:
CODECARBON_API_URL: http://localhost:8008
# The hostname used to communicate with the PostgreSQL service container
DATABASE_URL: postgresql://codecarbon-user:supersecret@localhost:5480/codecarbon_db
run: |
# hatch run api:server-ci &
sleep 2
# netstat -o -n -a | grep 8008
# hatch run api:test-integ
build-ui:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
working-directory: ./webapp
run: npm ci
- name: Build
working-directory: ./webapp
run: npm run build
- name: Check formatting with Prettier
working-directory: ./webapp
run: npx prettier . --check