Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdavis committed Sep 13, 2024
1 parent 8423cdb commit 918a664
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 204 deletions.
31 changes: 7 additions & 24 deletions .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,58 +37,41 @@ jobs:
strategy:
matrix:
python-version: ["3.11"]
os: [macos-latest, ubuntu-latest]
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install libomp (macOS only)
run: |
brew install libomp
if: ${{ runner.os == 'macOS' }}

- name: Set libomp environment variables (macOS only)
run: |
brew install libomp
LIBOMP_PATH="/opt/homebrew/opt/libomp"
echo "LDFLAGS=-L${LIBOMP_PATH}/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I${LIBOMP_PATH}/include" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${LIBOMP_PATH}/lib:\$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
echo "OMP_PATH=${LIBOMP_PATH}/include" >> $GITHUB_ENV
if: ${{ runner.os == 'macOS' }}

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -r prereq.txt
pip install pytest-timeout
- name: Dump GitHub Action environment
run: |
echo "OS: $(uname -a)"
python --version
pip freeze
- name: Limit OpenMP threads
run: |
echo "OMP_NUM_THREADS=2" >> $GITHUB_ENV
# - name: Test Core
# run: |
# pip install .[testing]
# pip freeze
# pytest -vvvsx --timeout=2000 --timeout-method=thread -m "not slow" --durations=50
- name: Test Core
run: |
pip install .[testing]
pip freeze
pytest -vvvsx -m "not slow" --durations=50
- name: Set macOS deployment target
run: |
echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV
if: ${{ runner.os == 'macOS' }}

- name: Test GOGGLE
run: |
pip install .[testing,goggle]
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ testing =
nbformat
pytest-benchmark
pytest-xdist[psutil]
pytest_timeout
pytest-xprocess
igraph
py # pytest 7.2.0 bug https://github.com/pytest-dev/pytest-xprocess/issues/110
Expand Down
2 changes: 1 addition & 1 deletion src/synthcity/metrics/eval_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ def evaluate(
model = XGBClassifier(
tree_method="approx",
n_jobs=2,
verbosity=2,
verbosity=0,
depth=3,
random_state=self._random_state,
)
Expand Down
2 changes: 1 addition & 1 deletion src/synthcity/utils/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def compress_dataset(
model = model = XGBClassifier(
tree_method="approx",
n_jobs=2,
verbosity=2,
verbosity=0,
depth=3,
)
try:
Expand Down
10 changes: 0 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,3 @@ def run_before_tests() -> Generator:
workspace = Path("workspace")
if workspace.exists():
shutil.rmtree(workspace, ignore_errors=True)


# Hook to modify the test result if it exceeds a timeout
def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo) -> None:
"""Modify the test result if it exceeds the timeout to skip instead of failing."""
if call.when == "call" and call.excinfo is not None:
print(f"Call info: {call}")
# Check if the test was stopped due to a timeout using call.result
if "Timeout" in str(call.excinfo.value):
pytest.skip(f"Test skipped due to exceeding the timeout: {item.nodeid}")
6 changes: 0 additions & 6 deletions tests/metrics/test_attacks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# stdlib
import sys
from typing import Type

# third party
Expand All @@ -16,7 +15,6 @@
from synthcity.plugins.core.dataloader import GenericDataLoader


@pytest.mark.skipif(sys.platform == "darwin", reason="Test skipped on MacOS")
@pytest.mark.parametrize("reduction", ["mean", "max", "min"])
@pytest.mark.parametrize(
"evaluator_t",
Expand Down Expand Up @@ -54,10 +52,6 @@ def test_reduction(reduction: str, evaluator_t: Type) -> None:
assert def_score == score[reduction]


@pytest.mark.skipif(
sys.platform == "darwin",
reason="Test skipped on MacOS",
)
@pytest.mark.parametrize(
"evaluator_t",
[
Expand Down
15 changes: 2 additions & 13 deletions tests/metrics/test_detection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# stdlib
import os
import sys
from pathlib import Path
from typing import Type

# third party
Expand Down Expand Up @@ -173,17 +171,8 @@ def test_detect_synth_timeseries(test_plugin: Plugin, evaluator_t: Type) -> None
@pytest.mark.slow_1
@pytest.mark.slow
def test_image_support_detection() -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)

dataset = datasets.MNIST(".", download=True)

X1 = ImageDataLoader(dataset).sample(100)
X2 = ImageDataLoader(dataset).sample(100)
Expand Down
15 changes: 2 additions & 13 deletions tests/metrics/test_performance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# stdlib
import os
import sys
from pathlib import Path
from typing import Optional, Type

# third party
Expand Down Expand Up @@ -484,17 +482,8 @@ def test_evaluate_performance_time_series_survival(
@pytest.mark.slow_1
@pytest.mark.slow
def test_image_support_perf() -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)

dataset = datasets.MNIST(".", download=True)

X1 = ImageDataLoader(dataset).sample(100)
X2 = ImageDataLoader(dataset).sample(100)
Expand Down
13 changes: 1 addition & 12 deletions tests/metrics/test_privacy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# stdlib
import os
import sys
from pathlib import Path
from typing import Type

# third party
Expand Down Expand Up @@ -86,17 +84,8 @@ def test_evaluator(evaluator_t: Type, test_plugin: Plugin) -> None:

@pytest.mark.skipif(sys.platform != "linux", reason="Linux only for faster results")
def test_image_support() -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)
dataset = datasets.MNIST(".", download=True)

X1 = ImageDataLoader(dataset).sample(100)
X2 = ImageDataLoader(dataset).sample(100)
Expand Down
15 changes: 2 additions & 13 deletions tests/metrics/test_sanity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# stdlib
import os
import sys
from pathlib import Path
from typing import Callable, Tuple

# third party
Expand Down Expand Up @@ -199,17 +197,8 @@ def test_evaluate_distant_values(test_plugin: Plugin) -> None:

@pytest.mark.skipif(sys.platform != "linux", reason="Linux only for faster results")
def test_image_support() -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)

dataset = datasets.MNIST(".", download=True)

X1 = ImageDataLoader(dataset).sample(100)
X2 = ImageDataLoader(dataset).sample(100)
Expand Down
15 changes: 2 additions & 13 deletions tests/metrics/test_statistical.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# stdlib
import os
import sys
from pathlib import Path
from typing import Any, Tuple, Type

# third party
Expand Down Expand Up @@ -289,17 +287,8 @@ def test_evaluate_survival_km_distance(test_plugin: Plugin) -> None:

@pytest.mark.skipif(sys.platform != "linux", reason="Linux only for faster results")
def test_image_support() -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)

