Skip to content
Draft
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
*tests
**/tests
*.pyc
**/*.pyc
docker*
10 changes: 0 additions & 10 deletions setup.cfg → .flake8
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
[metadata]
license_file = LICENSE

[bdist_wheel]
universal=1

[flake8]
ignore = E203, E266, E501, W503, E302
max-line-length = 110
max-complexity = 18
select = B,C,E,F,W,T4,B9
exclude = .git,.ropeproject,.tox,build,env,venv,__pycache__

[tool:pytest]
DJANGO_SETTINGS_MODULE=tests.settings
addopts = -v --tb=short
41 changes: 23 additions & 18 deletions .github/workflows/test_djelme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,46 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
id: setup-py
with:
python-version: '3.7'
python-version: 3.9 # must match language_version in .pre-commit-config.yaml
- run: alias python${{ steps.setup-py.outputs.python-version }}=${{ steps.setup-py.outputs.python-path }}
- run: pip install -U tox
- name: alias pythonX.Y for tox
run: alias python${{ steps.setup-py.outputs.python-version }}=${{ steps.setup-py.outputs.python-path }}
- run: TOXENV=lint tox


test:
strategy:
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
python: ['3.7', '3.8', '3.9', '3.10']
django: ['1.11', '2.0', '2.1', '2.2', '3.0', '3.1', '3.2', '4.0', '4.1']
# TODO: elasticsearch: ['6', '7', '8', '9']
elastic: ['6', '7', '8']
exclude:
- {python: '3.6', django: '4.0'}
- {python: '3.6', django: '4.1'}
- {python: '3.7', django: '4.0'}
- {python: '3.7', django: '4.1'}
- {python: '3.10', django: '1.11'}
- {python: '3.10', django: '2.0'}
runs-on: ubuntu-latest
container: python:${{matrix.python}}-slim
services:
elasticsearch:
image: elasticsearch:6.8.23
ports:
- 9201:9200
elasticsearch6:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
env:
discovery.type: single-node
elasticsearch7:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
env:
discovery.type: single-node
elasticsearch8:
image: docker.elastic.co/elasticsearch/elasticsearch:8.4.1
env:
discovery.type: single-node
ELASTIC_CLIENT_APIVERSIONING: 1 # act like es7
xpack.security.enabled: "false" # it'll be fine
action.destructive_requires_name: "false" # we'll delete * in a moment
env:
ELASTICSEARCH_HOST: elasticsearch${{matrix.elastic}}:9200
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
id: setup-py
with:
python-version: ${{ matrix.python }}
- run: pip install -U tox
- run: alias python${{ steps.setup-py.outputs.python-version }}=${{ steps.setup-py.outputs.python-path }}
- run: TOXENV=`echo 'py${{ matrix.python }}-django${{matrix.django}}' | sed 's/\.//g'` tox
- run: TOXENV=`echo 'py${{matrix.python}}-django${{matrix.django}}-es${{matrix.elastic}}' | sed 's/\.//g'` tox

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: 22.8.0
hooks:
- id: black
language_version: python3.7
language_version: python3.9
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
Expand Down
26 changes: 21 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
elasticsearch6:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
environment:
discovery.type: single-node
elasticsearch7:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
environment:
discovery.type: single-node
elasticsearch8:
image: docker.elastic.co/elasticsearch/elasticsearch:8.4.1
environment:
discovery.type: single-node
ELASTIC_CLIENT_APIVERSIONING: 1 # act like es7
xpack.security.enabled: "false"
action.destructive_requires_name: "false"
testbox:
build:
context: .
dockerfile: testbox.Dockerfile
depends_on:
- elasticsearch
# - elasticsearch6
# - elasticsearch7
- elasticsearch8
environment:
TOXENV: py39-django40
ELASTICSEARCH_HOST: elasticsearch:9200
# ELASTICSEARCH_HOST: elasticsearch6:9200
# ELASTICSEARCH_HOST: elasticsearch7:9200
ELASTICSEARCH_HOST: elasticsearch8:9200
volumes:
- ./:/code:cached
2 changes: 1 addition & 1 deletion elasticsearch_metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def check_index_template(cls, using=None):
"""
client = connections.get_connection(using or "default")
try:
template = client.indices.get_template(cls._template_name)
template = client.indices.get_template(name=cls._template_name)
except NotFoundError as client_error:
template_name = cls._template_name
metric_name = cls.__name__
Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "django-elasticsearch-metrics"
description="Django app for storing time-series metrics in Elasticsearch."
requires-python = ">=3.7"
license = { file = "LICENSE" }
readme = "README.md"
dependencies = [
"elasticsearch-dsl>=6.3,<7",
]
keywords = [
"django",
"elastic",
"elasticsearch",
"elasticsearch-dsl",
"time-series",
"metrics",
"statistics",
]
classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Framework :: Django",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
"Framework :: Django :: 2.1",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
]
authors = [
{ name = "Steven Loria", email = "steve@cos.io" },
{ name = "Dawn Pattison", email = "pattison.dawn@cos.io" },
]
maintainers = [
{ name = "Abram Booth", email = "abram@cos.io" },
]
dynamic = ["version"]

[project.urls]
Issues = "https://github.com/CenterForOpenScience/django-elasticsearch-metrics/issues"
Changelog = "https://github.com/CenterForOpenScience/django-elasticsearch-metrics/blob/master/CHANGELOG.md"

[project.optional-dependencies]
dev = [
"pytest",
"mock",
"pytest-django==3.10.0",
"factory-boy==2.11.1",
"flake8==5.0.4",
"flake8-bugbear==18.8.0",
"pre-commit==2.17.0",
"konch>=3.0",
"tox",
]

[tool.setuptools.dynamic]
version = { attr = "elasticsearch_metrics.__version__" }

[tool.setuptools.packages.find]
exclude = ["tests*"]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "tests.settings"
addopts = "-v --tb=short"
96 changes: 0 additions & 96 deletions setup.py

This file was deleted.

2 changes: 2 additions & 0 deletions testbox.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ WORKDIR /code
COPY ./ /code

RUN pip install .[dev]
RUN pip install Django==3.2.15

ENV TOXENV py39-django32-es7
CMD ["tox"]
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _es_marker(request, client):

def teardown_es():
client.indices.delete(index="*")
client.indices.delete_template("*")
client.indices.delete_template(name="*")

teardown_es()
yield
Expand Down
Loading