Skip to content

Commit 5cec1ea

Browse files
authored
chore: add license header to all file + CI GH action check (#1599)
* added licence comment on correctors.py * added licence comments to various files * added licence comment on ratio_estimators.py * added licence comment to various files * added licence comment to tests/ files * added licence comment to __init__ module files * added check on headers as a CI step within github workflows * fix: fixed debugging output in CI script for checking licence headers * Moved license-check to separate file
1 parent 196c106 commit 5cec1ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+229
-2
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: License Header Check
2+
3+
on: [pull_request, workflow_dispatch]
4+
5+
defaults:
6+
run:
7+
shell: bash
8+
9+
jobs:
10+
check-license-headers:
11+
name: Check License Headers
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
lfs: false
20+
21+
- name: Check license headers
22+
run: |
23+
expected_header_1="# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed"
24+
expected_header_2="# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>"
25+
26+
invalid_files=()
27+
28+
while IFS= read -r file; do
29+
file_header_1=$(head -n 1 "$file")
30+
file_header_2=$(head -n 2 "$file" | tail -n 1)
31+
32+
invalid=false
33+
34+
# Check the first line
35+
if [ "$file_header_1" != "$expected_header_1" ]; then
36+
invalid=true
37+
fi
38+
39+
# Check the second line
40+
if [ "$file_header_2" != "$expected_header_2" ]; then
41+
invalid=true
42+
fi
43+
44+
# If either line is invalid, add to the list
45+
if [ "$invalid" = true ]; then
46+
invalid_files+=("$file")
47+
fi
48+
49+
done < <(find sbi tests -name "*.py" -type f)
50+
51+
# Report results
52+
if [ ${#invalid_files[@]} -ne 0 ]; then
53+
echo "❌ Missing or incorrect license headers in the following files:"
54+
for file in "${invalid_files[@]}"; do
55+
echo " $file"
56+
done
57+
echo "Make sure the following two lines are provided and correctly spelled at the very start of all above listed files"
58+
echo "$expected_header_1"
59+
echo "$expected_header_2"
60+
exit 1
61+
else
62+
echo "✅ All files have the correct license headers."
63+
exit 0
64+
fi

sbi/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.__version__ import __version__ # noqa: F401

sbi/analysis/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.analysis.conditional_density import (
25
ConditionedMDN,
36
conditional_corrcoeff,

sbi/diagnostics/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.diagnostics.lc2st import LC2ST
25
from sbi.diagnostics.misspecification import (
36
calc_misspecification_logprob,

sbi/diagnostics/tarp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
"""
25
Implementation taken from Lemos et al, 'Sampling-Based Accuracy Testing of
36
Posterior Estimators for General Inference' https://arxiv.org/abs/2302.03026

sbi/examples/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.examples.minimal import flexible, simple

sbi/examples/minimal.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
import torch
25

36
from sbi.inference import SNPE, infer, simulate_for_sbi

sbi/inference/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.inference.abc import MCABC, SMCABC
25
from sbi.inference.trainers.base import (
36
NeuralInference, # noqa: F401

sbi/inference/abc/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.inference.abc.mcabc import MCABC
25
from sbi.inference.abc.smcabc import SMCABC
36

sbi/inference/posteriors/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
2+
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
3+
14
from sbi.inference.posteriors.direct_posterior import DirectPosterior
25
from sbi.inference.posteriors.ensemble_posterior import EnsemblePosterior
36
from sbi.inference.posteriors.importance_posterior import ImportanceSamplingPosterior

0 commit comments

Comments
 (0)