Skip to content

Commit

Permalink
Merge branch 'master' into AI-2198-project-governance-teammate
Browse files Browse the repository at this point in the history
  • Loading branch information
saravmajestic authored Dec 11, 2024
2 parents aec0f0f + 7111c9e commit 3f0e632
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 71 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.50.3",
"version": "0.50.4",
"engines": {
"vscode": "^1.81.0"
},
Expand Down
6 changes: 5 additions & 1 deletion src/altimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,12 @@ export class AltimateRequest {
status: response.status,
textResponse,
});
let jsonResponse: any;
try {
jsonResponse = JSON.parse(textResponse);
} catch {}
throw new APIError(
`Could not process request, server responded with ${response.status}: ${textResponse}`,
`Could not process request, server responded with ${response.status}: ${jsonResponse?.detail || textResponse}`,
);
} catch (e) {
this.dbtTerminal.error("apiCatchAllError", "catchAllError", e, true, {
Expand Down
2 changes: 1 addition & 1 deletion src/dbt_client/dbtCloudIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class DBTCloudProjectIntegration
} else {
this.initializePaths();
}
if (!this.adapterType) {
if (this.adapterType === "unknown") {
// We only fetch the adapter type once, as it may impact compilation preview otherwise
await this.findAdapterType();
}
Expand Down
3 changes: 3 additions & 0 deletions src/manifest/dbtWorkspaceFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ export class DBTWorkspaceFolder implements Disposable {
}

async discoverProjects() {
// Ignore dbt_packages and venv/site-packages/dbt project folders
const excludePattern = "**/{dbt_packages,site-packages}";
const dbtProjectFiles = await workspace.findFiles(
new RelativePattern(
this.workspaceFolder,
`**/${DBTProject.DBT_PROJECT_FILE}`,
),
new RelativePattern(this.workspaceFolder, excludePattern),
);
this.dbtTerminal.info(
"discoverProjects",
Expand Down
10 changes: 10 additions & 0 deletions src/webview_provider/newLineagePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ export class NewLineagePanel
.getProject()
?.throwDiagnosticsErrorIfAvailable();
} catch (err) {
this.dbtTerminal.error(
"Lineage:getMissingLineageMessage",
(err as Error).message,
err,
);
return { message: (err as Error).message, type: "error" };
}

Expand All @@ -476,6 +481,7 @@ export class NewLineagePanel
const aiEnabled = this.altimate.enabled();
const event = this.queryManifestService.getEventByCurrentProject();
if (!event?.event) {
this.dbtTerminal.info("Lineage:getStartingNode", "No event found");
return {
aiEnabled,
missingLineageMessage: this.getMissingLineageMessage(),
Expand All @@ -485,6 +491,10 @@ export class NewLineagePanel
const tableName = this.getFilename();
const _node = nodeMetaMap.lookupByBaseName(tableName);
if (!_node) {
this.dbtTerminal.info(
"Lineage:getStartingNode",
`No node found for ${tableName}`,
);
return {
aiEnabled,
missingLineageMessage: this.getMissingLineageMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const DocumentationPropagationButton = ({
const [allColumns, setAllColumns] = useState<DocsItem[]>([]);
const [currColumns, setCurrColumns] = useState<DocsItem[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isSaved, setIsSaved] = useState(false);
const [tableMetadata, setTableMetadata] = useState<TableMetadata[]>([]);
const [testsMetadata, setTestsMetadata] = useState<Record<string, unknown>>(
{},
Expand All @@ -72,6 +73,7 @@ export const DocumentationPropagationButton = ({
setAllColumns([]);
setCurrColumns(startColumn);
setTableMetadata([]);
setIsSaved(false);
}, [currentDocsData?.uniqueId, name]);

const loadMoreDownstreamModels = async () => {
Expand Down Expand Up @@ -165,6 +167,7 @@ export const DocumentationPropagationButton = ({
}

await executeRequestInSync("saveDocumentationBulk", { models: req });
setIsSaved(true);
};

const setAllColumnsValue = (value: boolean) => {
Expand All @@ -183,6 +186,10 @@ export const DocumentationPropagationButton = ({
return null;
}

if (!currColumnDescription) {
return null;
}

return (
<Drawer
buttonProps={{ color: "primary", title: "Propagate documentation" }}
Expand All @@ -193,81 +200,91 @@ export const DocumentationPropagationButton = ({
>
<Stack direction="column" className="gap-0 mb-2">
<div className={styles.itemRow}>
<div className="fw-semibold">Model:</div>
<div>Model:</div>
<div>{currentDocsData?.name}</div>
</div>
<div className={styles.itemRow}>
<div className="fw-semibold">Column:</div>
<div>Column:</div>
<div>{name}</div>
</div>
{currColumnDescription && (
<div className={styles.itemRow}>
<div className="fw-semibold">Description:</div>
<div className={styles.colDesc}>
<div>Description:</div>
<div>{currColumnDescription}</div>
</div>
)}
</Stack>
<Stack className="mb-2">
<Button color="primary" onClick={() => setAllColumnsValue(true)}>
Select All
</Button>
<Button color="primary" onClick={() => setAllColumnsValue(false)}>
Unselect All
</Button>
</Stack>
<Stack direction="column" className="gap-md">
{allColumns.map((item) => {
const key = item.model + "/" + item.column;
return (
<Stack key={key} className={styles.itemCard}>
<Input
type="checkbox"
checked={selectedColumns[key]}
onChange={() =>
setSelectedColumns((prev) => ({
...prev,
[key]: !prev[key],
}))
}
/>
<Stack direction="column" className="gap-0 w-100">
<div className={styles.itemRow}>
<div>Model:</div>
<div>{item.model.split(".").pop()}</div>
</div>
<div className={styles.itemRow}>
<div>Column:</div>
<div>{item.column}</div>
</div>
<div className={styles.itemRow}>
<div>Description:</div>
<div>{item.description}</div>
</div>
</Stack>
</Stack>
);
})}
{currColumns.length > 0 && (
<Button
color="primary"
outline
onClick={loadMoreDownstreamModels}
disabled={isLoading}
>
Load 3 more downstream levels
</Button>
)}
<Button
color="primary"
disabled={
Object.values(selectedColumns).filter((v) => Boolean(v)).length ===
0
}
onClick={() => propagateDocumentation()}
>
Propagate documentation to selected models
</Button>
</Stack>
{!isLoading && allColumns.length === 0 ? (
<div className="mt-4">
No downstream column level lineage detected to propagate the
documentation
</div>
) : (
<>
<Stack className="mb-2">
<Button color="primary" onClick={() => setAllColumnsValue(true)}>
Select All
</Button>
<Button color="primary" onClick={() => setAllColumnsValue(false)}>
Unselect All
</Button>
</Stack>
<Stack direction="column" className="gap-md">
{allColumns.map((item) => {
const key = item.model + "/" + item.column;
return (
<Stack key={key} className={styles.itemCard}>
<Input
type="checkbox"
checked={selectedColumns[key]}
onChange={() =>
setSelectedColumns((prev) => ({
...prev,
[key]: !prev[key],
}))
}
/>
<Stack direction="column" className="gap-0 w-100">
<div className={styles.itemRow}>
<div>Model:</div>
<div>{item.model.split(".").pop()}</div>
</div>
<div className={styles.itemRow}>
<div>Column:</div>
<div>{item.column}</div>
</div>
<div className={styles.itemRow}>
<div>Description:</div>
<div>{item.description}</div>
</div>
</Stack>
</Stack>
);
})}
{currColumns.length > 0 && (
<Button
color="primary"
outline
onClick={loadMoreDownstreamModels}
disabled={isLoading}
>
Load 3 more downstream levels
</Button>
)}
<Button
color="primary"
disabled={
Object.values(selectedColumns).filter((v) => Boolean(v))
.length === 0
}
onClick={() => propagateDocumentation()}
>
Propagate documentation to selected models
</Button>
{isSaved && <div>Saved documentation successfully</div>}
</Stack>
</>
)}
</Drawer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
grid-template-columns: 1fr 3fr;

:nth-child(1) {
font-weight: 500;
font-weight: 600;
}

:nth-child(2) {
line-break: anywhere;
color: var(--text-grey2-color);
}
}

.colDesc {
:nth-child(1) {
font-weight: 600;
}

:nth-child(2) {
Expand Down

0 comments on commit 3f0e632

Please sign in to comment.