Skip to content

Commit

Permalink
Improve CI (#102)
Browse files Browse the repository at this point in the history
* update pytest

* update deps

* add pre-commit

* apply pre-commit

* update CI script + improve pytest support

* update flaky limit for test_concat_basic

* use python version as part of the cache key

* try to pass flaky test

* try harder on flaky test

* don't run tests in parallel on CI

* mark test_del3 as flaky

* try to pass del3 test on python 3.11

* try to keep alive

* skip test_del3 on python 3.11

* mark another test as flaky
  • Loading branch information
cgarciae authored Mar 22, 2023
1 parent 7a1f1fc commit c91ec0d
Show file tree
Hide file tree
Showing 115 changed files with 1,857 additions and 1,626 deletions.
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

66 changes: 0 additions & 66 deletions .github/workflows/ci_test.yml

This file was deleted.

108 changes: 108 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Checks that we can build and validate the Unittest
name: Run Tests
on:
push:
branches:
- main
pull_request:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- name: Check out the code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/[email protected]
with:
version: 1.4.0

- name: Setup Poetry
run: |
poetry config virtualenvs.in-project true
- name: Cache
id: cache
uses: actions/[email protected]
with:
path: '.venv'
key: run-tests-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
if [ -d ".venv" ]; then rm -rf .venv; fi
poetry install --without docs
- name: Install Package
run: |
poetry install --without docs
- name: Run Tests
run: |
poetry run pytest --cov=pypeln --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3

test-import:
name: Test Import without Dev Dependencies
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- name: Check out the code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/[email protected]
with:
version: 1.4.0

- name: Setup Poetry
run: |
poetry config virtualenvs.in-project true
- name: Cache
id: cache
uses: actions/[email protected]
with:
path: '.venv'
key: test-import-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry install --only main
- name: Install Package
run: |
poetry install --only main
- name: Test Import
run: |
poetry run python -c "import pypeln"
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args: ["--target-version", "py38", "--fast"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]


5 changes: 3 additions & 2 deletions benchmarks/100_million_downloads/client-async-as-completed.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# client-async-as-completed.py

from aiohttp import ClientSession, TCPConnector
import asyncio
from itertools import islice
import sys
from itertools import islice

from aiohttp import ClientSession, TCPConnector


def limited_as_completed(coros, limit):
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/100_million_downloads/client-async-sem.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# client-async-sem.py

from aiohttp import ClientSession, TCPConnector
import asyncio
import sys

from aiohttp import ClientSession, TCPConnector

limit = 1000


Expand Down
6 changes: 3 additions & 3 deletions benchmarks/100_million_downloads/client-pypeln-idiomatic.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# client-pypeln-pl.task.py

from aiohttp import ClientSession, TCPConnector
import asyncio
import sys
import pypeln as pl

from aiohttp import ClientSession, TCPConnector

import pypeln as pl

limit = 1000
urls = ("http://localhost:8080/{}".format(i) for i in range(int(sys.argv[1])))


async def main():

async with ClientSession(connector=TCPConnector(limit=0)) as session:

async def fetch(url):
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/100_million_downloads/client-pypeln-io.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# client-pypeln-pl.task.py

from aiohttp import ClientSession, TCPConnector
import asyncio
import sys
import pypeln as pl

from aiohttp import ClientSession, TCPConnector

import pypeln as pl

limit = 1000
urls = ("http://localhost:8080/{}".format(i) for i in range(int(sys.argv[1])))
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/100_million_downloads/client-task-pool.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# client-task-pool.py

from aiohttp import ClientSession, TCPConnector
import asyncio
import sys

from aiohttp import ClientSession, TCPConnector

from pypeln.task import TaskPool

limit = 1000
Expand All @@ -16,7 +18,6 @@ async def fetch(url, session):
async def _main(url, total_requests):
connector = TCPConnector(limit=None)
async with ClientSession(connector=connector) as session, TaskPool(limit) as tasks:

for i in range(total_requests):
await tasks.put(fetch(url.format(i), session))

Expand Down
3 changes: 2 additions & 1 deletion benchmarks/100_million_downloads/server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# server.py

from aiohttp import web
import asyncio
import random

from aiohttp import web


async def handle(request):
await asyncio.sleep(random.randint(0, 3))
Expand Down
6 changes: 4 additions & 2 deletions examples/io_downloads.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from aiohttp import ClientSession
import pypeln as pl
import asyncio
import sys

from aiohttp import ClientSession

import pypeln as pl


async def fetch(url, session):
print("url")
Expand Down
6 changes: 4 additions & 2 deletions examples/io_downloads_wrong.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from aiohttp import ClientSession
import pypeln as pl
import asyncio
import sys

from aiohttp import ClientSession

import pypeln as pl


async def fetch(url, session):
async with session.get(url) as response:
Expand Down
6 changes: 4 additions & 2 deletions examples/process_error.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pypeln as pl
from tqdm import tqdm
import time

from tqdm import tqdm

import pypeln as pl

total = 300_000


Expand Down
Loading

0 comments on commit c91ec0d

Please sign in to comment.