workpeg 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- workpeg-0.3.0/PKG-INFO +316 -0
- workpeg-0.3.0/README.md +297 -0
- {workpeg-0.2.0 → workpeg-0.3.0}/pyproject.toml +4 -4
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/__init__.py +1 -1
- workpeg-0.3.0/src/workpeg/build.py +34 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/cli.py +35 -5
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/config.py +1 -1
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/create_new.py +4 -4
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/run.py +21 -15
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/runtime.py +1 -1
- workpeg-0.3.0/src/workpeg.egg-info/PKG-INFO +316 -0
- workpeg-0.3.0/src/workpeg.egg-info/SOURCES.txt +31 -0
- workpeg-0.3.0/src/workpeg.egg-info/entry_points.txt +2 -0
- workpeg-0.3.0/src/workpeg.egg-info/top_level.txt +1 -0
- {workpeg-0.2.0 → workpeg-0.3.0}/tests/test_build.py +1 -1
- {workpeg-0.2.0 → workpeg-0.3.0}/tests/test_cli.py +44 -11
- {workpeg-0.2.0 → workpeg-0.3.0}/tests/test_create_new.py +1 -1
- {workpeg-0.2.0 → workpeg-0.3.0}/tests/test_run.py +42 -9
- {workpeg-0.2.0 → workpeg-0.3.0}/tests/test_runtime.py +1 -1
- {workpeg-0.2.0 → workpeg-0.3.0}/tests/test_submit.py +7 -7
- workpeg-0.2.0/PKG-INFO +0 -194
- workpeg-0.2.0/README.md +0 -175
- workpeg-0.2.0/src/workpeg.egg-info/PKG-INFO +0 -194
- workpeg-0.2.0/src/workpeg.egg-info/SOURCES.txt +0 -31
- workpeg-0.2.0/src/workpeg.egg-info/entry_points.txt +0 -2
- workpeg-0.2.0/src/workpeg.egg-info/top_level.txt +0 -1
- workpeg-0.2.0/src/workpeg_sdk/build.py +0 -34
- {workpeg-0.2.0 → workpeg-0.3.0}/LICENSE +0 -0
- {workpeg-0.2.0 → workpeg-0.3.0}/MANIFEST.in +0 -0
- {workpeg-0.2.0 → workpeg-0.3.0}/setup.cfg +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/submit.py +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/__init__.py +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/functions/Dockerfile +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/functions/LICENSE +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/functions/README.md +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/functions/app/__init__.py +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/functions/app/main.py +0 -0
- {workpeg-0.2.0/src/workpeg_sdk → workpeg-0.3.0/src/workpeg}/templates/functions/requirements.txt +0 -0
- {workpeg-0.2.0 → workpeg-0.3.0}/src/workpeg.egg-info/dependency_links.txt +0 -0
- {workpeg-0.2.0 → workpeg-0.3.0}/src/workpeg.egg-info/requires.txt +0 -0
workpeg-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: workpeg
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Workpeg function runtime and SDK
|
|
5
|
+
Author-email: Workpeg <support@workpeg.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://gitlab.com/workpeg/workpeg
|
|
8
|
+
Project-URL: Repository, https://gitlab.com/workpeg/workpeg
|
|
9
|
+
Keywords: workpeg,serverless,functions,runtime
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: requests>=2.31.0
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Workpeg SDK
|
|
21
|
+
|
|
22
|
+
Python SDK for building, packaging, and running **Workpeg Functions and Pegs**.
|
|
23
|
+
|
|
24
|
+
The SDK provides:
|
|
25
|
+
|
|
26
|
+
* Project scaffolding
|
|
27
|
+
* Local execution (fast + Docker runtime)
|
|
28
|
+
* Docker-based packaging
|
|
29
|
+
* Registry submission
|
|
30
|
+
|
|
31
|
+
Workpeg is designed as an **execution layer**, not just a code runner — functions evolve into **Pegs** that integrate into a larger system.
|
|
32
|
+
|
|
33
|
+
**Repository**
|
|
34
|
+
[https://gitlab.com/workpeg/workpeg-sdk](https://gitlab.com/workpeg/workpeg-sdk)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
# Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install workpeg
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or from source:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install -e .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
# Quick Start
|
|
53
|
+
|
|
54
|
+
## 1. Create a Function
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
workpeg new-function my-function
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Structure:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
my-function/
|
|
64
|
+
app/
|
|
65
|
+
__init__.py
|
|
66
|
+
main.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Example:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
def main(context, payload):
|
|
73
|
+
return {
|
|
74
|
+
"message": "Hello from Workpeg",
|
|
75
|
+
"payload": payload,
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 2. Run (Fast Local Runtime)
|
|
82
|
+
|
|
83
|
+
For quick iteration without Docker:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
echo '{"context": {}, "payload": {"name": "world"}}' | workpeg runtime
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 3. Build (Docker Image)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
workpeg build
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Optional tag:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
workpeg build --tag my-image
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This produces a runnable container for your function.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 4. Run (Docker Runtime)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
workpeg run --with docker
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
This will:
|
|
114
|
+
|
|
115
|
+
* Build the image (if needed)
|
|
116
|
+
* Start a container
|
|
117
|
+
* Expose an HTTP endpoint
|
|
118
|
+
|
|
119
|
+
Default:
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
http://localhost:8000
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Optional network (advanced)
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
workpeg run --with docker --network workpeg_net
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Useful when integrating with other containers (e.g. your API service).
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 5. Submit to Registry
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
workpeg submit my-function:1.0.0
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Authentication:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
export WORKPEG_PK=<your-token>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Registry:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
https://repo.workpeg.com
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
# Runtime Modes
|
|
156
|
+
|
|
157
|
+
Workpeg supports multiple execution backends:
|
|
158
|
+
|
|
159
|
+
| Runtime | Purpose | Status |
|
|
160
|
+
| ------- | -------------------- | ----------- |
|
|
161
|
+
| docker | Local development | ✅ Available |
|
|
162
|
+
| cracker | Firecracker microVMs | 🚧 Planned |
|
|
163
|
+
|
|
164
|
+
Select runtime:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
workpeg run --with docker
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
If unspecified:
|
|
171
|
+
|
|
172
|
+
1. Uses `workpeg.json`
|
|
173
|
+
2. Falls back to `cracker` (future default)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
# Configuration
|
|
178
|
+
|
|
179
|
+
Optional config file:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
workpeg.json
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Example:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"runtime": {
|
|
190
|
+
"default": "docker",
|
|
191
|
+
"docker": {
|
|
192
|
+
"port": 8000
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"build": {
|
|
196
|
+
"image": "my-custom-image"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
# Function Contract
|
|
204
|
+
|
|
205
|
+
Your function must implement:
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
def main(context: dict, payload: dict):
|
|
209
|
+
return {...}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Input
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"context": {...},
|
|
217
|
+
"payload": {...}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Success Output
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"status": "success",
|
|
226
|
+
"result": {...}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Error Output
|
|
231
|
+
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"status": "error",
|
|
235
|
+
"error_type": "...",
|
|
236
|
+
"error": "..."
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
# Entrypoint
|
|
243
|
+
|
|
244
|
+
Default:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
app.main:main
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Override:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
FUNCTION_ENTRYPOINT=app.main:handler workpeg runtime
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
# Project Layout
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
my-function/
|
|
262
|
+
├─ app/
|
|
263
|
+
│ ├─ __init__.py
|
|
264
|
+
│ └─ main.py
|
|
265
|
+
├─ requirements.txt
|
|
266
|
+
└─ workpeg.json (optional)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
# Docker Requirement (Important)
|
|
272
|
+
|
|
273
|
+
For `workpeg build` and `workpeg run --with docker`:
|
|
274
|
+
|
|
275
|
+
* Docker must be installed
|
|
276
|
+
* Docker CLI must be available on PATH
|
|
277
|
+
* Docker daemon must be running
|
|
278
|
+
|
|
279
|
+
If using inside containers:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
-v /var/run/docker.sock:/var/run/docker.sock
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
# Philosophy
|
|
288
|
+
|
|
289
|
+
Workpeg is built around a simple progression:
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
Function → Package → Runtime → Peg → System
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
* Functions are stateless execution units
|
|
296
|
+
* Pegs add structure, state, and integrations
|
|
297
|
+
* Workpeg orchestrates execution
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
# Roadmap
|
|
302
|
+
|
|
303
|
+
Planned:
|
|
304
|
+
|
|
305
|
+
* Firecracker runtime (production)
|
|
306
|
+
* Warm container/microVM execution
|
|
307
|
+
* Peg UI layer (Streamlit-like)
|
|
308
|
+
* Deployment workflows
|
|
309
|
+
* Isolation + sandboxing
|
|
310
|
+
* Registry approvals & governance
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
# License
|
|
315
|
+
|
|
316
|
+
MIT License
|
workpeg-0.3.0/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Workpeg SDK
|
|
2
|
+
|
|
3
|
+
Python SDK for building, packaging, and running **Workpeg Functions and Pegs**.
|
|
4
|
+
|
|
5
|
+
The SDK provides:
|
|
6
|
+
|
|
7
|
+
* Project scaffolding
|
|
8
|
+
* Local execution (fast + Docker runtime)
|
|
9
|
+
* Docker-based packaging
|
|
10
|
+
* Registry submission
|
|
11
|
+
|
|
12
|
+
Workpeg is designed as an **execution layer**, not just a code runner — functions evolve into **Pegs** that integrate into a larger system.
|
|
13
|
+
|
|
14
|
+
**Repository**
|
|
15
|
+
[https://gitlab.com/workpeg/workpeg-sdk](https://gitlab.com/workpeg/workpeg-sdk)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install workpeg
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or from source:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install -e .
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# Quick Start
|
|
34
|
+
|
|
35
|
+
## 1. Create a Function
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
workpeg new-function my-function
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Structure:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
my-function/
|
|
45
|
+
app/
|
|
46
|
+
__init__.py
|
|
47
|
+
main.py
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Example:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
def main(context, payload):
|
|
54
|
+
return {
|
|
55
|
+
"message": "Hello from Workpeg",
|
|
56
|
+
"payload": payload,
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 2. Run (Fast Local Runtime)
|
|
63
|
+
|
|
64
|
+
For quick iteration without Docker:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
echo '{"context": {}, "payload": {"name": "world"}}' | workpeg runtime
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 3. Build (Docker Image)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
workpeg build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Optional tag:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
workpeg build --tag my-image
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This produces a runnable container for your function.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 4. Run (Docker Runtime)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
workpeg run --with docker
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This will:
|
|
95
|
+
|
|
96
|
+
* Build the image (if needed)
|
|
97
|
+
* Start a container
|
|
98
|
+
* Expose an HTTP endpoint
|
|
99
|
+
|
|
100
|
+
Default:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
http://localhost:8000
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Optional network (advanced)
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
workpeg run --with docker --network workpeg_net
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Useful when integrating with other containers (e.g. your API service).
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 5. Submit to Registry
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
workpeg submit my-function:1.0.0
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Authentication:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
export WORKPEG_PK=<your-token>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Registry:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
https://repo.workpeg.com
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
# Runtime Modes
|
|
137
|
+
|
|
138
|
+
Workpeg supports multiple execution backends:
|
|
139
|
+
|
|
140
|
+
| Runtime | Purpose | Status |
|
|
141
|
+
| ------- | -------------------- | ----------- |
|
|
142
|
+
| docker | Local development | ✅ Available |
|
|
143
|
+
| cracker | Firecracker microVMs | 🚧 Planned |
|
|
144
|
+
|
|
145
|
+
Select runtime:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
workpeg run --with docker
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
If unspecified:
|
|
152
|
+
|
|
153
|
+
1. Uses `workpeg.json`
|
|
154
|
+
2. Falls back to `cracker` (future default)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
# Configuration
|
|
159
|
+
|
|
160
|
+
Optional config file:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
workpeg.json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"runtime": {
|
|
171
|
+
"default": "docker",
|
|
172
|
+
"docker": {
|
|
173
|
+
"port": 8000
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"build": {
|
|
177
|
+
"image": "my-custom-image"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
# Function Contract
|
|
185
|
+
|
|
186
|
+
Your function must implement:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
def main(context: dict, payload: dict):
|
|
190
|
+
return {...}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Input
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"context": {...},
|
|
198
|
+
"payload": {...}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Success Output
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"status": "success",
|
|
207
|
+
"result": {...}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Error Output
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"status": "error",
|
|
216
|
+
"error_type": "...",
|
|
217
|
+
"error": "..."
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
# Entrypoint
|
|
224
|
+
|
|
225
|
+
Default:
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
app.main:main
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Override:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
FUNCTION_ENTRYPOINT=app.main:handler workpeg runtime
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
# Project Layout
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
my-function/
|
|
243
|
+
├─ app/
|
|
244
|
+
│ ├─ __init__.py
|
|
245
|
+
│ └─ main.py
|
|
246
|
+
├─ requirements.txt
|
|
247
|
+
└─ workpeg.json (optional)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
# Docker Requirement (Important)
|
|
253
|
+
|
|
254
|
+
For `workpeg build` and `workpeg run --with docker`:
|
|
255
|
+
|
|
256
|
+
* Docker must be installed
|
|
257
|
+
* Docker CLI must be available on PATH
|
|
258
|
+
* Docker daemon must be running
|
|
259
|
+
|
|
260
|
+
If using inside containers:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
-v /var/run/docker.sock:/var/run/docker.sock
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
# Philosophy
|
|
269
|
+
|
|
270
|
+
Workpeg is built around a simple progression:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
Function → Package → Runtime → Peg → System
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
* Functions are stateless execution units
|
|
277
|
+
* Pegs add structure, state, and integrations
|
|
278
|
+
* Workpeg orchestrates execution
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
# Roadmap
|
|
283
|
+
|
|
284
|
+
Planned:
|
|
285
|
+
|
|
286
|
+
* Firecracker runtime (production)
|
|
287
|
+
* Warm container/microVM execution
|
|
288
|
+
* Peg UI layer (Streamlit-like)
|
|
289
|
+
* Deployment workflows
|
|
290
|
+
* Isolation + sandboxing
|
|
291
|
+
* Registry approvals & governance
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
# License
|
|
296
|
+
|
|
297
|
+
MIT License
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "workpeg"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Workpeg function runtime and SDK"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -29,20 +29,20 @@ Homepage = "https://gitlab.com/workpeg/workpeg"
|
|
|
29
29
|
Repository = "https://gitlab.com/workpeg/workpeg"
|
|
30
30
|
|
|
31
31
|
[project.scripts]
|
|
32
|
-
workpeg = "
|
|
32
|
+
workpeg = "workpeg.cli:main"
|
|
33
33
|
|
|
34
34
|
[tool.setuptools]
|
|
35
35
|
package-dir = {"" = "src"}
|
|
36
36
|
|
|
37
37
|
[tool.setuptools.package-data]
|
|
38
|
-
|
|
38
|
+
workpeg = ["templates/**"]
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
[tool.setuptools.packages.find]
|
|
42
42
|
where = ["src"]
|
|
43
43
|
|
|
44
44
|
[tool.setuptools.exclude-package-data]
|
|
45
|
-
|
|
45
|
+
workpeg = [
|
|
46
46
|
"templates/**/__pycache__/**",
|
|
47
47
|
"templates/**/*.pyc",
|
|
48
48
|
"templates/**/*.pyo",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# src/workpeg/build.py
|
|
2
|
+
import subprocess
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from workpeg.config import load_config
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def slugify(value: str) -> str:
|
|
9
|
+
return value.lower().replace("_", "-").replace(".", "-").replace(" ", "-")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def default_image_name(project_path: Path) -> str:
|
|
13
|
+
project_name = slugify(project_path.resolve().name)
|
|
14
|
+
return f"workpeg-fn-{project_name}"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def build_image(path: str = ".", tag: str | None = None) -> str:
|
|
18
|
+
project_path = Path(path).resolve()
|
|
19
|
+
cfg = load_config(project_path / "workpeg.json")
|
|
20
|
+
|
|
21
|
+
image = tag or cfg.get("build", {}).get("image") or default_image_name(project_path)
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
subprocess.run(
|
|
25
|
+
["docker", "build", "-t", image, str(project_path)],
|
|
26
|
+
check=True,
|
|
27
|
+
)
|
|
28
|
+
except FileNotFoundError as exc:
|
|
29
|
+
raise RuntimeError(
|
|
30
|
+
"Docker CLI not found. Install Docker or run this command in an environment "
|
|
31
|
+
"where the 'docker' binary is available."
|
|
32
|
+
) from exc
|
|
33
|
+
|
|
34
|
+
return image
|