Skip to content

Commit

Permalink
Merge pull request #6 from marwan37/python-lsp-integration
Browse files Browse the repository at this point in the history
LSP server Integration via vscode-python-tools-extension + pivot away from FastAPI to direct ZenML library use
  • Loading branch information
strickvl authored Mar 27, 2024
2 parents b339105 + b3a663f commit be2fc19
Show file tree
Hide file tree
Showing 108 changed files with 9,403 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],

"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"]
},

"env": {
"browser": true,
"es2021": true
}
}
24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": ["camelCase", "PascalCase"]
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: VSCode Extension CI

on: [push, pull_request]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'

- name: Install dependencies
run: npm install

- name: Build VSCode Extension
run: npm run compile

- name: Run VSCode Extension Formatter
run: npm run format

- name: Run VSCode Extension Linter
run: npm run lint

- name: Run headless test
uses: coactions/setup-xvfb@v1
with:
run: npm test
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.DS_Store
Thumbs.db
.vscode-test/
.idea/
.eslintcache
lib-cov
*.log
*.log*
pids

# Node
.npm/
node_modules/
package-lock.json
npm-debug.log

# Build outputs
dist/
out/
build/
*.tsbuildinfo
.history/

# env
.env
.env*

# Output of 'npm pack'
*.tgz

# From vscode-python-tools-extension-template
*.vsix
.venv/
.vs/
.nox/
bundled/libs/
**/__pycache__
**/.pytest_cache
**/.vs

11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"proseWrap": "preserve",
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "es5",
"bracketSpacing": true
}
7 changes: 7 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[MESSAGES CONTROL]
disable=
C0103, # Name doesn't conform to naming style
C0415, # Import outside toplevel
W0613, # Unused argument
R0801, # Similar lines in multiple files
R0903, # Too few public methods
5 changes: 5 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
});
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"amodio.tsl-problem-matcher",
"ms-vscode.extension-test-runner"
]
}
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"timeout": 20000
}
]
}
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Place your settings in this file to overwrite default and user settings.
{
"python.defaultInterpreterPath": "",
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"python.testing.pytestArgs": ["src/test/python_tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.cwd": "${workspaceFolder}",
"python.analysis.extraPaths": ["bundled/libs", "bundled/tool"]
}
45 changes: 45 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$ts-webpack-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": []
},
{
"type": "npm",
"script": "compile",
"group": "build",
"problemMatcher": [],
"label": "npm: compile",
"detail": "webpack"
}
]
}
15 changes: 15 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.vscode/**
.vscode-test/**
out/**
node_modules/**
src/**
.gitignore
.yarnrc
webpack.config.js
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.js.map
**/*.ts
**/.vscode-test.*
100 changes: 100 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Contributing to ZenML VSCode Extension

We appreciate your interest in contributing to the ZenML VSCode extension! This guide will help you get started with setting up your development environment, making changes, and proposing those changes back to the project. By following these guidelines, you'll ensure a smooth and efficient contribution process.

## Setting Up Your Development Environment

1. **Fork and Clone**: Fork the [zenml-io/vscode-zenml repository](https://github.com/zenml-io/vscode-zenml) and clone it to your local machine.

```bash
git clone https://github.com/YOUR_USERNAME/vscode-zenml.git
git checkout develop
```

2. **Install Dependencies**: Navigate to the cloned repository directory and install the required dependencies.

```bash
cd vscode-zenml
npm install
```

3. **Compile the Project**: Build the TypeScript source code into JavaScript.

```bash
npm run compile
```

### Python Environment Setup

The extension's Python functionality requires setting up a corresponding Python environment.

1. Create and activate a Python virtual environment using Python 3.8 or greater. (e.g., `python -m venv .venv` on Windows, or `python3 -m venv .venv` on Unix-based systems).
2. Install `nox` for environment management.

```bash
python -m pip install nox
```

3. Use `nox` to set up the environment.

```bash
nox --session setup
```

4. Install any Python dependencies specified in `requirements.txt`.

```bash
pip install -r requirements.txt
```

## Development Workflow

- **Running the Extension**: Press `F5` to open a new VSCode window with the
extension running, or click the `Start Debugging` button in the VSCode menubar
under the `Run` menu.
- **Making Changes**: Edit the source code. The TypeScript code is in the `src` directory, and Python logic for the LSP server is in `bundled/tool`.

### Testing

- **Writing Tests**: Add tests in the `src/test` directory. Follow the naming convention `*.test.ts` for test files.
- **Running Tests**: Use the provided npm scripts to compile and run tests.

```bash
npm run test
```

### Debugging

- **VSCode Debug Console**: Utilize the debug console in the VSCode development window for troubleshooting and inspecting values.
- **Extension Host Logs**: Review the extension host logs for runtime errors or unexpected behavior.

## Contributing Changes

1. **Create a Branch**: Make your changes in a new git branch based on the `develop` branch.

```bash
git checkout -b feature/your-feature-name
```

2. **Commit Your Changes**: Write clear, concise commit messages following the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) guidelines.
3. **Push to Your Fork**: Push your branch to your fork on GitHub.

```bash
git push origin feature/your-feature-name
```

4. **Open a Pull Request**: Go to the original `zenml-io/vscode-zenml` repository and create a pull request from your feature branch. Please follow our [contribution guidelines](https://github.com/zenml-io/zenml/blob/develop/CONTRIBUTING.md) for more details on proposing pull requests.

## Troubleshooting Common Issues

- Ensure all dependencies are up to date and compatible.
- Rebuild the project (`npm run compile`) after making changes.
- Reset your development environment if encountering persistent issues by re-running `nox` setup commands and reinstalling dependencies.
- You can also run the `scripts/clear_and_compile.sh` script, which will delete the cache, `dist` folder, and recompile automatically.
- Check the [ZenML documentation](https://docs.zenml.io) and [GitHub issues](https://github.com/zenml-io/zenml/issues) for common problems and solutions.

### Additional Resources

- [ZenML VSCode Extension Repository](https://github.com/zenml-io/vscode-zenml)
- [ZenML Documentation](https://docs.zenml.io)
- [ZenML Slack Community](https://zenml.io/slack-invite)
Loading

0 comments on commit be2fc19

Please sign in to comment.