Skip to content

Commit 2db62a4

Browse files
committed
improved make process with more artifacts and all dependency versions included in logs
1 parent c7c92c1 commit 2db62a4

File tree

2 files changed

+55
-9
lines changed

2 files changed

+55
-9
lines changed

Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ create_distribution: static_analysis test create_documentation
158158
source "$$tempDir/bin/activate" &&\
159159
echo "Now installing tar.gz." &&\
160160
python3 -m pip --no-input --timeout 360 --retries 100 --require-virtualenv install "$(CWD)/dist/moptipy-$(VERSION).tar.gz" && ## nosem \
161-
echo "Finished, cleaning up." &&\
161+
echo "Installing tar.gz has worked. We now create the list of packages in this environment via pip freeze." &&\
162+
pip freeze > "$(CWD)/dist/moptipy-$(VERSION)-requirements_frozen.txt" &&\
163+
echo "Now fixing moptipy line in requirements file." &&\
164+
sed -i "s/^moptipy.*/moptipy==$(VERSION)/" "$(CWD)/dist/moptipy-$(VERSION)-requirements_frozen.txt" &&\
165+
echo "Now we deactivate the environment." &&\
162166
deactivate &&\
163167
rm -rf "$$tempDir" &&\
164168
echo "Now testing the wheel." &&\
@@ -169,9 +173,14 @@ create_distribution: static_analysis test create_documentation
169173
source "$$tempDir/bin/activate" &&\
170174
echo "Now installing wheel." &&\
171175
python3 -m pip --no-input --timeout 360 --retries 100 --require-virtualenv install "$(CWD)/dist/moptipy-$(VERSION)-py3-none-any.whl" && ## nosem \
172-
echo "Finished, cleaning up." &&\
176+
echo "Now we deactivate the environment." &&\
173177
deactivate &&\
178+
echo "Finished, cleaning up." &&\
174179
rm -rf "$$tempDir" &&\
180+
echo "Now also packaging the documentation." &&\
181+
cd docs/build &&\
182+
tar --dereference --exclude=".nojekyll" -c * | xz -v -9e -c > "$(CWD)/dist/moptipy-$(VERSION)-documentation.tar.xz" &&\
183+
cd $(CWD) &&\
175184
echo "Successfully finished building source distribution."
176185

177186
# We install the package and see if that works out.

moptipy/utils/sys_info.py

+44-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,29 @@
1313
import moptipy.version as ver
1414
from moptipy.api import logging
1515
from moptipy.utils.logger import InMemoryLogger, Logger, KeyValueLogSection, \
16-
CSV_SEPARATOR
16+
CSV_SEPARATOR, KEY_VALUE_SEPARATOR, SCOPE_SEPARATOR
1717
from moptipy.utils.path import Path
1818

1919

20+
def __cpu_affinity(proc: Optional[psutil.Process] = None) -> Optional[str]:
21+
"""
22+
Get the CPU affinity.
23+
24+
:param proc: the process handle
25+
:return: the CPU affinity string.
26+
"""
27+
if proc is None:
28+
proc = psutil.Process()
29+
if proc is None:
30+
return None
31+
cpua = proc.cpu_affinity()
32+
if cpua:
33+
cpua = CSV_SEPARATOR.join(map(str, cpua))
34+
if len(cpua) > 0:
35+
return cpua
36+
return None
37+
38+
2039
# noinspection PyBroadException
2140
def __make_sys_info() -> str:
2241
"""
@@ -131,10 +150,9 @@ def __get_mem_size() -> Optional[int]:
131150
__v(k, logging.KEY_NODE_NAME, platform.node())
132151
proc = psutil.Process()
133152
__v(k, logging.KEY_PROCESS_ID, hex(proc.pid))
134-
cpua = proc.cpu_affinity()
153+
cpua = __cpu_affinity(proc)
135154
if cpua:
136-
__v(k, logging.KEY_CPU_AFFINITY,
137-
CSV_SEPARATOR.join(map(str, cpua)))
155+
__v(k, logging.KEY_CPU_AFFINITY, cpua)
138156
del proc, cpua
139157

140158
# see https://stackoverflow.com/questions/166506/.
@@ -151,8 +169,11 @@ def __get_mem_size() -> Optional[int]:
151169

152170
with kv.scope(logging.SCOPE_VERSIONS) as k:
153171
__v(k, "moptipy", ver.__version__)
154-
for package in ["numpy", "numba", "matplotlib",
155-
"psutil", "scikit-learn"]:
172+
for package in ["cycler", "fonttools", "joblib", "kiwisolver",
173+
"llvmlite", "matplotlib", "numba", "numpy",
174+
"packaging", "Pillow", "psutil", "pyparsing",
175+
"python-dateutil", "scikit-learn", "scipy",
176+
"six", "threadpoolctl"]:
156177
__v(k, package.replace("-", ""),
157178
ilm.version(package).strip())
158179

@@ -214,7 +235,23 @@ def __make_mhz_str(tpl: Tuple[int, ...]) -> str:
214235

215236
def refresh_sys_info():
216237
"""Refresh the system information."""
217-
__SYS_INFO[0] = __make_sys_info()
238+
sys_info_str = __SYS_INFO[0]
239+
start = f"\n{logging.SCOPE_SESSION}{SCOPE_SEPARATOR}" \
240+
f"{logging.KEY_CPU_AFFINITY}{KEY_VALUE_SEPARATOR}"
241+
start_i = sys_info_str.find(start)
242+
if start_i < 0:
243+
return # no affinity, don't need to update
244+
start_i += len(start)
245+
end_i = sys_info_str.find("\n", start_i)
246+
if end_i <= start_i:
247+
raise ValueError(f"Empty {logging.KEY_CPU_AFFINITY}?")
248+
affinity = __cpu_affinity()
249+
if affinity is None:
250+
raise ValueError(
251+
f"first affinity query is {sys_info_str[start_i:end_i]},"
252+
f" but second one is None?")
253+
sys_info_str = f"{sys_info_str[:start_i]}{affinity}{sys_info_str[end_i:]}"
254+
__SYS_INFO[0] = sys_info_str
218255

219256

220257
def log_sys_info(logger: Logger) -> None:

0 commit comments

Comments
 (0)