Skip to content

Commit 602fed1

Browse files
committed
creating the docs
1 parent 6374a0c commit 602fed1

6 files changed

Lines changed: 230 additions & 9 deletions

File tree

docs/development.md

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,124 @@
11
# Contribute to development
2-
SQLMesh is licensed under [Apache 2.0](https://github.com/TobikoData/sqlmesh/blob/main/LICENSE). We encourage community contribution and would love for you to get involved.
2+
3+
SQLMesh is licensed under [Apache 2.0](https://github.com/TobikoData/sqlmesh/blob/main/LICENSE). We encourage community contribution and would love for you to get involved. The following document outlines the process to contribute to SQLMesh.
34

45
## Prerequisites
6+
7+
Before you begin, ensure you have the following installed on your machine. Exacltly how to install these is dependent on your operating system.
8+
59
* Docker
610
* Docker Compose V2
711
* OpenJDK >= 11
812
* Python >= 3.9 < 3.13
913

10-
## Commands reference
14+
## Virtual environment setup
15+
16+
We do recommend using a virtual environment to develop SQLMesh.
17+
18+
```bash
19+
python -m venv .venv
20+
source .venv/bin/activate
21+
```
22+
23+
Once you have activated your virtual environment, you can install the dependencies by running the following command.
1124

12-
Install dev dependencies:
1325
```bash
1426
make install-dev
1527
```
28+
29+
Optionally, you can use pre-commit to automatically run linters/formatters:
30+
31+
```bash
32+
make install-pre-commit
33+
```
34+
35+
## Python development
36+
1637
Run linters and formatters:
38+
1739
```bash
1840
make style
1941
```
42+
2043
Run faster tests for quicker local feedback:
44+
2145
```bash
2246
make fast-test
2347
```
48+
2449
Run more comprehensive tests that run on each commit:
50+
2551
```bash
2652
make slow-test
2753
```
54+
2855
Run Airflow tests that will run when PR is merged to main:
56+
2957
```bash
3058
make airflow-docker-test-with-env
3159
```
32-
Install docs dependencies:
60+
61+
## Documentation
62+
63+
In order to run the documentation server, you will need to install the dependencies by running the following command.
64+
3365
```bash
3466
make install-doc
3567
```
36-
Run docs server:
68+
69+
Once you have installed the dependencies, you can run the documentation server by running the following command.
70+
3771
```bash
3872
make docs-serve
3973
```
74+
4075
Run docs tests:
76+
4177
```bash
4278
make doc-test
4379
```
80+
81+
## UI development
82+
83+
In addition to the Python development, you can also develop the UI.
84+
85+
The UI is built using React and Typescript. To run the UI, you will need to install the dependencies by running the following command.
86+
87+
```bash
88+
npm install
89+
```
90+
4491
Run ide:
92+
4593
```bash
4694
make ui-up
4795
```
48-
(Optional) Use pre-commit to automatically run linters/formatters:
49-
```bash
50-
make install-pre-commit
96+
97+
## Developing the VSCode extension
98+
99+
Developing the VSCode extension is most easily done by launching the debug process from a visual studio code workspace.
100+
101+
By default, the VSCode extension will run the SQLMesh server locally and open a new visual studio code window that allows you to try out the SQLMesh IDE. It by default opens the `examples/sushi` project.
102+
103+
Please see the below diagram for a high level overview of the UI.
104+
105+
```mermaid
106+
graph TD
107+
A[VSCode Extension] --> |start server| B[SQLMesh Server]
108+
A --> |creates webviews| C[Webviews]
109+
C --> |reads react webpages from| B
110+
A --> |calls lsp| B
111+
React[React App] --> |embedded in| B
112+
```
113+
114+
For development purposes, the React app is not embedded into the python server. Instead a separate instance of the React app is run. This allows you to make changes to the UI and see them immediately.
115+
116+
This makes the architecture diagram at development time look like the following.
117+
118+
```mermaid
119+
graph TD
120+
A[VSCode Extension] --> |start server| B[SQLMesh Server]
121+
A --> |creates webviews| C[Webviews]
122+
React [React Server] --> |passes on api requests| B
123+
C --> |reads react webpages from| React
51124
```

vscode/assets/images/dag.svg

Lines changed: 34 additions & 0 deletions
Loading

vscode/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
"activationEvents": [],
1313
"main": "./dist/extension.js",
1414
"contributes": {
15+
"viewsContainers": {
16+
"panel": [
17+
{
18+
"id": "lineage_view",
19+
"title": "Lineage",
20+
"icon": "./assets/images/dag.svg"
21+
}
22+
]
23+
},
24+
"views": {
25+
"lineage_view": [
26+
{
27+
"id": "sqlmesh.lineage",
28+
"name": "",
29+
"type": "webview"
30+
}
31+
]
32+
},
1533
"commands": [
1634
{
1735
"command": "sqlmesh.format",

vscode/src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { checkIfConfigurationChanged } from './common/settings'
1313
import { getInterpreterFromSetting } from './common/settings'
1414
import { startWebServer, WebServer } from './web-server/server'
1515
import { isErr } from './functional/result'
16+
import { LineagePanel } from './webviews/lineagePanel'
1617

1718
let lsClient: LanguageClient | undefined
1819
let webServer: WebServer | undefined
@@ -112,6 +113,12 @@ export function activate(context: vscode.ExtensionContext) {
112113

113114
startServer(serverOutputChannel)
114115

116+
// Register the webview
117+
const lineagePanel = new LineagePanel(context.extensionUri, () => webServer?.url ?? "")
118+
context.subscriptions.push(
119+
vscode.window.registerWebviewViewProvider(LineagePanel.viewType, lineagePanel)
120+
)
121+
115122
setImmediate(async () => {
116123
const interpreterDetails = await getInterpreterDetails()
117124
if (interpreterDetails.path) {
@@ -121,7 +128,7 @@ export function activate(context: vscode.ExtensionContext) {
121128
traceInfo("Extension activated")
122129
}
123130

124-
export async function startServer(serverOutputChannel: vscode.LogOutputChannel) {
131+
export async function startServer(serverOutputChannel: vscode.LogOutputChannel): Promise<WebServer> {
125132
if (webServer) {
126133
return webServer
127134
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import {
2+
CancellationToken,
3+
commands,
4+
Disposable,
5+
TextEditor,
6+
Uri,
7+
WebviewView,
8+
WebviewViewProvider,
9+
WebviewViewResolveContext,
10+
window,
11+
workspace,
12+
} from "vscode"
13+
14+
export class LineagePanel implements WebviewViewProvider, Disposable {
15+
public static readonly viewType = "sqlmesh.lineage"
16+
17+
private panel: WebviewView | undefined
18+
private getServerUrl: () => string
19+
private _extensionUri: Uri
20+
21+
public constructor(
22+
extensionUri: Uri,
23+
getServerUrl: () => string
24+
) {
25+
this._extensionUri = extensionUri
26+
this.getServerUrl = getServerUrl
27+
window.onDidChangeActiveTextEditor((event: TextEditor | undefined) => {
28+
if (this.panel) {
29+
this.panel.webview.html = this.getHtml()
30+
}
31+
})
32+
}
33+
34+
private getPanel() {
35+
return this.panel
36+
}
37+
38+
public resolveWebviewView(
39+
webviewView: WebviewView,
40+
_context: WebviewViewResolveContext,
41+
_token: CancellationToken,
42+
) {
43+
if (this.panel) {
44+
webviewView = this.panel
45+
}
46+
this.panel = webviewView
47+
48+
webviewView.webview.options = {
49+
// Allow scripts in the webview
50+
enableScripts: true,
51+
localResourceRoots: [
52+
this._extensionUri
53+
]
54+
}
55+
56+
// Set content options for external URL access
57+
const externalUrl = this.getServerUrl();
58+
const externalAuthority = new URL(externalUrl).origin;
59+
60+
webviewView.webview.html = this.getHtml()
61+
}
62+
63+
getHtml() {
64+
const externalUrl = this.getServerUrl()
65+
const externalAuthority = new URL(externalUrl).origin;
66+
67+
return `
68+
<!DOCTYPE html>
69+
<html>
70+
<head>
71+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; frame-src ${externalAuthority}; script-src 'unsafe-inline'; style-src 'unsafe-inline';">
72+
</head>
73+
<body>
74+
<div>${externalUrl}</div>
75+
<iframe src="${externalUrl}" style="width:100%; height:100vh;" frameborder="0"></iframe>
76+
</body>
77+
</html> `
78+
}
79+
80+
81+
dispose() {
82+
// WebviewView doesn't have a dispose method
83+
// We can clear references
84+
this.panel = undefined;
85+
}
86+
}

web/client/src/AppVSCode.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function AppVSCode() {
2+
return <div>AppVscode</div>
3+
}

0 commit comments

Comments
 (0)