Skip to content

Commit

Permalink
reimplement tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kondratyevd committed Mar 5, 2024
1 parent 6ed6bdd commit 07fa3e1
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 142 deletions.
85 changes: 8 additions & 77 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- master

jobs:
default:
test-data-access:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -20,10 +20,10 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Default test
run: python3 af_benchmark/benchmark.py tests/test-default.yaml
- name: Run data access tests
run: python3 tests/test-data-access.py

read-from-dir:
test-executors:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -38,9 +38,9 @@ jobs:
run: pip install -r requirements.txt

- name:
run: python3 af_benchmark/benchmark.py tests/test-read-from-dir.yaml
run: python3 tests/test-executors.py

futures-executor:
test-processing:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -54,75 +54,6 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Test futures executor
run: python3 af_benchmark/benchmark.py tests/test-futures.yaml

dask-local-executor:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Test Dask executor (local)
run: python3 af_benchmark/benchmark.py tests/test-dask-local.yaml

explicit-columns:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Test explicit list of columns
run: python3 af_benchmark/benchmark.py tests/test-explicit-columns.yaml

read-by-file:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Test parallelization over files
run: python3 af_benchmark/benchmark.py tests/test-read-by-file.yaml

read-by-column:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Test parallelization over columns
run: python3 af_benchmark/benchmark.py tests/test-read-by-column.yaml

- name: Test processing
run: tests/test-processing.py

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
executor:
backend: sequential
data-access:
mode: explicit-files
files:
- tests/data/nano_dimuon.root
executor:
backend: sequential
processor:
parallelize_over: files
columns:
- event
- Muon_pt
columns: 5
operation: sum
10 changes: 0 additions & 10 deletions tests/test-dask-local.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions tests/test-data-access.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from utils import run_tests


def test_data_access_explicit_files(b):
b.config["data-access"]["mode"] = "explicit-files"
b.config["data-access"]["files"] = ["tests/data/nano_dimuon.root"]
b.run()
print(f"Successfully tested accessing data via explicing list of files")

def test_data_access_explicit_dirs(b):
b.config["data-access"]["mode"] = "explicit-dirs"
b.config["data-access"]["directories"] = ["tests/data/"]
b.run()
print(f"Successfully tested accessing data via explicing list of directories")


if __name__=='__main__':
run_tests(
config="tests/config-default.yaml",
functions=[
test_data_access_explicit_files,
test_data_access_explicit_dirs,
]
)

10 changes: 0 additions & 10 deletions tests/test-default.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions tests/test-executors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from utils import run_tests


def test_executor_sequential(b):
b.config["executor"]["backend"] = "sequential"
b.run()
print(f"Successfully tested sequential executor")

def test_executor_futures(b):
b.config["executor"]["backend"] = "futures"
b.run()
print(f"Successfully tested futures executor")

def test_executor_dask_local(b):
b.config["executor"]["backend"] = "dask-local"
b.config["executor"]["workers"] = 1
b.run()
print(f"Successfully tested dask-local executor")


if __name__=='__main__':
run_tests(
config="tests/config-default.yaml",
functions=[
test_executor_sequential,
test_executor_futures,
test_executor_dask_local
]
)


10 changes: 0 additions & 10 deletions tests/test-futures.yaml

This file was deleted.

73 changes: 73 additions & 0 deletions tests/test-processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from utils import run_tests


def test_processor_columns_explicit(b):
b.config["processor"]["columns"] = ["Muon_pt", "Muon_eta"]
b.run()
print(f"Successfully tested processing explicit list of columns")

def test_processor_columns_number(b):
b.config["processor"]["columns"] = 5
b.run()
print(f"Successfully tested processing given number of columns")

def test_processor_collections(b):
b.config["processor"]["columns"] = []
b.config["processor"]["collections"] = ["Muon"]
b.run()
print(f"Successfully tested processing a collection of columns")

def test_processor_operation_nothing(b):
b.config["processor"]["operation"] = "nothing"
b.run()
print(f"Successfully tested doing nothing to specified columns")

def test_processor_operation_load(b):
b.config["processor"]["operation"] = "load_into_memory"
b.run()
print(f"Successfully tested loading specified columns into memory")

def test_processor_parallelize_over_files(b):
b.config["processor"]["parallelize_over"] = "files"
b.config["executor"]["backend"] = "futures"
b.config["data-access"]["files"] = [
"tests/data/nano_dimuon.root",
"tests/data/nano_dimuon.root"
]
b.run()
print(f"Successfully tested parallelization over files")

def test_processor_parallelize_over_columns(b):
b.config["processor"]["parallelize_over"] = "columns"
b.config["executor"]["backend"] = "futures"
b.config["processor"]["columns"] = 2
b.run()
print(f"Successfully tested parallelization over files")

def test_processor_parallelize_over_files_and_columns(b):
b.config["processor"]["parallelize_over"] = "files_and_columns"
b.config["executor"]["backend"] = "futures"
b.config["data-access"]["files"] = [
"tests/data/nano_dimuon.root",
"tests/data/nano_dimuon.root"
]
b.config["processor"]["columns"] = 2
b.run()
print(f"Successfully tested parallelization over files and columns")


if __name__=='__main__':
run_tests(
config="tests/config-default.yaml",
functions=[
test_processor_columns_explicit,
test_processor_columns_number,
test_processor_collections,
test_processor_operation_nothing,
test_processor_operation_load,
test_processor_parallelize_over_files,
test_processor_parallelize_over_columns,
test_processor_parallelize_over_files_and_columns,
]
)

10 changes: 0 additions & 10 deletions tests/test-read-by-column.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions tests/test-read-by-file.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions tests/test-read-from-dir.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os, sys
sys.path.append(os.getcwd()+"/af_benchmark")
import copy
from benchmark import Benchmark

def run_tests(config, functions):
b = Benchmark(config)
for func in functions:
old_config = copy.deepcopy(b.config)
func(b)
b.reset()
b.config = old_config

0 comments on commit 07fa3e1

Please sign in to comment.