Skip to content

Commit

Permalink
Merge 785c684 into 30ce54e
Browse files Browse the repository at this point in the history
  • Loading branch information
markedwards committed Oct 5, 2022
2 parents 30ce54e + 785c684 commit 9743714
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 31 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Code quality

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[lint]
- name: Run code quality tests
run: |
flake8
mypy
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
python: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', 'pypy3.9']

steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name: Run unit tests
run: pytest --cov=aiodataloader
- name: Send coverage to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ DataLoader is a generic utility to be used as part of your application's data
fetching layer to provide a simplified and consistent API over various remote
data sources such as databases or web services via batching and caching.

[![Build Status](https://travis-ci.org/syrusakbary/aiodataloader.svg)](https://travis-ci.org/syrusakbary/aiodataloader)
[![PyPI version](https://badge.fury.io/py/aiodataloader.svg)](https://badge.fury.io/py/aiodataloader)
![Test Status](https://github.com/syrusakbary/aiodataloader/actions/workflows/test.yml/badge.svg)
![Lint Status](https://github.com/syrusakbary/aiodataloader/actions/workflows/lint.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/syrusakbary/aiodataloader/badge.svg?branch=master&service=github)](https://coveralls.io/github/syrusakbary/aiodataloader?branch=master)

A port of the "Loader" API originally developed by [@schrockn][] at Facebook in
Expand Down
14 changes: 7 additions & 7 deletions aiodataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def dispatch_queue(loader):

async def dispatch_queue_batch(loader, queue):
# Collect all keys to be loaded in this dispatch
keys = [l.key for l in queue]
keys = [ql.key for ql in queue]

# Call the provided batch_load_fn for this loader with the loader queue's keys.
batch_future = loader.batch_load_fn(keys)
Expand Down Expand Up @@ -233,11 +233,11 @@ async def dispatch_queue_batch(loader, queue):

# Step through the values, resolving or rejecting each Future in the
# loaded queue.
for l, value in zip(queue, values):
for ql, value in zip(queue, values):
if isinstance(value, Exception):
l.future.set_exception(value)
ql.future.set_exception(value)
else:
l.future.set_result(value)
ql.future.set_result(value)

except Exception as e:
return failed_dispatch(loader, queue, e)
Expand All @@ -248,6 +248,6 @@ def failed_dispatch(loader, queue, error):
Do not cache individual loads if the entire batch dispatch fails,
but still reject each request so they do not hang.
"""
for l in queue:
loader.clear(l.key)
l.future.set_exception(error)
for ql in queue:
loader.clear(ql.key)
ql.future.set_exception(error)
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[flake8]
exclude = test_*,scripts,setup.py,docs
max-line-length = 120

[mypy]
files = aiodataloader.py, test_aiodataloader.py
follow_imports = silent
ignore_missing_imports = True
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ def get_version(filename):
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'License :: OSI Approved :: MIT License',
],
keywords='concurrent future deferred aiodataloader',
py_modules=['aiodataloader'],
extras_require={
'lint': ['flake8', 'mypy'],
'test': tests_require,
},
tests_require=tests_require, )

0 comments on commit 9743714

Please sign in to comment.