mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-07 20:46:31 +00:00
refactor: update package strategy in ui (#3396)
* update ui package: first try * update README * fixes * update schemas * restore schemas * use matrix folder in tests * fix tests * fix schemas * really fix schemas * don't use matrix folder * remove blank line * cleaner pytest command
This commit is contained in:
parent
3860bb9966
commit
8c1a34494d
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@ -82,7 +82,7 @@ jobs:
|
||||
|
||||
- name: Pylint
|
||||
run: |
|
||||
pylint -ry -j 0 haystack/ rest_api/rest_api ui/
|
||||
pylint -ry -j 0 haystack/ rest_api/rest_api ui/ui
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
@ -627,7 +627,6 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
@ -643,7 +642,8 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
pytest ${{ env.PYTEST_PARAMS }} rest_api/ ui/
|
||||
pytest ${{ env.PYTEST_PARAMS }} rest_api/
|
||||
pytest ${{ env.PYTEST_PARAMS }} ui/
|
||||
|
||||
- uses: act10ns/slack@v1
|
||||
with:
|
||||
|
||||
@ -3,14 +3,13 @@ FROM python:3.7.4-stretch
|
||||
# RUN apt-get update && apt-get install -y curl git pkg-config cmake
|
||||
|
||||
# copy code
|
||||
RUN mkdir ui/
|
||||
COPY . /opt/ui
|
||||
COPY . /ui
|
||||
|
||||
# install as a package
|
||||
RUN pip install --upgrade pip && \
|
||||
pip install /opt/ui/
|
||||
pip install /ui/
|
||||
|
||||
WORKDIR /opt
|
||||
WORKDIR /ui
|
||||
EXPOSE 8501
|
||||
|
||||
# cmd for running the API
|
||||
|
||||
@ -14,7 +14,7 @@ The UI interacts with the Haystack REST API. To get started with Haystack please
|
||||
|
||||
Execute in this folder:
|
||||
```
|
||||
streamlit run webapp.py
|
||||
streamlit run ui/webapp.py
|
||||
```
|
||||
|
||||
Requirements: This expects a running Haystack REST API at `http://localhost:8000`
|
||||
@ -34,7 +34,7 @@ The evaluation mode leverages the feedback REST API endpoint of haystack. The us
|
||||
|
||||
In order to use the UI in evaluation mode, you need an ElasticSearch instance with pre-indexed files and the Haystack REST API. You can set the environment up via docker images. For ElasticSearch, you can check out our [documentation](https://haystack.deepset.ai/usage/document-store#initialisation) and for setting up the REST API this [link](https://github.com/deepset-ai/haystack/blob/main/README.md#7-rest-api).
|
||||
|
||||
To enter the evaluation mode, select the checkbox "Evaluation mode" in the sidebar. The UI will load the predefined questions from the file [`eval_labels_examples`](https://raw.githubusercontent.com/deepset-ai/haystack/main/ui/eval_labels_example.csv). The file needs to be prefilled with your data. This way, the user will get a random question from the set and can give his feedback with the buttons below the questions. To load a new question, click the button "Get random question".
|
||||
To enter the evaluation mode, select the checkbox "Evaluation mode" in the sidebar. The UI will load the predefined questions from the file [`eval_labels_examples`](https://raw.githubusercontent.com/deepset-ai/haystack/main/ui/ui/eval_labels_example.csv). The file needs to be prefilled with your data. This way, the user will get a random question from the set and can give his feedback with the buttons below the questions. To load a new question, click the button "Get random question".
|
||||
|
||||
The file just needs to have two columns separated by semicolon. You can add more columns but the UI will ignore them. Every line represents a questions answer pair. The columns with the questions needs to be named “Question Text” and the answer column “Answer” so that they can be loaded correctly. Currently, the easiest way to create the file is manually by adding question answer pairs.
|
||||
|
||||
|
||||
73
ui/pyproject.toml
Normal file
73
ui/pyproject.toml
Normal file
@ -0,0 +1,73 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "ui"
|
||||
description = 'Minimal UI 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 = [
|
||||
"streamlit >= 1.9.0, < 2",
|
||||
"st-annotated-text >= 2.0.0, < 3",
|
||||
"markdown >= 3.3.4, < 4"
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://github.com/deepset-ai/haystack/tree/main/ui#readme"
|
||||
Issues = "https://github.com/deepset-ai/haystack/issues"
|
||||
Source = "https://github.com/deepset-ai/haystack/tree/main/ui"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "ui/__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=ui --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 = [
|
||||
"ui/__about__.py",
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
exclude_lines = [
|
||||
"no cov",
|
||||
"if __name__ == .__main__.:",
|
||||
"if TYPE_CHECKING:",
|
||||
]
|
||||
|
||||
[tool.black]
|
||||
line-length = 120
|
||||
skip_magic_trailing_comma = true # For compatibility with pydoc>=4.6, check if still needed.
|
||||
40
ui/setup.py
40
ui/setup.py
@ -1,40 +0,0 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
VERSION = "0.0.0"
|
||||
try:
|
||||
# After git clone, VERSION.txt is in the root folder
|
||||
VERSION = open(Path(__file__).parent.parent / "VERSION.txt", "r").read()
|
||||
except Exception:
|
||||
try:
|
||||
# In Docker, VERSION.txt is in the same folder
|
||||
VERSION = open(Path(__file__).parent / "VERSION.txt", "r").read()
|
||||
except Exception as e:
|
||||
logging.exception("No VERSION.txt found!")
|
||||
|
||||
setup(
|
||||
name="farm-haystack-ui",
|
||||
version=VERSION,
|
||||
description="Demo UI 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/ui",
|
||||
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=["streamlit>=1.9.0, <2", "st-annotated-text>=2.0.0, <3", "markdown>=3.3.4, <4"],
|
||||
)
|
||||
10
ui/ui/__about__.py
Normal file
10
ui/ui/__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!")
|
||||
Loading…
x
Reference in New Issue
Block a user