🚀 Base installations and first run
-
Node.js: Install NVM to manage Node versions
nvm install 20.19.6- installs correct Node versionnvm use 20.19.6- switch to the correct version- Verify installation:
node --versionnpm --version
-
Python: Python 3.11 (see pyproject.toml for exact version requirements)
-
Poetry: For Python dependency management (
pip install poetry) -
vsce: For packaging VSIX files @vscode/vsce - installed as a dev dependency via npm
-
Go to
/sema4aifolder and install Node dependencies:npm install
-
Set up Python environment (see "Creating a local environment for python backend development" below)
-
Open
/sema4ai/.vscode/sema4ai-code.code-workspacein VS Code and run debug
🏗️ If you need to develop the extension backend you need the setup below.
Recommendation: Create a Python Virtual Environment with whatever tool you like. Once you've created the env, activate it & then continue with the development installation. For information regarding which Python Version you should use, please consult the pyproject.toml file.
- Navigate to
/sema4aidirectory - Install Python dependencies with Poetry:
poetry install
- Configure your IDE to use the Python interpreter:
- VS Code: Use the
Python: Select Interpretercommand and select.venv/Scripts/python(Windows) or.venv/bin/python(Linux/Mac) - The virtual environment will be created in
.venv/by Poetry
- VS Code: Use the
From the /sema4ai directory, run python -m dev to see all available commands. Common ones include:
python -m dev codegen- Generate code (package.json, constants, etc.)python -m dev local_install- Build and install VSIX locallypython -m dev vendor-robocorp-ls-core- Vendor the language server corepython -m dev remove-vendor-robocorp-ls-core- Remove vendored corepython -m dev set-version <version>- Set version in all filespython -m dev set-rcc-version <version>- Set RCC versionpython -m dev ruff_format- Check Python formattingpython -m dev ruff_format --format- Format Python code
From the /sema4ai directory:
- Compile TypeScript:
npm run compile - Watch mode (auto-compile on changes):
npm run watch - Format check:
npm run prettier - Format fix:
npm run prettier-fix
From the /sema4ai directory:
- Format Python code:
python -m dev ruff_format --format - Check Python formatting:
python -m dev ruff_format - Generate code (after adding commands/settings):
python -m dev codegen - Vendor language server core:
python -m dev vendor-robocorp-ls-core
From the /sema4ai directory:
python -m dev local_installThis will:
- Vendor the language server core
- Package the extension as a VSIX
- Install it in VS Code
- Remove the vendored core
Alternatively, to just package without installing:
python -m dev vendor-robocorp-ls-core
npm run vsce:package
python -m dev remove-vendor-robocorp-ls-coreFrom the /sema4ai directory:
npm testThis will compile the TypeScript code and run the test suite located in vscode-client/src/tests/.
From the /sema4ai/tests directory:
poetry run python -u ../../sema4ai-python-ls-core/tests/run_tests.py -rfE -otests_output -vv -n 1 -m "not data_server and not rcc_env" .For integration tests, see /sema4ai/tests/sema4ai_code_tests/test_vscode_integration.py.
Note: Tests require the Python environment to be set up with poetry install (see "Creating a local environment for python backend development" below).
To add a new command, add it at the COMMANDS in /sema4ai/codegen/commands.py and then execute
(in a shell in the /sema4ai directory) python -m dev codegen.
This should add the command to the package.json as well as the files related to the constants.
Then, you may handle the command either in /sema4ai/vscode-client/src/extension.ts if the
command requires some VSCode-only API or in the language server (which is ideal as less work would
be required when porting the extension to a different client).
Note: that it's also possible to have one command call another command, so, if needed the command could start on the client and then call parts of it on the server.
Note: the code in the extension side (in TypeScript) should be kept to a minimum (as it needs to be redone if porting to a different client).
Note: at least one integration test for each action must be added in
/sema4ai/tests/sema4ai_code_tests/test_vscode_integration.py
To add a new setting, add it at the SETTINGS in /sema4ai/codegen/settings.py and then execute
(in a shell in the /sema4ai directory) python -m dev codegen.
We prebuilt the Python env. that the extension it self needs using RCC.
- The dependencies are set based in
/sema4ai/bin/create_env/conda.yamlfiles.- Update all of these in sync
- Once updated the environment builds are handled by GHA
- After the runs are done, the file:
/sema4ai/vscode-client/src/rcc.tsneeds to be updated to set theBASENAME_PREBUILT_XXXglobal variables based on the new paths. - Also, the
pyproject.tomlshould be updated so that the python development environment is updated accordingly.
- Check RCC versions from changelog
- In a shell in the
/sema4aidirectory run:python -m dev set-rcc-version 20.3.3 - Remove the rcc executable from the
binfolder to redownload the next time the extension is executed.
