Skip to content

Commit 5d6c61d

Browse files
authored
Major versions upgrade (#76)
* Major version(s) bump Upgraded python version to 3.11.5, and also lifting dependencies to resonably modern versions. Dropped Flask-grapql as it was only a wrapper for grapql-server. Change-Id: I151ccd444393d5fcbd15f7ca9b45573db6b27f91 * Add docker compose file Add docker compose file(s), with dependency services defined, to aid in setting up a proper development environment. Change-Id: I20564878ba52b4215edb7eb945b37852912af59f * Update tox environment Bump version(s) of python as well as test environment dependencies Change-Id: I50632d04d65559e5d24a308e1218b89636b18122 * Update Python version for Github actions Change-Id: I966bb752dbc9c30e5b3ba30581efa9be2b062672
1 parent 970cf87 commit 5d6c61d

File tree

14 files changed

+142
-41
lines changed

14 files changed

+142
-41
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on: [push, pull_request]
1010
jobs:
1111
run-tox:
1212
# The type of runner that the job will run on
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-latest
1414

1515
# Steps represent a sequence of tasks that will be executed as part of the job
1616
steps:
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup python
2121
uses: actions/setup-python@v2
2222
with:
23-
python-version: 3.6.15
23+
python-version: 3.11.5
2424
- name: Install Tox
2525
run: pip install tox
2626
- name: Upgrade setuptools

Dockerfile.graphql-api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:3.6.12-buster AS build
1+
FROM python:3.11.5 AS build
22

33
COPY . /src
44
WORKDIR /src
55
RUN python3 setup.py bdist_wheel
66

7-
FROM python:3.6.12-slim-buster
7+
FROM python:3.11.5-slim
88

99
LABEL org.opencontainers.image.source=https://github.com/eiffel-community/eiffel-graphql-api
1010
LABEL org.opencontainers.image.authors=eiffel-graphql-api-maintainers@googlegroups.com

Dockerfile.storage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:3.6.12-buster AS build
1+
FROM python:3.11.5 AS build
22

33
COPY . /src
44
WORKDIR /src
55
RUN python3 setup.py bdist_wheel
66

7-
FROM python:3.6.12-slim-buster
7+
FROM python:3.11.5-slim
88

99
LABEL org.opencontainers.image.source=https://github.com/eiffel-community/eiffel-graphql-api
1010
LABEL org.opencontainers.image.authors=eiffel-graphql-api-maintainers@googlegroups.com

deploy/development.env

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
RABBITMQ_HOST=rabbitmq
2+
RABBITMQ_EXCHANGE=amq.fanout
3+
RABBITMQ_USERNAME=guest
4+
RABBITMQ_PASSWORD=guest
5+
RABBITMQ_PORT=5672
6+
RABBITMQ_VHOST=
7+
RABBITMQ_QUEUE=graphql-test
8+
RABBITMQ_DURABLE_QUEUE=true
9+
MONGODB_CONNSTRING=mongodb://root:pass@mongodb/admin
10+
MONGODB_DATABASE=admin
11+
MONGODB_INITDB_ROOT_USERNAME=root
12+
MONGODB_INITDB_ROOT_PASSWORD=pass

deploy/docker-compose.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
networks:
2+
eiffel-graphql-api-network:
3+
name: "eiffel-graphql-api-network"
4+
5+
services:
6+
mongodb:
7+
image: "mongodb/mongodb-community-server"
8+
env_file:
9+
- development.env
10+
networks:
11+
- eiffel-graphql-api-network
12+
13+
rabbitmq:
14+
image: "rabbitmq:3-management-alpine"
15+
networks:
16+
- eiffel-graphql-api-network
17+
ports:
18+
- 15672:15672
19+
- 5672:5672
20+
21+
api:
22+
build:
23+
context: ../
24+
dockerfile: Dockerfile.graphql-api
25+
ports:
26+
- 5000:5000
27+
networks:
28+
- eiffel-graphql-api-network
29+
env_file:
30+
- development.env
31+
depends_on:
32+
- mongodb
33+
34+
storage:
35+
build:
36+
context: ../
37+
dockerfile: Dockerfile.storage
38+
networks:
39+
- eiffel-graphql-api-network
40+
env_file:
41+
- development.env
42+
depends_on:
43+
- rabbitmq
44+
- mongodb

docs/requirements.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
sphinx<2
2-
pyscaffold==2.5.10
3-
mistune==0.8.4
4-
m2r==0.2.1
5-
sphinx-rtd-theme<0.5
1+
sphinx~=6.2.1
2+
m2r==0.3.1
3+
sphinx-rtd-theme==1.3.0

requirements.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
# numpy==1.13.3
1616
# scipy==1.0
1717
#
18-
eiffellib==1.2.0
19-
requests==2.22.0
18+
eiffellib[rabbitmq]==2.4
19+
requests==2.31.0
2020
pymongo[srv]==3.12.0
21-
graphql-core==2.2.1
22-
gql==0.1.0
23-
Flask==1.1.1
24-
Flask-GraphQL==2.0.0
25-
graphene==2.1.8
26-
gunicorn==20.0.4
27-
greenlet==0.4.14
28-
gevent==1.4.0
21+
graphql-core==3.2.3
22+
gql[requests]==3.4.1
23+
Flask==2.3.3
24+
graphql-server==3.0.0b6
25+
graphene==3.3
26+
gunicorn==21.2.0
27+
greenlet==2.0.2
28+
gevent==22.10.2

setup.cfg

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
name = eiffel-graphql-api
33
description = Eiffel GraphQL API and storage solution.
44
author = Tobias Persson
5-
author-email = tobiaspn@axis.com
5+
author_email = tobiaspn@axis.com
66
license = Apache License, Version 2.0
7-
long-description = file: README.rst
8-
long-description-content-type = text/x-rst; charset=UTF-8
7+
long_description = file: README.rst
8+
long_description_content_type = text/x-rst; charset=UTF-8
99
url = https://github.com/eiffel-community/eiffel-graphql-api
10-
project-urls =
10+
project_urls =
1111
Documentation = https://eiffel-graphql-api.readthedocs.io
1212
platforms = any
1313
classifiers =
@@ -23,7 +23,18 @@ package_dir =
2323
=src
2424
# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD!
2525
setup_requires = pyscaffold>=3.2a0,<3.3a0
26-
install_requires = eiffellib==1.2.0;requests==2.22.0;pymongo[srv]==3.12.0;graphql-core==2.2.1;gql==0.1.0;Flask==1.1.1;Flask-GraphQL==2.0.0;graphene==2.1.8;gunicorn==20.0.4;greenlet==0.4.14;gevent==1.4.0
26+
install_requires =
27+
eiffellib[rabbitmq]==2.4.1
28+
requests==2.31.0
29+
pymongo[srv]==3.12.0
30+
graphql-core==3.2.3
31+
gql[requests]==3.4.1
32+
Flask==2.3.3
33+
graphql-server==3.0.0b6
34+
graphene==3.3
35+
gunicorn==21.2.0
36+
greenlet==2.0.2
37+
gevent==22.10.2
2738

2839
[options.package_data]
2940
* = *.json

src/eiffel_graphql_api/graphql/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616
"""Eiffel GraphQL Flask API APP."""
1717
from flask import Flask
18-
from flask_graphql import GraphQLView
18+
from graphql_server.flask.graphqlview import GraphQLView
1919

2020
from .schemas.schema import SCHEMA
2121

src/eiffel_graphql_api/graphql/schemas/lib/bigint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def serializer(value):
3636
@staticmethod
3737
def parse_literal(node):
3838
"""Parse node literal and convert to float if too large."""
39-
if isinstance(node, ast.IntValue):
39+
if isinstance(node, ast.IntValueNode):
4040
num = int(node.value)
4141
if num > MAX_INT or num < MIN_INT:
4242
return float(int(num))

src/eiffel_graphql_api/graphql/schemas/links/artifact.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,45 @@ def resolve_artifact_created(self, _):
4343
return ArtifactCreated(event)
4444

4545

46-
class ReusedArtifact(Artifact):
46+
class ReusedArtifact(graphene.ObjectType):
4747
"""Reused artifact link."""
4848

49+
artifact_created = graphene.Field(ArtifactCreated)
50+
51+
def __init__(self, link):
52+
"""Initialize link."""
53+
# pylint:disable=super-init-not-called
54+
self.link = link
55+
56+
def resolve_artifact_created(self, _):
57+
"""Resolve artifact created link."""
58+
from ..union import NotFound # pylint:disable=import-outside-toplevel
59+
60+
event = find_one(
61+
"EiffelArtifactCreatedEvent", {"meta.id": self.link.get("target")}
62+
)
63+
if event is None:
64+
return NotFound(self.link, "Could not find event in database.")
65+
return ArtifactCreated(event)
66+
4967

50-
class ArtifactPreviousVersion(Artifact):
68+
class ArtifactPreviousVersion(graphene.ObjectType):
5169
"""Previous artifact version link."""
70+
71+
artifact_created = graphene.Field(ArtifactCreated)
72+
73+
def __init__(self, link):
74+
"""Initialize link."""
75+
# pylint:disable=super-init-not-called
76+
self.link = link
77+
78+
def resolve_artifact_created(self, _):
79+
"""Resolve artifact created link."""
80+
from ..union import NotFound # pylint:disable=import-outside-toplevel
81+
82+
event = find_one(
83+
"EiffelArtifactCreatedEvent", {"meta.id": self.link.get("target")}
84+
)
85+
if event is None:
86+
return NotFound(self.link, "Could not find event in database.")
87+
return ArtifactCreated(event)

src/eiffel_graphql_api/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def parse_args(args):
4444
:param args: Command line parameters as list of strings.
4545
:type args: list
4646
:return: Command line parameters namespace.
47-
:rtype: :obj:`argparse.Namespace
47+
:rtype: :obj:`argparse.Namespace`
4848
"""
4949
parser = argparse.ArgumentParser(
5050
description="Tool for storing eiffel events in a Mongo database."

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def wait_for_webserver_connection():
5454
timeout = time.time() + 30
5555
while time.time() < timeout:
5656
try:
57-
query_handler.execute("{nothing}")
57+
query_handler.execute("{ __schema { description } }")
5858
LOGGER.info("Up and running")
5959
return
6060
except HTTPError: # BadRequest means the webserver came up.

tox.ini

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py36,black,docs,pylint,pydocstyle
7+
envlist = py311,black,docs,pylint,pydocstyle
88

99
[testenv]
1010
deps =
11-
pytest==7.0
12-
pytest-cov==4.0.0
11+
pytest==7.4.1
12+
pytest-cov==4.1.0
1313
mongomock==4.1.2
1414
setenv = MONGODB_CONNSTRING = mongodb://localhost:27017
1515
MONGODB_DATABASE = testing_eiffel_graphql_api
1616
commands =
17-
pytest -s --log-format="%(levelname)%: %(message)s" {posargs}
18-
basepython = python3.6
17+
pytest -s --log-format="%(levelname)s: %(message)s" {posargs}
18+
basepython = python3.11.5
1919

2020
[testenv:black]
2121
deps =
22-
black==22.8.0
22+
black==23.9.1
2323
commands =
2424
black --check --diff .
2525

@@ -31,9 +31,9 @@ commands =
3131

3232
[testenv:pylint]
3333
deps =
34-
pylint==2.12.2
35-
pytest==7.0
36-
pytest-cov==4.0.0
34+
pylint==2.17.5
35+
pytest==7.4.1
36+
pytest-cov==4.1.0
3737
mongomock==4.1.2
3838
commands =
3939
pylint src/eiffel_graphql_api tests

0 commit comments

Comments
 (0)