Skip to content

Commit

Permalink
Merge branch 'master' into fix/notebook-bugs-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
saravmajestic authored Nov 4, 2024
2 parents ee2c227 + 3f30d31 commit 2e9a616
Show file tree
Hide file tree
Showing 7 changed files with 34,340 additions and 22,816 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 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.48.1",
"version": "0.48.3",
"engines": {
"vscode": "^1.81.0"
},
Expand Down
28 changes: 17 additions & 11 deletions src/dbt_client/dbtCloudIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +994,6 @@ 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 @@ -1022,12 +1013,11 @@ 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(
"DbtCloudIntegrationInitializePathsExceptionError",
"adapter type throws error, ignoring",
"dbt environment show not returning required info, ignoring",
true,
error,
);
Expand All @@ -1037,6 +1027,20 @@ export class DBTCloudProjectIntegration
this.macroPaths = [join(this.projectRoot.fsPath, "macros")];
this.packagesInstallPath = join(this.projectRoot.fsPath, "dbt_packages");
}

try {
const projectConfig = DBTProject.readAndParseProjectConfig(
this.projectRoot,
);
this.projectName = projectConfig.name;
} catch (error) {
this.terminal.warn(
"DbtCloudIntegrationProjectNameFromConfigExceptionError",
"project name could not be read from dbt_project.yml, ignoring",
true,
error,
);
}
}

private async findAdapterType() {
Expand Down Expand Up @@ -1192,6 +1196,8 @@ export class DBTCloudProjectIntegration

async applyDeferConfig(): Promise<void> {}

async applySelectedTarget(): Promise<void> {}

throwDiagnosticsErrorIfAvailable(): void {
this.throwBridgeErrorIfAvailable();
}
Expand Down
6 changes: 6 additions & 0 deletions src/dbt_client/dbtCoreIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,12 @@ export class DBTCoreProjectIntegration
(python) =>
python!`project.set_defer_config(${deferToProduction}, ${manifestPath}, ${favorState})`,
);
await this.refreshProjectConfig();
await this.rebuildManifest();
}

async applySelectedTarget(): Promise<void> {
await this.refreshProjectConfig();
await this.rebuildManifest();
}

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 @@ -390,6 +390,7 @@ export interface DBTProjectIntegration extends Disposable {
args: HealthcheckArgs,
): Promise<ProjectHealthcheck>;
applyDeferConfig(): Promise<void>;
applySelectedTarget(): Promise<void>;
getAllDiagnostic(): Diagnostic[];
throwDiagnosticsErrorIfAvailable(): void;
getPythonBridgeStatus(): boolean;
Expand Down
13 changes: 12 additions & 1 deletion src/manifest/dbtProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EventEmitter,
FileSystemWatcher,
languages,
ProgressLocation,
Range,
RelativePattern,
Uri,
Expand Down Expand Up @@ -219,7 +220,17 @@ export class DBTProject implements Disposable {
}

async setSelectedTarget(targetName: string) {
await this.dbtProjectIntegration.setSelectedTarget(targetName);
await window.withProgress(
{
location: ProgressLocation.Notification,
title: "Changing target...",
cancellable: false,
},
async () => {
await this.dbtProjectIntegration.setSelectedTarget(targetName);
await this.dbtProjectIntegration.applySelectedTarget();
},
);
}

getDBTProjectFilePath() {
Expand Down
Loading

0 comments on commit 2e9a616

Please sign in to comment.