Skip to content
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
3 changes: 3 additions & 0 deletions .circleci/circle_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
poetry>=1.1.6
tox>=3.23.1
tox-poetry>=0.3.0
166 changes: 104 additions & 62 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,97 +1,139 @@
version: 2.1

# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.9
- image: redislabs/redisai:edge-cpu-bionic

working_directory: ~/repo
commands:

abort_for_docs:
steps:
- checkout

- restore_cache: # Download and cache dependencies
keys:
- v1-dependencies-{{ checksum "test-requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
name: Avoid tests for docs
command: |
virtualenv --no-site-packages venv
. venv/bin/activate
pip install -r test-requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "test-requirements.txt" }}
if [[ $CIRCLE_BRANCH == *docs ]]; then
echo "Identifies as documents PR, no testing required"
circleci step halt
fi
abort_for_noci:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a generic name across all the clients? if not can we rename to abort_tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the generic name currently in use in all clients.

steps:
- run:
name: run tests
name: Ignore CI for specific branches
command: |
. venv/bin/activate
nosetests --with-coverage -vsx test
codecov
- store_artifacts:
path: test-reports
destination: test-reports
if [[ $CIRCLE_BRANCH == *noci ]]; then
echo "Identifies as actively ignoring CI, no testing required."
circleci step halt
fi
build_nightly:
docker:
- image: circleci/python:3.6.9
- image: redislabs/redisai:edge-cpu-bionic
working_directory: ~/repo
early_return_for_forked_pull_requests:
description: >-
If this build is from a fork, stop executing the current job and return success.
This is useful to avoid steps that will fail due to missing credentials.
steps:
- run:
name: Early return if this build is from a forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
build_and_test:
steps:
- checkout

- restore_cache: # Download and cache dependencies
keys:
- v1-dependencies-{{ checksum "test-requirements.txt" }}
- v1-dependencies-{{ checksum "pyproject.toml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
name: install tox dependencies
command: |
virtualenv --no-site-packages venv
. venv/bin/activate
pip install -r test-requirements.txt
pip install --user --quiet -r .circleci/circle_requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "test-requirements.txt" }}
- run:
name: build sdist and wheels
command: |
poetry build
- run:
name: run tests
name: lint
command: |
. venv/bin/activate
nosetests -vsx test
tox -e linters
- run:
name: run tests
command:
tox -e tests

# no need for store_artifacts on nightly builds
- save_cache:
paths:
- ./.tox
- ~/.cache/pip
key: v1-dependencies-{{ checksum "pyproject.toml" }}

jobs:
build:
parameters:
python_version:
type: string
default: "latest"
docker:
- image: circleci/python:<<parameters.python_version>>
- image: redislabs/redisai:edge-cpu-bionic

steps:
- build_and_test
- store_artifacts:
path: test-reports
destination: test-reports

nightly:
parameters:
python_version:
type: string
docker:
- image: circleci/python:<<parameters.python_version>>
- image: redislabs/redisai:edge-cpu-bionic
steps:
- build_and_test
- dockerize

on-any-branch: &on-any-branch
filters:
branches:
only:
- /.*/
tags:
ignore: /.*/

on-master: &on-master
filters:
branches:
only:
- master

python-versions: &python-versions
matrix:
parameters:
python_version:
- "3.6.9"
- "3.7.9"
- "3.8.9"
- "3.9.4"
- "latest"

workflows:
version: 2
commit:
jobs:
- build
- build:
<<: *on-any-branch
<<: *python-versions

nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
<<: *on-master
jobs:
- build_nightly
- build
55 changes: 24 additions & 31 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
name: Publish Pypi
on:
release:
types: [published]
types: [ published ]

jobs:
publish:
name: publish
pytest:
name: Publish to PyPi
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- uses: actions/checkout@master
- name: Set up Python 3.6
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.6
python-version: 3.7

- name: Install twine
run: |
pip install twine

- name: Install wheel
run: |
pip install wheel

- name: Create a source distribution
run: |
python setup.py sdist
- name: Install Poetry
uses: dschep/[email protected]

- name: Create a wheel
run: |
python setup.py bdist_wheel
- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}

- name: Create a .pypirc
- name: Set Poetry config
run: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
echo -e "[testpypi]" >> ~/.pypirc
echo -e "username = __token__" >> ~/.pypirc
echo -e "password = ${{ secrets.TESTPYPI_TOKEN }}" >> ~/.pypirc
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs

