Skip to content

Commit 819c995

Browse files
committed
docs: update readme
1 parent 48b0a54 commit 819c995

File tree

2 files changed

+96
-219
lines changed

2 files changed

+96
-219
lines changed

README.md

Lines changed: 96 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,299 +1,176 @@
1-
# Deepnote Toolkit
1+
![Deepnote Toolkit cover image](deepnote-toolkit-cover-image.png)
2+
3+
<div align="center">
24

35
[![CI](https://github.com/deepnote/deepnote-toolkit/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/deepnote/deepnote-toolkit/actions/workflows/ci.yml)
46
[![codecov](https://codecov.io/gh/deepnote/deepnote-toolkit/graph/badge.svg?token=JCRUJP2BB9)](https://codecov.io/gh/deepnote/deepnote-toolkit)
57

6-
> [!WARNING]
7-
> This code is distributed to user context, so we are treating it as a public repository - ensure no secrets are included in the codebase.
8-
9-
Welcome to the Deepnote Toolkit, our homegrown Python package managed by Poetry. It is an essential Python package that needs to be installed in the user's environment, which is operated by Deepnote. This package encapsulates all the code that needs to run in the user's space environment.
10-
11-
### Key features
12-
13-
- Deepnote component library
14-
- Python kernel with scientific computing libraries
15-
- SQL support with query caching
16-
- Data visualization (Altair, Plotly)
17-
- Streamlit apps support with auto-reload
18-
- Language Server Protocol integration
19-
- Git integration with SSH/HTTPS authentication
20-
- Prometheus metrics collection
21-
- Integration environment variables management
22-
23-
### Bundle types
24-
25-
The toolkit consists of two main bundle types:
26-
27-
1. **Kernel Bundle**: Libraries available to user code execution (pandas, numpy, etc.)
28-
2. **Server Bundle**: Dependencies for running infrastructure services (Jupyter, Streamlit, LSP)
298

30-
### How to setup?
9+
[Website](https://deepnote.com/?utm_source=github&utm_medium=github&utm_campaign=github&utm_content=readme_main)[Docs](https://deepnote.com/docs?utm_source=github&utm_medium=github&utm_campaign=github&utm_content=readme_main)[Blog](https://deepnote.com/blog?utm_source=github&utm_medium=github&utm_campaign=github&utm_content=readme_main)[X](https://x.com/DeepnoteHQ)[Examples](https://deepnote.com/explore?utm_source=github&utm_medium=github&utm_campaign=github&utm_content=readme_main)[Community](https://github.com/deepnote/deepnote/discussions)
3110

32-
#### Option 1: Using mise (Recommended)
11+
</div>
3312

34-
[mise](https://mise.jdx.dev/) automatically manages Python, Java, and other tool versions:
35-
36-
1. Install mise: [Getting started](https://mise.jdx.dev/getting-started.html)
37-
2. Run setup:
38-
39-
```bash
40-
mise install # Installs Python 3.12 and Java 11
41-
mise run setup # Installs dependencies and pre-commit hooks
42-
```
13+
# Deepnote Toolkit
4314

44-
#### Option 2: Manual setup
15+
The Deepnote Toolkit is a Python package that powers the [Deepnote notebook environment](https://github.com/deepnote/deepnote/). It provides the essential functionality that runs in user workspaces, enabling interactive data science workflows with SQL, visualizations, and integrations.
4516

46-
1. Install poetry: [Installation](https://python-poetry.org/docs/#installation)
47-
2. Install Java 11 (required for PySpark tests):
48-
- macOS: `brew install openjdk@11`
49-
- Ubuntu/Debian: `sudo apt-get install openjdk-11-jdk`
50-
- RHEL/Fedora: `sudo dnf install java-11-openjdk-devel`
51-
3. Set up venv for development package:
5217

53-
```bash
54-
# if python 3.10 is installed this should use
55-
$ poetry env use 3.10
56-
```
18+
## Installation
5719

58-
4. Verify the virtual environment location:
20+
The toolkit is automatically installed in Deepnote workspaces. For local development or testing:
5921

60-
```bash
61-
$ poetry env info
62-
```
22+
```bash
23+
pip install deepnote-toolkit
24+
```
6325

64-
5. Install dependencies:
26+
For server components (Jupyter, Streamlit, LSP):
6527

66-
```bash
67-
$ poetry install
68-
```
28+
```bash
29+
pip install deepnote-toolkit[server]
30+
```
6931

70-
6. Install Poe Poetry addon:
32+
## Features
7133

72-
```bash
73-
$ poetry self add 'poethepoet[poetry_plugin]'
74-
```
34+
### Core capabilities
35+
- **SQL execution engine**: Multi-database SQL support with connection management, query templating via Jinja2, intelligent caching, and query chaining with CTE generation
36+
- **Interactive visualizations**: Vega-Lite charts with VegaFusion optimization, multi-layer support, and interactive selections
37+
- **Data processing**: Enhanced DataFrame utilities, data sanitization, and DuckDB in-memory analytics
38+
- **Jupyter integration**: Custom IPython kernel with scientific computing libraries (pandas, numpy, etc.)
7539

76-
7. Install pre-commit hooks:
40+
### Developer tools
41+
- **CLI interface**: Command-line tools for server management and configuration
42+
- **Streamlit support**: Auto-reload development workflow for Streamlit applications
43+
- **Language server protocol**: Code intelligence and autocompletion support
44+
- **Runtime initialization**: Session persistence, environment variable management, and post-start hooks
7745

78-
```bash
79-
$ poetry poe setup-hooks
80-
```
46+
### Infrastructure
47+
- **Git integration**: SSH/HTTPS authentication for repository access
48+
- **SSH tunneling**: Secure database connections through SSH tunnels
49+
- **Metrics collection**: Prometheus metrics for monitoring and observability
50+
- **Feature flags**: Dynamic feature toggling support
8151

82-
8. Verify installation:
52+
## Architecture
8353

84-
```bash
85-
$ poetry poe lint
86-
$ poetry poe format
87-
```
54+
The toolkit is organized into two deployment bundles:
8855

89-
### Setup troubleshooting
56+
1. **Kernel bundle**: Core libraries available to user code (pandas, numpy, SQL drivers, visualization libraries)
57+
2. **Server bundle**: Infrastructure services (Jupyter Server, Streamlit, Python LSP Server)
9058

91-
1. If `poetry install` fails with error `library 'ssl' not found`:
59+
### Main modules
9260

93-
```bash
94-
env LDFLAGS="-I/opt/homebrew/opt/openssl/include -L/opt/homebrew/opt/openssl/lib" poetry install
95-
```
61+
- **`deepnote_toolkit.sql`**: SQL execution, templating, caching, and query chaining
62+
- **`deepnote_toolkit.chart`**: Vega-Lite chart rendering with VegaFusion optimization
63+
- **`deepnote_toolkit.cli`**: Command-line interface for toolkit management
64+
- **`deepnote_toolkit.ocelots`**: Deepnote component library for interactive UI elements
65+
- **`deepnote_toolkit.runtime`**: Runtime initialization and session management
66+
- **`deepnote_core`**: Core utilities shared across the toolkit
9667

97-
2. If `poetry install` fails installing `pymssql`, install `freetds` via homebrew.
68+
## Usage
9869

99-
## CLI Quick Start
70+
### CLI commands
10071

101-
The toolkit includes a pip-native CLI:
72+
The toolkit provides a command-line interface for managing servers and configuration:
10273

10374
```bash
104-
# Install the package with server components
105-
poetry install --with server
106-
107-
# Run the CLI to see available commands
108-
poetry run deepnote-toolkit --help
109-
11075
# Start Jupyter server on default port (8888)
111-
poetry run deepnote-toolkit server
76+
deepnote-toolkit server
11277

11378
# Start servers with custom configuration
114-
poetry run deepnote-toolkit server --jupyter-port 9000
79+
deepnote-toolkit server --jupyter-port 9000
11580

11681
# View/modify configuration
117-
poetry run deepnote-toolkit config show
118-
poetry run deepnote-toolkit config set server.jupyter_port 9000
82+
deepnote-toolkit config show
83+
deepnote-toolkit config set server.jupyter_port 9000
11984
```
12085

121-
**Security Note**: The CLI will warn if Jupyter runs without authentication. For local development only. Set `DEEPNOTE_JUPYTER_TOKEN` for shared environments.
86+
**Security note**: The CLI will warn if Jupyter runs without authentication. For local development only. Set `DEEPNOTE_JUPYTER_TOKEN` for shared environments.
12287

123-
## Testing
12488

125-
Tests run against all supported Python versions using nox in Docker for reproducible environments.
89+
## Development
12690

127-
### Local Testing
91+
### Testing
12892

129-
#### Using mise (Recommended)
93+
The project uses nox for testing across multiple Python versions (3.9-3.12) in Docker containers.
13094

95+
**Quick testing with mise:**
13196
```bash
132-
# Run unit tests (no coverage by default)
133-
mise run test
134-
135-
# Run unit tests with coverage
136-
mise run test:coverage
137-
138-
# Run tests quickly without nox/coverage overhead
139-
mise run test:quick tests/unit/test_file.py
140-
mise run test:quick tests/unit/test_file.py::TestClass::test_method -v
141-
142-
# Pass custom arguments (including --coverage)
143-
mise run test -- --coverage tests/unit/test_file.py
97+
mise run test # Run unit tests
98+
mise run test:coverage # Run with coverage
99+
mise run test:quick tests/unit/ # Fast testing without nox overhead
144100
```
145101

146-
#### Using nox directly
147-
102+
**Using nox directly:**
148103
```bash
149-
# Run unit tests without coverage
150-
poetry run nox -s unit
151-
152-
# Run unit tests with coverage
153-
poetry run nox -s unit -- --coverage
154-
155-
# Run specific test file
156-
poetry run nox -s unit -- tests/unit/test_file.py
104+
poetry run nox -s unit # Run unit tests
105+
poetry run nox -s unit -- --coverage # With coverage
106+
poetry run nox -s unit -- tests/unit/test_file.py # Specific file
157107
```
158108

159-
#### Using Docker
109+
**Using Docker:**
160110
```bash
161-
# Run unit tests
162-
TEST_TYPE="unit" TOOLKIT_VERSION="local-build" ./bin/test
163-
164-
# Run integration tests
165-
TEST_TYPE="integration" TOOLKIT_VERSION="local-build" TOOLKIT_INDEX_URL="http://localhost:8000" ./bin/test
166-
167-
# Or use the test-local script for both unit tests and integration tests
168-
./bin/test-local
169-
170-
# Run a specific file with test-local
171-
./bin/test-local tests/unit/test_file.py
172-
173-
# ... or specific test
174-
./bin/test-local tests/unit/test_file.py::TestClass::test_method
111+
./bin/test-local # Run all tests
112+
./bin/test-local tests/unit/test_file.py # Specific file
175113
```
176114

177-
### Test Coverage
178-
179-
- Unit tests for core functionality
180-
- Integration tests for bundle installation
181-
- Server startup tests
182-
- Environment variable handling
183-
184-
## Development Workflow
115+
### Test coverage
185116

186-
### Using in Deepnote Projects
117+
- Unit tests for SQL execution, charting, and utilities
118+
- Integration tests for bundle installation and server startup
119+
- Python 3.9-3.12 compatibility testing
120+
- Coverage threshold: 55%
187121

188-
When you push a commit, a new version of `deepnote/jupyter-for-local` is built with your commit hash (shortened!). Use it in projects by updating `common.yml`:
122+
### Local development with Docker
189123

190-
```yaml
191-
jupyter:
192-
image: "deepnote/jupyter-for-local:SHORTENED_COMMIT_SHA"
193-
```
194-
195-
Alternatively, to develop against local copy of toolkit, first run this command to build the image:
124+
For local development with hot-reload:
196125

197126
```bash
127+
# Build the development image
198128
docker build \
199129
--build-arg "FROM_PYTHON_TAG=3.11" \
200130
-t deepnote/deepnote-toolkit-local-hotreload \
201131
-f ./dockerfiles/jupyter-for-local-hotreload/Dockerfile .
202-
```
203-
204-
And start container:
205-
206-
```bash
207-
# To include server logs in the output add this argument
208-
# -e WITH_SERVER_LOGS=1 \
209-
210-
# Some toolkit features (e.g. feature flags support) require
211-
# DEEPNOTE_PROJECT_ID to be set to work correctly. Add this
212-
# argument with your project id
213-
# -e DEEPNOTE_PROJECT_ID=981af2c1-fe8b-41b7-94bf-006b74cf0641 \
214132

133+
# Start the container
215134
docker run \
216135
-v "$(pwd)":/deepnote-toolkit \
217136
-v /tmp/deepnote-mounts:/deepnote-mounts:shared \
218-
-p 8888:8888 \
219-
-p 2087:2087 \
220-
-p 8051:8051 \
137+
-p 8888:8888 -p 2087:2087 -p 8051:8051 \
221138
-w /deepnote-toolkit \
222-
--add-host=localstack.dev.deepnote.org:host-gateway \
223139
--rm \
224140
--name deepnote-toolkit-local-hotreload-container \
225-
deepnote/deepnote-toolkit-local-hotreload
141+
deepnote/deepnote-toolkit-local-hotreload
226142
```
227143

228-
This will start a container with Deepnote toolkit mounted inside and expose all required ports. If you change code that is executed in kernel (e.g. you updated DataFrame formatter), you need only to restart kernel from Deepnote's UI. If you updated code that is starts Jupyter itself, you need to restart container. And if you add/modify dependencies you need to rebuild image.
144+
**Hot-reload behavior:**
145+
- Kernel code changes: Restart kernel from Jupyter UI
146+
- Server code changes: Restart container
147+
- Dependency changes: Rebuild image
229148

230-
Now, you need to modify `common.yml` in the Deepnote app. First, replace `jupyter` service with noop image:
149+
### Docker images
231150

232-
```yml
233-
jupyter:
234-
image: 'screwdrivercd/noop-container'
235-
```
236-
237-
And change `JUPYTER_HOST` variable of executor to point to host machine:
238-
239-
```yml
240-
executor:
241-
environment:
242-
JUPYTER_HOST: host.docker.internal
243-
```
244-
245-
### Review Apps
246-
247-
Each PR creates a review app for testing. Access it via GitHub checks. Monitor logs in Grafana:
248-
249-
```
250-
{pod="p-PROJECT_ID", container="notebook"}
251-
```
252-
253-
### Adding Dependencies
254-
255-
- Kernel dependencies: Add to `[tool.poetry.dependencies]` in pyproject.toml
256-
257-
```bash
258-
# Add a package to kernel bundle (available in notebooks)
259-
$ poetry add pandas
260-
261-
# Add a package with specific version
262-
$ poetry add "pandas>=2.0.0"
263-
```
264-
265-
```bash
266-
# Add a development dependency
267-
$ poetry add --group dev pytest
268-
```
269-
270-
After adding dependencies, run tests to verify compatibility:
271-
272-
```bash
273-
$ ./bin/test-local
274-
```
151+
The repository includes three main Dockerfiles:
275152

276-
### Docker Usage
153+
- **`builder.Dockerfile`**: Builds Python packages for versions 3.9-3.12, generates kernel and server bundles
154+
- **`test.Dockerfile`**: Provides reproducible test environment for nox across Python versions
155+
- **`jupyter-for-local.Dockerfile`**: Development environment with Jupyter integration for local testing
277156

278-
We use Docker to ensure reproducible environments due to Jupyter libraries' binary dependencies:
157+
## Contributing
279158

280-
- `builder.Dockerfile`: Creates Python package bundles for different versions (3.9-3.12), generates kernel and server bundles, and packages the toolkit for distribution using Poetry.
159+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding standards, and contribution guidelines.
281160

282-
- `test.Dockerfile`: Provides consistent test environment for running unit and integration tests across Python versions using nox. Used both locally and in CI/CD pipeline.
161+
## License
283162

284-
- `jupyter-for-local.Dockerfile`: Creates development environment with Jupyter integration, used for local development from docker-compose used in main monorepo.
163+
Apache License 2.0 - See [LICENSE](LICENSE) for details.
285164

286-
### Production Releases
165+
## Support
287166

288-
To release a new version to production:
167+
- **Documentation**: [docs.deepnote.com](https://docs.deepnote.com)
168+
- **Issues**: [GitHub Issues](https://github.com/deepnote/deepnote-toolkit/issues)
169+
- **Security**: See [SECURITY.md](SECURITY.md) for reporting vulnerabilities
289170

290-
1. Merge your changes to main. This will automatically trigger a GitHub Actions workflow that runs the test suite and a staging deployment.
291-
2. Trigger a new [GitHub Release](https://github.com/deepnote/deepnote-toolkit/releases) in the GitHub UI.
292-
3. Monitor [the GitHub Actions workflows](https://github.com/deepnote/deepnote-toolkit/actions) and ensure a successful production deployment.
293171

294-
Note: The production release pipeline automatically creates two PRs in the ops and app-config repositories:
172+
<div align="center">
295173

296-
- A staging PR that updates staging values and is auto-merged
297-
- A production PR that updates production values and requires manual approval and merge
174+
**Built with 💙 by the Deepnote team**
298175

299-
Important: Always test the changes in the staging environment before approving and merging the production PR to ensure everything works as expected.
176+
</div>

deepnote-toolkit-cover-image.png

6.46 MB
Loading

0 commit comments

Comments
 (0)