dataset = datasets.MNIST(".", download=True)

X1 = ImageDataLoader(dataset).sample(100)
X2 = ImageDataLoader(dataset).sample(100)
Expand Down
16 changes: 1 addition & 15 deletions tests/plugins/core/models/test_convnet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# stdlib
import os
from pathlib import Path

# third party
import numpy as np
import pytest
Expand Down Expand Up @@ -67,17 +63,7 @@ def test_train_clf() -> None:
transforms.Normalize(mean=(0.5,), std=(0.5,)),
]
)
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True, transform=data_transform)
else:
dataset = datasets.MNIST(mnist_dir, train=True, transform=data_transform)
dataset = datasets.MNIST(".", download=True, transform=data_transform)
dataset = Subset(dataset, np.arange(len(dataset))[:100])

classes = 10
Expand Down
14 changes: 1 addition & 13 deletions tests/plugins/core/models/test_image_gan.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# stdlib
import os
from pathlib import Path

# third party
import numpy as np
import pytest
Expand Down Expand Up @@ -30,15 +26,7 @@
# Load MNIST dataset as tensors
batch_size = 128

# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv("MNIST_DATA_DIR", ".") # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True, transform=data_transform)
else:
dataset = datasets.MNIST(mnist_dir, train=True, transform=data_transform)
dataset = datasets.MNIST(".", download=True, transform=data_transform)

dataset = Subset(dataset, np.arange(len(dataset))[:100])
dataset = FlexibleDataset(dataset)
Expand Down
28 changes: 4 additions & 24 deletions tests/plugins/core/test_dataloader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# stdlib
import os
import sys
from datetime import datetime
from pathlib import Path
from typing import Any

# third party
Expand Down Expand Up @@ -642,17 +640,8 @@ def test_time_series_survival_pack_unpack_padding(as_numpy: bool) -> None:
@pytest.mark.parametrize("height", [55, 64])
@pytest.mark.parametrize("width", [32, 22])
def test_image_dataloader_sanity(height: int, width: int) -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)

dataset = datasets.MNIST(".", download=True)

loader = ImageDataLoader(
data=dataset,
Expand Down Expand Up @@ -693,17 +682,8 @@ def test_image_dataloader_sanity(height: int, width: int) -> None:

@pytest.mark.skipif(sys.platform != "linux", reason="Linux only for faster results")
def test_image_dataloader_create_from_info() -> None:
# Get the MNIST dataset directory from an environment variable
mnist_dir = os.getenv(
"MNIST_DATA_DIR", "."
) # Default to current directory if not set

# Check if the MNIST dataset is already downloaded
mnist_path = Path(mnist_dir) / "MNIST" / "processed"
if not mnist_path.exists():
dataset = datasets.MNIST(mnist_dir, download=True)
else:
dataset = datasets.MNIST(mnist_dir, train=True)

dataset = datasets.MNIST(".", download=True)

loader = ImageDataLoader(
data=dataset,
Expand Down
Loading

0 comments on commit 918a664

Please sign in to comment.