Skip to content

Commit 7e45eda

Browse files
committed
Comment out segment processing temporarily
1 parent 2a9d4ac commit 7e45eda

File tree

1 file changed

+80
-74
lines changed
  • packages/core/src/services/tracing/segments

1 file changed

+80
-74
lines changed

packages/core/src/services/tracing/segments/process.ts

Lines changed: 80 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-nocheck
3+
/* eslint-disable */
4+
15
import { differenceInMilliseconds, isAfter, isBefore } from 'date-fns'
26
import { scan } from 'promptl-ai'
37
import {
48
ApiKey,
5-
BaseSegmentMetadata,
69
DocumentType,
710
EvaluationType,
811
EvaluationV2,
@@ -12,7 +15,6 @@ import {
1215
SegmentMetadata,
1316
SegmentSource,
1417
SegmentType,
15-
SegmentWithDetails,
1618
SpanStatus,
1719
SpanType,
1820
SpanWithDetails,
@@ -75,101 +77,102 @@ export async function processSegment(
7577

7678
const type = state.current?.type ?? state.segment.type
7779

78-
const specification = SEGMENT_SPECIFICATIONS[type]
79-
if (!specification) {
80-
return Result.error(new UnprocessableEntityError('Invalid segment type'))
81-
}
82-
83-
let metadata = {
84-
...({
85-
traceId: traceId,
86-
segmentId: id,
87-
type: type,
88-
} satisfies BaseSegmentMetadata),
89-
} as SegmentMetadata
90-
91-
// @ts-expect-error seems typescript cannot infer that state types are the same
92-
const processing = await specification.process(state, tx)
93-
if (processing.error) return Result.error(processing.error)
94-
metadata = { ...metadata, ...processing.value }
95-
96-
// Note: edge case when the global document segment is being processed right now for the first time
97-
if (metadata.type === SegmentType.Document) {
98-
state.run = { metadata } as SegmentWithDetails<SegmentType.Document>
99-
}
100-
101-
const computingei = computeExternalId(state)
102-
if (computingei.error) return Result.error(computingei.error)
103-
const externalId = computingei.value
104-
105-
const enrichingnm = enrichName(state)
106-
if (enrichingnm.error) return Result.error(enrichingnm.error)
107-
const name = enrichingnm.value
108-
109-
const computingsc = computeSource(state)
110-
if (computingsc.error) return Result.error(computingsc.error)
111-
const source = computingsc.value
112-
113-
const computingst = computeStatus(state)
114-
if (computingst.error) return Result.error(computingst.error)
115-
const { status, message } = computingst.value
80+
// const specification = SEGMENT_SPECIFICATIONS[type]
81+
// if (!specification) {
82+
// return Result.error(new UnprocessableEntityError('Invalid segment type'))
83+
// }
84+
85+
// let metadata = {
86+
// ...({
87+
// traceId: traceId,
88+
// segmentId: id,
89+
// type: type,
90+
// } satisfies BaseSegmentMetadata),
91+
// } as SegmentMetadata
92+
93+
// // @ts-expect-error seems typescript cannot infer that state types are the same
94+
// const processing = await specification.process(state, tx)
95+
// if (processing.error) return Result.error(processing.error)
96+
// metadata = { ...metadata, ...processing.value }
97+
98+
// // Note: edge case when the global document segment is being processed right now for the first time
99+
// if (metadata.type === SegmentType.Document) {
100+
// state.run = { metadata } as SegmentWithDetails<SegmentType.Document>
101+
// }
102+
103+
// const computingei = computeExternalId(state)
104+
// if (computingei.error) return Result.error(computingei.error)
105+
// const externalId = computingei.value
106+
107+
// const enrichingnm = enrichName(state)
108+
// if (enrichingnm.error) return Result.error(enrichingnm.error)
109+
// const name = enrichingnm.value
110+
111+
// const computingsc = computeSource(state)
112+
// if (computingsc.error) return Result.error(computingsc.error)
113+
// const source = computingsc.value
114+
115+
// const computingst = computeStatus(state)
116+
// if (computingst.error) return Result.error(computingst.error)
117+
// const { status, message } = computingst.value
116118

117119
const computinglu = computeLogUuid(state)
118120
if (computinglu.error) return Result.error(computinglu.error)
119121
const logUuid = computinglu.value
120122

121-
const computingdc = computeDocument(state)
122-
if (computingdc.error) return Result.error(computingdc.error)
123-
const { commitUuid, documentUuid, documentHash,
124-
documentType, provider, model } = computingdc.value // prettier-ignore
123+
// const computingdc = computeDocument(state)
124+
// if (computingdc.error) return Result.error(computingdc.error)
125+
// const { commitUuid, documentUuid, documentHash,
126+
// documentType, provider, model } = computingdc.value // prettier-ignore
125127

126-
const computingeu = computeExperimentUuid(state)
127-
if (computingeu.error) return Result.error(computingeu.error)
128-
const experimentUuid = computingeu.value
128+
// const computingeu = computeExperimentUuid(state)
129+
// if (computingeu.error) return Result.error(computingeu.error)
130+
// const experimentUuid = computingeu.value
129131

130-
const computingsa = computeStatistics(state)
131-
if (computingsa.error) return Result.error(computingsa.error)
132-
const { tokens, cost, duration } = computingsa.value
132+
// const computingsa = computeStatistics(state)
133+
// if (computingsa.error) return Result.error(computingsa.error)
134+
// const { tokens, cost, duration } = computingsa.value
133135

134-
const computingts = computeTimestamps(state)
135-
if (computingts.error) return Result.error(computingts.error)
136-
const { startedAt, endedAt } = computingts.value
136+
// const computingts = computeTimestamps(state)
137+
// if (computingts.error) return Result.error(computingts.error)
138+
// const { startedAt, endedAt } = computingts.value
137139

138140
const repository = new SegmentsRepository(args.workspace.id, tx)
139141
const locking = await repository.lock({ segmentId: id, traceId })
140142
if (locking.error) {
141143
return Result.error(new ConflictError('Segment processing data race'))
142144
}
143145

144-
const saving = await saveMetadata({ metadata, workspace: args.workspace }, disk) // prettier-ignore
145-
if (saving.error) return Result.error(saving.error)
146+
// const saving = await saveMetadata({ metadata, workspace: args.workspace }, disk) // prettier-ignore
147+
// if (saving.error) return Result.error(saving.error)
146148

149+
// TODO(tracing): temporal segment fixing patch
147150
const fields = {
148151
...(state.current ?? {}),
149152
id: id,
150153
traceId: traceId,
151154
parentId: parentId,
152155
workspaceId: args.workspace.id,
153156
apiKeyId: args.apiKey.id,
154-
externalId: externalId,
155-
name: name,
156-
source: source,
157+
externalId: undefined, // externalId,
158+
name: 'name', // name,
159+
source: SegmentSource.API, // source,
157160
type: type,
158-
status: status,
159-
message: message,
161+
status: SpanStatus.Ok, // status,
162+
message: undefined, // message,
160163
logUuid: logUuid,
161-
commitUuid: commitUuid,
162-
documentUuid: documentUuid,
163-
documentHash: documentHash,
164-
documentType: documentType,
165-
experimentUuid: experimentUuid,
166-
provider: provider,
167-
model: model,
168-
tokens: tokens,
169-
cost: cost,
170-
duration: duration,
171-
startedAt: startedAt,
172-
endedAt: endedAt,
164+
commitUuid: '7fdf3f27-ed4e-4710-a8fd-90b4121e2106', // commitUuid,
165+
documentUuid: '7fdf3f27-ed4e-4710-a8fd-90b4121e2106', // documentUuid,
166+
documentHash: 'documentHash', // documentHash,
167+
documentType: DocumentType.Prompt, // documentType,
168+
experimentUuid: undefined, // experimentUuid,
169+
provider: 'provider', // provider,
170+
model: 'model', // model,
171+
tokens: 0, // tokens,
172+
cost: 0, // cost,
173+
duration: 0, // duration,
174+
startedAt: new Date(), // startedAt,
175+
endedAt: new Date(), // endedAt,
173176
}
174177

175178
const segment = (await tx
@@ -227,12 +230,15 @@ export async function processSegment(
227230
await tracingQueue.add('processSegmentJob', payload, {
228231
attempts: TRACING_JOBS_MAX_ATTEMPTS,
229232
deduplication: {
230-
id: processSegmentJobKey(payload, { ...segment, metadata }),
233+
id: processSegmentJobKey(payload, {
234+
...segment,
235+
metadata: undefined,
236+
}),
231237
},
232238
})
233239
}
234240

235-
return Result.ok({ segment: { ...segment, metadata } })
241+
return Result.ok({ segment: { ...segment, metadata: undefined } })
236242
})
237243
}
238244

0 commit comments

Comments
 (0)