Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy refactor #509

Merged
merged 36 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ab2da20
serve web UI with FastAPI / uvicorn (#414)
pmeier May 16, 2024
dee960f
Merge branch 'main' into deploy-dev
pmeier Jun 10, 2024
528b953
unify API and UI servers (#418)
pmeier Jun 12, 2024
425b8b8
re-enable browser opening functionality (#431)
pmeier Jun 19, 2024
4d37e33
introduce engine for API (#434)
pmeier Jun 26, 2024
40f0b6c
refactor document registering and upload (#441)
pmeier Jul 9, 2024
a4002b2
Merge branch 'main' into deploy-dev
pmeier Jul 11, 2024
974862a
use backend engine in UI (#443)
pmeier Jul 11, 2024
2444011
Merge branch 'main' into deploy-dev
pmeier Aug 2, 2024
3f5ffa6
Merge branch 'main' into deploy-dev
pmeier Aug 26, 2024
d869bd0
Merge branch 'main' into deploy-dev
pmeier Aug 29, 2024
8016b66
Merge branch 'main' into deploy-dev
pmeier Dec 11, 2024
f41aa30
use bokeh_fastapi through panel (#503)
pmeier Dec 11, 2024
aa099ad
Merge branch 'deploy-dev' of github.com:Quansight/ragna into deploy-dev
pmeier Dec 11, 2024
f0f09dc
install bokeh_fastapi through panel (#513)
pmeier Dec 11, 2024
ac13a3c
add session based auth workflow (#464)
pmeier Dec 11, 2024
d444255
fix env name in CI
pmeier Dec 12, 2024
0d1e09b
fix docs
pmeier Dec 12, 2024
dc7595d
debug windows CI failure
pmeier Dec 12, 2024
1cbe83a
Revert "debug windows CI failure"
pmeier Dec 12, 2024
5765874
disable UI tests completely
pmeier Dec 12, 2024
388e676
trigger CI
pmeier Dec 12, 2024
b540c9e
disable cache restore keys
pmeier Dec 12, 2024
26da321
no progress bars in CI
pmeier Dec 12, 2024
3c363f0
pipefail
pmeier Dec 12, 2024
769c645
improve cache key step
pmeier Dec 12, 2024
5b2217f
debug seg fault
pmeier Dec 12, 2024
bcfe59b
fix tee option for macos
pmeier Dec 12, 2024
19ff247
debug
pmeier Dec 12, 2024
58ead9f
try conda as installer instead of mamba
pmeier Dec 12, 2024
49aabc7
Revert "try conda as installer instead of mamba"
pmeier Dec 12, 2024
509afb7
more debug
pmeier Dec 12, 2024
1cd64be
pin pymupdf
pmeier Dec 12, 2024
122312f
lint
pmeier Dec 12, 2024
e309c03
revert debug
pmeier Dec 12, 2024
37a3812
cleanup
pmeier Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@ runs:
using: composite

steps:
- name: Setup mambaforge and development environment
- name: Setup miniforge and empty development environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: ragna-dev

- name: Display conda info
shell: bash -el {0}
shell: bash -elo pipefail {0}
run: conda info

- name: Set cache date
id: cache-key
shell: bash
run: |
DATE=$(date +'%Y%m%d')
echo $DATE
echo "DATE=$DATE" >> $GITHUB_OUTPUT
echo "date=${DATE}" | tee -a "${GITHUB_OUTPUT}"

- name: Restore conda environment
id: cache
Expand All @@ -41,33 +39,31 @@ runs:
env-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version
}}|${{steps.cache-key.outputs.date }}-${{ hashFiles('environment-dev.yml',
'pyproject.toml') }}
restore-keys: |
env-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python-version }}

- name: Update conda environment if necessary
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
sed -i'' -e 's/python *= *[0-9.]\+/python =${{ inputs.python-version }}/g' environment-dev.yml
cat environment-dev.yml
mamba env update --file environment-dev.yml
mamba env update --quiet --file environment-dev.yml
git checkout -- environment-dev.yml

- name: Install playwright
shell: bash -el {0}
run: playwright install
# - name: Install playwright
# shell: bash -el {0}
# run: playwright install

- name: Install ragna
shell: bash -el {0}
shell: bash -elo pipefail {0}
run: |
if [[ ${{ inputs.optional-dependencies }} == true ]]
then
PROJECT_PATH='.[all]'
else
PROJECT_PATH='.'
fi
pip install --editable "${PROJECT_PATH}"
pip install --verbose --progress-bar=off --editable "${PROJECT_PATH}"

- name: Display development environment
shell: bash -el {0}
shell: bash -elo pipefail {0}
run: conda list
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand Down
133 changes: 66 additions & 67 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand All @@ -70,74 +70,73 @@ jobs:
id: tests
run: |
pytest \
--ignore tests/deploy/ui \
--junit-xml=test-results.xml \
--durations=25
--ignore tests/deploy/ui \
--junit-xml=test-results.xml \
--durations=25

- name: Surface failing tests
if: steps.tests.outcome != 'success'
uses: pmeier/[email protected]
with:
path: test-results.xml

pytest-ui:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
browser:
- chromium
- firefox
python-version:
- "3.10"
- "3.10"
- "3.12"
exclude:
- python-version: "3.11"
os: windows-latest
- python-version: "3.12"
os: windows-latest
- python-version: "3.11"
os: macos-latest
- python-version: "3.12"
os: macos-latest
include:
- browser: webkit
os: macos-latest
python-version: "3.10"

fail-fast: false

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -el {0}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup environment
uses: ./.github/actions/setup-env
with:
python-version: ${{ matrix.python-version }}

- name: Run unit tests
id: tests
run: |
pytest tests/deploy/ui \
--browser ${{ matrix.browser }} \
--video=retain-on-failure

- name: Upload playwright video
if: failure()
uses: actions/upload-artifact@v4
with:
name:
playwright-${{ matrix.os }}-${{ matrix.python-version}}-${{ github.run_id }}
path: test-results
# pytest-ui:
# strategy:
# matrix:
# os:
# - ubuntu-latest
# - windows-latest
# - macos-latest
# browser:
# - chromium
# - firefox
# python-version:
# - "3.10"
# - "3.10"
# - "3.12"
# exclude:
# - python-version: "3.11"
# os: windows-latest
# - python-version: "3.12"
# os: windows-latest
# - python-version: "3.11"
# os: macos-latest
# - python-version: "3.12"
# os: macos-latest
# include:
# - browser: webkit
# os: macos-latest
# python-version: "3.10"
#
# fail-fast: false
#
# runs-on: ${{ matrix.os }}
#
# defaults:
# run:
# shell: bash -elo pipefail {0}
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
#
# - name: Setup environment
# uses: ./.github/actions/setup-env
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Run unit tests
# id: tests
# run: |
# pytest tests/deploy/ui \
# --browser ${{ matrix.browser }} \
# --video=retain-on-failure
#
# - name: Upload playwright video
# if: failure()
# uses: actions/upload-artifact@v4
# with:
# name:
# playwright-${{ matrix.os }}-${{ matrix.python-version}}-${{ github.run_id }}
# path: test-results
2 changes: 1 addition & 1 deletion .github/workflows/update-docker-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
shell: bash -elo pipefail {0}

steps:
- name: Checkout repository
Expand Down
3 changes: 0 additions & 3 deletions docs/assets/images/web-ui-login.png

This file was deleted.

22 changes: 12 additions & 10 deletions docs/examples/gallery_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,30 @@ def answer(self, messages):

config = Config(assistants=[DemoStreamingAssistant])

rest_api = ragna_docs.RestApi()
ragna_deploy = ragna_docs.RagnaDeploy(config)

client, document = rest_api.start(config, authenticate=True, upload_document=True)
client, document = ragna_deploy.get_http_client(
authenticate=True, upload_sample_document=True
)

# %%
# Start and prepare the chat

chat = (
client.post(
"/chats",
"/api/chats",
json={
"name": "Tutorial REST API",
"documents": [document],
"document_ids": [document["id"]],
"source_storage": source_storages.RagnaDemoSourceStorage.display_name(),
"assistant": DemoStreamingAssistant.display_name(),
"params": {},
},
)
.raise_for_status()
.json()
)

client.post(f"/chats/{chat['id']}/prepare").raise_for_status()
client.post(f"/api/chats/{chat['id']}/prepare").raise_for_status()

# %%
# Streaming the response is performed with [JSONL](https://jsonlines.org/). Each line
Expand All @@ -140,7 +141,7 @@ def answer(self, messages):

with client.stream(
"POST",
f"/chats/{chat['id']}/answer",
f"/api/chats/{chat['id']}/answer",
json={"prompt": "What is Ragna?", "stream": True},
) as response:
chunks = [json.loads(data) for data in response.iter_lines()]
Expand All @@ -163,7 +164,8 @@ def answer(self, messages):
print("".join(chunk["content"] for chunk in chunks))

# %%
# Before we close the example, let's stop the REST API and have a look at what would
# have printed in the terminal if we had started it with the `ragna api` command.
# Before we close the example, let's terminate the REST API and have a look at what
# would have printed in the terminal if we had started it with the `ragna deploy`
# command.

rest_api.stop()
ragna_deploy.terminate()
Loading
Loading