- name: Publish to Test PyPI
if: github.event_name == 'release'
run: |
twine upload --skip-existing -r testpypi dist/*
- name: Install Dependencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'

- name: Publish to PyPI
if: github.event_name == 'release'
run: |
twine upload -r pypi dist/*
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG OSNICK=bionic

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A future goal - I'd like to build dockers out of these, and given people a one stop shop. We are not currently using it.

ARG TARGET=cpu

FROM redislabs/redisai:edge-${TARGET}-${OSNICK} as builder

RUN apt update && apt install -y python3 python3-pip
ADD . /build
WORKDIR /build
RUN pip3 install poetry
RUN poetry config virtualenvs.create false
RUN poetry build

### clean docker stage
FROM redislabs/redisai:edge-${TARGET}-${OSNICK} as runner

RUN apt update && apt install -y python3 python3-pip
RUN rm -rf /var/cache/apt/

COPY --from=builder /build/dist/redisai*.tar.gz /tmp/
RUN pip3 install /tmp/redisai*.tar.gz
26 changes: 24 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ redisai-py
:target: https://codecov.io/gh/RedisAI/redisai-py

.. image:: https://readthedocs.org/projects/redisai-py/badge/?version=latest
:target: https://redisai-py.readthedocs.io/en/latest/?badge=latest
:target: https://redisai-py.readthedocs.io/en/latest/?badge=latest

.. image:: https://img.shields.io/badge/Forum-RedisAI-blue
:target: https://forum.redislabs.com/c/modules/redisai

.. image:: https://img.shields.io/discord/697882427875393627?style=flat-square
:target: https://discord.gg/rTQm7UZ
:target: https://discord.gg/rTQm7UZ

.. image:: https://snyk.io/test/github/RedisAI/redisai-py/badge.svg?targetFile=pyproject.toml)](https://snyk.io/test/github/RedisAI/redisai-py?targetFile=pyproject.toml

redisai-py is the Python client for RedisAI. Checkout the
`documentation <https://redisai-py.readthedocs.io/en/latest/>`_ for API details and examples
Expand All @@ -47,6 +49,26 @@ Installation

$ pip install ml2rt

Development
-----------

1. Assuming you have virtualenv installed, create a virtualenv to manage your python dependencies, and activate it.
```virtualenv -v venv; source venv/bin/activate```
2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies.
```pip install poetry```
3. Install dependencies.
```poetry install --no-root```

[tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded.

**Contributing**

Prior to submitting a pull request, please ensure you've built and installed poetry as above. Then:

1. Run the linter.
```tox -e linters.```
2. Run the unit tests. This assumes you have a redis server running, with the [RedisAI module](https://redisai.io) already loaded. If you don't, you may want to install a [docker build](https://hub.docker.com/r/redislabs/redisai/tags).
```tox -e tests```

`RedisAI example repo <https://github.com/RedisAI/redisai-examples>`_ shows few examples
made using redisai-py under `python_client` folder. Also, checkout
Expand Down
52 changes: 52 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[tool.poetry]
name = "redisai"
version = "1.0.2"
description = "RedisAI Python Client"
authors = ["RedisLabs <[email protected]>"]
license = "BSD-3-Clause"
readme = "README.rst"

packages = [
{ include = 'redisai' },
]

classifiers = [
'Topic :: Database',
'Programming Language :: Python',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'License :: OSI Approved :: BSD License',
'Development Status :: 5 - Production/Stable'
]

[tool.poetry.dependencies]
python = "^3.6"
redis = ">=2.10"
hiredis = ">=0.20"
numpy = ">=1.19.5"
six = ">=1.10.0"
Deprecated = "^1.2.12"

[tool.poetry.dev-dependencies]
codecov = "^2.1.11"
flake8 = "^3.9.2"
rmtest = "^0.7.0"
nose = "^1.3.7"
ml2rt = "^0.2.0"
tox = ">=3.23.1"
tox-poetry = "^0.3.0"
bandit = "^1.7.0"
pylint = "^2.8.2"
vulture = "^2.3"

[tool.poetry.urls]
url = "https://redisai.io"
repository = "https://github.com/RedisAI/redisai-py"


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Loading