mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-26 14:38:36 +00:00
refactor: update package strategy in rest_api (#3148)
* update packaging * fix author metadata * add newline * add empty readme * fix path to pipeline files * fix pylint job * fix metadata
This commit is contained in:
parent
e2110644c4
commit
6790eaf7d8
2
.github/utils/generate_openapi_specs.py
vendored
2
.github/utils/generate_openapi_specs.py
vendored
@ -10,7 +10,7 @@ sys.path.append(".")
|
||||
from rest_api.utils import get_openapi_specs, get_app, get_pipelines # pylint: disable=wrong-import-position
|
||||
from haystack import __version__ # pylint: disable=wrong-import-position
|
||||
|
||||
REST_PATH = Path("./rest_api").absolute()
|
||||
REST_PATH = Path("./rest_api/rest_api").absolute()
|
||||
PIPELINE_PATH = str(REST_PATH / "pipeline" / "pipeline_empty.haystack-pipeline.yml")
|
||||
APP_PATH = str(REST_PATH / "application.py")
|
||||
DOCS_PATH = Path("./docs") / "_src" / "api" / "openapi"
|
||||
|
||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Pylint
|
||||
run: |
|
||||
pylint -ry -j 0 haystack/ rest_api/ ui/
|
||||
pylint -ry -j 0 haystack/ rest_api/rest_api ui/
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
|
||||
71
rest_api/pyproject.toml
Normal file
71
rest_api/pyproject.toml
Normal file
@ -0,0 +1,71 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "rest-api"
|
||||
description = 'API server for Haystack (https://github.com/deepset-ai/haystack)'
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
license = "Apache-2.0"
|
||||
keywords = []
|
||||
authors = [
|
||||
{ name = "deepset.ai", email = "malte.pietsch@deepset.ai" },
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Science/Research",
|
||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
]
|
||||
dependencies = [
|
||||
"farm-haystack",
|
||||
"fastapi<1",
|
||||
"uvicorn<1",
|
||||
"gunicorn<21",
|
||||
"python-multipart<1", # optional FastAPI dependency for form data
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://github.com/deepset-ai/haystack/tree/main/rest_api#readme"
|
||||
Issues = "https://github.com/deepset-ai/haystack/issues"
|
||||
Source = "https://github.com/deepset-ai/haystack/tree/main/rest_api"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "rest_api/__about__.py"
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
[tool.hatch.build.targets.wheel]
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
dependencies = [
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
]
|
||||
[tool.hatch.envs.default.scripts]
|
||||
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=rest_api --cov=tests"
|
||||
no-cov = "cov --no-cov"
|
||||
|
||||
[[tool.hatch.envs.test.matrix]]
|
||||
python = ["37", "38", "39", "310"]
|
||||
|
||||
[tool.coverage.run]
|
||||
branch = true
|
||||
parallel = true
|
||||
omit = [
|
||||
"rest_api/__about__.py",
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
exclude_lines = [
|
||||
"no cov",
|
||||
"if __name__ == .__main__.:",
|
||||
"if TYPE_CHECKING:",
|
||||
]
|
||||
10
rest_api/rest_api/__about__.py
Normal file
10
rest_api/rest_api/__about__.py
Normal file
@ -0,0 +1,10 @@
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
__version__ = "0.0.0"
|
||||
try:
|
||||
__version__ = open(Path(__file__).parent.parent / "VERSION.txt", "r").read()
|
||||
except Exception as e:
|
||||
logging.exception("No VERSION.txt found!")
|
||||
0
rest_api/rest_api/controller/errors/__init__.py
Normal file
0
rest_api/rest_api/controller/errors/__init__.py
Normal file
@ -1,6 +1,6 @@
|
||||
from typing import Dict, Any
|
||||
|
||||
import collections
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
import time
|
||||
import json
|
||||
@ -72,7 +72,7 @@ def _process_request(pipeline, request) -> Dict[str, Any]:
|
||||
|
||||
# format targeted node filters (e.g. "params": {"Retriever": {"filters": {"value"}}})
|
||||
for key in params.keys():
|
||||
if isinstance(params[key], collections.Mapping) and "filters" in params[key].keys():
|
||||
if isinstance(params[key], Mapping) and "filters" in params[key].keys():
|
||||
params[key]["filters"] = _format_filters(params[key]["filters"])
|
||||
|
||||
result = pipeline.run(query=request.query, params=params, debug=request.debug)
|
||||
@ -1,45 +0,0 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
VERSION = "0.0.0"
|
||||
try:
|
||||
VERSION = open(Path(__file__).parent.parent / "VERSION.txt", "r").read()
|
||||
except Exception as e:
|
||||
logging.exception("No VERSION.txt found!")
|
||||
|
||||
|
||||
setup(
|
||||
name="farm-haystack-rest-api",
|
||||
version=VERSION,
|
||||
description="Demo REST API server for Haystack (https://github.com/deepset-ai/haystack)",
|
||||
author="deepset.ai",
|
||||
author_email="malte.pietsch@deepset.ai",
|
||||
url=" https://github.com/deepset-ai/haystack/tree/main/rest_api",
|
||||
classifiers=[
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Science/Research",
|
||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||
"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",
|
||||
],
|
||||
packages=find_packages(),
|
||||
python_requires=">=3.7, <4",
|
||||
install_requires=[
|
||||
# The link below cannot be translated properly into setup.cfg
|
||||
# because it looks into the parent folder.
|
||||
# TODO check if this is still a limitation later on
|
||||
f"farm-haystack @ file://localhost/{Path(__file__).parent.parent}#egg=farm-haystack",
|
||||
"fastapi<1",
|
||||
"uvicorn<1",
|
||||
"gunicorn<21",
|
||||
"python-multipart<1", # optional FastAPI dependency for form data
|
||||
],
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user