Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snakemake module #367

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 0 additions & 78 deletions .github/workflows/ci-linux.yaml

This file was deleted.

76 changes: 0 additions & 76 deletions .github/workflows/ci-mac.yaml

This file was deleted.

76 changes: 0 additions & 76 deletions .github/workflows/ci-windows.yaml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 5 * * TUE"

env:
CACHE_NUMBER: 2 # Change this value to manually reset the environment cache

jobs:
build:
strategy:
fail-fast: false
max-parallel: 3
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2

- name: Fill submodule
run: |
git submodule update --init

- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: latest
environment-file: pypsa-earth/envs/environment.yaml
log-level: debug
init-shell: bash
cache-environment: true
cache-downloads: true

- name: Set cache dates
run: |
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV

- name: Cache data and cutouts folders
uses: actions/cache@v3
with:
path: |
data
cutouts
key: data-cutouts-${{ env.WEEK }}-${{ env.CACHE_NUMBER }}


- name: Conda list
run: conda list

- name: Run Test
run: make test
14 changes: 7 additions & 7 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ jobs:
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: docker://ghcr.io/github/super-linter:slim-v4
env:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ data/costs*
/data/ports.csv
/data/energy_totals_DF_2030
/data/energy_totals_XX_2038
data/
data/osm/
data/raw/
data/base_network/

/data/airports.csv
/data/energy_totals_base.csv
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ repos:
rev: v1.33.0
hooks:
- id: yamllint
args: [--format, parsable, -c=.yamllint]
args: [-c=.yamllint]

# Format Snakemake rule / workflow files
- repo: https://github.com/snakemake/snakefmt
Expand Down
9 changes: 4 additions & 5 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ extends: default

rules:
braces:
# Do not allow flow mappings using curly braces "{" and "}"
forbid: true
forbid: false
brackets:
max-spaces-inside: 0
max-spaces-inside-empty: 0
comments:
require-starting-space: true
min-spaces-from-content: 2
require-starting-space: false
min-spaces-from-content: 0
# Force correct indentation of comments
# yamllint disable-line rule:braces
comments-indentation: {}
Expand All @@ -35,7 +34,7 @@ rules:
key-duplicates: {}
line-length:
level: warning
max: 88
max: 350
new-line-at-end-of-file: enable
truthy:
check-keys: false # Disable truthy check hits on keys like "on": ...
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: PyPSA-Earth and PyPSA-Eur Authors
#
# SPDX-License-Identifier: AGPL-3.0-or-later

.PHONY: test setup clean

test:
set -e
snakemake -c4 solve_sector_networks --configfile pypsa-earth/config.tutorial.yaml test/config.test1.yaml
echo "All tests completed successfully."

setup:
# Add setup commands here
echo "Setup complete."

clean:
# Add clean-up commands here
snakemake -j1 solve_sector_networks --delete-all-output --configfile test/config.test1.yaml
echo "Clean-up complete."
Loading
Loading