Skip to content

Commit e4bee74

Browse files
committed
ts: show coordinator program id in front
1 parent 67ba214 commit e4bee74

File tree

7 files changed

+36
-10
lines changed

7 files changed

+36
-10
lines changed

website/backend/src/coordinator.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
export type UniqueRunKey = `${string}-${string}-${string}` & { __uniqueRunKey: true }
1+
export type UniqueRunKey = `${string}-${string}-${string}` & {
2+
__uniqueRunKey: true
3+
}
24

3-
export function runKey(programId: string, runId: string, index: number): UniqueRunKey {
5+
export function runKey(
6+
programId: string,
7+
runId: string,
8+
index: number
9+
): UniqueRunKey {
410
return `${programId}-${runId}-${index}` as UniqueRunKey
511
}
612

@@ -13,13 +19,13 @@ export function getRunFromKey(
1319
const [runId, index] = splitAtLastInstance(runKey, '-')
1420
return ['', runId, Number.parseInt(index, 10)]
1521
}
16-
22+
1723
// New format: programId-runId-index
1824
// Handle case where runId might contain dashes by joining middle parts
1925
const programId = parts[0]
2026
const index = parts[parts.length - 1]
2127
const runId = parts.slice(1, -1).join('-')
22-
28+
2329
return [programId, runId, Number.parseInt(index, 10)]
2430
}
2531

website/backend/src/dataStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface ChainDataStore {
2323

2424
export interface CoordinatorDataStore extends ChainDataStore {
2525
eventEmitter: EventEmitter<{ update: [UniqueRunKey] }>
26-
26+
2727
readonly programId: PublicKey
2828

2929
createRun(

website/backend/src/dataStores/flatFileCoordinator.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ export class FlatFileCoordinatorDataStore implements CoordinatorDataStore {
263263
})
264264
}
265265

266-
this.#runsMutatedSinceLastSync.add(runKey(this.#programId.toString(), lastRun.runId, index))
266+
this.#runsMutatedSinceLastSync.add(
267+
runKey(this.#programId.toString(), lastRun.runId, index)
268+
)
267269
}
268270

269271
setRunPaused(pubkey: string, paused: boolean, timestamp: ChainTimestamp) {
@@ -278,7 +280,9 @@ export class FlatFileCoordinatorDataStore implements CoordinatorDataStore {
278280
lastRun.lastUpdated = timestamp
279281
lastRun.pauseTimestamps.push([newPauseState, timestamp])
280282

281-
this.#runsMutatedSinceLastSync.add(runKey(this.#programId.toString(), lastRun.runId, index))
283+
this.#runsMutatedSinceLastSync.add(
284+
runKey(this.#programId.toString(), lastRun.runId, index)
285+
)
282286
}
283287

284288
witnessRun(
@@ -432,7 +436,9 @@ export class FlatFileCoordinatorDataStore implements CoordinatorDataStore {
432436
}
433437

434438
getRunDataById(runId: string, index: number): RunData | null {
435-
const cachedRun = this.#runCache.get(runKey(this.#programId.toString(), runId, index))
439+
const cachedRun = this.#runCache.get(
440+
runKey(this.#programId.toString(), runId, index)
441+
)
436442
if (cachedRun) {
437443
return cachedRun
438444
}
@@ -577,14 +583,18 @@ export class FlatFileCoordinatorDataStore implements CoordinatorDataStore {
577583

578584
const runData = {
579585
info,
586+
programId: this.#programId.toString(),
580587
state,
581588
recentTxs: run.recentTxs,
582589
metrics: {
583590
summary,
584591
history,
585592
},
586593
}
587-
this.#runCache.set(runKey(this.#programId.toString(), runId, index), runData)
594+
this.#runCache.set(
595+
runKey(this.#programId.toString(), runId, index),
596+
runData
597+
)
588598
return runData
589599
}
590600
}
@@ -671,6 +681,7 @@ function makeRunSummary(
671681
size: run.lastState.metadata.num_parameters,
672682
trainingStep,
673683
type: 'text', // TODO add type / tags? :)
684+
programId: this.#programId.toString(),
674685
}
675686
return summary
676687
}

website/backend/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,11 @@ async function main() {
262262
return
263263
}
264264

265-
const key = runKey(coordinator.dataStore.programId.toString(), matchingRun.info.id, matchingRun.info.index)
265+
const key = runKey(
266+
coordinator.dataStore.programId.toString(),
267+
matchingRun.info.id,
268+
matchingRun.info.index
269+
)
266270
let listeners = liveRunListeners.get(key)
267271
if (!listeners) {
268272
listeners = new Set()

website/frontend/src/components/RunSummary.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function RunSummaryCard({
6464
type,
6565
index,
6666
isOnlyRunAtThisIndex,
67+
programId,
6768
},
6869
}: {
6970
info: RunSummary
@@ -80,6 +81,7 @@ export function RunSummaryCard({
8081
<RunTitleRow>
8182
<RunTitle className={text['display/2xl']}>
8283
{name || id} {isOnlyRunAtThisIndex ? '' : `(v${index + 1})`}
84+
{programId && ` - ${programId.slice(0, 12)}`}
8385
</RunTitle>
8486
<StatusChip status={status.type} style="minimal" />
8587
</RunTitleRow>

website/frontend/src/routes/runs/$run.$index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function RouteComponent() {
143143
<span className={text['display/4xl']}>
144144
{info.name || info.id}{' '}
145145
{info.isOnlyRunAtThisIndex ? '' : `(v${info.index + 1})`}
146+
{run.programId && ` - ${run.programId.slice(0, 12)}`}
146147
</span>
147148
<TitleRightInfo>
148149
<StatusChip status={info.status.type} style="minimal" />

website/shared/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface RunSummary {
7474
size: bigint
7575
arch: LLMArchitecture
7676
type: ModelType
77+
programId: string
7778
}
7879

7980
export type Metrics = {
@@ -109,6 +110,7 @@ export interface TxSummary {
109110

110111
export interface RunData {
111112
info: RunSummary
113+
programId: string
112114
state?: {
113115
phase: RunState
114116
phaseStartTime: Date

0 commit comments

Comments
 (0)