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.
- {workpeg-0.3.0/src/workpeg.egg-info → workpeg-0.3.2}/PKG-INFO +1 -1
- {workpeg-0.3.0 → workpeg-0.3.2}/pyproject.toml +1 -1
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/run.py +14 -5
- {workpeg-0.3.0 → workpeg-0.3.2/src/workpeg.egg-info}/PKG-INFO +1 -1
- {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_run.py +115 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/LICENSE +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/MANIFEST.in +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/README.md +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/setup.cfg +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/__init__.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/build.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/cli.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/config.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/create_new.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/runtime.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/submit.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/__init__.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/Dockerfile +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/LICENSE +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/README.md +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/app/__init__.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/app/main.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg/templates/functions/requirements.txt +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/SOURCES.txt +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/dependency_links.txt +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/entry_points.txt +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/requires.txt +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/src/workpeg.egg-info/top_level.txt +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_build.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_cli.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_create_new.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_runtime.py +0 -0
- {workpeg-0.3.0 → workpeg-0.3.2}/tests/test_submit.py +0 -0
|
@@ -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(
|
|
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
|
-
|
|
26
|
-
|
|
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]
|
|
@@ -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
|
|
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
|