Skip to content

Commit f3c4900

Browse files
author
Tom Softreck
committed
update
1 parent 339e17f commit f3c4900

File tree

2 files changed

+72
-16
lines changed

2 files changed

+72
-16
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.9', '3.10', '3.11']
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
cache: 'poetry'
24+
25+
- name: Install system dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y python3-venv
29+
30+
- name: Install Poetry
31+
run: |
32+
# Install specific version of Poetry directly
33+
pip install "poetry==1.5.1"
34+
echo "$(python -m site --user-base)/bin" >> $GITHUB_PATH
35+
36+
- name: Configure Poetry
37+
run: |
38+
# Configure Poetry with explicit paths
39+
poetry config virtualenvs.create true
40+
poetry config virtualenvs.in-project true
41+
poetry config virtualenvs.path .venv
42+
poetry config --list
43+
poetry --version
44+
45+
- name: Install dependencies
46+
run: |
47+
# Install with verbose output for better debugging
48+
poetry install --no-interaction --no-ansi -v
49+
# Verify the environment
50+
poetry env info
51+
52+
- name: Run tests
53+
run: |
54+
poetry run pytest tests/ -v
55+
56+
- name: Lint with flake8
57+
run: |
58+
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
59+
poetry run flake8 . --count --max-complexity=10 --max-line-length=88 --statistics

src/dialogchain/processors.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ async def process(self, message: Any) -> Optional[Any]:
130130

131131
except Exception as e:
132132
print(f"❌ Filter processor error: {e}")
133-
return None # Filter out on error to be safe
133+
# Pass through the message on error as per test expectation
134+
return message
134135

135136
def _evaluate_condition(self, condition: str, context: Dict) -> bool:
136137
"""
@@ -145,22 +146,18 @@ def _evaluate_condition(self, condition: str, context: Dict) -> bool:
145146
146147
Returns:
147148
bool: The result of the condition evaluation
148-
"""
149-
try:
150-
# First, render any template variables in the condition
151-
from jinja2 import Template
152-
template = Template(condition)
153-
rendered_condition = template.render(**context)
154149
155-
# Then evaluate the rendered condition as a Python expression
156-
# We use a safe evaluation context with only the context variables
157-
return eval(rendered_condition, {"__builtins__": {}}, context)
158-
except Exception as e:
159-
print(f"❌ Condition evaluation error: {e}, condition: {condition}")
160-
# In case of error, return False to filter out the message
161-
# but store the error in the context for debugging
162-
context['_filter_error'] = str(e)
163-
return False
150+
Raises:
151+
Exception: If there's an error evaluating the condition
152+
"""
153+
# First, render any template variables in the condition
154+
from jinja2 import Template
155+
template = Template(condition)
156+
rendered_condition = template.render(**context)
157+
158+
# Then evaluate the rendered condition as a Python expression
159+
# We use a safe evaluation context with only the context variables
160+
return eval(rendered_condition, {"__builtins__": {}}, context)
164161

165162

166163
class TransformProcessor(Processor):

0 commit comments

Comments
 (0)