pyallel 1.3.0__tar.gz → 1.3.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyallel
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Summary: Run and handle the output of multiple executables in pyallel (as in parallel)
5
5
  Home-page: https://github.com/Danthewaann/pyallel
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyallel"
3
- version = "1.3.0"
3
+ version = "1.3.1"
4
4
  description = "Run and handle the output of multiple executables in pyallel (as in parallel)"
5
5
  authors = ["Daniel Black <danielcrblack@gmail.com>"]
6
6
  license = "MIT"
@@ -35,7 +35,7 @@ def run_interactive(
35
35
  if poll > 0:
36
36
  return poll
37
37
 
38
- printer.clear()
38
+ printer.reset()
39
39
  process_group_manager.run()
40
40
  if not process_group_manager.next():
41
41
  return 0
@@ -243,9 +243,9 @@ class Printer:
243
243
  end="",
244
244
  )
245
245
 
246
- self.clear()
246
+ self.reset()
247
247
 
248
- def clear(self) -> None:
248
+ def reset(self) -> None:
249
249
  self._printed.clear()
250
250
 
251
251
 
@@ -260,6 +260,7 @@ def set_process_lines(
260
260
 
261
261
  # Allocate lines to processes that have a fixed percentage of lines set
262
262
  used_lines = 0
263
+ process_with_most_lines: ProcessOutput | None = None
263
264
  other_processes: list[ProcessOutput] = []
264
265
  for out in output.processes:
265
266
  if not out.process.percentage_lines:
@@ -269,6 +270,12 @@ def set_process_lines(
269
270
  out.process.lines = int(lines * out.process.percentage_lines)
270
271
  used_lines += out.process.lines
271
272
 
273
+ if (
274
+ process_with_most_lines is None
275
+ or process_with_most_lines.process.lines < out.process.lines
276
+ ):
277
+ process_with_most_lines = out
278
+
272
279
  lines -= used_lines
273
280
 
274
281
  # Allocate the rest of the available lines to the other processes that don't have fixed lines set
@@ -280,11 +287,18 @@ def set_process_lines(
280
287
  for out in other_processes:
281
288
  out.process.lines = tail
282
289
 
283
- # If we have lines left to allocate, we give all of them to the last process
290
+ # If we have lines left to allocate, we give all of them to the process with the highest
291
+ # allocated lines or to the last process
284
292
  if remainder:
285
- for out in other_processes[-1::-1]:
286
- out.process.lines += remainder
287
- break
293
+ if process_with_most_lines:
294
+ process_with_most_lines.process.lines += remainder
295
+ else:
296
+ other_processes[-1].process.lines += remainder
297
+ else:
298
+ # Otherwise allocate remaining lines to the process with the highest allocated lines
299
+ remainder = lines
300
+ if remainder and process_with_most_lines:
301
+ process_with_most_lines.process.lines += remainder
288
302
 
289
303
 
290
304
  def get_num_lines(line: str, columns: int | None = None) -> int:
@@ -82,7 +82,7 @@ class Process:
82
82
 
83
83
  args, *parts = cmd
84
84
 
85
- percentage_lines = 0.0
85
+ percentage_lines = 0
86
86
  for arg in args.split(" "):
87
87
  try:
88
88
  arg, value = args.split("=")
@@ -91,17 +91,17 @@ class Process:
91
91
 
92
92
  if arg == "lines":
93
93
  try:
94
- percentage_lines = int(value) / 100
94
+ percentage_lines = int(value)
95
95
  except ValueError:
96
96
  raise InvalidLinesModifierError(
97
97
  "lines modifier must be a number between 1 and 100"
98
98
  )
99
99
 
100
- if not 0.0 < percentage_lines <= 1.0:
100
+ if not 0 < percentage_lines <= 100:
101
101
  raise InvalidLinesModifierError(
102
102
  "lines modifier must be a number between 1 and 100"
103
103
  )
104
104
 
105
105
  break
106
106
 
107
- return cls(id, " ".join(parts), percentage_lines)
107
+ return cls(id, " ".join(parts), round(percentage_lines / 100, 2))
@@ -72,7 +72,7 @@ class ProcessGroup:
72
72
  percentage_lines_sum += process.percentage_lines
73
73
  processes.append(process)
74
74
 
75
- if percentage_lines_sum > 1.0:
75
+ if round(percentage_lines_sum, 2) > 1.0:
76
76
  raise InvalidLinesModifierError(
77
77
  "lines modifier must not exceed 100 across all processes within each process group"
78
78
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes