Skip to content

Commit

Permalink
ci: Enable black check for evaluation SDK (#37305)
Browse files Browse the repository at this point in the history
* chore: set black=true

* style: Run black
  • Loading branch information
kdestin authored Sep 12, 2024
1 parent eaadfa0 commit 0b71075
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ class _InternalEvaluationMetrics:
enum over time.
"""

ECI = "eci"
ECI = "eci"
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,4 @@ async def evaluate_with_rai_service(
annotation_response = await fetch_result(operation_id, rai_svc_url, credential, token)
result = parse_response(annotation_response, metric_name)

return result
return result
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def nltk_tokenize(text: str) -> List[str]:
# By default, use NLTK word tokenizer
tokens = nltk.word_tokenize(text)

return list(tokens)
return list(tokens)
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ class Prefixes:
PF_BATCH_TIMEOUT_SEC = "PF_BATCH_TIMEOUT_SEC"

OTEL_EXPORTER_OTLP_TRACES_TIMEOUT = "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT"
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT_DEFAULT = 60
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT_DEFAULT = 60
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def log_artifact(self, artifact_folder: str, artifact_name: str = EVALUATION_ART
remote_paths = {"paths": []}
local_paths = []
# Go over the artifact folder and upload all artifacts.
for (root, _, filenames) in os.walk(artifact_folder):
for root, _, filenames in os.walk(artifact_folder):
upload_path = root_upload_path
if root != artifact_folder:
rel_path = os.path.relpath(root, artifact_folder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ def _evaluate( # pylint: disable=too-many-locals

# Target Run
pf_client = PFClient(
config={"trace.destination": _trace_destination_from_project_scope(azure_ai_project)}
if azure_ai_project
else None,
config=(
{"trace.destination": _trace_destination_from_project_scope(azure_ai_project)} if azure_ai_project else None
),
user_agent=USER_AGENT,
)

Expand Down Expand Up @@ -601,4 +601,4 @@ def _evaluate( # pylint: disable=too-many-locals
if output_path:
_write_output(output_path, result)

return result
return result
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ def wrapper(*args, **kwargs) -> Callable:
azure_ai_project = kwargs.get("azure_ai_project", None)

pf_client = PFClient(
config={"trace.destination": _trace_destination_from_project_scope(azure_ai_project)}
if azure_ai_project
else None,
config=(
{"trace.destination": _trace_destination_from_project_scope(azure_ai_project)}
if azure_ai_project
else None
),
user_agent=USER_AGENT,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
"RougeScoreEvaluator",
"RougeType",
"ProtectedMaterialEvaluator",
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ def __call__(self, *, question: str, answer: str, **kwargs):
return async_run_allowing_running_loop(self._async_evaluator, question=question, answer=answer, **kwargs)

def _to_async(self):
return self._async_evaluator
return self._async_evaluator
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ def __call__(self, *, question: str, answer: str, **kwargs):
return async_run_allowing_running_loop(self._async_evaluator, question=question, answer=answer, **kwargs)

def _to_async(self):
return self._async_evaluator
return self._async_evaluator
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@

class ConversationRole(Enum):
"""Role in a chatbot conversation"""

USER = "user"
ASSISTANT = "assistant"
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class _UnstableAdversarialScenario(Enum):
Values listed here are subject to potential change, and/or migration to the main enum over time.
"""

ECI = "adv_politics"
ECI = "adv_politics"
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ async def __call__(
concurrent_async_task=concurrent_async_task,
_jailbreak_type="xpia",
)
return jb_sim_results
return jb_sim_results
2 changes: 1 addition & 1 deletion sdk/evaluation/azure-ai-evaluation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
mypy = false
pyright = false
pylint = false
black = false
black = true
bandit = false

0 comments on commit 0b71075

Please sign in to comment.