-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add Dataset pipelines (experimental) #1933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ankur Goyal (ankrgyl)
wants to merge
13
commits into
main
Choose a base branch
from
dataset-pipeline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d8444b6
initial commit
ankrgyl 222b907
updates
ankrgyl c62ac9c
Merge branch 'main' into dataset-pipeline
ankrgyl 5e991ba
Merge branch 'main' into dataset-pipeline
ankrgyl f32c4ca
test
ankrgyl bebf90a
include additional fields
ankrgyl 33e1fa8
propagate is_root field
ankrgyl 9d9d568
Fix dataset pipeline CI failures
ankrgyl b41fab5
Restore public API compatibility
ankrgyl 6e6231f
Use generated object reference type
ankrgyl cc31ec4
Avoid unused summary fetch in wrapper flush
ankrgyl eebc78d
Merge branch 'main' into dataset-pipeline
ankrgyl d98f6be
comments
ankrgyl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "braintrust": patch | ||
| --- | ||
|
|
||
| Add dataset pipeline helpers for deriving datasets from traced spans. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import type { ObjectReferenceType as ObjectReference } from "./generated_types"; | ||
| import type { | ||
| BaseMetadata, | ||
| Dataset, | ||
| DefaultMetadataType, | ||
| FullInitDatasetOptions, | ||
| } from "./logger"; | ||
| import type { Trace } from "./trace"; | ||
|
|
||
| export type DatasetPipelineScope = "span" | "trace"; | ||
|
|
||
| export type DatasetPipelineSource = { | ||
| projectId?: string; | ||
| projectName?: string; | ||
| orgName?: string; | ||
| filter?: string; | ||
| scope?: DatasetPipelineScope; | ||
| }; | ||
|
|
||
| type DatasetPipelineInitDatasetOptions = FullInitDatasetOptions<false>; | ||
|
|
||
| export type DatasetPipelineOrigin = ObjectReference; | ||
|
|
||
| export type DatasetPipelineTarget = { | ||
| projectId?: DatasetPipelineInitDatasetOptions["projectId"]; | ||
| projectName?: DatasetPipelineInitDatasetOptions["project"]; | ||
| orgName?: DatasetPipelineInitDatasetOptions["orgName"]; | ||
| datasetName: NonNullable<DatasetPipelineInitDatasetOptions["dataset"]>; | ||
| description?: DatasetPipelineInitDatasetOptions["description"]; | ||
| metadata?: DatasetPipelineInitDatasetOptions["metadata"]; | ||
| }; | ||
|
|
||
| export type DatasetPipelineRow = Parameters<Dataset["insert"]>[0]; | ||
|
|
||
| export type DatasetPipelineTransformArgs< | ||
| Input = unknown, | ||
| Output = unknown, | ||
| Expected = unknown, | ||
| Metadata extends BaseMetadata = DefaultMetadataType, | ||
| > = { | ||
| input?: Input; | ||
| output?: Output; | ||
| expected?: Expected; | ||
| metadata?: Metadata extends void ? Record<string, unknown> : Metadata; | ||
| trace?: Trace; | ||
| }; | ||
|
|
||
| export type DatasetPipelineTransformResult = | ||
| | DatasetPipelineRow | ||
| | DatasetPipelineRow[] | ||
| | null | ||
| | undefined; | ||
|
|
||
| export type DatasetPipelineTransform = ( | ||
| args: DatasetPipelineTransformArgs, | ||
| ) => DatasetPipelineTransformResult | Promise<DatasetPipelineTransformResult>; | ||
|
|
||
| export type DatasetPipelineDefinition = { | ||
| name?: string; | ||
| source: DatasetPipelineSource; | ||
| transform: DatasetPipelineTransform; | ||
| target: DatasetPipelineTarget; | ||
| }; | ||
|
|
||
| const DATASET_PIPELINE_MARKER = "__braintrustDatasetPipeline"; | ||
|
|
||
| declare global { | ||
| // eslint-disable-next-line no-var | ||
| var __braintrust_dataset_pipelines: DatasetPipelineDefinition[] | undefined; | ||
| } | ||
|
|
||
| function registry(): DatasetPipelineDefinition[] { | ||
| if (!globalThis.__braintrust_dataset_pipelines) { | ||
| globalThis.__braintrust_dataset_pipelines = []; | ||
| } | ||
| return globalThis.__braintrust_dataset_pipelines; | ||
| } | ||
|
|
||
| export function getRegisteredDatasetPipelines(): DatasetPipelineDefinition[] { | ||
| return [...registry()]; | ||
| } | ||
|
|
||
| export function isDatasetPipelineDefinition( | ||
| value: unknown, | ||
| ): value is DatasetPipelineDefinition { | ||
| return ( | ||
| typeof value === "object" && | ||
| value !== null && | ||
| DATASET_PIPELINE_MARKER in value | ||
| ); | ||
| } | ||
|
|
||
| export function DatasetPipeline( | ||
| definition: DatasetPipelineDefinition, | ||
| ): DatasetPipelineDefinition { | ||
| const registered = Object.assign(definition, { | ||
| [DATASET_PIPELINE_MARKER]: true, | ||
| }); | ||
| registry().push(registered); | ||
| return registered; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.