Skip to content

Commit fcdf8c8

Browse files
committed
temp [ci skip]
1 parent 066c0f0 commit fcdf8c8

7 files changed

Lines changed: 23 additions & 11 deletions

File tree

sqlmesh/lsp/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ def __init__(self, **data):
5454
setattr(model.details, field, None)
5555

5656
super().__init__(**data)
57+
58+
class ApiResponseGetLineage(ApiResponse):
59+
"""
60+
Response from the SQLMesh API for the get_lineage endpoint.
61+
Specifies the data type more precisely as a list of models.
62+
"""
63+
data: t.Dict[str, t.List[str]]

sqlmesh/lsp/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
from sqlmesh._version import __version__
1212
from sqlmesh.core.context import Context
1313
from sqlmesh.core.linter.definition import AnnotatedRuleViolation
14-
from sqlmesh.lsp.api import API_FEATURE, ApiRequest, ApiResponse, ApiResponseGetModels
14+
from sqlmesh.lsp.api import API_FEATURE, ApiRequest, ApiResponse, ApiResponseGetLineage, ApiResponseGetModels
1515
from sqlmesh.lsp.completions import get_sql_completions
1616
from sqlmesh.lsp.context import LSPContext
1717
from sqlmesh.lsp.custom import ALL_MODELS_FEATURE, AllModelsRequest, AllModelsResponse
1818
from sqlmesh.lsp.reference import get_model_definitions_for_a_path
19+
from web.server.api.endpoints.lineage import model_lineage
1920
from web.server.api.endpoints.models import get_models
2021

2122

@@ -60,7 +61,13 @@ def api(ls: LanguageServer, request: ApiRequest) -> ApiResponse:
6061
if request.url == "/api/models":
6162
response = ApiResponseGetModels(data=get_models(self.lsp_context.context))
6263
return response
63-
return ApiResponse(data={})
64+
elif request.url.startswith("/api/lineage"):
65+
name = request.url.split("/")[-1]
66+
lineage = model_lineage(name, self.lsp_context.context)
67+
non_set_lineage = {k: v for k, v in lineage.items() if v is not None}
68+
response = ApiResponseGetLineage(data=non_set_lineage)
69+
return response
70+
raise NotImplementedError(f"API request not implemented: {request.url}")
6471

6572
@self.server.feature(types.TEXT_DOCUMENT_DID_OPEN)
6673
def did_open(

vscode/extension/src/webviews/lineagePanel.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
190190
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; frame-src ${externalAuthority}; connect-src ${externalAuthority}; img-src ${externalAuthority} data:; script-src 'unsafe-inline' ${externalAuthority}; style-src 'unsafe-inline' ${externalAuthority};">
191191
</head>
192192
<body>
193-
${isProduction() ? '' : `<div>${externalUrl}</div>`}
194193
<iframe src="${externalUrl}" style="width:100%; height:100vh;" frameborder="0" allow="clipboard-read; clipboard-write"></iframe>
195194
</body>
196195
</html> `

vscode/react/src/api/instance.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function fetchAPIDevelopment<T = any, B extends object = any>(
7474
if (isErr(payload)) {
7575
reject(new Error(payload.error as string))
7676
} else {
77-
resolve(payload.value)
77+
resolve(payload.value.data)
7878
}
7979
}
8080
}
@@ -92,6 +92,8 @@ async function fetchAPIDevelopment<T = any, B extends object = any>(
9292
requestId,
9393
url: config.url,
9494
params: config.params as any,
95+
data: config.data,
96+
method: config.method,
9597
},
9698
}, '*')
9799
return

vscode/react/src/pages/lineage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ export function LineagePage() {
5353
}
5454

5555
function Lineage() {
56-
const { data, isLoading: isLoadingModels } = useApiModels()
57-
console.log('data', data, 'isLoadingModels', isLoadingModels)
58-
if (isLoadingModels) {
56+
const { data: models, isLoading: isLoadingModels } = useApiModels()
57+
console.log('data', models, 'isLoadingModels', isLoadingModels)
58+
if (isLoadingModels || models === undefined) {
5959
return <div>Loading models...</div>
6060
}
61-
const models = data?.data
6261
console.log('models', models)
6362
const modelsRecord = models.reduce(
6463
(acc, model) => {

web/client/src/library/pages/lineage/Lineage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export default function PageLineage(): JSX.Element {
2020

2121
function handleClickModel(modelName: string): void {
2222
const model = models.get(modelName)
23-
2423
if (isNil(model)) return
25-
2624
navigate(EnumRoutes.LineageModels + '/' + model.name)
2725
}
2826

web/server/api/endpoints/lineage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def column_lineage(
146146

147147

148148
@router.get("/{model_name:str}")
149-
async def model_lineage(
149+
def model_lineage(
150150
model_name: str,
151151
context: Context = Depends(get_loaded_context),
152152
) -> t.Dict[str, t.Set[str]]:

0 commit comments

Comments
 (0)