Skip to content

Commit

Permalink
Merge branch 'master' into open-panel-other-than-sql
Browse files Browse the repository at this point in the history
  • Loading branch information
anandgupta42 authored Oct 25, 2024
2 parents 1d359c0 + ae8f551 commit 4a99930
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 103 deletions.
6 changes: 3 additions & 3 deletions dbt_core_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,9 @@ def validate_sql_dry_run(self, compiled_sql: str):
def get_target_names(self):
from dbt.config.profile import read_profile
profile = read_profile(self.args.profiles_dir)
project = profile[self.project_name]
if "outputs" in project:
outputs = project["outputs"]
profile = profile[self.config.profile_name]
if "outputs" in profile:
outputs = profile["outputs"]
return outputs.keys()
return []

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bugs": {
"url": "https://github.com/AltimateAI/vscode-dbt-power-user/issues"
},
"version": "0.47.4",
"version": "0.47.6",
"engines": {
"vscode": "^1.81.0"
},
Expand Down Expand Up @@ -100,7 +100,7 @@
"dbt.enableTeammates": {
"type": "boolean",
"description": "Enable AltimateAI teammates feature.",
"default": false
"default": true
},
"dbt.disableQueryHistory": {
"type": "boolean",
Expand Down
15 changes: 15 additions & 0 deletions src/dbt_client/dbtCloudIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class DBTCloudProjectIntegration
private static QUEUE_ALL = "all";
private targetPath?: string;
private version: number[] | undefined;
private projectName: string = "unknown_" + crypto.randomUUID();
private adapterType: string = "unknown";
private packagesInstallPath?: string;
private modelPaths?: string[];
Expand Down Expand Up @@ -376,6 +377,10 @@ export class DBTCloudProjectIntegration
return this.version || [0, 0, 0];
}

getProjectName(): string {
return this.projectName;
}

getPythonBridgeStatus(): boolean {
return this.python.connected;
}
Expand Down Expand Up @@ -988,6 +993,15 @@ export class DBTCloudProjectIntegration
stderr,
);
}
const lookupValue = (lookupString: string) => {
const regexString = `${lookupString}\\s*(.*)`;
const regexp = new RegExp(regexString, "gm");
const matches = regexp.exec(stdout);
if (matches?.length === 2) {
return matches[1];
}
throw new Error(`Could not find any entries for ${lookupString}`);
};
const lookupEntries = (lookupString: string) => {
const regexString = `${lookupString}\\s*\\[(.*)\\]`;
const regexp = new RegExp(regexString, "gm");
Expand All @@ -1007,6 +1021,7 @@ export class DBTCloudProjectIntegration
this.macroPaths = lookupEntries("Macro paths").map((p) =>
join(this.projectRoot.fsPath, p),
);
this.projectName = lookupValue("Project name");
this.packagesInstallPath = join(this.projectRoot.fsPath, "dbt_packages");
} catch (error) {
this.terminal.warn(
Expand Down
12 changes: 12 additions & 0 deletions src/dbt_client/dbtCoreIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class DBTCoreProjectIntegration
private adapterType?: string;
private targetName?: string;
private version?: number[];
private projectName: string = "unknown_" + crypto.randomUUID();
private packagesInstallPath?: string;
private modelPaths?: string[];
private seedPaths?: string[];
Expand Down Expand Up @@ -378,6 +379,7 @@ export class DBTCoreProjectIntegration
this.macroPaths = await this.findMacroPaths();
this.packagesInstallPath = await this.findPackagesInstallPath();
this.version = await this.findVersion();
this.projectName = await this.findProjectName();
this.adapterType = await this.findAdapterType();
}

Expand Down Expand Up @@ -560,6 +562,10 @@ export class DBTCoreProjectIntegration
return this.version;
}

getProjectName(): string {
return this.projectName;
}

async findAdapterType(): Promise<string | undefined> {
return this.python.lock<string>(
(python) => python`project.config.credentials.type`,
Expand Down Expand Up @@ -1060,6 +1066,12 @@ export class DBTCoreProjectIntegration
);
}

private async findProjectName(): Promise<string> {
return this.python?.lock<string>(
(python) => python!`to_dict(project.config.project_name)`,
);
}

private throwBridgeErrorIfAvailable() {
const allDiagnostics: DiagnosticCollection[] = [
this.pythonBridgeDiagnostics,
Expand Down
1 change: 1 addition & 0 deletions src/dbt_client/dbtIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export interface DBTProjectIntegration extends Disposable {
getPackageInstallPath(): string | undefined;
getAdapterType(): string | undefined;
getVersion(): number[] | undefined;
getProjectName(): string;
getSelectedTarget(): string | undefined;
// parse manifest
rebuildManifest(): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/manifest/dbtProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class DBTProject implements Disposable {
}

public getProjectName() {
return this.projectConfig.name;
return this.dbtProjectIntegration.getProjectName();
}

getSelectedTarget() {
Expand Down
18 changes: 18 additions & 0 deletions src/services/docGenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ import {
import { QueryManifestService } from "./queryManifestService";
import { TelemetryEvents } from "../telemetry/events";

export interface DocumentationSchemaColumn {
name: string;
description: string;
data_type?: string;
quote?: boolean;
[key: string]: unknown;
}
interface DocumentationSchemaModel {
name: string;
description: string;
tests: any;
columns: [];
}
export interface DocumentationSchema {
version: number;
models: DocumentationSchemaModel[];
}

interface GenerateDocsForColumnsProps {
panel: WebviewView | WebviewPanel | undefined;
message: any;
Expand Down
21 changes: 10 additions & 11 deletions src/webview_provider/altimateWebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,16 @@ export class AltimateWebviewProvider implements WebviewViewProvider {

try {
switch (command) {
case "getTeammatesStatus":
{
const isEnabled = workspace
.getConfiguration("dbt")
.get<boolean>("enableTeammates", false);
this.sendResponseToWebview({
command: "teammatesUpdated",
data: isEnabled,
});
break;
}
case "getTeammatesStatus": {
const isEnabled = workspace
.getConfiguration("dbt")
.get<boolean>("enableTeammates", false);
this.sendResponseToWebview({
command: "teammatesUpdated",
data: isEnabled,
});
break;
}
case "configEnabled":
this.handleSyncRequestFromWebview(
syncRequestId,
Expand Down
Loading

0 comments on commit 4a99930

Please sign in to comment.