diff --git a/package-lock.json b/package-lock.json index eb368023b..3acee9b05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.39.9", "license": "MIT", "dependencies": { - "@vscode/codicons": "^0.0.35", + "@vscode/codicons": "^0.0.36", "@vscode/extension-telemetry": "^0.9.6", "@vscode/vsce": "^2.24.0", "@vscode/webview-ui-toolkit": "^1.4.0", @@ -820,9 +820,9 @@ "dev": true }, "node_modules/@vscode/codicons": { - "version": "0.0.35", - "resolved": "https://registry.npmjs.org/@vscode/codicons/-/codicons-0.0.35.tgz", - "integrity": "sha512-7iiKdA5wHVYSbO7/Mm0hiHD3i4h+9hKUe1O4hISAe/nHhagMwb2ZbFC8jU6d7Cw+JNT2dWXN2j+WHbkhT5/l2w==" + "version": "0.0.36", + "resolved": "https://registry.npmjs.org/@vscode/codicons/-/codicons-0.0.36.tgz", + "integrity": "sha512-wsNOvNMMJ2BY8rC2N2MNBG7yOowV3ov8KlvUE/AiVUlHKTfWsw3OgAOQduX7h0Un6GssKD3aoTVH+TF3DSQwKQ==" }, "node_modules/@vscode/extension-telemetry": { "version": "0.9.6", @@ -7553,9 +7553,9 @@ "dev": true }, "@vscode/codicons": { - "version": "0.0.35", - "resolved": "https://registry.npmjs.org/@vscode/codicons/-/codicons-0.0.35.tgz", - "integrity": "sha512-7iiKdA5wHVYSbO7/Mm0hiHD3i4h+9hKUe1O4hISAe/nHhagMwb2ZbFC8jU6d7Cw+JNT2dWXN2j+WHbkhT5/l2w==" + "version": "0.0.36", + "resolved": "https://registry.npmjs.org/@vscode/codicons/-/codicons-0.0.36.tgz", + "integrity": "sha512-wsNOvNMMJ2BY8rC2N2MNBG7yOowV3ov8KlvUE/AiVUlHKTfWsw3OgAOQduX7h0Un6GssKD3aoTVH+TF3DSQwKQ==" }, "@vscode/extension-telemetry": { "version": "0.9.6", diff --git a/package.json b/package.json index 3170f83b1..72aa244b7 100644 --- a/package.json +++ b/package.json @@ -1170,7 +1170,7 @@ "ms-python.python" ], "dependencies": { - "@vscode/codicons": "^0.0.35", + "@vscode/codicons": "^0.0.36", "@vscode/extension-telemetry": "^0.9.6", "@vscode/vsce": "^2.24.0", "@vscode/webview-ui-toolkit": "^1.4.0", diff --git a/src/commands/sqlToModel.ts b/src/commands/sqlToModel.ts index 6b486731f..4f8b227b7 100644 --- a/src/commands/sqlToModel.ts +++ b/src/commands/sqlToModel.ts @@ -61,7 +61,7 @@ export class SqlToModel { if (!event) { window.showErrorMessage( extendErrorWithSupportLinks( - "Could not convert to model due to pending initiation, Please retry again.", + "The extension is still initializing, please retry again.", ), ); this.telemetry.sendTelemetryError("sqlToModelNoManifestError"); diff --git a/src/commands/walkthroughCommands.ts b/src/commands/walkthroughCommands.ts index a2d7a19fb..a71a7fbd8 100644 --- a/src/commands/walkthroughCommands.ts +++ b/src/commands/walkthroughCommands.ts @@ -152,7 +152,14 @@ export class WalkthroughCommands { const { stdout, stderr } = await this.commandProcessExecutionFactory .createCommandProcessExecution({ command: this.pythonEnvironment.pythonPath, - args: ["-m", "pip", "install", "dbt", "--no-cache-dir"], + args: [ + "-m", + "pip", + "install", + "dbt", + "--no-cache-dir", + "--force-reinstall", + ], cwd: getFirstWorkspacePath(), envVars: this.pythonEnvironment.environmentVariables, }) @@ -232,7 +239,13 @@ export class WalkthroughCommands { }, async () => { try { - const args = ["-m", "pip", "install"]; + const args = [ + "-m", + "pip", + "install", + "--no-cache-dir", + "--force-reinstall", + ]; if (packageVersion >= "1.8") { args.push(`dbt-core==${packageVersion}`); args.push(`${packageName}>=${packageVersion}`); diff --git a/src/dbt_client/dbtCloudIntegration.ts b/src/dbt_client/dbtCloudIntegration.ts index dbd9426a5..6e95b0cb0 100644 --- a/src/dbt_client/dbtCloudIntegration.ts +++ b/src/dbt_client/dbtCloudIntegration.ts @@ -85,6 +85,27 @@ export class DBTCloudDetection implements DBTDetection { throw new Error(stderr); } if (stdout.includes("dbt Cloud CLI")) { + const regex = /dbt Cloud CLI - (\d*\.\d*\.\d*)/gm; + const matches = regex.exec(stdout); + if (matches?.length === 2) { + const version = matches[1].split("."); + const minVersion = "0.37.6"; + if ( + parseInt(version[0]) <= 0 && + parseInt(version[1]) <= 37 && + parseInt(version[2]) <= 6 + ) { + window.showErrorMessage( + `This version of dbt Cloud is not supported. Please update to a dbt Cloud CLI version higher than ${minVersion}`, + ); + this.terminal.debug( + "DBTCLIDetectionFailed", + "dbt cloud cli was found but version is not supported. Detection command returned : " + + stdout, + ); + return true; + } + } this.terminal.debug("DBTCLIDetectionSuccess", "dbt cloud cli detected"); return true; } else { @@ -169,6 +190,7 @@ export class DBTCloudProjectIntegration private rebuildManifestCancellationTokenSource: | CancellationTokenSource | undefined; + private pathsInitalized = false; constructor( private executionInfrastructure: DBTCommandExecutionInfrastructure, @@ -208,7 +230,13 @@ export class DBTCloudProjectIntegration } async refreshProjectConfig(): Promise { - await this.initializePaths(); + if (!this.pathsInitalized) { + // First time let,s block + await this.initializePaths(); + this.pathsInitalized = true; + } else { + this.initializePaths(); + } this.findAdapterType(); } @@ -489,7 +517,7 @@ export class DBTCloudProjectIntegration ), ); command.addArgument("--source"); - command.addArgument("dbtPowerUser"); + command.addArgument("dbt-power-user"); return command; } @@ -774,14 +802,56 @@ export class DBTCloudProjectIntegration // get dbt config private async initializePaths() { - // all hardcoded as there is no way to get them reliably - // we can't parse jinja - // TODO: read from dbt_project.yml instead - this.targetPath = join(this.projectRoot.fsPath, "target"); - this.modelPaths = [join(this.projectRoot.fsPath, "models")]; - this.seedPaths = [join(this.projectRoot.fsPath, "seeds")]; - this.macroPaths = [join(this.projectRoot.fsPath, "macros")]; - this.packagesInstallPath = join(this.projectRoot.fsPath, "dbt_packages"); + const packagePathsCommand = this.dbtCloudCommand( + new DBTCommand("Getting paths...", [ + "environment", + "show", + "--project-paths", + ]), + ); + try { + const { stdout, stderr } = await packagePathsCommand.execute(); + if (stderr) { + this.terminal.warn( + "DbtCloudIntegrationInitializePathsStdError", + "packaging paths command returns warning, ignoring", + true, + stderr, + ); + } + const lookupEntries = (lookupString: string) => { + const regexString = `${lookupString}\\s*\\[(.*)\\]`; + const regexp = new RegExp(regexString, "gm"); + const matches = regexp.exec(stdout); + if (matches?.length === 2) { + return matches[1].split(",").map((m) => m.slice(1, -1)); + } + throw new Error(`Could not find any entries for ${lookupString}`); + }; + this.targetPath = join(this.projectRoot.fsPath, "target"); + this.modelPaths = lookupEntries("Model paths").map((p) => + join(this.projectRoot.fsPath, p), + ); + this.seedPaths = lookupEntries("Seed paths").map((p) => + join(this.projectRoot.fsPath, p), + ); + this.macroPaths = lookupEntries("Macro paths").map((p) => + join(this.projectRoot.fsPath, p), + ); + this.packagesInstallPath = join(this.projectRoot.fsPath, "dbt_packages"); + } catch (error) { + this.terminal.warn( + "DbtCloudIntegrationInitializePathsExceptionError", + "adapter type throws error, ignoring", + true, + error, + ); + this.targetPath = join(this.projectRoot.fsPath, "target"); + this.modelPaths = [join(this.projectRoot.fsPath, "models")]; + this.seedPaths = [join(this.projectRoot.fsPath, "seeds")]; + this.macroPaths = [join(this.projectRoot.fsPath, "macros")]; + this.packagesInstallPath = join(this.projectRoot.fsPath, "dbt_packages"); + } } private async findAdapterType() { @@ -800,7 +870,7 @@ export class DBTCloudProjectIntegration const { stdout, stderr } = await adapterTypeCommand.execute(); if (stderr) { this.terminal.warn( - "DbtCloudIntegrationAdapterDetectioStdErrError", + "DbtCloudIntegrationAdapterDetectionStdError", "adapter type returns stderr, ignoring", true, stderr,