Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into types
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Sep 10, 2024
2 parents 3c672b3 + 03320e6 commit c9edd02
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 20 deletions.
9 changes: 7 additions & 2 deletions .github/ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/1-bug.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Thanks for wanting to report an issue you've found in valkey-py. Please delete this text and fill in the template below.
It is of course not always possible to reduce your code to a small test case, but it's highly appreciated to have as much data as possible. Thank you!
<!--
Thanks for reporting an issue you've found in valkey-py.
Please delete this text and fill in the template below.
It is of course not always possible to reduce your code to a
small test case, but it's highly appreciated to have as much
data as possible. Thank you!
-->

**Version**: What valkey-py and what valkey version is the issue happening on?

Expand Down
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/2-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
Thanks for opening a feature request!
-->

**Description**: Description of your feature request

**Example use cases**: List some possible use cases for this feature
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Security Issues
url: mailto:[email protected]
about: Please report security vulnerabilities here.
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
### Pull Request check-list

_Please make sure to review and check all of these items:_
<!-- Please make sure to review and check all of these items: -->

- [ ] Do tests and lints pass with this change?
- [ ] Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
- [ ] Is the new or changed code fully tested?
- [ ] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
- [ ] Is there an example added to the examples folder (if applicable)?

_NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open._
<!-- NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open. -->

### Description of change

_Please provide a description of the change here._
<!-- Please provide a description of the change here. -->
49 changes: 48 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,29 @@ jobs:
pip install -r dev_requirements.txt
invoke linters
populate-cache:
runs-on: ubuntu-latest
timeout-minutes: 60
name: Update docker cache
steps:
- uses: actions/checkout@v4
- name: Cache docker images
id: custom-cache
uses: actions/cache@v3
with:
path: ./custom-cache/
key: custom-cache
- if: ${{ steps.custom-cache.outputs.cache-hit != 'true' || github.event_name == 'schedule' }}
name: Update Cache
run: |
mkdir -p ./custom-cache/
docker compose --profile all build
docker pull valkey/valkey:latest
docker save valkey-py-stunnel:latest valkey-py-cluster:latest valkey/valkey:latest -o ./custom-cache/all.tar
run-tests:
runs-on: ubuntu-latest
needs: [populate-cache]
timeout-minutes: 60
strategy:
max-parallel: 15
Expand All @@ -70,6 +91,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Cache docker images
id: custom-cache
uses: actions/cache@v3
with:
path: ./custom-cache/
fail-on-cache-miss: true
key: custom-cache
- name: Use Cache
run: docker image load -i ./custom-cache/all.tar

- name: run tests
run: |
pip install -U setuptools wheel
Expand All @@ -79,7 +111,11 @@ jobs:
pip install "libvalkey>=4.0.0"
fi
invoke devenv
sleep 10 # time to settle
if [[ "${{matrix.test-type}}" == "standalone" ]]; then
./util/wait-for-it.sh localhost:6379
else
./util/wait-for-it.sh localhost:16379
fi
invoke ${{matrix.test-type}}-tests --protocol=${{ matrix.protocol-version }}
if [[ "${{matrix.python-version}}" != pypy-* ]]; then
invoke ${{matrix.test-type}}-tests --uvloop --protocol=${{ matrix.protocol-version }}
Expand Down Expand Up @@ -111,6 +147,17 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Cache docker images
id: custom-cache
uses: actions/cache@v3
with:
path: ./custom-cache/
fail-on-cache-miss: true
key: custom-cache
- name: Use Cache
run: docker image load -i ./custom-cache/all.tar

- name: Run installed unit tests
run: |
bash .github/workflows/install_and_test.sh ${{ matrix.extension }}
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
Please use
python setup.py install

and report errors to Salvatore Mesoraca ([email protected])
and report errors to via https://github.com/valkey-io/valkey-py/issues/new

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
async-timeout>=4.0.3
async-timeout>=4.0.3; python_version<"3.11"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
long_description_content_type="text/markdown",
keywords=["Valkey", "key-value store", "database"],
license="MIT",
version="6.0.0",
version="6.0.1",
packages=find_packages(
include=[
"valkey",
Expand Down Expand Up @@ -36,7 +36,7 @@
author_email="[email protected]",
python_requires=">=3.8",
install_requires=[
'async-timeout>=4.0.3; python_version<="3.12"',
'async-timeout>=4.0.3; python_version<"3.11"',
],
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
3 changes: 1 addition & 2 deletions tests/test_asyncio/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ async def test_blocking_timeout(self, r):
lock2 = self.get_lock(r, "foo", sleep=sleep, blocking_timeout=bt)
start = asyncio.get_running_loop().time()
assert not await lock2.acquire()
# The elapsed duration should be less than the total blocking_timeout
assert bt >= (asyncio.get_running_loop().time() - start) > bt - sleep
assert (asyncio.get_running_loop().time() - start) > (bt - sleep)
await lock1.release()

async def test_context_manager(self, r):
Expand Down
8 changes: 2 additions & 6 deletions tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ def test_blocking_timeout(self, r):
assert lock1.acquire(blocking=False)
bt = 0.4
sleep = 0.05
fudge_factor = 0.1
lock2 = self.get_lock(r, "foo", sleep=sleep, blocking_timeout=bt)
start = time.monotonic()
assert not lock2.acquire()
# The elapsed duration should be less than the total blocking_timeout
assert (bt + fudge_factor) > (time.monotonic() - start) > bt - sleep
assert (time.monotonic() - start) > (bt - sleep)
lock1.release()

def test_context_manager(self, r):
Expand All @@ -120,12 +118,10 @@ def test_context_manager_blocking_timeout(self, r):
with self.get_lock(r, "foo", blocking=False):
bt = 0.4
sleep = 0.05
fudge_factor = 0.05
lock2 = self.get_lock(r, "foo", sleep=sleep, blocking_timeout=bt)
start = time.monotonic()
assert not lock2.acquire()
# The elapsed duration should be less than the total blocking_timeout
assert (bt + fudge_factor) > (time.monotonic() - start) > bt - sleep
assert (time.monotonic() - start) > (bt - sleep)

def test_context_manager_raises_when_locked_not_acquired(self, r):
r.set("foo", "bar")
Expand Down
5 changes: 4 additions & 1 deletion valkey/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,10 @@ def initialize(self):
self.nodes_cache = tmp_nodes_cache
self.slots_cache = tmp_slots
# Set the default node
self.default_node = self.get_nodes_by_server_type(PRIMARY)[0]
try:
self.default_node = self.get_nodes_by_server_type(PRIMARY)[0]
except IndexError:
raise ValkeyClusterException("No primary nodes found in the cluster")
if self._dynamic_startup_nodes:
# Populate the startup nodes with all discovered nodes
self.startup_nodes = tmp_nodes_cache
Expand Down

0 comments on commit c9edd02

Please sign in to comment.