Skip to content

Commit b104372

Browse files
author
Robertson
committed
Merge branch 'main' into feature/e2e-func-tests
2 parents 6c618db + 616b3a1 commit b104372

9 files changed

Lines changed: 48 additions & 18 deletions

File tree

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# OAuth credentials for Athena API
2+
OAUTH_CLIENT_ID=your_oauth_client_id
3+
OAUTH_CLIENT_SECRET=your_oauth_client_secret
4+
OAUTH_AUTH_URL=https://crispthinking.auth0.com/oauth/token
5+
OAUTH_AUDIENCE=crisp-athena-live
6+
7+
# Athena server configuration
8+
# ATHENA_HOST=trust-messages.crispthinking.com
9+
ATHENA_AFFILIATE=athena-test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ wheels/
88

99
# Virtual environments
1010
.venv
11-
.env
11+
.env*
1212

1313
docs/_build/
1414

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ repository, or in your shell environment:
139139

140140
You must set the following variables:
141141
```
142-
ATHENA_HOST=your-athena-host (e.g. myathenahost.com)
142+
ATHENA_HOST=your-athena-host (e.g. localhost:5001)
143143
ATHENA_TEST_AFFILIATE=your-affiliate-id
144144
OAUTH_CLIENT_ID=your-oauth-client-id
145145
OAUTH_CLIENT_SECRET=your-oauth-client-secret

docs/api/options.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Environment-Based Configuration
157157
158158
# Load from environment variables
159159
options = AthenaOptions(
160-
host=os.getenv("ATHENA_HOST", "localhost:50051"),
160+
host=os.getenv("ATHENA_HOST", "trust-messages-global.crispthinking.com"),
161161
deployment_id=os.getenv("ATHENA_DEPLOYMENT_ID", "default"),
162162
resize_images=os.getenv("ATHENA_RESIZE_IMAGES", "true").lower() == "true",
163163
compress_images=os.getenv("ATHENA_COMPRESS_IMAGES", "true").lower() == "true",

docs/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This example shows:
4848
"OAUTH_AUTH_URL", "https://crispthinking.auth0.com/oauth/token"
4949
)
5050
audience = os.getenv("OAUTH_AUDIENCE", "crisp-athena-live")
51-
host = os.getenv("ATHENA_HOST", "localhost")
51+
host = os.getenv("ATHENA_HOST", "trust-messages-global.crispthinking.com")
5252
5353
# Create credential helper
5454
credential_helper = CredentialHelper(

examples/classify_single_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async def main() -> int:
203203
logger.error("OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET must be set")
204204
return 1
205205

206-
host = os.getenv("ATHENA_HOST", "localhost")
206+
host = os.getenv("ATHENA_HOST", "trust-messages-global.crispthinking.com")
207207
logger.info("Connecting to %s", host)
208208

209209
# Create credential helper

examples/example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ async def main() -> int:
152152
logger.error("OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET must be set")
153153
return 1
154154

155-
host = os.getenv("ATHENA_HOST", "localhost")
155+
host = os.getenv("ATHENA_HOST", "trust-messages-global.crispthinking.com")
156+
affiliate = os.getenv("ATHENA_AFFILIATE", "athena-test")
156157
logger.info("Connecting to %s", host)
157158

158159
# Create credential helper
@@ -192,7 +193,7 @@ async def main() -> int:
192193
compress_images=True,
193194
timeout=120.0, # Maximum duration, not forced timeout
194195
keepalive_interval=30.0, # Longer intervals for persistent streams
195-
affiliate="crisp",
196+
affiliate=affiliate,
196197
)
197198

198199
sent, received = await run_oauth_example(

src/resolver_athena_client/client/transformers/core.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
_expected_raw_size = EXPECTED_WIDTH * EXPECTED_HEIGHT * 3
2020

2121

22-
def _is_raw_rgb_expected_size(data: bytes) -> bool:
23-
"""Detect if data is already a raw RGB array of expected size."""
22+
def _is_raw_brg_expected_size(data: bytes) -> bool:
23+
"""Detect if data is already a raw BRG array of expected size."""
2424
return len(data) == _expected_raw_size
2525

2626

@@ -37,7 +37,7 @@ async def resize_image(image_data: ImageData) -> ImageData:
3737

3838
def process_image() -> tuple[bytes, bool]:
3939
# Fast path for raw RGB arrays of correct size
40-
if _is_raw_rgb_expected_size(image_data.data):
40+
if _is_raw_brg_expected_size(image_data.data):
4141
return image_data.data, False # No transformation needed
4242

4343
# Try to load the image data directly
@@ -55,8 +55,17 @@ def process_image() -> tuple[bytes, bool]:
5555
else:
5656
resized_image = rgb_image
5757

58-
# Convert to raw RGB bytes (C-order: height x width x channels)
59-
return resized_image.tobytes(), True # Data was transformed
58+
rgb_bytes = resized_image.tobytes()
59+
60+
# Convert RGB to BRG by swapping channels
61+
brg_bytes = bytearray(len(rgb_bytes))
62+
63+
for i in range(0, len(rgb_bytes), 3):
64+
brg_bytes[i] = rgb_bytes[i + 2]
65+
brg_bytes[i + 1] = rgb_bytes[i]
66+
brg_bytes[i + 2] = rgb_bytes[i + 1]
67+
68+
return bytes(brg_bytes), True # Data was transformed
6069

6170
# Use thread pool for CPU-intensive processing
6271
resized_bytes, was_transformed = await asyncio.to_thread(process_image)

tests/functional/test_classify_single.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,24 @@ async def test_classify_single(
3737
msg = f"Image Result Error: {result.error.message}"
3838
pytest.fail(msg)
3939

40-
hash_checks = [
40+
found_hash_check = False
41+
42+
for classification in result.classifications:
43+
if classification.label.startswith("KnownCSAM-"):
44+
assert classification.weight == 0.0
45+
found_hash_check = True
46+
break
47+
48+
assert found_hash_check, "No KnownHash- classification found"
49+
50+
assert [
4151
classification
4252
for classification in result.classifications
43-
if "hash" in classification.label.lower()
53+
if classification.label == "UnknownCSAM-Entropy"
4454
]
4555

46-
assert len(hash_checks) > 0, "No hash checks found in classifications"
47-
48-
for hash_check in hash_checks:
49-
assert hash_check.weight == 0.0
56+
assert [
57+
classification
58+
for classification in result.classifications
59+
if classification.label == "UnknownCSAM-PCSAM"
60+
]

0 commit comments

Comments
 (0)