omniopt2 8471__py3-none-any.whl → 9171__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.
Files changed (52) hide show
  1. .gitignore +2 -0
  2. .helpers.py +0 -9
  3. .omniopt.py +1298 -903
  4. .omniopt_plot_scatter.py +1 -1
  5. .omniopt_plot_scatter_hex.py +1 -1
  6. .pareto.py +134 -0
  7. .shellscript_functions +24 -15
  8. .tests/pylint.rc +0 -4
  9. README.md +1 -1
  10. omniopt +33 -22
  11. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.helpers.py +0 -9
  12. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt.py +1298 -903
  13. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_scatter.py +1 -1
  14. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_scatter_hex.py +1 -1
  15. omniopt2-9171.data/data/bin/.pareto.py +134 -0
  16. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.shellscript_functions +24 -15
  17. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/omniopt +33 -22
  18. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/omniopt_plot +1 -1
  19. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/pylint.rc +0 -4
  20. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/test_requirements.txt +1 -0
  21. {omniopt2-8471.dist-info → omniopt2-9171.dist-info}/METADATA +6 -5
  22. omniopt2-9171.dist-info/RECORD +73 -0
  23. omniopt2.egg-info/PKG-INFO +6 -5
  24. omniopt2.egg-info/SOURCES.txt +1 -0
  25. omniopt2.egg-info/requires.txt +4 -3
  26. omniopt_plot +1 -1
  27. pyproject.toml +1 -1
  28. requirements.txt +3 -3
  29. test_requirements.txt +1 -0
  30. omniopt2-8471.dist-info/RECORD +0 -71
  31. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.colorfunctions.sh +0 -0
  32. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.general.sh +0 -0
  33. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_cpu_ram_usage.py +0 -0
  34. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_general.py +0 -0
  35. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_gpu_usage.py +0 -0
  36. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_kde.py +0 -0
  37. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_scatter_generation_method.py +0 -0
  38. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_time_and_exit_code.py +0 -0
  39. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_trial_index_result.py +0 -0
  40. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.omniopt_plot_worker.py +0 -0
  41. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.random_generator.py +0 -0
  42. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/.tpe.py +0 -0
  43. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/LICENSE +0 -0
  44. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/apt-dependencies.txt +0 -0
  45. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/omniopt_docker +0 -0
  46. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/omniopt_evaluate +0 -0
  47. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/omniopt_share +0 -0
  48. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/requirements.txt +3 -3
  49. {omniopt2-8471.data → omniopt2-9171.data}/data/bin/setup.py +0 -0
  50. {omniopt2-8471.dist-info → omniopt2-9171.dist-info}/WHEEL +0 -0
  51. {omniopt2-8471.dist-info → omniopt2-9171.dist-info}/licenses/LICENSE +0 -0
  52. {omniopt2-8471.dist-info → omniopt2-9171.dist-info}/top_level.txt +0 -0
.omniopt_plot_scatter.py CHANGED
@@ -79,7 +79,7 @@ if ORIGINAL_PWD:
79
79
  os.chdir(ORIGINAL_PWD)
80
80
 
81
81
  @beartype
82
- def set_title(df_filtered: pd.DataFrame, result_column_values: pd.core.series.Series, num_entries: int, _min: Union[int, float, None], _max: Union[int, float, None]) -> None:
82
+ def set_title(df_filtered: pd.DataFrame, result_column_values: pd.Series, num_entries: int, _min: Union[int, float, None], _max: Union[int, float, None]) -> None:
83
83
  title = helpers.get_title(args, result_column_values, df_filtered, num_entries, _min, _max)
84
84
 
85
85
  if fig:
@@ -93,7 +93,7 @@ if ORIGINAL_PWD:
93
93
  os.chdir(ORIGINAL_PWD)
94
94
 
95
95
  @beartype
96
- def set_title(df_filtered: pd.DataFrame, result_column_values: pd.core.series.Series, num_entries: int, _min: Union[float, int, None] = None, _max: Union[float, int, None] = None) -> None:
96
+ def set_title(df_filtered: pd.DataFrame, result_column_values: pd.Series, num_entries: int, _min: Union[float, int, None] = None, _max: Union[float, int, None] = None) -> None:
97
97
  title = helpers.get_title(args, result_column_values, df_filtered, num_entries, _min, _max)
