Skip to content

Commit

Permalink
refactor: update package strategy in rest_api (deepset-ai#3148)
Browse files Browse the repository at this point in the history
* update packaging

* fix author metadata

* add newline

* add empty readme

* fix path to pipeline files

* fix pylint job

* fix metadata
  • Loading branch information
masci authored Sep 5, 2022
1 parent e211064 commit 6790eaf
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/utils/generate_openapi_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
File renamed without changes.
71 changes: 71 additions & 0 deletions rest_api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
]
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 changes: 10 additions & 0 deletions rest_api/rest_api/__about__.py
Original file line number Diff line number Diff line change
@@ -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!")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict, Any

import collections
from collections.abc import Mapping
import logging
import time
import json
Expand Down Expand Up @@ -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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 0 additions & 45 deletions rest_api/setup.py

This file was deleted.

0 comments on commit 6790eaf

Please sign in to comment.