Skip to content

Commit

Permalink
fix jwt import and mark test
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesHolland committed Jul 15, 2024
1 parent 0bb0da3 commit 2402ec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from typing import List
from urllib.parse import urlparse

import jwt
# Check if the jwt package is available, since it's only included in the
# promtpflow-evals[azure] package.
try:
import jwt
except:
jwt = None
import numpy as np
import requests
from azure.core.credentials import TokenCredential
Expand Down Expand Up @@ -191,7 +196,7 @@ def get_rai_svc_url(project_scope: dict, token: str):
def fetch_or_reuse_token(credential: TokenCredential, token: str = None):
acquire_new_token = True
try:
if token:
if token and jwt:
# Decode the token to get its expiration time
decoded_token = jwt.decode(token, options={"verify_signature": False})
exp_time = decoded_token["exp"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_individual_evaluator_service_based(self, project_scope, azure_cred):
assert score["violence_score"] < 1.0
assert score["violence_reason"], "violence_reason must not be None or empty."

@pytest.mark.azuretest
def test_content_safety_service_unavailable(self, project_scope, azure_cred):
eval_fn = ViolenceEvaluator(project_scope, azure_cred)
# Doing this is replay mode breaks causes mismatch between scrubbed recordings
Expand Down

0 comments on commit 2402ec6

Please sign in to comment.