98
98
 
99
99
  if fig:
.pareto.py ADDED
@@ -0,0 +1,134 @@
1
+ import os
2
+ import importlib.util
3
+ from typing import Tuple, List, Dict, Any
4
+ from rich.table import Table
5
+ from rich.text import Text
6
+ import numpy as np
7
+
8
+
9
+ # ----------------- Helpers import -----------------
10
+ script_dir = os.path.dirname(os.path.realpath(__file__))
11
+ helpers_file: str = f"{script_dir}/.helpers.py"
12
+ spec = importlib.util.spec_from_file_location(
13
+ name="helpers",
14
+ location=helpers_file,
15
+ )
16
+ if spec is not None and spec.loader is not None:
17
+ helpers = importlib.util.module_from_spec(spec)
18
+ spec.loader.exec_module(helpers)
19
+ else:
20
+ raise ImportError(f"Could not load module from {helpers_file}")
21
+
22
+ # ----------------- Table utilities -----------------
23
+ def pareto_front_table_filter_rows(rows: List[Dict[str, str]], idxs: List[int]) -> List[Dict[str, str]]:
24
+ result = []
25
+ for row in rows:
26
+ try:
27
+ trial_index = int(row["trial_index"])
28
+ except (KeyError, ValueError):
29
+ continue
30
+
31
+ if row.get("trial_status", "").strip().upper() == "COMPLETED" and trial_index in idxs:
32
+ result.append(row)
33
+ return result
34
+
35
+ def pareto_front_table_add_headers(table: Table, param_cols: List[str], result_cols: List[str]) -> None:
36
+ for col in param_cols:
37
+ table.add_column(col, justify="center")
38
+ for col in result_cols:
39
+ table.add_column(Text(f"{col}", style="cyan"), justify="center")
40
+
41
+ def pareto_front_table_add_rows(table: Table, rows: List[Dict[str, str]], param_cols: List[str], result_cols: List[str]) -> None:
42
+ for row in rows:
43
+ values = [str(helpers.to_int_when_possible(row[col])) for col in param_cols]
44
+ result_values = [Text(str(helpers.to_int_when_possible(row[col])), style="cyan") for col in result_cols]
45
+ table.add_row(*values, *result_values, style="bold green")
46
+
47
+ # ----------------- Pareto internal utilities -----------------
48
+ def _validate_xy(x: np.ndarray, y: np.ndarray) -> None:
49
+ if x.shape != y.shape:
50
+ raise ValueError("Input arrays x and y must have the same shape.")
51
+ if x.size == 0:
52
+ raise ValueError("Input arrays must not be empty.")
53
+ if not np.isfinite(x).all() or not np.isfinite(y).all():
54
+ raise ValueError("Input arrays must contain only finite numbers (no NaN/Inf).")
55
+
56
+ def _point_dominates(xi: float, yi: float, xj: float, yj: float, x_minimize: bool, y_minimize: bool) -> bool:
57
+ """Return True if j dominates i (standard weak Pareto: >= in all, > in at least one)."""
58
+ if x_minimize:
59
+ x_better_eq = xj <= xi
60
+ x_strict = xj < xi
61
+ else:
62
+ x_better_eq = xj >= xi
63
+ x_strict = xj > xi
64
+
65
+ if y_minimize:
66
+ y_better_eq = yj <= yi
67
+ y_strict = yj < yi
68
+ else:
69
+ y_better_eq = yj >= yi
70
+ y_strict = yj > yi
71
+
72
+ return x_better_eq and y_better_eq and (x_strict or y_strict)
73
+
74
+ def _find_dominated(x: np.ndarray, y: np.ndarray, x_minimize: bool, y_minimize: bool) -> np.ndarray:
75
+ n = len(x)
76
+ is_dominated = np.zeros(n, dtype=bool)
77
+ for i in range(n):
78
+ if is_dominated[i]:
79
+ continue
80
+ xi, yi = x[i], y[i]
81
+ for j in range(n):
82
+ if i == j:
83
+ continue
84
+ xj, yj = x[j], y[j]
85
+ if _point_dominates(xi, yi, xj, yj, x_minimize, y_minimize):
86
+ is_dominated[i] = True
87
+ break
88
+ return is_dominated
89
+
90
+ # ----------------- Public Pareto functions -----------------
91
+ def pareto_front_general(
92
+ x: np.ndarray,
93
+ y: np.ndarray,
94
+ x_minimize: bool = True,
95
+ y_minimize: bool = True
96
+ ) -> np.ndarray:
97
+ try:
98
+ xa = np.asarray(x, dtype=float).ravel()
99
+ ya = np.asarray(y, dtype=float).ravel()
100
+ _validate_xy(xa, ya)
101
+ is_dominated = _find_dominated(xa, ya, x_minimize, y_minimize)
102
+ return np.where(~is_dominated)[0]
103
+ except Exception as e:
104
+ print("Error in pareto_front_general:", str(e))
105
+ return np.array([], dtype=int)
106
+
107
+ def pareto_front_filter_complete_points(
108
+ path_to_calculate: str,
109
+ records: Dict[Tuple[int, str], Dict[str, Dict[str, float]]],
110
+ primary_name: str,
111
+ secondary_name: str
112
+ ) -> List[Tuple[Tuple[int, str], float, float]]:
113
+ points = []
114
+ for key, metrics in records.items():
115
+ means = metrics['means']
116
+ if primary_name in means and secondary_name in means:
117
+ points.append((key, means[primary_name], means[secondary_name]))
118
+ if len(points) == 0:
119
+ raise ValueError(f"No full data points with both objectives found in {path_to_calculate}.")
120
+ return points
121
+
122
+ def pareto_front_select_pareto_points(
123
+ x: np.ndarray,
124
+ y: np.ndarray,
125
+ x_minimize: bool,
126
+ y_minimize: bool,
127
+ points: List[Tuple[Any, float, float]],
128
+ num_points: int
129
+ ) -> List[Tuple[Any, float, float]]:
130
+ indices = pareto_front_general(x, y, x_minimize, y_minimize)
131
+ # Sort by x ascending
132
+ sorted_indices = indices[np.argsort(x[indices])]
133
+ selected_points = [points[i] for i in sorted_indices[:num_points]]
134
+ return selected_points
.shellscript_functions CHANGED
@@ -207,13 +207,14 @@
207
207
  bar="${bar} "
