workpeg 0.3.0__tar.gz → 0.3.1__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.1}/PKG-INFO +1 -1
  2. {workpeg-0.3.0 → workpeg-0.3.1}/pyproject.toml +1 -1
  3. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/run.py +10 -5
  4. {workpeg-0.3.0 → workpeg-0.3.1/src/workpeg.egg-info}/PKG-INFO +1 -1
  5. {workpeg-0.3.0 → workpeg-0.3.1}/tests/test_run.py +76 -0
  6. {workpeg-0.3.0 → workpeg-0.3.1}/LICENSE +0 -0
  7. {workpeg-0.3.0 → workpeg-0.3.1}/MANIFEST.in +0 -0
  8. {workpeg-0.3.0 → workpeg-0.3.1}/README.md +0 -0
  9. {workpeg-0.3.0 → workpeg-0.3.1}/setup.cfg +0 -0
  10. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/__init__.py +0 -0
  11. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/build.py +0 -0
  12. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/cli.py +0 -0
  13. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/config.py +0 -0
  14. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/create_new.py +0 -0
  15. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/runtime.py +0 -0
  16. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/submit.py +0 -0
  17. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/__init__.py +0 -0
  18. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/functions/Dockerfile +0 -0
  19. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/functions/LICENSE +0 -0
  20. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/functions/README.md +0 -0
  21. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/functions/app/__init__.py +0 -0
  22. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/functions/app/main.py +0 -0
  23. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg/templates/functions/requirements.txt +0 -0
  24. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg.egg-info/SOURCES.txt +0 -0
  25. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg.egg-info/dependency_links.txt +0 -0
  26. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg.egg-info/entry_points.txt +0 -0
  27. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg.egg-info/requires.txt +0 -0
  28. {workpeg-0.3.0 → workpeg-0.3.1}/src/workpeg.egg-info/top_level.txt +0 -0
  29. {workpeg-0.3.0 → workpeg-0.3.1}/tests/test_build.py +0 -0
  30. {workpeg-0.3.0 → workpeg-0.3.1}/tests/test_cli.py +0 -0
  31. {workpeg-0.3.0 → workpeg-0.3.1}/tests/test_create_new.py +0 -0
  32. {workpeg-0.3.0 → workpeg-0.3.1}/tests/test_runtime.py +0 -0
  33. {workpeg-0.3.0 → workpeg-0.3.1}/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.1
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.1"
8
8
  description = "Workpeg function runtime and SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -12,7 +12,12 @@ 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
+ ) -> None:
16
21
  project_path = Path(path).resolve()
17
22
  cfg = load_config(project_path / "workpeg.json")
18
23
  port = cfg.get("runtime", {}).get("docker", {}).get("port", 8000)
@@ -21,10 +26,10 @@ def run_with_docker(path: str = ".", build_first: bool = True, network: str | No
21
26
  cfg.get("build", {}).get("image") or project_path.name
22
27
  )
23
28
 
24
- cmd = [
25
- "docker", "run", "--rm",
26
- "-p", f"{port}:{port}",
27
- ]
29
+ cmd = ["docker", "run", "--rm"]
30
+
31
+ if expose:
32
+ cmd += ["-p", f"{port}:{port}"]
28
33
 
29
34
  if network:
30
35
  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.1
4
4
  Summary: Workpeg function runtime and SDK
5
5
  Author-email: Workpeg <support@workpeg.com>
6
6
  License: MIT
@@ -155,3 +155,79 @@ def test_run_main_with_docker_and_network(monkeypatch):
155
155
  "build_first": True,
156
156
  "network": "workpeg_net",
157
157
  }
158
+
159
+ # def run_with_docker(
160
+ # path: str = ".",
161
+ # build_first: bool = True,
162
+ # network: str | None = None,
163
+ # expose: bool = True,
164
+ # ) -> None:
165
+ # project_path = Path(path).resolve()
166
+ # cfg = load_config(project_path / "workpeg.json")
167
+ # port = cfg.get("runtime", {}).get("docker", {}).get("port", 8000)
168
+
169
+ # image = build_image(path) if build_first else (
170
+ # cfg.get("build", {}).get("image") or project_path.name
171
+ # )
172
+
173
+ # cmd = [
174
+ # "docker", "run", "--rm",
175
+ # "-p", f"{port}:{port}" if expose else "",
176
+ # ]
177
+
178
+ # if network:
179
+ # cmd += ["--network", network]
180
+
181
+ # cmd.append(image)
182
+
183
+ # subprocess.run(cmd, check=True)
184
+
185
+
186
+ def test_run_with_docker_no_expose(monkeypatch, tmp_path):
187
+ project = tmp_path / "demo"
188
+ project.mkdir()
189
+ (project / "workpeg.json").write_text(
190
+ '{"runtime": {"docker": {"port": 9000}}}'
191
+ )
192
+
193
+ calls = []
194
+
195
+ def fake_run(cmd, check):
196
+ calls.append((cmd, check))
197
+
198
+ monkeypatch.setattr(run.subprocess, "run", fake_run)
199
+
200
+ run.run_with_docker(path=str(project), build_first=False, expose=False)
201
+
202
+ assert len(calls) == 1
203
+ cmd, check = calls[0]
204
+ assert cmd == [
205
+ "docker", "run", "--rm",
206
+ "demo",
207
+ ]
208
+ assert check is True
209
+
210
+
211
+ def test_run_with_docker_expose(monkeypatch, tmp_path):
212
+ project = tmp_path / "demo"
213
+ project.mkdir()
214
+ (project / "workpeg.json").write_text(
215
+ '{"runtime": {"docker": {"port": 9000}}}'
216
+ )
217
+
218
+ calls = []
219
+
220
+ def fake_run(cmd, check):
221
+ calls.append((cmd, check))
222
+
223
+ monkeypatch.setattr(run.subprocess, "run", fake_run)
224
+
225
+ run.run_with_docker(path=str(project), build_first=False, expose=True)
226
+
227
+ cmd, check = calls[0]
228
+ assert cmd == [
229
+ "docker", "run", "--rm",
230
+ "-p", "9000:9000",
231
+ "demo",
232
+ ]
233
+ 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