Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
penguine-ip committed Jan 22, 2025
1 parent bec29f0 commit 0a38a1a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions deepeval/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def capture_evaluation_run(type: str):
span.set_attribute("environment", IS_RUNNING_IN_JUPYTER)
span.set_attribute("user.status", get_status())
span.set_attribute("user.unique_id", get_unique_id())
span.set_attribute("feature_status.evaluation", get_feature_status(Feature.EVALUATION))
span.set_attribute(
"feature_status.evaluation",
get_feature_status(Feature.EVALUATION),
)
if anonymous_public_ip:
span.set_attribute("user.public_ip", anonymous_public_ip)
set_last_feature(Feature.EVALUATION)
Expand Down Expand Up @@ -165,7 +168,10 @@ def capture_synthesizer_run(
span.set_attribute("environment", IS_RUNNING_IN_JUPYTER)
span.set_attribute("user.status", get_status())
span.set_attribute("user.unique_id", get_unique_id())
span.set_attribute("feature_status.synthesizer", get_feature_status(Feature.SYNTHESIZER))
span.set_attribute(
"feature_status.synthesizer",
get_feature_status(Feature.SYNTHESIZER),
)
span.set_attribute("method", method)
span.set_attribute("max_generations", max_generations)
span.set_attribute("evolutions", num_evolutions)
Expand All @@ -190,7 +196,10 @@ def capture_red_teamer_run(
span.set_attribute("environment", IS_RUNNING_IN_JUPYTER)
span.set_attribute("user.status", get_status())
span.set_attribute("user.unique_id", get_unique_id())
span.set_attribute("feature_status.redteaming", get_feature_status(Feature.REDTEAMING))
span.set_attribute(
"feature_status.redteaming",
get_feature_status(Feature.REDTEAMING),
)
span.set_attribute(
"attacks_per_vulnerability", attacks_per_vulnerability_type
)
Expand All @@ -216,7 +225,10 @@ def capture_guardrails(guards: List[str]):
span.set_attribute("environment", IS_RUNNING_IN_JUPYTER)
span.set_attribute("user.status", get_status())
span.set_attribute("user.unique_id", get_unique_id())
span.set_attribute("feature_status.guardrail", get_feature_status(Feature.GUARDRAIL))
span.set_attribute(
"feature_status.guardrail",
get_feature_status(Feature.GUARDRAIL),
)
for guard in guards:
span.set_attribute(f"vulnerability.{guard}", 1)
set_last_feature(Feature.GUARDRAIL)
Expand All @@ -234,7 +246,10 @@ def capture_benchmark_run(benchmark: str, num_tasks: int):
span.set_attribute("environment", IS_RUNNING_IN_JUPYTER)
span.set_attribute("user.status", get_status())
span.set_attribute("user.unique_id", get_unique_id())
span.set_attribute("feature_status.benchmark", get_feature_status(Feature.BENCHMARK))
span.set_attribute(
"feature_status.benchmark",
get_feature_status(Feature.BENCHMARK),
)
span.set_attribute("benchmark", benchmark)
span.set_attribute("num_tasks", num_tasks)
set_last_feature(Feature.BENCHMARK)
Expand Down Expand Up @@ -324,8 +339,9 @@ def set_last_feature(feature: Feature):
data[feature_status_key] = "old"
write_telemetry_file(data)


def get_feature_status(feature: Feature) -> str:
"""Gets the status of a feature ('new' or 'old') from the telemetry file."""
data = read_telemetry_file()
feature_status_key = f"DEEPEVAL_{feature.value.upper()}_STATUS"
return data.get(feature_status_key, "new")
return data.get(feature_status_key, "new")

0 comments on commit 0a38a1a

Please sign in to comment.