Skip to content

run pytest against nightly #238

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

Merged
merged 4 commits into from
Sep 3, 2022
Merged
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
35 changes: 35 additions & 0 deletions .github/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Install project dependencies

inputs:
python-version:
required: true
os:
required: true

runs:
using: composite
steps:

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install Poetry
shell: bash
run: python -m pip install poetry

- name: Determine poetry version
shell: bash
run: echo "::set-output name=VERSION::$(poetry --version)"
id: poetry_version

- name: Cache poetry.lock
uses: actions/cache@v3
with:
path: poetry.lock
key: ${{ inputs.os }}-${{ inputs.python-version }}-poetry-${{ steps.poetry_version.outputs.VERSION }}-${{ hashFiles('pyproject.toml') }}

- name: Install project dependencies
shell: bash
run: poetry install -vvv --no-root
55 changes: 30 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'Test'
on:
[push, pull_request, workflow_dispatch]
jobs:
test:
released:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
Expand All @@ -13,34 +13,17 @@ jobs:
python-version: ['3.8', '3.9', '3.10']

steps:

- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Install project dependencies
uses: ./.github/setup
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: pip install poetry

- name: Determine poetry version
run: echo "::set-output name=VERSION::$(poetry --version)"
id: poetry_version

- name: Cache poetry.lock
uses: actions/cache@v3
with:
path: poetry.lock
key: ${{ matrix.os }}-${{ matrix.python-version }}-poetry-${{ steps.poetry_version.outputs.VERSION }}-${{ hashFiles('pyproject.toml') }}

- name: Install project dependencies
run: poetry install -vvv --no-root

- name: Show poetry python location (Windows)
shell: pwsh
run: |
poetry run where python
run: poetry run where python
if: matrix.os == 'windows-latest'

- name: Run mypy on 'tests' (using the local stubs) and on the local stubs
Expand All @@ -52,8 +35,30 @@ jobs:
- name: Run pytest
run: poetry run poe pytest

- if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
uses: pre-commit/action@v3.0.0

- name: Install pandas-stubs and run tests on the installed stubs
run: poetry run poe test_dist

nightly:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: '3.10'

- name: Run pytest (against pandas nightly)
run: poetry run poe pytest --nightly

precommit:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3

- uses: pre-commit/action@v3.0.0
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ script = "scripts.test:test(dist=True)"

[tool.poe.tasks.pytest]
help = "Run pytest"
script = "scripts.test.run:pytest"
script = "scripts.test:pytest(nightly)"
args = [{name = "nightly", positional = false, default = false, type = "boolean", required = false, help= "Use pandas nightly (off by default)"}]

[tool.poe.tasks.style]
help = "Run pre-commit"
Expand Down
5 changes: 5 additions & 0 deletions scripts/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ def stubtest(allowlist: str, check_missing: bool, nightly: bool) -> None:
if nightly:
steps.append(_step.nightly)
run_job(steps + [stubtest])


def pytest(nightly: bool) -> None:
steps = [_step.nightly] if nightly else []
run_job(steps + [_step.pytest])
19 changes: 12 additions & 7 deletions scripts/test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def pyright_src():


def pytest():
cmd = ["pytest", "--cache-clear"]
cmd = ["pytest", "--cache-clear", "-Werror"]
subprocess.run(cmd, check=True)


Expand Down Expand Up @@ -81,22 +81,27 @@ def restore_src():


def nightly_pandas():
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas"]
subprocess.run(cmd, check=True)
cmd = [
sys.executable,
"-m",
"pip",
"install",
"-i",
"--use-deprecated=legacy-resolver",
"--upgrade",
"--index-url",
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
"pandas",
]
subprocess.run(cmd, check=True)


def released_pandas():
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas"]
subprocess.run(cmd, check=True)
cmd = [sys.executable, "-m", "pip", "install", "pandas"]
# query pandas version
text = Path("pyproject.toml").read_text()
version_line = next(
line for line in text.splitlines() if line.startswith("pandas = ")
)
version = version_line.split('"')[1]

cmd = [sys.executable, "-m", "pip", "install", f"pandas=={version}"]
subprocess.run(cmd, check=True)
24 changes: 11 additions & 13 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,10 @@ def test_types_to_csv() -> None:

def test_types_to_csv_when_path_passed() -> None:
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
path: Path = Path("./dummy_path.txt")
try:
assert not path.exists()
with ensure_clean() as file:
path = Path(file)
df.to_csv(path)
df5: pd.DataFrame = pd.read_csv(path)
finally:
path.unlink()


def test_types_copy() -> None:
Expand Down Expand Up @@ -788,16 +785,17 @@ def test_to_markdown() -> None:
def test_types_to_feather() -> None:
pytest.importorskip("pyarrow")
df = pd.DataFrame(data={"col1": [1, 1, 2], "col2": [3, 4, 5]})
df.to_feather("dummy_path")
# kwargs for pyarrow.feather.write_feather added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
df.to_feather("dummy_path", compression="zstd", compression_level=3, chunksize=2)

# to_feather has been able to accept a buffer since pandas 1.0.0
# See https://pandas.pydata.org/docs/whatsnew/v1.0.0.html
# Docstring and type were updated in 1.2.0.
# https://github.com/pandas-dev/pandas/pull/35408
with ensure_clean() as path:
df.to_feather(path)
# kwargs for pyarrow.feather.write_feather added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
df.to_feather(path, compression="zstd", compression_level=3, chunksize=2)

# to_feather has been able to accept a buffer since pandas 1.0.0
# See https://pandas.pydata.org/docs/whatsnew/v1.0.0.html
# Docstring and type were updated in 1.2.0.
# https://github.com/pandas-dev/pandas/pull/35408
with open(path, mode="wb") as file:
df.to_feather(file)


# compare() method added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
Expand Down
40 changes: 24 additions & 16 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,43 +163,51 @@ def test_clipboard_iterator():
def test_sas_bdat() -> None:
path = pathlib.Path(CWD, "data", "airline.sas7bdat")
check(assert_type(read_sas(path), DataFrame), DataFrame)
check(
with check(
assert_type(read_sas(path, iterator=True), Union[SAS7BDATReader, XportReader]),
SAS7BDATReader,
)
check(
):
pass
with check(
assert_type(read_sas(path, iterator=True, format="sas7bdat"), SAS7BDATReader),
SAS7BDATReader,
)
check(
):
pass
with check(
assert_type(read_sas(path, chunksize=1), Union[SAS7BDATReader, XportReader]),
SAS7BDATReader,
)
check(
):
pass
with check(
assert_type(read_sas(path, chunksize=1, format="sas7bdat"), SAS7BDATReader),
SAS7BDATReader,
)
):
pass


def test_sas_xport() -> None:
path = pathlib.Path(CWD, "data", "SSHSV1_A.xpt")
check(assert_type(read_sas(path), DataFrame), DataFrame)
check(
with check(
assert_type(read_sas(path, iterator=True), Union[SAS7BDATReader, XportReader]),
XportReader,
)
check(
):
pass
with check(
assert_type(read_sas(path, iterator=True, format="xport"), XportReader),
XportReader,
)
check(
):
pass
with check(
assert_type(read_sas(path, chunksize=1), Union[SAS7BDATReader, XportReader]),
XportReader,
)
check(
):
pass
with check(
assert_type(read_sas(path, chunksize=1, format="xport"), XportReader),
XportReader,
)
):
pass


def test_hdf():
Expand Down