Skip to content

Commit

Permalink
add retries to get_airfoil
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdavis committed Sep 3, 2024
1 parent 722c270 commit 2e65e01
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ install_requires =
decaf-synthetic-data>=0.1.6
optuna>=3.1
shap
tenacity
tqdm
loguru
pydantic<2.0
Expand Down
16 changes: 16 additions & 0 deletions tests/plugins/core/models/helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
# stdlib
import urllib.error

# third party
import pandas as pd
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed


@retry(
stop=stop_after_attempt(5), # Retry up to 5 times
wait=wait_fixed(2), # Wait 2 seconds between retries
retry=retry_if_exception_type(urllib.error.HTTPError), # Retry on HTTPError
)
def get_airfoil_dataset() -> pd.DataFrame:
"""
Downloads the Airfoil Self-Noise dataset and returns it as a DataFrame.
Returns:
pd.DataFrame: The Airfoil Self-Noise dataset.
"""
# Read the dataset from the URL
df = pd.read_csv(
"https://archive.ics.uci.edu/static/public/291/airfoil+self+noise.zip",
sep="\t",
Expand Down
14 changes: 14 additions & 0 deletions tests/plugins/domain_adaptation/da_helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# stdlib
import urllib.error
from typing import Dict, List, Type

# third party
import pandas as pd
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

# synthcity absolute
from synthcity.plugins import Plugin, Plugins
Expand All @@ -23,7 +25,19 @@ def from_serde() -> Plugin:
return [from_api(), from_module(), from_serde()]


@retry(
stop=stop_after_attempt(5), # Retry up to 5 times
wait=wait_fixed(2), # Wait 2 seconds between retries
retry=retry_if_exception_type(urllib.error.HTTPError), # Retry on HTTPError
)
def get_airfoil_dataset() -> pd.DataFrame:
"""
Downloads the Airfoil Self-Noise dataset and returns it as a DataFrame.
Returns:
pd.DataFrame: The Airfoil Self-Noise dataset.
"""
# Read the dataset from the URL
df = pd.read_csv(
"https://archive.ics.uci.edu/static/public/291/airfoil+self+noise.zip",
sep="\t",
Expand Down
14 changes: 14 additions & 0 deletions tests/plugins/generic/generic_helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# stdlib
import urllib.error
from typing import Dict, List, Optional, Type

# third party
import pandas as pd
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

# synthcity absolute
from synthcity.plugins import Plugin
Expand All @@ -29,7 +31,19 @@ def from_serde() -> Plugin:
return [from_api(), from_module(), from_serde()]


@retry(
stop=stop_after_attempt(5), # Retry up to 5 times
wait=wait_fixed(2), # Wait 2 seconds between retries
retry=retry_if_exception_type(urllib.error.HTTPError), # Retry on HTTPError
)
def get_airfoil_dataset() -> pd.DataFrame:
"""
Downloads the Airfoil Self-Noise dataset and returns it as a DataFrame.
Returns:
pd.DataFrame: The Airfoil Self-Noise dataset.
"""
# Read the dataset from the URL
df = pd.read_csv(
"https://archive.ics.uci.edu/static/public/291/airfoil+self+noise.zip",
sep="\t",
Expand Down
14 changes: 14 additions & 0 deletions tests/plugins/privacy/fhelpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# stdlib
import urllib.error
from typing import Dict, List, Type

# third party
import pandas as pd
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

# synthcity absolute
from synthcity.plugins import Plugin, Plugins
Expand All @@ -25,7 +27,19 @@ def from_serde() -> Plugin:
return [from_api(), from_module(), from_serde()]


@retry(
stop=stop_after_attempt(5), # Retry up to 5 times
wait=wait_fixed(2), # Wait 2 seconds between retries
retry=retry_if_exception_type(urllib.error.HTTPError), # Retry on HTTPError
)
def get_airfoil_dataset() -> pd.DataFrame:
"""
Downloads the Airfoil Self-Noise dataset and returns it as a DataFrame.
Returns:
pd.DataFrame: The Airfoil Self-Noise dataset.
"""
# Read the dataset from the URL
df = pd.read_csv(
"https://archive.ics.uci.edu/static/public/291/airfoil+self+noise.zip",
sep="\t",
Expand Down
16 changes: 16 additions & 0 deletions tests/utils/test_compression.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# stdlib
import urllib.error

# third party
import pandas as pd
from sklearn.datasets import load_diabetes
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

# synthcity absolute
from synthcity.utils.compression import compress_dataset, decompress_dataset


@retry(
stop=stop_after_attempt(5), # Retry up to 5 times
wait=wait_fixed(2), # Wait 2 seconds between retries
retry=retry_if_exception_type(urllib.error.HTTPError), # Retry on HTTPError
)
def get_airfoil_dataset() -> pd.DataFrame:
"""
Downloads the Airfoil Self-Noise dataset and returns it as a DataFrame.
Returns:
pd.DataFrame: The Airfoil Self-Noise dataset.
"""
# Read the dataset from the URL
df = pd.read_csv(
"https://archive.ics.uci.edu/static/public/291/airfoil+self+noise.zip",
sep="\t",
Expand Down

0 comments on commit 2e65e01

Please sign in to comment.