Skip to content

Commit b53fc0b

Browse files
authored
Merge pull request #65 from galaxyproject/dev
Final 1.x release
2 parents 1673b6f + 2fe024d commit b53fc0b

6 files changed

Lines changed: 114 additions & 43 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Benchmarking Scripts
1+
# Automated Benchmarking
22
An opinionated Python Bioblend script for automating benchmarking tasks in Galaxy.
33

44

@@ -7,8 +7,8 @@ An opinionated Python Bioblend script for automating benchmarking tasks in Galax
77

88
1. Clone this repository.
99
```bash
10-
git clone https://github.com/ksuderman/bioblend-scripts.git
11-
cd bioblend-scripts
10+
git clone https://github.com/galaxyproject/gxabm.git
11+
cd gxabm
1212
```
1313
1. Create a virtual env and install the required libraries
1414
```bash

abm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
from lib import job, dataset, workflow, history, library, folder, benchmark, helm, kubectl, config
1919

2020
log = logging.getLogger('abm')
21-
log.setLevel(logging.ERROR)
21+
log.setLevel(logging.INFO)
2222

23-
VERSION = '1.4.0'
23+
VERSION = '1.4.1'
2424

2525
BOLD = '\033[1m'
2626
CLEAR = '\033[0m'
@@ -118,7 +118,7 @@ def alias(shortcut, fullname):
118118

119119
def parse_menu():
120120
log.debug('parse_menu')
121-
menu_config = f'{os.path.dirname(__file__)}/lib/menu.yml'
121+
menu_config = f'{os.path.dirname(os.path.abspath(__file__))}/lib/menu.yml'
122122
if not os.path.exists(menu_config):
123123
print(f"ERROR: Unable to load the menu configuration from {menu_config}")
124124
sys.exit(1)

config/dna2.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- workflow_id: d8beac5a0d816eee
2+
output_history_base_name: DNA 29C 116G-MEM
3+
runs:
4+
- history_name: HG00171
5+
inputs:
6+
- name: FASTQ Dataset
7+
dataset_id: 3ef6e7918b01e665
8+
- history_name: HG00152
9+
inputs:
10+
- name: FASTQ Dataset
11+
dataset_id: daf58ed87714bfc3
12+
- history_name: HG00599
13+
inputs:
14+
- name: FASTQ Dataset
15+
dataset_id: 1c8ebd93f5710bc6
16+
- history_name: HG01167
17+
inputs:
18+
- name: FASTQ Dataset
19+
dataset_id: c49cc12509f57ec1
20+
- history_name: HG003
21+
inputs:
22+
- name: FASTQ Dataset
23+
dataset_id: 845199e085d0abbe
24+
- workflow_id: b94314cb9cb46380
25+
output_history_base_name: PairedDNA 29C 116G-MEM
26+
runs:
27+
- history_name: SRS9540951
28+
inputs:
29+
- name: FASTQ Dataset
30+
dataset_id: 4b0ef3aaf341f57b

lib/benchmark.py

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,49 @@ def run(args: list):
3838

3939
profiles = load_profiles()
4040
num_runs = config['runs']
41-
for n in range(num_runs):
41+
for cloud in config['cloud']:
42+
if cloud not in profiles:
43+
print(f"WARNING: No profile found for {cloud}")
44+
continue
45+
if not set_active_profile(cloud):
46+
print(f"ERROR: Unable to set the profile for {cloud}")
47+
continue
48+
if lib.KUBECONFIG is None:
49+
print(f"ERROR: No kubeconfig set for {cloud}")
50+
continue
4251
print("------------------------")
43-
print(f"Benchmarking run #{n+1}")
44-
for cloud in config['cloud']:
45-
if cloud not in profiles:
46-
print(f"WARNING: no profile for instance {cloud}")
52+
print(f"Benchmarking: {cloud}")
53+
for conf in config['job_configs']:
54+
job_conf_path = f"rules/{conf}.yml"
55+
if not helm.update([job_conf_path]):
56+
print(f"WARNING: job conf not found {conf}")
4757
continue
48-
if not set_active_profile(cloud):
49-
print(f"WARNING: unable to set {cloud} as the active profile")
50-
if lib.KUBECONFIG is None:
51-
print(f"WARNGING: no kubeconfig for instance {cloud}")
52-
continue
53-
for job_conf in config['job_configs']:
54-
job_conf_path = f"rules/{job_conf}.yml"
55-
if not helm.update([job_conf_path]):
56-
print(f"WARNING: job conf not found {job_conf}")
57-
continue
58-
history_name_prefix = f"Run {n} {job_conf}"
58+
for n in range(num_runs):
59+
history_name_prefix = f"{n} {cloud} {conf}"
5960
for workflow_conf in config['workflow_conf']:
6061
workflow.run([workflow_conf, history_name_prefix])
6162

63+
# for n in range(num_runs):
64+
# print("------------------------")
65+
# print(f"Benchmarking run #{n+1}")
66+
# for cloud in config['cloud']:
67+
# if cloud not in profiles:
68+
# print(f"WARNING: no profile for instance {cloud}")
69+
# continue
70+
# if not set_active_profile(cloud):
71+
# print(f"WARNING: unable to set {cloud} as the active profile")
72+
# if lib.KUBECONFIG is None:
73+
# print(f"WARNGING: no kubeconfig for instance {cloud}")
74+
# continue
75+
# for job_conf in config['job_configs']:
76+
# job_conf_path = f"rules/{job_conf}.yml"
77+
# if not helm.update([job_conf_path]):
78+
# print(f"WARNING: job conf not found {job_conf}")
79+
# continue
80+
# history_name_prefix = f"Run {n} {job_conf}"
81+
# for workflow_conf in config['workflow_conf']:
82+
# workflow.run([workflow_conf, history_name_prefix])
83+
6284

6385
def test(args: list):
6486
print(common.GALAXY_SERVER)
@@ -73,15 +95,19 @@ def summarize(args: list):
7395
:return: None
7496
"""
7597
row = [''] * 12
98+
print("Workflow,History,Server,Tool ID,State,Slots,Memory,Runtime,CPU,Memory Limit,Memory Max usage,Memory Soft Limit")
7699
for file in os.listdir(METRICS_DIR):
77100
input_path = os.path.join(METRICS_DIR, file)
78101
with open(input_path, 'r') as f:
79102
data = json.load(f)
80-
row[0] = data['workflow_id']
81-
row[1] = data['history_id']
82-
row[2] = data['server'] if data['server'] is not None else 'https://iu1.usegvl.org/galaxy'
83-
row[3] = data['metrics']['tool_id']
84-
row[4] = data['metrics']['state']
103+
row[0] = data['run']
104+
row[1] = data['cloud']
105+
row[2] = data['conf']
106+
row[3] = data['workflow_id']
107+
row[4] = data['history_id']
108+
row[5] = data['server'] if data['server'] is not None else 'https://iu1.usegvl.org/galaxy'
109+
row[6] = data['metrics']['tool_id']
110+
row[7] = data['metrics']['state']
85111
add_metrics_to_row(data['metrics']['job_metrics'], row)
86112
print(','.join(row))
87113

@@ -91,7 +117,8 @@ def add_metrics_to_row(metrics_list: list, row: list):
91117
for job_metrics in metrics_list:
92118
if job_metrics['name'] in accept_metrics:
93119
index = accept_metrics.index(job_metrics['name'])
94-
row[index + 5] = job_metrics['raw_value']
120+
row[index + 8] = job_metrics['raw_value']
121+
# row.append(job_metrics['raw_value'])
95122

96123

97124

lib/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ def connect():
4141

4242

4343
def set_active_profile(profile_name: str):
44-
print(f"Parsing profile for {profile_name}")
44+
# print(f"Parsing profile for {profile_name}")
4545
lib.GALAXY_SERVER, lib.API_KEY, lib.KUBECONFIG = parse_profile(profile_name)
46-
print(lib.KUBECONFIG)
4746
return lib.GALAXY_SERVER != None
4847

4948

lib/workflow.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ def run(args: list):
230230
print(f"Wrote invocation data to {output_path}")
231231
invocations = gi.invocations.wait_for_invocation(id, 86400, 10, False)
232232
print("Waiting for jobs")
233+
if len(args) > 1:
234+
for parts in args[1].split():
235+
invocations['run'] = parts[0]
236+
invocations['cloud'] = parts[1]
237+
invocations['job_conf'] = parts[2]
233238
wait_for_jobs(gi, invocations)
234239
print("Benchmarking run complete")
235240
return True
@@ -387,20 +392,30 @@ def wait_for_jobs(gi: GalaxyInstance, invocations: dict):
387392
"""
388393
wfid = invocations['workflow_id']
389394
hid = invocations['history_id']
395+
run = invocations['run']
396+
cloud = invocations['cloud']
397+
conf = invocations['job_conf']
390398
for step in invocations['steps']:
391399
job_id = step['job_id']
392400
if job_id is not None:
393401
print(f"Waiting for job {job_id} on {lib.GALAXY_SERVER}")
394-
status = gi.jobs.wait_for_job(job_id, 86400, 10, False)
395-
data = gi.jobs.show_job(job_id, full_details=True)
396-
metrics = {
397-
'workflow_id': wfid,
398-
'history_id': hid,
399-
'metrics': data,
400-
'status': status,
401-
'server': lib.GALAXY_SERVER
402-
}
403-
output_path = os.path.join(METRICS_DIR, f"{job_id}.json")
404-
with open(output_path, "w") as f:
405-
json.dump(metrics, f, indent=4)
406-
print(f"Wrote metrics to {output_path}")
402+
try:
403+
# TDOD Should retry if anything throws an exception.
404+
status = gi.jobs.wait_for_job(job_id, 86400, 10, False)
405+
data = gi.jobs.show_job(job_id, full_details=True)
406+
metrics = {
407+
'run': run,
408+
'cloud': cloud,
409+
'job_conf': conf,
410+
'workflow_id': wfid,
411+
'history_id': hid,
412+
'metrics': data,
413+
'status': status,
414+
'server': lib.GALAXY_SERVER
415+
}
416+
output_path = os.path.join(METRICS_DIR, f"{job_id}.json")
417+
with open(output_path, "w") as f:
418+
json.dump(metrics, f, indent=4)
419+
print(f"Wrote metrics to {output_path}")
420+
except Exception as e:
421+
print(f"ERROR: {e}")

0 commit comments

Comments
 (0)