fm-weck 1.1.3__py3-none-any.whl → 1.2.0__py3-none-any.whl
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.
- fm_weck/__init__.py +1 -1
- fm_weck/engine.py +40 -4
- fm_weck/resources/run_with_overlay.sh +2 -4
- fm_weck/serve.py +8 -0
- {fm_weck-1.1.3.dist-info → fm_weck-1.2.0.dist-info}/METADATA +1 -1
- {fm_weck-1.1.3.dist-info → fm_weck-1.2.0.dist-info}/RECORD +8 -8
- {fm_weck-1.1.3.dist-info → fm_weck-1.2.0.dist-info}/WHEEL +0 -0
- {fm_weck-1.1.3.dist-info → fm_weck-1.2.0.dist-info}/entry_points.txt +0 -0
fm_weck/__init__.py
CHANGED
fm_weck/engine.py
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
# SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
|
|
8
8
|
import logging
|
|
9
|
+
import shutil
|
|
9
10
|
import subprocess
|
|
10
11
|
from abc import ABC, abstractmethod
|
|
11
12
|
from functools import cached_property, singledispatchmethod
|
|
12
13
|
from pathlib import Path
|
|
14
|
+
from tempfile import mkdtemp
|
|
13
15
|
from typing import List, Optional, Union
|
|
14
16
|
|
|
15
17
|
from fm_tools.fmdata import FmData, FmImageConfig
|
|
@@ -33,10 +35,24 @@ class Engine(ABC):
|
|
|
33
35
|
self.image = self._initialize_image(image)
|
|
34
36
|
self.extra_args = {}
|
|
35
37
|
self._engine = None
|
|
38
|
+
self._tmp_output_dir = Path(mkdtemp("fm_weck_output")).resolve()
|
|
39
|
+
|
|
40
|
+
self.output_dir = Path.cwd() / "output"
|
|
41
|
+
self.log_file = None
|
|
42
|
+
|
|
43
|
+
def __del__(self):
|
|
44
|
+
if self._tmp_output_dir.exists():
|
|
45
|
+
shutil.rmtree(self._tmp_output_dir)
|
|
36
46
|
|
|
37
47
|
def get_workdir(self):
|
|
38
48
|
return Path("/home/cwd")
|
|
39
49
|
|
|
50
|
+
def set_output_log(self, output_log: Path):
|
|
51
|
+
self.log_file = output_log
|
|
52
|
+
|
|
53
|
+
def set_output_files_dir(self, output_log: Path):
|
|
54
|
+
self.output_dir = output_log
|
|
55
|
+
|
|
40
56
|
def mount(self, source: str, target: str):
|
|
41
57
|
self.extra_args["mounts"] = self.extra_args.get("mounts", []) + [
|
|
42
58
|
"-v",
|
|
@@ -63,11 +79,22 @@ class Engine(ABC):
|
|
|
63
79
|
f"{Path.cwd().absolute()}:/home/cwd",
|
|
64
80
|
"-v",
|
|
65
81
|
f"{Config().cache_location}:/home/weck_cache",
|
|
82
|
+
"-v",
|
|
83
|
+
f"{self._tmp_output_dir}:/home/output",
|
|
66
84
|
"--workdir",
|
|
67
85
|
str(self.get_workdir()),
|
|
68
86
|
"--rm",
|
|
69
87
|
]
|
|
70
88
|
|
|
89
|
+
def _move_output(self):
|
|
90
|
+
if not self.output_dir.exists():
|
|
91
|
+
self.output_dir.mkdir()
|
|
92
|
+
for file in self._tmp_output_dir.iterdir():
|
|
93
|
+
if file.is_file():
|
|
94
|
+
shutil.copy(file, self.output_dir / file.name)
|
|
95
|
+
elif file.is_dir():
|
|
96
|
+
shutil.copytree(file, self.output_dir, dirs_exist_ok=True)
|
|
97
|
+
|
|
71
98
|
def assemble_command(self, command: tuple[str, ...]) -> list[str]:
|
|
72
99
|
base = self.base_command()
|
|
73
100
|
if self.add_benchexec_capabilities:
|
|
@@ -219,10 +246,16 @@ class Engine(ABC):
|
|
|
219
246
|
|
|
220
247
|
return tag
|
|
221
248
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
249
|
+
def _run_process(self, command: tuple[str, ...] | list[str]):
|
|
250
|
+
if self.log_file is None:
|
|
251
|
+
process = subprocess.Popen(command)
|
|
252
|
+
process.wait()
|
|
253
|
+
return
|
|
254
|
+
|
|
255
|
+
self.log_file.parent.mkdir(parents=True, exist_ok=True)
|
|
256
|
+
with self.log_file.open("wb") as f:
|
|
257
|
+
process = subprocess.Popen(command, stdout=f, stderr=f)
|
|
258
|
+
process.wait()
|
|
226
259
|
|
|
227
260
|
def run(self, *command: str) -> None:
|
|
228
261
|
if self.image is None:
|
|
@@ -231,6 +264,7 @@ class Engine(ABC):
|
|
|
231
264
|
command = self.assemble_command(command)
|
|
232
265
|
logger.info("Running: %s", command)
|
|
233
266
|
self._run_process(command)
|
|
267
|
+
self._move_output()
|
|
234
268
|
|
|
235
269
|
|
|
236
270
|
class Podman(Engine):
|
|
@@ -305,6 +339,8 @@ class Docker(Engine):
|
|
|
305
339
|
f"{Path.cwd().absolute()}:/home/cwd",
|
|
306
340
|
"-v",
|
|
307
341
|
f"{Config().cache_location}:/home/weck_cache",
|
|
342
|
+
"-v",
|
|
343
|
+
f"{self._tmp_output_dir}:/home/output",
|
|
308
344
|
"--workdir",
|
|
309
345
|
str(self.get_workdir()),
|
|
310
346
|
"--rm",
|
|
@@ -22,10 +22,8 @@ cp -r "/home/weck_cache/$TOOL_DIR" /tmp/overlay/
|
|
|
22
22
|
mount -t overlay overlay -o lowerdir=/home/cwd:/tmp/overlay/"$TOOL_DIR",upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /home/_cwd
|
|
23
23
|
cd /home/_cwd && "$@"
|
|
24
24
|
|
|
25
|
-
#
|
|
26
|
-
[ ! -d /home/cwd/output ] && mkdir /home/cwd/output
|
|
27
|
-
|
|
25
|
+
# Fm-Weck mounts a tempdir to /home/output
|
|
28
26
|
# Test if upper is empty
|
|
29
27
|
if [ ! -z "$(ls -A /tmp/overlay/upper)" ]; then
|
|
30
|
-
cp -r /tmp/overlay/upper/* /home/
|
|
28
|
+
cp -r /tmp/overlay/upper/* /home/output
|
|
31
29
|
fi
|
fm_weck/serve.py
CHANGED
|
@@ -88,6 +88,8 @@ def run_guided(
|
|
|
88
88
|
additional_args: list[str],
|
|
89
89
|
data_model: Optional[DataModel] = None,
|
|
90
90
|
skip_download: bool = False,
|
|
91
|
+
log_output_to: Optional[Path] = None,
|
|
92
|
+
output_files_to: Optional[Path] = None,
|
|
91
93
|
):
|
|
92
94
|
property_path = None
|
|
93
95
|
if prop is not None:
|
|
@@ -106,6 +108,12 @@ def run_guided(
|
|
|
106
108
|
fm_data, shelve_space = setup_fm_tool(fm_tool, version, configuration, skip_download)
|
|
107
109
|
engine = Engine.from_config(fm_data, configuration)
|
|
108
110
|
|
|
111
|
+
if log_output_to is not None:
|
|
112
|
+
engine.set_output_log(log_output_to)
|
|
113
|
+
|
|
114
|
+
if output_files_to is not None:
|
|
115
|
+
engine.set_output_files_dir(output_files_to)
|
|
116
|
+
|
|
109
117
|
current_dir = Path.cwd().resolve()
|
|
110
118
|
os.chdir(shelve_space)
|
|
111
119
|
command = fm_data.command_line(
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
fm_weck/__init__.py,sha256=
|
|
1
|
+
fm_weck/__init__.py,sha256=GbTdG1r5vnEJc4b9I0Xwyxgg70ktYxl8SzTrO61ssgM,351
|
|
2
2
|
fm_weck/__main__.py,sha256=E7z4-9t6To3hbIPjRPu6iW17YCrtqpDSbFSpd9pX4NA,350
|
|
3
3
|
fm_weck/cli.py,sha256=eeL3GbYO6W5af47ZgIR0mKYug0OrFsJn0Md1aVLDITI,10582
|
|
4
4
|
fm_weck/config.py,sha256=6f4R-iWmWehHghuhoU-UyCpNotYFec_oDelJB4A15BQ,4861
|
|
5
|
-
fm_weck/engine.py,sha256=
|
|
5
|
+
fm_weck/engine.py,sha256=OTTP3r-2xQx1GHpcepbVwR8iJuYK-cqux6cXCF9P_aU,11366
|
|
6
6
|
fm_weck/image_mgr.py,sha256=kZxcZaMiv5orWO7bLsN7xaQRXjof8uOGud7sb57ZvRo,1655
|
|
7
|
-
fm_weck/serve.py,sha256=
|
|
7
|
+
fm_weck/serve.py,sha256=hZc30B7EO0agetEHlKnRdNoMsK_FXuzvdIS6hhhzJgM,5166
|
|
8
8
|
fm_weck/resources/Containerfile,sha256=MltxP1of9klsQFNR8WyngRTJrPwxQTF4C9ennRxVqSo,391
|
|
9
9
|
fm_weck/resources/__init__.py,sha256=ewuOXBraX5Tb8XkWE6xrv0cwrxG4r5Ckj5n_tRjeRf4,946
|
|
10
|
-
fm_weck/resources/run_with_overlay.sh,sha256=
|
|
10
|
+
fm_weck/resources/run_with_overlay.sh,sha256=IHuxwx5Ri32oGGxku4etcg0kIu2N8BvTpOB6q4MaErM,804
|
|
11
11
|
fm_weck/resources/properties/coverage-branches.prp,sha256=Gl2r1cgBFoh4M2laa8dVGhteHkL04oiBRLzxz_hbkEU,56
|
|
12
12
|
fm_weck/resources/properties/coverage-branches.prp.license,sha256=KzWZF1bpljIbdvwfzfWoP4DLMq6W1jXNN6WXWF0fxY0,214
|
|
13
13
|
fm_weck/resources/properties/coverage-conditions.prp,sha256=tj307UJBhj-PZqRxjijeNb0foWe2hWIc8CQP54gIUao,57
|
|
@@ -124,7 +124,7 @@ fm_weck/resources/fm_tools/wasp-c.yml,sha256=NWEb2vpIBu75kZJdEq0am8Mpi2HFu5nhDI1
|
|
|
124
124
|
fm_weck/resources/fm_tools/wit4java.yml,sha256=SukwwE46DsDmZouAwHhr_aaOjxIaeOrIS7o7P4eDWX0,1243
|
|
125
125
|
fm_weck/resources/fm_tools/witch.yml,sha256=5d5aYmkrlG78M-RLdDbdi6EJWOfD0CskWtJWGXtwEyI,1152
|
|
126
126
|
fm_weck/resources/fm_tools/witnesslint.yml,sha256=Y6A2TXPyjVxZ9Fhmyd7GOKY7x1_jXjshvmrIM4uW96A,3085
|
|
127
|
-
fm_weck-1.
|
|
128
|
-
fm_weck-1.
|
|
129
|
-
fm_weck-1.
|
|
130
|
-
fm_weck-1.
|
|
127
|
+
fm_weck-1.2.0.dist-info/METADATA,sha256=GWtHnf8JK9-H-JDjn4Obp0ui_R3w5HODiZyJDT-7v6E,2771
|
|
128
|
+
fm_weck-1.2.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
129
|
+
fm_weck-1.2.0.dist-info/entry_points.txt,sha256=toWpKCSY1u593MPnI_xW5gnwlnkerP4AvmPQ1s2nPgY,50
|
|
130
|
+
fm_weck-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|