Skip to content

Commit

Permalink
Merge pull request #547 from kbase/dev-aioarango
Browse files Browse the repository at this point in the history
RE2022-266: Vendor aioarango
  • Loading branch information
MrCreosote authored Nov 16, 2023
2 parents c5f2552 + e307869 commit 067e16f
Show file tree
Hide file tree
Showing 28 changed files with 11,604 additions and 213 deletions.
12 changes: 2 additions & 10 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ aiohttp = "==3.8.6"
requests = "==2.31.0"
jinja-cli = "==1.2.2"
pandas = "==2.1.2"
aioarango = "==1.0.0"
ftputil = "==5.0.4"
beautifulsoup4 = "==4.12.2"
jsonschema = "==4.19.2"
Expand All @@ -22,15 +21,12 @@ aiodns = "==3.1.1"
docker = "==6.1.3"
click = "==8.1.7"
PyYAML = "==6.0.1"
# Unfortunately aioarango requires requests-toolbelt < 0.10.0, which is not compatible with
# urrlib3 >= 2.0.0
# We're going to have to figure out some alternative to aioarango at some point as it seems to be
# abandonware
urllib3 = "==1.26.17"
python-dateutil = "==2.8.2"
numpy = "==1.26.1"
jsonschema-default = "==1.6.0"
mergedeep = "==1.3.4"
httpx = "==0.25.1"
requests-toolbelt = "==1.0.0"

[dev-packages]
pytest = "==7.4.3"
Expand All @@ -41,10 +37,6 @@ ipython = "==8.17.2"
pytest-asyncio = "==0.21.1"
# currently for design/experiments/store_mongo.py
pymongo = "==4.6.0"
# later version of dns python has an import problem with httpcore
# https://stackoverflow.com/questions/76766226/i-cant-import-pymongo
# Note aioarango forces an old version of httpcore
dnspython = "==2.3.0"
sourmash = "==4.8.4"
prometheus-client = "==0.18.0"

Expand Down
375 changes: 177 additions & 198 deletions Pipfile.lock

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions aioarango/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016-2021 Joohwan Oh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions aioarango/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import aioarango.errno as errno # noqa: F401
from aioarango.client import ArangoClient # noqa: F401
from aioarango.exceptions import * # noqa: F401 F403
from aioarango.http import * # noqa: F401 F403
72 changes: 72 additions & 0 deletions aioarango/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from typing import Callable, Optional, TypeVar

from aioarango.connection import Connection
from aioarango.executor import ApiExecutor
from aioarango.request import Request
from aioarango.response import Response
from aioarango.result import Result

T = TypeVar("T")


class ApiGroup:
"""Base class for API groups.
:param connection: HTTP connection.
:param executor: API executor.
"""

def __init__(self, connection: Connection, executor: ApiExecutor) -> None:
self._conn = connection
self._executor = executor

@property
def conn(self) -> Connection:
"""Return the HTTP connection.
:return: HTTP connection.
:rtype: aioarango.connection.BasicConnection | aioarango.connection.JwtConnection |
aioarango.connection.JwtSuperuserConnection
"""
return self._conn

@property
def db_name(self) -> str:
"""Return the name of the current database.
:return: Database name.
:rtype: str
"""
return self._conn.db_name

@property
def username(self) -> Optional[str]:
"""Return the username.
:returns: Username.
:rtype: str
"""
return self._conn.username

@property
def context(self) -> str:
"""Return the API execution context.
:return: API execution context. Possible values are "default", "async",
"batch" and "transaction".
:rtype: str
"""
return self._executor.context

async def _execute(
self, request: Request, response_handler: Callable[[Response], T]
) -> Result[T]:
"""Execute an API.
:param request: HTTP request.
:type request: aioarango.request.Request
:param response_handler: HTTP response handler.
:type response_handler: callable
:return: API execution result.
"""
return await self._executor.execute(request, response_handler)
Loading

0 comments on commit 067e16f

Please sign in to comment.