From 7c0dc2eb69a233dc8a8d7a601bd1ea7623f339b5 Mon Sep 17 00:00:00 2001 From: jacek-oet Date: Mon, 23 Sep 2024 20:21:01 +0200 Subject: [PATCH] feat: add snakemake container to workflow --- .github/workflows/ci.yaml | 28 --------------- .github/workflows/generate_nc_files.yml | 45 ++++++------------------- 2 files changed, 11 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 44f6770..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: CI - -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [main] - pull_request: - branches: [main] - # Allows you to run this workflow manually from the Actions tab - # workflow_dispatch: - -jobs: - CI: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Check code formatting - run: | - python -m venv /tmp/venv - pip install --upgrade pip pre-commit - pre-commit install - pre-commit run --all-files diff --git a/.github/workflows/generate_nc_files.yml b/.github/workflows/generate_nc_files.yml index 66fa044..cd91430 100644 --- a/.github/workflows/generate_nc_files.yml +++ b/.github/workflows/generate_nc_files.yml @@ -9,48 +9,25 @@ on: jobs: generate_nc_files: runs-on: ubuntu-latest - container: - image: mambaorg/micromamba:latest # Use a Docker image with micromamba + container: snakemake/snakemake:v8.20.4 # Use the Docker container for the entire job + steps: - name: Checkout Repositories uses: actions/checkout@v2 with: fetch-depth: 0 # Fetch all history for versioning - - name: Install Git - run: | - apt-get update && apt-get install -y git - - - name: Clone PyPSA-Eur + - name: Clone PyPSA-eur Repository run: | - git clone --branch master https://github.com/PyPSA/pypsa-eur.git - cd pypsa-eur - git checkout a69373b9 + git clone --branch master https://github.com/PyPSA/pypsa-eur.git + cd pypsa-eur + git checkout a69373b9 - - name: Set Up Conda Environment + - name: Set Up Environment run: | - micromamba create -f envs/environment.yaml -n pypsa-eur - micromamba activate pypsa-eur - micromamba install -y -n pypsa-eur python=3.8 # Ensure python version - micromamba run -n pypsa-eur pip install git+https://github.com/open-energy-transition/linopy.git@only-generate-problem-files --no-deps + cd pypsa-eur - - name: Run Snakemake Commands - run: | - cd pypsa-eur - micromamba run -n pypsa-eur time snakemake -call all --cores all --printshellcmds --configfile ~/code/solver-benchmark/benchmarks/pypsa/pypsa-eur-sec-2-lv1-3h.yaml - micromamba run -n pypsa-eur time snakemake -call solve_elec_networks --cores all --printshellcmds --configfile ~/code/solver-benchmark/benchmarks/pypsa/pypsa-eur-elec-10-lvopt-3h.yaml - micromamba run -n pypsa-eur time snakemake -call results/networks/elec_s_20_ec_lv1_24h_op.nc --cores all --printshellcmds --configfile ~/code/solver-benchmark/benchmarks/pypsa/pypsa-eur-elec-20-lv1-3h-op.yaml - micromamba run -n pypsa-eur time snakemake -call results/networks/elec_s_20_ec_lv1_24h_op.nc --cores all --printshellcmds --configfile ~/code/solver-benchmark/benchmarks/pypsa/pypsa-eur-elec-20-lv1-3h-op-ucconv.yaml - micromamba run -n pypsa-eur time python pypsa-wind+sol+ely-1h-ucwind.py - micromamba run -n pypsa-eur time python pypsa-wind+sol+ely-1h.py + micromamba env create -f envs/environment.yaml --yes + micromamba run -n pypsa-eur pip install git+https://github.com/open-energy-transition/linopy.git@only-generate-problem-files --no-deps + micromamba run -n pypsa-eur snakemake results/networks/elec_s_20_ec_lv1_3h_op.nc --cores all --printshellcmds --configfile ../benchmarks/pypsa/pypsa-eur-elec-20-lv1-3h-op.yaml ; echo -e '\a' - - name: Copy NC Files - run: | - # Replace this with the actual path to your NC file - cp /tmp/linopy-problem-*.nc ~/code/solver-benchmarks/runner/benchmarks/ - - - name: Upload Artifacts - uses: actions/upload-artifact@v2 - with: - name: nc-files - path: ~/code/solver-benchmarks/runner/benchmarks/*.nc