dwind 0.3.1__py3-none-any.whl → 0.3.2__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.
- dwind/__init__.py +1 -1
- dwind/btm_sizing.py +1 -2
- dwind/cli/__init__.py +0 -0
- dwind/cli/collect.py +114 -0
- dwind/cli/debug.py +137 -0
- dwind/cli/run.py +288 -0
- dwind/cli/utils.py +166 -0
- dwind/config.py +147 -6
- dwind/main.py +20 -0
- dwind/model.py +128 -63
- dwind/mp.py +30 -35
- dwind/resource.py +120 -41
- dwind/scenarios.py +73 -36
- dwind/utils/array.py +16 -89
- dwind/utils/hpc.py +44 -2
- dwind/utils/loader.py +63 -0
- dwind/utils/progress.py +60 -0
- dwind/valuation.py +368 -239
- {dwind-0.3.1.dist-info → dwind-0.3.2.dist-info}/METADATA +2 -1
- dwind-0.3.2.dist-info/RECORD +28 -0
- dwind-0.3.2.dist-info/entry_points.txt +2 -0
- dwind-0.3.1.dist-info/RECORD +0 -20
- dwind-0.3.1.dist-info/entry_points.txt +0 -2
- {dwind-0.3.1.dist-info → dwind-0.3.2.dist-info}/WHEEL +0 -0
- {dwind-0.3.1.dist-info → dwind-0.3.2.dist-info}/licenses/LICENSE.txt +0 -0
- {dwind-0.3.1.dist-info → dwind-0.3.2.dist-info}/top_level.txt +0 -0
dwind/utils/progress.py
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
import numpy as np
|
2
|
+
from joblib import Parallel, delayed
|
3
|
+
from threading import Thread
|
4
|
+
from rich.progress import Progress, BarColumn, TimeRemainingColumn, TextColumn
|
5
|
+
from rich.console import Console
|
6
|
+
from rich.live import Live
|
7
|
+
import time
|
8
|
+
|
9
|
+
# Define the number of tasks and create a shared memory numpy array to hold their progress
|
10
|
+
num_tasks = 4
|
11
|
+
progress_array = np.memmap("progress.mmap2", dtype=np.float32, mode="w+", shape=N)
|
12
|
+
|
13
|
+
# Define a function that performs a task and updates the progress array
|
14
|
+
def perform_task(task_idx, progress_array):
|
15
|
+
for i in range(100):
|
16
|
+
# Do some work here
|
17
|
+
# ...
|
18
|
+
|
19
|
+
# Update the progress array
|
20
|
+
time.sleep(0.1)
|
21
|
+
progress_array[task_idx] = i / 100
|
22
|
+
|
23
|
+
# Update the progress array to 100% on completion
|
24
|
+
progress_array[task_idx] = 1
|
25
|
+
|
26
|
+
# Define a function to continuously update the Rich progress bar
|
27
|
+
def update_progress_bar(
|
28
|
+
progress_array=progress_array,
|
29
|
+
num_tasks=num_tasks,
|
30
|
+
):
|
31
|
+
with Progress(
|
32
|
+
TextColumn("[bold blue]{task.fields[name]}"),
|
33
|
+
BarColumn(),
|
34
|
+
TextColumn("[bold green]{task.fields[status]}"),
|
35
|
+
TimeRemainingColumn(),
|
36
|
+
# console=console,
|
37
|
+
) as progress:
|
38
|
+
tasks = [
|
39
|
+
progress.add_task(
|
40
|
+
description=f"Task {i}",
|
41
|
+
name=f"Task {i}",
|
42
|
+
status="pending",
|
43
|
+
total=100,
|
44
|
+
)
|
45
|
+
for i in range(num_tasks)
|
46
|
+
]
|
47
|
+
|
48
|
+
while not all(progress_array == 1):
|
49
|
+
for i, task in enumerate(tasks):
|
50
|
+
progress.update(task, completed=int(progress_array[i] * 100))
|
51
|
+
time.sleep(0.1 * 2 ** abs(*np.random.randn(1)))
|
52
|
+
|
53
|
+
|
54
|
+
# Launch the progress bar update function in a separate thread
|
55
|
+
Thread(target=update_progress_bar, args=[progress_array, num_tasks]).start()
|
56
|
+
|
57
|
+
# Launch the tasks in parallel using joblib and the perform_task function
|
58
|
+
Parallel(n_jobs=-2, backend="loky")(
|
59
|
+
delayed(perform_task)(i, progress_array) for i in range(num_tasks)
|
60
|
+
)
|