Skip to content

Commit

Permalink
feat: diagnostics additional info and dbt install checks (#1307)
Browse files Browse the repository at this point in the history
* feat: showing allow list folders

* feat: printing all python paths

* feat: added python 3 check

* Update src/dbt_client/index.ts

---------

Co-authored-by: anandgupta42 <[email protected]>
Co-authored-by: Michiel De Smet <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2024
1 parent cae15df commit 9afa882
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,16 @@ export class VSCodeCommands implements Disposable {
);
this.dbtTerminal.logNewLine();

// Printing env vars
this.dbtTerminal.logBlockWithHeader(
[
"Printing all python paths...",
"* Please remove any sensitive information before sending it to us",
],
this.pythonEnvironment.allPythonPaths.map(({ path }) => path),
);
this.dbtTerminal.logNewLine();

// Printing extension settings
const dbtSettings = workspace.getConfiguration().inspect("dbt");
const globalValue: any = dbtSettings?.globalValue || {};
Expand Down Expand Up @@ -452,6 +462,9 @@ export class VSCodeCommands implements Disposable {
const dbtIntegrationMode = workspace
.getConfiguration("dbt")
.get<string>("dbtIntegration", "core");
const allowListFolders = workspace
.getConfiguration("dbt")
.get<string[]>("allowListFolders", []);
this.dbtTerminal.logBlock([
`Python Path=${this.pythonEnvironment.pythonPath}`,
`VSCode version=${version}`,
Expand All @@ -461,6 +474,7 @@ export class VSCodeCommands implements Disposable {
}`,
`DBT integration mode=${dbtIntegrationMode}`,
`First workspace path=${getFirstWorkspacePath()}`,
`AllowList Folders=${allowListFolders}`,
]);
this.dbtTerminal.logNewLine();

Expand Down
10 changes: 10 additions & 0 deletions src/dbt_client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ export class DBTClient implements Disposable {
}
return false;
}
if (!this.pythonEnvironment.isPython3) {
const answer = await window.showErrorMessage(
"Only Python 3 is supported by dbt, please select a Python 3 interpreter",
PythonInterpreterPromptAnswer.SELECT,
);
if (answer === PythonInterpreterPromptAnswer.SELECT) {
commands.executeCommand("python.setInterpreter");
}
return false;
}
return this.showErrorIfDbtIsNotInstalled();
}

Expand Down
7 changes: 7 additions & 0 deletions src/manifest/pythonEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class PythonEnvironment implements Disposable {
private executionDetails?: PythonExecutionDetails;
private disposables: Disposable[] = [];
private environmentVariableSource: Record<string, EnvFrom> = {};
public allPythonPaths: { path: string; pathType: string }[] = [];
public isPython3: boolean = true;
constructor(
private telemetry: TelemetryService,
private commandProcessExecutionFactory: CommandProcessExecutionFactory,
Expand Down Expand Up @@ -117,6 +119,11 @@ export class PythonEnvironment implements Disposable {
await extension.exports.ready;

const api = extension.exports;
this.allPythonPaths = await api.environment.getEnvironmentPaths();
const pythonPath = api.settings.getExecutionDetails(workspace.workspaceFile)
.execCommand[0];
const envDetails = await api.environment.getEnvironmentDetails(pythonPath);
this.isPython3 = envDetails.version[0] === "3";

const dbtInstalledPythonPath: string[] = [];
// TODO: support multiple workspacefolders for python detection
Expand Down

0 comments on commit 9afa882

Please sign in to comment.