Skip to content

Commit

Permalink
add validate_span_filter_condition to project type
Browse files Browse the repository at this point in the history
  • Loading branch information
axiomofjoy committed Mar 8, 2024
1 parent 358194f commit 1a56d21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ type Project implements Node {
spanEvaluationSummary(evaluationName: String!, timeRange: TimeRange, filterCondition: String): EvaluationSummary
documentEvaluationSummary(evaluationName: String!, timeRange: TimeRange, filterCondition: String): DocumentEvaluationSummary
streamingLastUpdatedAt: DateTime
validateSpanFilterCondition(condition: String!): ValidationResult!
}

type ProjectConnection {
Expand Down
18 changes: 18 additions & 0 deletions src/phoenix/server/api/types/Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
connection_from_list,
)
from phoenix.server.api.types.Span import Span, to_gql_span
from phoenix.server.api.types.ValidationResult import ValidationResult
from phoenix.trace.dsl import SpanFilter
from phoenix.trace.schemas import SpanID, TraceID

Expand Down Expand Up @@ -219,3 +220,20 @@ def streaming_last_updated_at(
self,
) -> Optional[datetime]:
return self.project.last_updated_at

@strawberry.field
def validate_span_filter_condition(self, condition: str) -> ValidationResult:
project = self.project
valid_eval_names = project.get_span_evaluation_names() if project else ()
try:
SpanFilter(
condition=condition,
evals=project,
valid_eval_names=valid_eval_names,
)
return ValidationResult(is_valid=True, error_message=None)
except SyntaxError as e:
return ValidationResult(
is_valid=False,
error_message=e.msg,
)

0 comments on commit 1a56d21

Please sign in to comment.