workpeg 0.3.0__tar.gz → 0.3.2__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.
Files changed (33) hide show
  1. {workpeg-0.3.0/src/workpeg.egg-info → workpeg-0.3.2}/PKG-INFO +1 -1
  2. {workpeg-0.3.0 → workpeg-0.3.2}/pyproject.toml +1 -1
  3. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/run.py +14 -5
  4. {workpeg-0.3.0 → workpeg-0.3.2/src/workpeg.egg-info}/PKG-INFO +1 -1
  5. {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_run.py +115 -0
  6. {workpeg-0.3.0 → workpeg-0.3.2}/LICENSE +0 -0
  7. {workpeg-0.3.0 → workpeg-0.3.2}/MANIFEST.in +0 -0
  8. {workpeg-0.3.0 → workpeg-0.3.2}/README.md +0 -0
  9. {workpeg-0.3.0 → workpeg-0.3.2}/setup.cfg +0 -0
  10. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/__init__.py +0 -0
  11. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/build.py +0 -0
  12. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/cli.py +0 -0
  13. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/config.py +0 -0
  14. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/create_new.py +0 -0
  15. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/runtime.py +0 -0
  16. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/submit.py +0 -0
  17. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/__init__.py +0 -0
  18. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/Dockerfile +0 -0
  19. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/LICENSE +0 -0
  20. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/README.md +0 -0
  21. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/app/__init__.py +0 -0
  22. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/app/main.py +0 -0
  23. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/requirements.txt +0 -0
  24. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/SOURCES.txt +0 -0
  25. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/dependency_links.txt +0 -0
  26. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/entry_points.txt +0 -0
  27. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/requires.txt +0 -0
  28. {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/top_level.txt +0 -0
  29. {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_build.py +0 -0
  30. {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_cli.py +0 -0
  31. {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_create_new.py +0 -0
  32. {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_runtime.py +0 -0
  33. {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_submit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workpeg
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Workpeg function runtime and SDK
5
5
  Author-email: Workpeg <support@workpeg.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "workpeg"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  description = "Workpeg function runtime and SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -12,7 +12,13 @@ def resolve_runtime(with_runtime: str | None, config: dict) -> str:
12
12
  return config.get("runtime", {}).get("default") or "cracker"
13
13
 
14
14
 
15
- def run_with_docker(path: str = ".", build_first: bool = True, network: str | None = None) -> None:
15
+ def run_with_docker(
16
+ path: str = ".",
17
+ build_first: bool = True,
18
+ network: str | None = None,
19
+ expose: bool = True,
20
+ name: str | None = None,
21
+ ) -> None:
16
22
  project_path = Path(path).resolve()
17
23
  cfg = load_config(project_path / "workpeg.json")
18
24
  port = cfg.get("runtime", {}).get("docker", {}).get("port", 8000)
@@ -21,10 +27,13 @@ def run_with_docker(path: str = ".", build_first: bool = True, network: str | No
21
27
  cfg.get("build", {}).get("image") or project_path.name
22
28
  )
23
29
 
24
- cmd = [
25
- "docker", "run", "--rm",
26
- "-p", f"{port}:{port}",
27
- ]
30
+ cmd = ["docker", "run", "--rm"]
31
+
32
+ if name:
33
+ cmd += ["--name", name]
34
+
35
+ if expose:
36
+ cmd += ["-p", f"{port}:{port}"]
28
37
 
29
38
  if network:
30
39
  cmd += ["--network", network]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workpeg
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Workpeg function runtime and SDK
5
5
  Author-email: Workpeg <support@workpeg.com>
6
6
  License: MIT
@@ -155,3 +155,118 @@ def test_run_main_with_docker_and_network(monkeypatch):
155
155
  "build_first": True,
156
156
  "network": "workpeg_net",
157
157
  }
158
+
159
+
160
+ def test_run_with_docker_no_expose(monkeypatch, tmp_path):
161
+ project = tmp_path / "demo"
162
+ project.mkdir()
163
+ (project / "workpeg.json").write_text(
164
+ '{"runtime": {"docker": {"port": 9000}}}'
165
+ )
166
+
167
+ calls = []
168
+
169
+ def fake_run(cmd, check):
170
+ calls.append((cmd, check))
171
+
172
+ monkeypatch.setattr(run.subprocess, "run", fake_run)
173
+
174
+ run.run_with_docker(path=str(project), build_first=False, expose=False)
175
+
176
+ assert len(calls) == 1
177
+ cmd, check = calls[0]
178
+ assert cmd == [
179
+ "docker", "run", "--rm",
180
+ "demo",
181
+ ]
182
+ assert check is True
183
+
184
+
185
+ def test_run_with_docker_expose(monkeypatch, tmp_path):
186
+ project = tmp_path / "demo"
187
+ project.mkdir()
188
+ (project / "workpeg.json").write_text(
189
+ '{"runtime": {"docker": {"port": 9000}}}'
190
+ )
191
+
192
+ calls = []
193
+
194
+ def fake_run(cmd, check):
195
+ calls.append((cmd, check))
196
+
197
+ monkeypatch.setattr(run.subprocess, "run", fake_run)
198
+
199
+ run.run_with_docker(path=str(project), build_first=False, expose=True)
200
+
201
+ cmd, check = calls[0]
202
+ assert cmd == [
203
+ "docker", "run", "--rm",
204
+ "-p", "9000:9000",
205
+ "demo",
206
+ ]
207
+ assert check is True
208
+
209
+
210
+ def test_run_with_docker_with_name(monkeypatch, tmp_path):
211
+ project = tmp_path / "demo"
212
+ project.mkdir()
213
+ (project / "workpeg.json").write_text(
214
+ '{"runtime": {"docker": {"port": 8000}}}'
215
+ )
216
+
217
+ calls = []
218
+
219
+ def fake_run(cmd, check):
220
+ calls.append((cmd, check))
221
+
222
+ monkeypatch.setattr(run.subprocess, "run", fake_run)
223
+
224
+ run.run_with_docker(
225
+ path=str(project),
226
+ build_first=False,
227
+ expose=False,
228
+ name="foo",
229
+ )
230
+
231
+ assert len(calls) == 1
232
+ cmd, check = calls[0]
233
+
234
+ assert cmd == [
235
+ "docker", "run", "--rm",
236
+ "--name", "foo",
237
+ "demo",
238
+ ]
239
+ assert check is True
240
+
241
+
242
+ def test_run_with_docker_name_and_network(monkeypatch, tmp_path):
243
+ project = tmp_path / "demo"
244
+ project.mkdir()
245
+ (project / "workpeg.json").write_text(
246
+ '{"runtime": {"docker": {"port": 8000}}}'
247
+ )
248
+
249
+ calls = []
250
+
251
+ def fake_run(cmd, check):
252
+ calls.append((cmd, check))
253
+
254
+ monkeypatch.setattr(run.subprocess, "run", fake_run)
255
+
256
+ run.run_with_docker(
257
+ path=str(project),
258
+ build_first=False,
259
+ expose=False,
260
+ name="foo",
261
+ network="workpeg_net",
262
+ )
263
+
264
+ cmd, check = calls[0]
265
+
266
+ assert cmd == [
267
+ "docker", "run", "--rm",
268
+ "--name", "foo",
269
+ "--network", "workpeg_net",
270
+ "demo",
271
+ ]
272
+ assert check is True
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes