|
2 | 2 |
|
3 | 3 | This document has detailed instructions on how to build ydb-python-sdk from source and run style and unit tests.
|
4 | 4 |
|
| 5 | +## Development Environment Setup |
| 6 | + |
| 7 | +### Using Dev Containers (Recommended) |
| 8 | + |
| 9 | +This repository includes a complete development environment using Docker containers that provides everything you need to start contributing immediately. The devcontainer setup includes: |
| 10 | + |
| 11 | +- **Python 3.9** development environment with all necessary dependencies |
| 12 | +- **YDB server** running locally in a container |
| 13 | +- **Pre-configured tools**: Git, GitHub CLI, YDB CLI, and essential Python packages |
| 14 | +- **VS Code extensions**: Python development tools, linting, formatting, and debugging support |
| 15 | + |
| 16 | +#### Prerequisites |
| 17 | + |
| 18 | +- [Docker](https://www.docker.com/get-started) installed and running |
| 19 | +- [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
| 20 | + |
| 21 | +#### Quick Start with Dev Containers |
| 22 | + |
| 23 | +1. Clone the repository: |
| 24 | + ```bash |
| 25 | + git clone https://github.com/ydb-platform/ydb-python-sdk.git |
| 26 | + cd ydb-python-sdk |
| 27 | + ``` |
| 28 | + |
| 29 | +2. Open in VS Code: |
| 30 | + ```bash |
| 31 | + code . |
| 32 | + ``` |
| 33 | + |
| 34 | +3. When prompted, click "Reopen in Container" or use the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`) and select "Dev Containers: Reopen in Container" |
| 35 | + |
| 36 | +4. Wait for the container to build and start (first time may take a few minutes) |
| 37 | + |
| 38 | +5. The development environment is ready! You can now run tests, debug code, and develop new features. |
| 39 | + |
| 40 | +### Using GitHub Codespaces |
| 41 | + |
| 42 | +GitHub Codespaces provides a cloud-based development environment that works directly in your browser or VS Code. It's perfect for quick contributions without setting up a local environment. |
| 43 | + |
| 44 | +#### Quick Start with Codespaces |
| 45 | + |
| 46 | +1. Navigate to the [repository on GitHub](https://github.com/ydb-platform/ydb-python-sdk) |
| 47 | +2. Click the green "Code" button |
| 48 | +3. Select the "Codespaces" tab |
| 49 | +4. Click "Create codespace on main" (or your desired branch) |
| 50 | +5. Wait for the environment to initialize (usually 2-3 minutes) |
| 51 | +6. Start coding directly in the browser or connect with your local VS Code |
| 52 | + |
| 53 | +#### What's Included in the Development Environment |
| 54 | + |
| 55 | +When you use either dev containers or Codespaces, the following environment is automatically set up: |
| 56 | + |
| 57 | +**Container Services:** |
| 58 | +- **SDK Container (`sdk`)**: Your main development environment running Python 3.9 on Debian Bookworm |
| 59 | +- **YDB Container (`ydb`)**: Local YDB server (version 25.1) for testing and development |
| 60 | + |
| 61 | +**Development Tools:** |
| 62 | +- **YDB CLI**: Pre-installed and configured to connect to the local YDB instance |
| 63 | +- **Python Environment**: All project dependencies installed via `pip install -e .` |
| 64 | +- **Git Configuration**: Automatic setup for signed commits (if configured) |
| 65 | +- **VS Code Extensions**: Python development stack including linting, formatting, and debugging |
| 66 | + |
| 67 | +**Network Configuration:** |
| 68 | +- **Port 2135**: YDB gRPC with TLS |
| 69 | +- **Port 2136**: YDB gRPC without TLS |
| 70 | +- **Port 8765**: YDB Monitoring interface |
| 71 | +- These ports are automatically forwarded and accessible from your local machine |
| 72 | + |
| 73 | +**Environment Variables:** |
| 74 | +The following environment variables are pre-configured for immediate use: |
| 75 | +- `YDB_CONNECTION_STRING=grpc://ydb:2136/local` - Standard connection |
| 76 | +- `YDB_CONNECTION_STRING_SECURE=grpcs://ydb:2135/local` - Secure connection |
| 77 | +- `YDB_SSL_ROOT_CERTIFICATES_FILE=/ydb_certs/ca.pem` - SSL certificates |
| 78 | +- `YDB_STATIC_CREDENTIALS_USER=root` and `YDB_STATIC_CREDENTIALS_PASSWORD=1234` - Test credentials |
| 79 | + |
| 80 | +**Automatic Setup Process:** |
| 81 | +1. **Initialize**: Git configuration for signed commits and user settings |
| 82 | +2. **Post-Create**: YDB CLI profile setup and GPG configuration for SSH signing |
| 83 | +3. **Post-Start**: Installation of Python dependencies, SDK package, and testing tools (tox) |
| 84 | + |
| 85 | +#### Running Tests in the Development Environment |
| 86 | + |
| 87 | +Once your environment is ready, you can run the test suite: |
| 88 | + |
| 89 | +```bash |
| 90 | +# Run all tests |
| 91 | +tox |
| 92 | + |
| 93 | +# Run specific test categories |
| 94 | +python -m pytest tests/ |
| 95 | + |
| 96 | +# Run with specific Python version |
| 97 | +tox -e py39 |
| 98 | +``` |
| 99 | + |
| 100 | +#### Connecting to the Local YDB Instance |
| 101 | + |
| 102 | +The YDB CLI is pre-configured to connect to the local instance: |
| 103 | + |
| 104 | +```bash |
| 105 | +# Run a simple query |
| 106 | +echo "SELECT 1;" | ydb |
| 107 | + |
| 108 | +# Access the web interface |
| 109 | +# Open http://localhost:8765 in your browser (when using local dev containers) |
| 110 | +# In codespaces you can access it via the provided URL in the terminal output. |
| 111 | +``` |
| 112 | + |
| 113 | +## Manual Setup (Alternative) |
| 114 | + |
| 115 | +If you prefer to set up your development environment manually without using dev containers: |
| 116 | + |
5 | 117 | ### Pre-requisites
|
6 | 118 |
|
7 | 119 | - Install [Docker](https://docs.docker.com/engine/install/).
|
@@ -52,4 +164,4 @@ Use the command below for regenerate protobuf code.
|
52 | 164 |
|
53 | 165 | ```sh
|
54 | 166 | make protobuf
|
55 |
| -``` |
| 167 | +``` |
0 commit comments