Skip to content

Commit

Permalink
add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
japdubengsub committed Dec 24, 2024
1 parent 4e2a742 commit 43b7529
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 2 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/lib-dspy-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Workflow to run DSPy tests
#
# Please read inputs to provide correct values.
#
name: SDK Lib DSPy Tests
run-name: "SDK Lib DSPy Tests ${{ github.ref_name }} by @${{ github.actor }}"
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }}
on:
workflow_call:

jobs:
tests:
name: DSPy Python ${{matrix.python_version}}
runs-on: ubuntu-latest
defaults:
run:
working-directory: sdks/python

strategy:
fail-fast: true
matrix:
python_version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Setup Python ${{matrix.python_version}}
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python_version}}

- name: Install opik
run: pip install .

- name: Install test tools
run: |
cd ./tests
pip install --no-cache-dir --disable-pip-version-check -r test_requirements.txt
- name: Install lib
run: |
cd ./tests
pip install --no-cache-dir --disable-pip-version-check -r library_integration/dspy/requirements.txt
- name: Run tests
run: |
cd ./tests/library_integration/dspy/
python -m pytest -vv .
7 changes: 7 additions & 0 deletions .github/workflows/lib-integration-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- aisuite
- haystack
- guardrails
- dspy
schedule:
- cron: "0 0 */1 * *"
pull_request:
Expand Down Expand Up @@ -87,3 +88,9 @@ jobs:
if: contains(fromJSON('["guardrails", "all"]'), needs.init_environment.outputs.LIBS)
uses: ./.github/workflows/lib-guardrails-tests.yml
secrets: inherit

dspy_tests:
needs: [init_environment]
if: contains(fromJSON('["dspy", "all"]'), needs.init_environment.outputs.LIBS)
uses: ./.github/workflows/lib-dspy-tests.yml
secrets: inherit
5 changes: 3 additions & 2 deletions sdks/python/src/opik/integrations/dspy/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def on_module_start(
instance=instance,
inputs=inputs,
)
new_trace_data = self._map_call_id_to_trace_data[call_id]
self._callback_context_set(new_trace_data)
new_span_data = self._map_call_id_to_span_data[call_id]
self._callback_context_set(new_span_data)
return

self._start_trace(
Expand Down Expand Up @@ -231,6 +231,7 @@ def on_lm_end(
self._end_trace(call_id=call_id)

def flush(self) -> None:
"""Sends pending Opik data to the backend"""
self._opik_client.flush()

def _callback_context_set(self, value: ContextType) -> None:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dspy
Loading

0 comments on commit 43b7529

Please sign in to comment.