Skip to content

Commit

Permalink
[NA] Add env setup to openai tests workflow (#102)
Browse files Browse the repository at this point in the history
* Add env setup to openai tests workflow

* Remove old fixture usage

* Move env setup to tests step

* Add debug print for integration test

* Add -ss arg to pytest

* Add debug print for integration test

* Fix log call

* Add log

* Move env setup to 1 level above

* Move env setup to 1 level above

* Delete env setup from runner

* Move env setup to runner

* Revert last change

* Add secrets: inherit

* Remove debug logs

* Remove -ss arg in pytest command
  • Loading branch information
alexkuzmik authored Nov 28, 2023
1 parent 657e01f commit 6af8e11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lib-integration-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
needs: [init_environment]
if: contains(fromJSON('["openai", "all"]'), needs.init_environment.outputs.LIBS)
uses: ./.github/workflows/lib-openai-tests.yml
secrets: inherit

notify_slack_failed:
if: ${{ always() && contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') }}
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/lib-openai-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Please read inputs to provide correct values.
#
name: Lib OpenAI Tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }}
on:
workflow_call:

Expand All @@ -29,7 +32,12 @@ jobs:
- name: Install comet-llm
run: pip install -e .

- name: Install test requirements
- 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 lib_integration/openai/requirements.txt
Expand Down
5 changes: 4 additions & 1 deletion tests/lib_integration/openai/test_openai_autologger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
import os

import pytest
Expand All @@ -8,15 +9,17 @@

from ... import testlib

LOGGER = logging.getLogger(__file__)

@pytest.fixture
def comet_setup():
with testlib.environ({"COMET_API_KEY": "FAKE-KEY"}):
yield

@pytest.mark.forked
def test_openai_autologger__chain_exists__openai_call_was_made__openai_call_added_to_chain_as_node(openai_setup, comet_setup):
def test_openai_autologger__chain_exists__openai_call_was_made__openai_call_added_to_chain_as_node(comet_setup):
import openai

comet_llm.start_chain(
inputs={"any-name": "any-input"},
metadata={"a": 123},
Expand Down

0 comments on commit 6af8e11

Please sign in to comment.