Skip to content

Commit ab84a90

Browse files
authored
docs: workspace dependencies (#1159)
* docs: workspace dependencies Signed-off-by: pyranota <[email protected]> * change feature matrix Signed-off-by: pyranota <[email protected]> --------- Signed-off-by: pyranota <[email protected]>
1 parent ad1a448 commit ab84a90

File tree

8 files changed

+437
-0
lines changed

8 files changed

+437
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
slug: workspace-dependencies
3+
version: v1.586.0
4+
title: Workspace Dependencies
5+
tags: ['Core concepts', 'Dependencies', 'Script editor']
6+
description: Centralized dependency management at the workspace level for shared dependency files across scripts.
7+
image: ./workspace-dependencies.png
8+
features:
9+
[
10+
'Centralized dependency management with shared dependency files stored in /dependencies directory.',
11+
'Support for Python, TypeScript (Bun), and PHP with language-specific annotations.',
12+
'Two dependency modes: requirements mode (explicit) and extra mode (hybrid with inference).',
13+
'Dependency file versioning and provenance tracking with Git sync support coming soon.',
14+
'CLI integration for managing workspace dependencies alongside scripts and flows.'
15+
]
16+
docs: /docs/core_concepts/workspace_dependencies
17+
---
18+
19+
Workspace dependencies provide centralized dependency management at the workspace level. Instead of managing dependencies individually per script, you can now define shared dependency files that multiple scripts can reference.
20+
21+
## Key Features
22+
23+
**Centralized Storage**: All dependency files are stored under `/dependencies` in your workspace, replacing the previous path-based "raw requirements" system.
24+
25+
**Language Support**: Full support for Python (`.requirements.in`), TypeScript/Bun (`.package.json`), and PHP (`.composer.json`) with their respective annotation syntax.
26+
27+
**Flexible Dependency Modes**:
28+
- **Requirements mode**: Use `# requirements: filename` to disable import inference and use only specified workspace dependencies
29+
- **Extra mode**: Use `# extra_requirements: filename` to add workspace dependencies while keeping import inference enabled (hybrid approach)
30+
31+
**Versioning**: Dependency files are versioned by Windmill with full provenance tracking. Git sync support is coming soon.
32+
33+
**Admin Control**: Workspace dependency files can only be managed by workspace administrators, ensuring proper governance.
34+
35+
## Migration from Raw Requirements
36+
37+
This feature replaces the previous "raw requirements" system. Users need to manually:
38+
1. Move existing dependency files to the workspace `/dependencies` directory
39+
2. Update scripts to use the new annotation syntax
40+
3. Upgrade to the latest Windmill CLI
41+
42+
See the [migration guide](/docs/core_concepts/workspace_dependencies/migration) for detailed instructions.
43+
44+
## Implementation Status
45+
46+
- ✅ Basic functionality with requirements mode
47+
- ✅ Python, TypeScript (Bun), and PHP support
48+
- ✅ CLI integration
49+
- ⏳ Git sync support (coming soon)
50+
- ⏳ Extra requirements mode (planned for next release)
51+
- ❌ Go support (not yet available)
461 KB
Loading

docs/core_concepts/44_workspace_settings/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Each workspace can be configured through the following sections:
1414
- [Object Storage (S3)](../38_object_storage_in_windmill/index.mdx#workspace-object-storage) - Set up S3-compatible storage
1515
- [Default App](../../apps/1_default_app/index.md) - Configure the default application settings
1616
- [Encryption](../30_workspace_secret_encryption/index.mdx) - Manage encryption keys and settings
17+
- [Workspace dependencies](../55_workspace_dependencies/index.mdx) - Centralized dependency management for scripts
1718
- [General](#general)
1819

1920
## General
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
import DocCard from '@site/src/components/DocCard';
2+
3+
# Workspace dependencies
4+
5+
Workspace dependencies allow you to manage dependencies centrally at the workspace level. Create shared dependency files that multiple scripts can reference, giving you control over dependency resolution and enabling consistent environments across your workspace.
6+
7+
![Workspace dependencies overview](./workspace-dependencies.png)
8+
9+
## Quick start
10+
11+
1. **Create dependency files** in workspace settings under `/dependencies`
12+
2. **Reference them in scripts** using annotations like `# requirements: myfile`
13+
3. **Choose your mode**: explicit control or hybrid with import inference
14+
15+
## Dependency files location
16+
17+
All dependency files are stored under `/dependencies` in your workspace:
18+
19+
```
20+
/dependencies/
21+
├── ml.requirements.in # Named Python dependencies
22+
├── api.package.json # Named TypeScript dependencies
23+
├── web.composer.json # Named PHP dependencies
24+
├── requirements.in # Python default (requirements mode)
25+
├── extra.requirements.in # Python default (extra mode)
26+
└── package.json # TypeScript default
27+
```
28+
29+
**Naming rules**:
30+
- Named files: `<name>.<extension>` (e.g., `ml.requirements.in`)
31+
- Unnamed defaults: `<extension>` or `extra.<extension>`
32+
- Cannot use `default` as a filename
33+
- One unnamed default per language (either standard OR `extra.` form)
34+
35+
## Using dependency files in scripts
36+
37+
### Requirements mode (explicit dependencies)
38+
39+
Disables [import inference](../../advanced/6_imports/index.mdx), uses only specified files:
40+
41+
```python
42+
# requirements: ml, api
43+
44+
import pandas as pd
45+
import requests
46+
47+
def main():
48+
return "Uses only ml.requirements.in and api.requirements.in"
49+
```
50+
51+
```typescript
52+
// package_json: frontend, shared
53+
54+
import axios from 'axios';
55+
import lodash from 'lodash';
56+
57+
export async function main() {
58+
return "Uses only frontend.package.json and shared.package.json";
59+
}
60+
```
61+
62+
### Extra mode (hybrid with inference)
63+
64+
Adds workspace dependencies to automatically [inferred imports](../../advanced/6_imports/index.mdx):
65+
66+
```python
67+
# extra_requirements: ml
68+
69+
import pandas as pd # Auto-inferred
70+
import numpy as np # From ml.requirements.in
71+
72+
def main():
73+
return "Combines inference + workspace dependencies";
74+
```
75+
76+
### Including workspace defaults
77+
78+
Use `default` token to include unnamed default files:
79+
80+
```python
81+
# requirements: default, ml
82+
# Includes /dependencies/requirements.in + ml.requirements.in
83+
```
84+
85+
```typescript
86+
// package_json: default, api
87+
// Includes /dependencies/package.json + api.package.json
88+
```
89+
90+
## Supported languages and features
91+
92+
| Language | Syntax | Extra implicit | Manual implicit | Manual explicit | Extra explicit |
93+
|----------|--------|----------------|-----------------|-----------------|----------------|
94+
| Python | `# (extra_)requirements:` ||| one external or less or inline | inline only |
95+
| TypeScript (Bun) | `// (extra_)package_json:` ||| one external or less ||
96+
| PHP | `// (extra_)composer_json:` ||| one external or less ||
97+
| Go | `// (extra_)go_mod:` |||||
98+
99+
Note: Go support not yet available. Extra requirements mode (`#extra_requirements:`, etc.) is planned for future releases.
100+
101+
## Setting up workspace dependencies
102+
103+
Requires workspace admin permissions.
104+
105+
1. Go to workspace settings → Dependencies
106+
2. Create new dependency files or upload existing ones
107+
3. Choose standard or `extra.` defaults for each language
108+
109+
<!-- Image placeholder: Workspace dependencies settings interface -->
110+
111+
### Creating dependency files
112+
113+
**Python example** (`ml.requirements.in`):
114+
```txt
115+
pandas>=1.5.0
116+
numpy>=1.21.0
117+
scikit-learn==1.1.2
118+
matplotlib>=3.5.0
119+
```
120+
121+
**TypeScript example** (`api.package.json`):
122+
```json
123+
{
124+
"dependencies": {
125+
"axios": "^0.27.2",
126+
"lodash": "^4.17.21",
127+
"windmill-client": "^1.147.3"
128+
}
129+
}
130+
```
131+
132+
**PHP example** (`web.composer.json`):
133+
```json
134+
{
135+
"require": {
136+
"guzzlehttp/guzzle": "^7.4",
137+
"monolog/monolog": "^2.8"
138+
}
139+
}
140+
```
141+
142+
### Setting workspace defaults
143+
144+
Choose default behavior for scripts without annotations:
145+
146+
**Requirements mode default**: Creates `/dependencies/requirements.in`
147+
- Scripts without annotations use this file only
148+
- Import inference disabled by default
149+
150+
**Extra mode default**: Creates `/dependencies/extra.requirements.in`
151+
- Scripts without annotations get these dependencies + inference
152+
- Hybrid mode by default
153+
154+
<!-- Image placeholder: Default dependency file selection -->
155+
156+
## Advanced usage
157+
158+
### Mixing workspace and inline dependencies
159+
160+
```python
161+
# requirements: ml, api
162+
# custom-package==1.0.0
163+
# another-dep>=2.0
164+
165+
import pandas as pd
166+
167+
def main():
168+
return "Uses workspace files + inline requirements"
169+
```
170+
171+
### Multiple dependency files
172+
173+
```python
174+
# requirements: base, ml, data-processing
175+
176+
def main():
177+
return "Combines multiple workspace dependency files"
178+
```
179+
180+
### Opting out of defaults
181+
182+
```python
183+
# disable_requirements
184+
# Script ignores workspace defaults
185+
186+
import pandas as pd # Must be available in environment
187+
188+
def main():
189+
return "No workspace dependencies"
190+
```
191+
192+
### Empty dependencies
193+
194+
```python
195+
# empty_requirements
196+
# Script has no external dependencies
197+
198+
def main():
199+
return "No dependencies at all"
200+
```
201+
202+
<!-- Image placeholder: Script editor showing dependency annotations -->
203+
204+
## CLI usage
205+
206+
### Sync dependency files
207+
```bash
208+
# Pull all workspace content including dependencies
209+
wmill sync pull
210+
211+
# Push dependency changes
212+
wmill sync push
213+
```
214+
215+
### Generate lockfiles
216+
```bash
217+
# Create lockfile using workspace dependencies
218+
wmill script generate-metadata my_script.py
219+
```
220+
221+
### Manage dependencies
222+
```bash
223+
# List available dependency files
224+
wmill dependencies list
225+
226+
# View dependency file content
227+
wmill dependencies show ml.requirements.in
228+
```
229+
230+
## Versioning and deployment
231+
232+
- Dependency files are versioned like scripts
233+
- Lockfiles record specific dependency file versions
234+
- Updating dependency files triggers redeployment of dependent scripts
235+
- Git sync includes dependency file changes
236+
237+
## Common patterns
238+
239+
### Team-based dependencies
240+
```
241+
/dependencies/
242+
├── frontend.package.json # Frontend team deps
243+
├── backend.package.json # Backend team deps
244+
├── data.requirements.in # Data team deps
245+
└── shared.requirements.in # Common dependencies
246+
```
247+
248+
### Environment-based
249+
```
250+
/dependencies/
251+
├── prod.requirements.in # Production-ready versions
252+
├── dev.requirements.in # Development dependencies
253+
└── test.requirements.in # Testing utilities
254+
```
255+
256+
### Feature-based
257+
```
258+
/dependencies/
259+
├── ml.requirements.in # Machine learning
260+
├── api.requirements.in # API integrations
261+
├── ui.package.json # UI components
262+
└── data.requirements.in # Data processing
263+
```
264+
265+
## Troubleshooting
266+
267+
### Missing dependencies
268+
- Check annotation syntax: `# requirements: filename`
269+
- Verify file exists in workspace `/dependencies`
270+
- Ensure file contains required packages
271+
272+
### Annotation conflicts
273+
- Use either `# requirements:` OR `# extra_requirements:`, not both
274+
- `# requirements:` takes precedence if both present
275+
276+
### Default file issues
277+
- Cannot have both standard and `extra.` defaults for same language
278+
- Choose one: `/dependencies/requirements.in` OR `/dependencies/extra.requirements.in`
279+
280+
### CLI problems
281+
- Upgrade to latest Windmill CLI
282+
- Ensure admin permissions for dependency management
283+
- Check dependency file format validity
284+
285+
### Import errors
286+
- Requirements mode disables import inference
287+
- Add missing packages to dependency files
288+
- Consider switching to extra mode if you want inference + workspace deps
289+
290+
For debugging, generate and inspect lockfiles:
291+
```bash
292+
wmill script generate-metadata script_path
293+
cat script_path.lock
294+
```
295+
296+
:::info
297+
Workspace dependencies replace the previous "raw requirements" system. See [migration guide](./migration.mdx) if upgrading from the old system.
298+
:::
299+
300+
<div className="grid grid-cols-2 gap-6 mb-4">
301+
<DocCard
302+
title="Migration guide"
303+
description="Migrate from the previous dependency system to workspace dependencies."
304+
href="/docs/core_concepts/workspace_dependencies/migration"
305+
/>
306+
<DocCard
307+
title="Dependency management overview"
308+
description="Understanding Windmill's dependency resolution and import system."
309+
href="/docs/advanced/imports"
310+
/>
311+
</div>

0 commit comments

Comments
 (0)