Skip to content

Commit 9bb6169

Browse files
committed
More fixes for CDS compilation task retry
1 parent 08961e9 commit 9bb6169

File tree

14 files changed

+47
-40
lines changed

14 files changed

+47
-40
lines changed

extractors/cds/tools/dist/cds-extractor.bundle.js

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractors/cds/tools/dist/cds-extractor.bundle.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractors/cds/tools/src/cds/compiler/compile.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function compileProjectLevel(
201201
'--to',
202202
'json',
203203
'--dest',
204-
'model.cds.json', // TODO: Replace `model.cds.json` with `model.<session_id>.cds.json`
204+
'model.cds.json',
205205
'--locations',
206206
'--log-level',
207207
'warn',
@@ -257,7 +257,6 @@ function compileProjectLevel(
257257
`CDS compiler generated JSON to output directory: ${projectJsonOutPath}`,
258258
);
259259
// Recursively rename generated .json files to have a .cds.json extension
260-
// TODO: Replace or remove this in favor of session-specific file suffixes (i.e. `.<session_id>.cds.json`).
261260
recursivelyRenameJsonFiles(projectJsonOutPath);
262261
} else {
263262
cdsExtractorLog('info', `CDS compiler generated JSON to file: ${projectJsonOutPath}`);

extractors/cds/tools/src/cds/compiler/graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function attemptCompilation(
1818
cacheDir: string | undefined,
1919
dependencyGraph: CdsDependencyGraph,
2020
): CompilationAttempt {
21-
const attemptId = `${task.id}_${Date.now()}_${Math.random().toString(36).substr(2, 5)}`;
2221
const startTime = new Date();
22+
const attemptId = `${task.id}_${startTime.getTime()}`;
2323

2424
const attempt: CompilationAttempt = {
2525
id: attemptId,

extractors/cds/tools/src/cds/compiler/retry.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,16 @@ function retryCompilationTask(
229229
projectDir: string,
230230
dependencyGraph: CdsDependencyGraph,
231231
): CompilationAttempt {
232-
const attemptId = `${task.id}_retry_${Date.now()}_${Math.random().toString(36).substr(2, 5)}`;
233232
const startTime = new Date();
233+
const attemptId = `${task.id}_retry_${startTime.getTime()}`;
234234

235-
// Use the original command string for consistency with existing compilation logic
235+
// Use the original command string for consistency with existing compilation logic.
236236
const cdsCommandString = retryCommand.originalCommand;
237237

238238
const attempt: CompilationAttempt = {
239239
id: attemptId,
240240
cdsCommand: cdsCommandString,
241-
cacheDir: projectDir, // For retry, we use the project directory
241+
cacheDir: projectDir,
242242
timestamp: startTime,
243243
result: {
244244
success: false,
@@ -247,14 +247,14 @@ function retryCompilationTask(
247247
};
248248

249249
try {
250-
// Use the same compilation logic as the original attempt
250+
// Use the same compilation logic as the original attempt.
251251
const primarySourceFile = task.sourceFiles[0];
252252

253253
const compilationResult = compileCdsToJson(
254254
primarySourceFile,
255255
dependencyGraph.sourceRootDir,
256256
cdsCommandString,
257-
projectDir, // Use project directory instead of cache directory for retry
257+
projectDir,
258258
// Convert CDS projects to BasicCdsProject format expected by compileCdsToJson
259259
new Map(
260260
Array.from(dependencyGraph.projects.entries()).map(([key, value]) => [
@@ -288,11 +288,11 @@ function retryCompilationTask(
288288
}
289289

290290
/**
291-
* Executes retry compilation for specific tasks
291+
* Executes retries for the provided array of {@link CompilationTask} instances.
292292
* @param tasksToRetry Tasks that need to be retried
293-
* @param project The project containing the tasks
294-
* @param dependencyGraph The dependency graph
295-
* @returns Retry execution results
293+
* @param project The {@link CdsProject} associated with the compilation tasks to retry
294+
* @param dependencyGraph The {@link CdsDependencyGraph} to update as tasks are retried
295+
* @returns The {@link ResultRetryCompilationTask}
296296
*/
297297
function retryCompilationTasksForProject(
298298
tasksToRetry: CompilationTask[],

extractors/cds/tools/src/cds/parser/graph.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export function buildCdsProjectDependencyGraph(sourceRootDir: string): CdsDepend
207207

208208
// Create the initial dependency graph structure
209209
const dependencyGraph: CdsDependencyGraph = {
210-
id: `cds_graph_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
210+
id: `cds_graph_${Date.now()}`,
211211
sourceRootDir,
212212
projects: new Map<string, CdsProject>(),
213213
debugInfo: {
@@ -245,7 +245,6 @@ export function buildCdsProjectDependencyGraph(sourceRootDir: string): CdsDepend
245245
successfulCompilations: 0,
246246
failedCompilations: 0,
247247
skippedCompilations: 0,
248-
retriedCompilations: 0,
249248
jsonFilesGenerated: 0,
250249
criticalErrors: [],
251250
warnings: [],

extractors/cds/tools/src/cds/parser/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ export interface ExtractionStatusSummary {
148148
failedCompilations: number;
149149
/** Skipped compilation tasks */
150150
skippedCompilations: number;
151-
/** Number of tasks that were successfully retried */
152-
retriedCompilations: number;
153151
/** JSON files generated */
154152
jsonFilesGenerated: number;
155153
/** Critical errors that stopped extraction */

extractors/cds/tools/src/logging/statusReport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function generateStatusReport(dependencyGraph: CdsDependencyGraph): strin
1313
lines.push('='.repeat(80));
1414
lines.push('');
1515

16-
// Overall summary
16+
// OVERALL SUMMARY
1717
lines.push('OVERALL SUMMARY:');
1818
lines.push(` Status: ${summary.overallSuccess ? 'SUCCESS' : 'FAILED'}`);
1919
lines.push(` Current Phase: ${dependencyGraph.currentPhase.toUpperCase()}`);
@@ -22,16 +22,16 @@ export function generateStatusReport(dependencyGraph: CdsDependencyGraph): strin
2222
lines.push(` JSON Files Generated: ${summary.jsonFilesGenerated}`);
2323
lines.push('');
2424

25-
// Compilation summary
25+
// COMPILATION SUMMARY
2626
lines.push('COMPILATION SUMMARY:');
2727
lines.push(` Total Tasks: ${summary.totalCompilationTasks}`);
2828
lines.push(` Successful: ${summary.successfulCompilations}`);
29-
lines.push(` Retried: ${summary.retriedCompilations}`);
29+
lines.push(` Retried: ${dependencyGraph.retryStatus.totalRetryAttempts}`);
3030
lines.push(` Failed: ${summary.failedCompilations}`);
3131
lines.push(` Skipped: ${summary.skippedCompilations}`);
3232
lines.push('');
3333

34-
// Retry summary (if retry attempts were made)
34+
// RETRY SUMMARY (if retry attempts were made)
3535
if (dependencyGraph.retryStatus.totalRetryAttempts > 0) {
3636
lines.push('RETRY SUMMARY:');
3737
lines.push(` Tasks Requiring Retry: ${dependencyGraph.retryStatus.totalTasksRequiringRetry}`);
@@ -48,7 +48,7 @@ export function generateStatusReport(dependencyGraph: CdsDependencyGraph): strin
4848
lines.push('');
4949
}
5050

51-
// Performance metrics
51+
// PERFORMANCE metrics
5252
lines.push('PERFORMANCE:');
5353
lines.push(` Total Duration: ${summary.performance.totalDurationMs}ms`);
5454
lines.push(` Parsing: ${summary.performance.parsingDurationMs}ms`);

extractors/cds/tools/test/src/cds/compiler/graph.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ function createMockDependencyGraph(
9393
successfulCompilations: 0,
9494
failedCompilations: 0,
9595
skippedCompilations: 0,
96-
retriedCompilations: 0,
9796
jsonFilesGenerated: 0,
9897
overallSuccess: false,
9998
criticalErrors: [],

extractors/cds/tools/test/src/cds/compiler/retry.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ describe('retry.ts', () => {
119119
successfulCompilations: 0,
120120
failedCompilations: 1,
121121
skippedCompilations: 0,
122-
retriedCompilations: 0,
123122
jsonFilesGenerated: 0,
124123
criticalErrors: [],
125124
warnings: [],

0 commit comments

Comments
 (0)