208
208
  done
209
209
 
210
- printf "[%s] %d%% \n" "$bar" "$percentage"
210
+ printf "[%s] \n" "$bar"
211
211
  }
212
212
 
213
213
  function ppip {
214
214
  MODULE=$1
215
215
  AS_REQUIREMENT_OF=$2
216
216
  NUMBER_OF_MAIN_MODULES=$3
217
+ STR=$4
217
218
 
218
219
  set +e
219
220
 
@@ -222,7 +223,7 @@
222
223
  PROGRESSBAR=$(generate_progress_bar_setup "$NUMBER_OF_MAIN_MODULES")
223
224
 
224
225
  if [[ -z $CI ]]; then
225
- green_reset_line "${PROGRESSBAR}Installing $MODULE "
226
+ green_reset_line "${PROGRESSBAR}➤${STR}Installing $MODULE "
226
227
  fi
227
228
 
228
229
 
@@ -235,10 +236,10 @@
235
236
  if [[ "$MODULE" != "$AS_REQUIREMENT_OF" ]] && [[ "$AS_REQUIREMENT_OF" != "-" ]]; then
236
237
  k=0
237
238
 
238
- for i in $(pip3 install --disable-pip-version-check --dry-run "$MODULE" | grep -v "already satisfied" | grep "Collecting" | sed -e 's#Collecting ##' | grep -v "^$MODULE$"); do
239
+ for i in $(pip3 install --default-timeout=300 --default-timeout=300 --disable-pip-version-check --dry-run "$MODULE" | grep -v "already satisfied" | grep "Collecting" | sed -e 's#Collecting ##' | grep -v "^$MODULE$"); do
239
240
  if [[ "$i" != "$MODULE" ]]; then
240
241
  if [[ $k -eq 0 ]]; then
241
- green_reset_line "${PROGRESSBAR}Installing requirements for $MODULE"
242
+ green_reset_line "${PROGRESSBAR}➤${STR}Installing requirements for $MODULE"
242
243
  fi
243
244
  ppip "$i" "$MODULE" "$NUMBER_OF_MAIN_MODULES" || {
244
245
  red_reset_line "❌Failed to install $i."
@@ -251,11 +252,11 @@
251
252
  done
252
253
 
253
254
  if [[ $k -gt 0 ]]; then
254
- green_reset_line "${PROGRESSBAR}Installed all requirements for $MODULE, now installing the package itself..."
255
+ green_reset_line "${PROGRESSBAR}➤${STR}Installed all requirements for $MODULE, now installing the package itself..."
255
256
  fi
256
257
  fi
257
258
 
258
- green_reset_line "${PROGRESSBAR}Installing $MODULE..."
259
+ green_reset_line "${PROGRESSBAR}➤${STR}Installing $MODULE..."
259
260
  mkdir -p logs
260
261
  export PIP_DISABLE_PIP_VERSION_CHECK=1
261
262
  INSTALL_ERRORS_FILE="logs/install_errors"
@@ -265,8 +266,8 @@
265
266
  fi
266
267
 
267
268
  if [[ -z $DEBUG ]]; then
268
- pip3 --disable-pip-version-check install -q $MODULE >&2 2>> $INSTALL_ERRORS_FILE || pip3 --disable-pip-version-check install $MODULE >&2 2>> $INSTALL_ERRORS_FILE || {
269
- red_reset_line "❌Failed to install $MODULE. Check $INSTALL_ERRORS_FILE"
269
+ pip3 --default-timeout=300 --disable-pip-version-check install -q $MODULE >&2 2>> $INSTALL_ERRORS_FILE || pip3 --default-timeout=300 --disable-pip-version-check install $MODULE >&2 2>> $INSTALL_ERRORS_FILE || {
270
+ red_reset_line "❌Failed to install $MODULE. Check $INSTALL_ERRORS_FILE\n"
270
271
 
271
272
  if [[ -n $CI ]] || { [[ -f /proc/self/cgroup ]] && grep -qE '/docker|/lxc' /proc/self/cgroup; }; then
272
273
  cat "$INSTALL_ERRORS_FILE"
@@ -275,8 +276,8 @@
275
276
  exit 20
276
277
  }
277
278
  else
278
- pip3 --disable-pip-version-check install $MODULE >&2 2>> $INSTALL_ERRORS_FILE || pip3 --disable-pip-version-check install $MODULE >&2 2>> $INSTALL_ERRORS_FILE || {
279
- red_reset_line "❌Failed to install $MODULE. Check $INSTALL_ERRORS_FILE"
279
+ pip3 --default-timeout=300 --disable-pip-version-check install $MODULE >&2 2>> $INSTALL_ERRORS_FILE || pip3 --default-timeout=300 --disable-pip-version-check install $MODULE >&2 2>> $INSTALL_ERRORS_FILE || {
280
+ red_reset_line "❌Failed to install $MODULE. Check $INSTALL_ERRORS_FILE\n"
280
281
 
281
282
  if [[ -n $CI ]] || { [[ -f /proc/self/cgroup ]] && grep -qE '/docker|/lxc' /proc/self/cgroup; }; then
282
283
  cat "$INSTALL_ERRORS_FILE"
@@ -323,17 +324,25 @@
323
324
  MAX_NR="${#install_those[@]}"
324
325
  NUMBER_OF_INSTALLED_MODULES=$(get_nr_of_already_installed_modules)
325
326
 
326
- PROGRESSBAR=$(generate_progress_bar_setup "$MAX_NR")
327
+ MAX_PERCENT=100
327
328
 
328
329
  for key in "${!install_those[@]}"; do
330
+ idx=$((idx+1))
329
331
  install_this=${install_those[$key]}
330
- PROGRESSBAR=$(generate_progress_bar_setup "$MAX_NR")
332
+ percent=$((idx * 100 / MAX_NR))
333
+
334
+ PROGRESSBAR=$(generate_progress_bar "$idx" "$MAX_NR")
335
+
336
+ STR="Checking ${idx_padded}/${MAX_NR}, ${percent_padded}%: "
337
+
331
338
  if [[ -z $CI ]]; then
332
- green_reset_line "${PROGRESSBAR}➤Checking if $install_this is installed..."
339
+ printf -v idx_padded "%*d" "${#MAX_NR}" "$idx"
340
+ printf -v percent_padded "%*d" "${#MAX_PERCENT}" "$percent"
341
+ green_reset_line "${PROGRESSBAR}➤$STR$install_this..."
333
342
  fi
334
343
 
335
344
  if ! echo "$FROZEN" | grep -q "$install_this"; then
336
- ppip "$install_this" "-" "$MAX_NR"
345
+ ppip "$install_this" "-" "$MAX_NR" "$STR"
337
346
  fi
338
347
  done
339
348
 
@@ -451,7 +460,7 @@
451
460
  exit 20
452
461
  }
453
462
 
454
- downgrade_output=$(pip3 --disable-pip-version-check install -q pip==24.0) || {
463
+ downgrade_output=$(pip3 --default-timeout=300 --disable-pip-version-check install -q pip==24.0) || {
455
464
  red_text "Failed to downgrade pip. Output:"
456
465
  red_text "$downgrade_output"
457
466
  }
.tests/pylint.rc CHANGED
@@ -103,10 +103,6 @@ recursive=no
103
103
  # source root.
104
104
  source-roots=
105
105
 
106
- # When enabled, pylint would attempt to guess common misconfiguration and emit
107
- # user-friendly hints instead of false-positive error messages.
108
- suggestion-mode=yes
109
-
110
106
  # Allow loading of arbitrary C extensions. Extensions are imported into the
111
107
  # active Python interpreter and may run arbitrary code.
112
108
  unsafe-load-any-extension=no
README.md CHANGED
@@ -57,7 +57,7 @@ for more details.
57
57
 
58
58
  ## Install from pypi
59
59
 
60
- This may not use the bleeding-edge version, but if you get the version from here it means, the test suite has completety tested it properly.
60
+ This may not use the bleeding-edge version, but if you get the version from here it means, the test suite has completely tested it properly.
61
61
 
62
62
  ```command
63
63
  pip3 install omniopt2
omniopt CHANGED
@@ -5,7 +5,7 @@
5
5
  # Step 1:
6
6
  # It checks whether the environment already exists, and
7
7
  # if so, loads it.
8
- # If it doesn't exist. it creates it in
8
+ # If it doesn't exist, it creates it in
9
9
  # ~/.omniax_$(uname -m)_$(python3 --version | sed -e 's# #_#g')
10
10
  # i.e. e.g. ~/.omniax_x86_64_Python_3.11.2/ . This is done so that there
11
11
  # is no need for multiple installations, so that, once installed, it doesn't
@@ -211,7 +211,7 @@
211
211
  fi
212
212
 
213
213
  if [[ ! -e $file ]]; then
214
- echo "Cannot parse non-existant toml." >&2
214
+ echo "Cannot parse non-existent toml." >&2
215
215
  return 1
216
216
  fi
217
217
 
@@ -238,7 +238,7 @@
238
238
  fi
239
239
 
240
240
  if [[ ! -e "$file" ]]; then
241
- echo "Cannot parse non-existant yaml." >&2
241
+ echo "Cannot parse non-existent yaml." >&2
242
242
  return 1
243
243
  fi
244
244
 
@@ -270,7 +270,7 @@
270
270
  fi
271
271
 
272
272
  if [[ ! -e "$file" ]]; then
273
- echo "Cannot parse non-existant json." >&2
273
+ echo "Cannot parse non-existent json." >&2
274
274
  return 1
275
275
  fi
276
276
 
@@ -337,7 +337,7 @@
337
337
 
338
338
  int_re='^[+-]?[0-9]+$'
339
339
 
340
- if [[ -n $PRINT_SEPERATOR ]]; then # for tests, so that things are properly visually seperated
340
+ if [[ -n $PRINT_SEPARATOR ]]; then # for tests, so that things are properly visually separated
341
341
  echo ""
342
342
  echo "========================================================================"
343
343
  echo ""
@@ -364,17 +364,17 @@
364
364
  fi
365
365
  }
366
366
 
367
- function start_periodidic_live_share {
367
+ function start_periodic_live_share {
368
368
  while true; do
369
369
  run_live_share 2>/dev/null >/dev/null
370
- sleep 30
370
+ sleep 10
371
371
  done
372
372
  }
373
373
 
374
374
  function myexit {
375
375
  CODE=$1
376
376
 
377
- end_all_bg_processes
377
+ end_all_bg_processes 2>/dev/null
378
378
 
379
379
  if [[ $follow -eq 1 ]]; then
380
380
  if [[ -z $CODE ]] || ! [[ $CODE =~ $int_re ]]; then
@@ -511,7 +511,11 @@
511
511
  if [ $minutes -eq 1 ]; then
512
512
  result="in about $minutes minute"
513
513
  else
514
- result="in about $minutes minutes"
514
+ if [ $minutes -eq 0 ]; then
515
+ result="soon"
516
+ else
517
+ result="in about $minutes minutes"
518
+ fi
515
519
  fi
516
520
  echo "$result"
517
521
  return
@@ -1016,6 +1020,10 @@ $complex_options_str
1016
1020
  args_string+=" --help "
1017
1021
  ;;
1018
1022
 
1023
+ --memray)
1024
+ export RUN_WITH_MEMRAY=1
1025
+ ;;
1026
+
1019
1027
  --flame_graph)
1020
1028
  export RUN_WITH_PYSPY=1
1021
1029
  ;;
@@ -1634,19 +1642,27 @@ EOF
1634
1642
  live_share_pid=""
1635
1643
 
1636
1644
  if [[ $live_share -eq 1 ]]; then
1637
- start_periodidic_live_share &
1645
+ start_periodic_live_share &
1638
1646
  live_share_pid=$!
1639
1647
  fi
1640
1648
 
1641
1649
  if [[ -z $RUN_WITH_COVERAGE ]]; then
1642
- if [[ -z $RUN_WITH_PYSPY ]]; then
1643
- stdbuf -e 0 -o 0 python3 "$SCRIPT_DIR/.omniopt.py" $args_string
1644
- EXIT_CODE=$?
1645
- else
1650
+ if [[ -n $RUN_WITH_PYSPY ]]; then
1646
1651
  echo "Starting OmniOpt with Py-Spy"
1647
1652
  pip install py-spy
1648
1653
  stdbuf -e 0 -o 0 py-spy record --rate 10 --subprocesses --native --output "$RUN_UUID.svg" python3 -- "$SCRIPT_DIR/.omniopt.py" $args_string
1649
1654
  EXIT_CODE=$?
1655
+ elif [[ -n $RUN_WITH_MEMRAY ]]; then
1656
+ echo "Starting OmniOpt with MemRay."
1657
+ echo "Check later on with 'memray flamegraph $RUN_UUID.bin'"
1658
+ export PYTORCH_NO_CUDA_MEMORY_CACHING=1
1659
+ export PYTHONFAULTHANDLER=1
1660
+ pip install memray
1661
+ stdbuf -e 0 -o 0 memray run -o "$RUN_UUID.bin" -- "$SCRIPT_DIR/.omniopt.py" $args_string
1662
+ EXIT_CODE=$?
1663
+ else
1664
+ stdbuf -e 0 -o 0 python3 "$SCRIPT_DIR/.omniopt.py" $args_string
1665
+ EXIT_CODE=$?
1650
1666
  fi
1651
1667
  else
1652
1668
  echo "Using coverage run -p because \$RUN_WITH_COVERAGE is set"
@@ -1655,7 +1671,7 @@ EOF
1655
1671
  fi
1656
1672
 
1657
1673
  if [[ $live_share -eq 1 ]] && [[ -n $live_share_pid ]]; then
1658
- kill -9 $live_share_pid
1674
+ kill -9 $live_share_pid >/dev/null 2>/dev/null
1659
1675
  fi
1660
1676
 
1661
1677
  set -e
@@ -1865,7 +1881,7 @@ EOF
1865
1881
  kill_tail_when_squeue_job_empty "$started_job_nr" &
1866
1882
 
1867
1883
  tail_log_file() {
1868
- trap 'ask_cancel' SIGINT
1884
+ #trap 'ask_cancel' SIGINT
1869
1885
  # weird exec stuff for disabling the "Terminated" message coming from kill
1870
1886
  exec 3>&2 # 3 is now a copy of 2
1871
1887
  exec 2> /dev/null # 2 now points to /dev/null
@@ -1912,34 +1928,29 @@ EOF
1912
1928
  exit_code_lines=$(grep -i "exit-code:*" "$LOG_PATH" 2>/dev/null)
1913
1929
  exit_code_lines_lines=$?
1914
1930
  if [ $exit_code_lines_lines -ne 0 ] || [ -z "$exit_code_lines" ]; then
1915
- echo "WARN: grep failed or no exit-code line found."
1916
1931
  exit_code_lines=""
1917
1932
  fi
1918
1933
 
1919
1934
  exit_code_sed=$(echo "$exit_code_lines" | sed -e 's#Exit-Code:*[[:space:]]*##i' -e 's#,.*##')
1920
1935
  exit_code_sed_sed=$?
1921
1936
  if [ $exit_code_sed_sed -ne 0 ] || [ -z "$exit_code_sed" ]; then
1922
- echo "WARN: sed failed or no data after sed."
1923
1937
  exit_code_sed=""
1924
1938
  fi
1925
1939
 
1926
1940
  exit_code_tail=$(echo "$exit_code_sed" | tail -n1)
1927
1941
  exit_code_tail_tail=$?
1928
1942
  if [ $exit_code_tail_tail -ne 0 ] || [ -z "$exit_code_tail" ]; then
1929
- echo "WARN: tail failed or no data after tail."
1930
1943
  exit_code_tail=""
1931
1944
  fi
1932
1945
 
1933
- exit_code_only_digits=$(echo "$exit_code_tail" | grep -o '[0-9]\+')
1946
+ exit_code_only_digits=$(echo "$exit_code_tail" | grep -o '[0-9]\+' | tail -n1)
1934
1947
  if [ -z "$exit_code_only_digits" ]; then
1935
- echo "WARN: No valid exit code found, setting it to 3"
1936
1948
  exit_code_only_digits=3
1937
1949
  fi
1938
1950
 
1939
1951
  exit_code="$exit_code_only_digits"
1940
1952
 
1941
1953
  if ! [[ "$exit_code" =~ ^[0-9]+$ ]]; then
1942
- echo "WARN: exit_code invalid ('$exit_code'), setting to 3"
1943
1954
  exit_code=3
1944
1955
  fi
1945
1956
 
@@ -10,7 +10,6 @@ try:
10
10
  import difflib
11
11
  import logging
12
12
  import os
13
- import platform
14
13
  import re
15
14
  import traceback
16
15
  import numpy as np
@@ -227,12 +226,6 @@ def print_color(color: str, text: str) -> None:
227
226
  print(f"Error: {e}")
228
227
  print(text)
229
228
 
230
- def check_python_version() -> None:
231
- python_version = platform.python_version()
232
- supported_versions = ["3.8.10", "3.8.20", "3.9.21", "3.10.4", "3.10.12", "3.11.2", "3.11.9", "3.9.2", "3.11.3", "3.12.3", "3.12.4", "3.12.5", "3.12.6", "3.12.7", "3.12.7+", "3.12.8", "3.13.1", "3.13.2", "3.13.3", "3.13.5"]
233
- if python_version not in supported_versions:
234
- print_color("yellow", f"Warning: Supported python versions are {', '.join(supported_versions)}, but you are running {python_version}. This may or may not cause problems. Just is just a warning.")
235
-
236
229
  def create_widgets(_data: Any) -> Any:
237
230
  _plt, button, MAXIMUM_TEXTBOX, MINIMUM_TEXTBOX, _args, TEXTBOX_MINIMUM, TEXTBOX_MAXIMUM, update_graph = _data
238
231
 
@@ -882,5 +875,3 @@ def die_if_cannot_be_plotted(run_dir: Optional[str]) -> None:
882
875
  if not can_be_plotted(run_dir):
883
876
  log_error(f"{run_dir} contains multiple RESULTS and thus can only be plotted by parallel plot")
884
877
  sys.exit(2)
885
-
886
- check_python_version()