Skip to content

Commit a93f450

Browse files
authored
Merge pull request #1128 from parea-ai/fix-instructor-key-error
try catch report_instructor_validation_errors
2 parents dc4b3fa + 3153623 commit a93f450

File tree

7 files changed

+4234
-3499
lines changed

7 files changed

+4234
-3499
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,33 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [ "3.8" ]
10+
python-version: [ "3.11" ]
1111

1212
steps:
13-
- uses: actions/checkout@v4.1.1
13+
- uses: actions/checkout@v4.2.2
1414
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v5.0.0
15+
uses: actions/setup-python@v5
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818

19-
- name: Install poetry
20-
run: make poetry-download
21-
22-
- name: Set up cache
23-
uses: actions/[email protected]
19+
- name: Install Poetry
20+
uses: snok/install-poetry@v1
21+
with:
22+
virtualenvs-create: true
23+
virtualenvs-in-project: true
24+
virtualenvs-path: .venv
25+
installer-parallel: true
26+
27+
- name: Load cached venv
28+
id: cached-poetry-dependencies
29+
uses: actions/cache@v4
2430
with:
2531
path: .venv
26-
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
32+
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
33+
2734
- name: Install dependencies
28-
run: |
29-
poetry config virtualenvs.in-project true
30-
poetry install
35+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
36+
run: poetry install --no-interaction --no-root
3137

3238
- name: Run style checks
3339
run: |
@@ -36,7 +42,3 @@ jobs:
3642
- name: Run tests
3743
run: |
3844
make test
39-
40-
# - name: Run safety checks
41-
# run: |
42-
# make check-safety

.github/workflows/greetings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
greeting:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/first-interaction@v1
9+
- uses: actions/first-interaction@v1.3.0
1010
with:
1111
repo-token: ${{ secrets.GITHUB_TOKEN }}
1212
pr-message: 'Hello @${{ github.actor }}, thank you for submitting a PR! We will respond as soon as possible.'

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
# Drafts your next Release notes as Pull Requests are merged into "master"
14-
- uses: release-drafter/release-drafter@v5.25.0
14+
- uses: release-drafter/release-drafter@v6.0.0
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ formatting: codestyle
4141
.PHONY: test
4242
test:
4343
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=parea tests/
44-
poetry run coverage-badge -o assets/images/coverage.svg -f
4544

4645
.PHONY: check-codestyle
4746
check-codestyle:

parea/utils/trace_integrations/instructor.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ def report_instructor_validation_errors() -> None:
5555
reason=reason,
5656
)
5757
trace_update_dict = {"scores": [instructor_score]}
58-
if children := trace_data.get()[instructor_trace_id.get()].children:
59-
last_child_trace_id = children[-1]
60-
trace_update_dict["configuration"] = trace_data.get()[last_child_trace_id].configuration
61-
trace_insert(trace_update_dict, instructor_trace_id.get())
58+
i_trace_id = instructor_trace_id.get()
59+
if i_trace_id:
60+
if children := trace_data.get()[i_trace_id].children:
61+
last_child_trace_id = children[-1]
62+
trace_update_dict["configuration"] = trace_data.get()[last_child_trace_id].configuration
63+
trace_insert(trace_update_dict, i_trace_id)
6264
instructor_trace_id.set("")
6365
instructor_val_err_count.set(0)
6466
instructor_val_errs.set([])
@@ -99,7 +101,11 @@ def fn_transform_generator_outputs(items: List) -> str:
99101
reasons = get_reasons(e)
100102
instructor_val_errs.set(instructor_val_errs.get() + reasons)
101103

102-
report_instructor_validation_errors()
104+
try:
105+
report_instructor_validation_errors()
106+
except Exception as e:
107+
logger.error(f"Failed to report instructor validation errors: {e}", exc_info=e)
108+
103109
current_log = trace_data.get()[trace_id]
104110
logger_update_record(UpdateLog(trace_id=trace_id, field_name_to_value_map={"scores": current_log.scores}, root_trace_id=current_log.root_trace_id))
105111

@@ -120,5 +126,8 @@ def __call__(
120126
reasons = get_reasons(args[1])
121127
instructor_val_errs.set(instructor_val_errs.get() + reasons)
122128
else:
123-
report_instructor_validation_errors()
129+
try:
130+
report_instructor_validation_errors()
131+
except Exception as e:
132+
logger.error(f"Failed to report instructor validation errors: {e}", exc_info=e)
124133
return wrapped(*args, **kwargs)

0 commit comments

Comments
 (0)