bmtool 0.5.6.2__tar.gz → 0.5.7.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.
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/PKG-INFO +1 -1
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/SLURM.py +66 -8
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool.egg-info/PKG-INFO +1 -1
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/setup.py +1 -1
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/LICENSE +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/README.md +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/__init__.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/__main__.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/bmplot.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/connectors.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/debug/__init__.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/debug/commands.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/debug/debug.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/graphs.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/manage.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/plot_commands.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/singlecell.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/synapses.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/util/__init__.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/util/commands.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/util/neuron/__init__.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/util/neuron/celltuner.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool/util/util.py +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool.egg-info/SOURCES.txt +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool.egg-info/dependency_links.txt +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool.egg-info/entry_points.txt +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool.egg-info/requires.txt +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/bmtool.egg-info/top_level.txt +0 -0
- {bmtool-0.5.6.2 → bmtool-0.5.7.1}/setup.cfg +0 -0
@@ -2,6 +2,7 @@ import time
|
|
2
2
|
import os
|
3
3
|
import subprocess
|
4
4
|
import json
|
5
|
+
import requests
|
5
6
|
|
6
7
|
|
7
8
|
def check_job_status(job_id):
|
@@ -18,9 +19,9 @@ def check_job_status(job_id):
|
|
18
19
|
result = subprocess.run(['scontrol', 'show', 'job', job_id], capture_output=True, text=True)
|
19
20
|
if result.returncode != 0:
|
20
21
|
# this check is not needed if check_interval is less than 5 min (~300 seconds)
|
21
|
-
|
22
|
-
|
23
|
-
raise Exception(f"Error checking job status: {result.stderr}")
|
22
|
+
if 'slurm_load_jobs error: Invalid job id specified' in result.stderr:
|
23
|
+
return 'COMPLETED' # Treat invalid job ID as completed because scontrol expires and removed job info when done.
|
24
|
+
#raise Exception(f"Error checking job status: {result.stderr}")
|
24
25
|
|
25
26
|
job_state = None
|
26
27
|
for line in result.stdout.split('\n'):
|
@@ -57,6 +58,25 @@ def submit_job(script_path):
|
|
57
58
|
return job_id
|
58
59
|
|
59
60
|
|
61
|
+
def send_teams_message(webhook,message):
|
62
|
+
"""Sends a message to a teams channel or chat
|
63
|
+
|
64
|
+
Args:
|
65
|
+
webhook (str): A microsoft teams webhook
|
66
|
+
message (str): A message to send in the chat/channel
|
67
|
+
"""
|
68
|
+
message = {
|
69
|
+
"text": f"{message}"
|
70
|
+
}
|
71
|
+
|
72
|
+
# Send POST request to trigger the flow
|
73
|
+
response = requests.post(
|
74
|
+
webhook,
|
75
|
+
json=message, # Using 'json' instead of 'data' for automatic serialization
|
76
|
+
headers={'Content-Type': 'application/json'}
|
77
|
+
)
|
78
|
+
|
79
|
+
|
60
80
|
class seedSweep:
|
61
81
|
def __init__(self, json_file_path, param_name):
|
62
82
|
"""
|
@@ -239,6 +259,31 @@ export OUTPUT_DIR={case_output_dir}
|
|
239
259
|
if status not in self.status_list:
|
240
260
|
return False
|
241
261
|
return True
|
262
|
+
|
263
|
+
def check_block_completed(self):
|
264
|
+
"""checks if all the jobs in the block have been completed by slurm
|
265
|
+
|
266
|
+
Returns:
|
267
|
+
bool: True if all block jobs have been ran, false if job is still running
|
268
|
+
"""
|
269
|
+
for job_id in self.job_ids:
|
270
|
+
status = check_job_status(job_id)
|
271
|
+
if status != 'COMPLETED': # can add PENDING here for debugging NOT FOR ACTUALLY USING IT
|
272
|
+
return False
|
273
|
+
return True
|
274
|
+
|
275
|
+
|
276
|
+
def check_block_running(self):
|
277
|
+
"""checks if a job is running
|
278
|
+
|
279
|
+
Returns:
|
280
|
+
bool: True if jobs are RUNNING false if anything else
|
281
|
+
"""
|
282
|
+
for job_id in self.job_ids:
|
283
|
+
status = check_job_status(job_id)
|
284
|
+
if status != 'RUNNING': #
|
285
|
+
return False
|
286
|
+
return True
|
242
287
|
|
243
288
|
|
244
289
|
class SequentialBlockRunner:
|
@@ -249,13 +294,15 @@ class SequentialBlockRunner:
|
|
249
294
|
blocks (list): List of SimulationBlock instances to be run.
|
250
295
|
json_editor (seedSweep or multiSweep): Instance of seedSweep to edit JSON file.
|
251
296
|
param_values (list): List of values for the parameter to be modified.
|
297
|
+
webhook (str): a microsoft webhook for teams. When used will send teams messages to the hook!
|
252
298
|
"""
|
253
299
|
|
254
|
-
def __init__(self, blocks, json_editor=None, param_values=None, check_interval=200):
|
300
|
+
def __init__(self, blocks, json_editor=None, param_values=None, check_interval=200,webhook=None):
|
255
301
|
self.blocks = blocks
|
256
302
|
self.json_editor = json_editor
|
257
303
|
self.param_values = param_values
|
258
304
|
self.check_interval = check_interval
|
305
|
+
self.webhook = webhook
|
259
306
|
|
260
307
|
def submit_blocks_sequentially(self):
|
261
308
|
"""
|
@@ -283,12 +330,23 @@ class SequentialBlockRunner:
|
|
283
330
|
# Submit the block
|
284
331
|
print(f"Submitting block: {block.block_name}", flush=True)
|
285
332
|
block.submit_block()
|
286
|
-
|
333
|
+
if self.webhook:
|
334
|
+
message = f"SIMULATION UPDATE: Block {i} has been submitted! There are {(len(self.blocks)-1)-i} left to be submitted"
|
335
|
+
send_teams_message(self.webhook,message)
|
336
|
+
|
287
337
|
# Wait for the block to complete
|
288
|
-
|
289
|
-
|
290
|
-
|
338
|
+
if i == len(self.blocks) - 1: # Corrected index to check the last block
|
339
|
+
while not block.check_block_completed():
|
340
|
+
print(f"Waiting for the last block {i} to complete...")
|
341
|
+
time.sleep(self.check_interval)
|
342
|
+
else: # Not the last block so if job is running lets start a new one (checks status list)
|
343
|
+
while not block.check_block_status():
|
344
|
+
print(f"Waiting for block {i} to complete...")
|
345
|
+
time.sleep(self.check_interval)
|
291
346
|
|
292
347
|
print(f"Block {block.block_name} completed.", flush=True)
|
293
348
|
print("All blocks are done!",flush=True)
|
349
|
+
if self.webhook:
|
350
|
+
message = "SIMULATION UPDATE: Simulation are Done!"
|
351
|
+
send_teams_message(self.webhook,message)
|
294
352
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|