workpeg 0.3.1__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.
- {workpeg-0.3.1/src/workpeg.egg-info → workpeg-0.3.2}/PKG-INFO +1 -1
- {workpeg-0.3.1 → workpeg-0.3.2}/pyproject.toml +1 -1
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/run.py +4 -0
- {workpeg-0.3.1 → workpeg-0.3.2/src/workpeg.egg-info}/PKG-INFO +1 -1
- {workpeg-0.3.1 → workpeg-0.3.2}/tests/test_run.py +65 -26
- {workpeg-0.3.1 → workpeg-0.3.2}/LICENSE +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/MANIFEST.in +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/README.md +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/setup.cfg +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/__init__.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/build.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/cli.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/config.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/create_new.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/runtime.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/submit.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/__init__.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/functions/Dockerfile +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/functions/LICENSE +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/functions/README.md +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/functions/app/__init__.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/functions/app/main.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg/templates/functions/requirements.txt +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg.egg-info/SOURCES.txt +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg.egg-info/dependency_links.txt +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg.egg-info/entry_points.txt +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg.egg-info/requires.txt +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/src/workpeg.egg-info/top_level.txt +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/tests/test_build.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/tests/test_cli.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/tests/test_create_new.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/tests/test_runtime.py +0 -0
- {workpeg-0.3.1 → workpeg-0.3.2}/tests/test_submit.py +0 -0
|
@@ -17,6 +17,7 @@ def run_with_docker(
|
|
|
17
17
|
build_first: bool = True,
|
|
18
18
|
network: str | None = None,
|
|
19
19
|
expose: bool = True,
|
|
20
|
+
name: str | None = None,
|
|
20
21
|
) -> None:
|
|
21
22
|
project_path = Path(path).resolve()
|
|
22
23
|
cfg = load_config(project_path / "workpeg.json")
|
|
@@ -28,6 +29,9 @@ def run_with_docker(
|
|
|
28
29
|
|
|
29
30
|
cmd = ["docker", "run", "--rm"]
|
|
30
31
|
|
|
32
|
+
if name:
|
|
33
|
+
cmd += ["--name", name]
|
|
34
|
+
|
|
31
35
|
if expose:
|
|
32
36
|
cmd += ["-p", f"{port}:{port}"]
|
|
33
37
|
|
|
@@ -156,32 +156,6 @@ def test_run_main_with_docker_and_network(monkeypatch):
|
|
|
156
156
|
"network": "workpeg_net",
|
|
157
157
|
}
|
|
158
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
159
|
|
|
186
160
|
def test_run_with_docker_no_expose(monkeypatch, tmp_path):
|
|
187
161
|
project = tmp_path / "demo"
|
|
@@ -231,3 +205,68 @@ def test_run_with_docker_expose(monkeypatch, tmp_path):
|
|
|
231
205
|
"demo",
|
|
232
206
|
]
|
|
233
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
|
|
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
|