Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 9608a86

Browse files
committed
enh: added a python script to create a kubernetes job
1 parent b045873 commit 9608a86

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ ENV/
103103

104104
# Mac OS nonsense:
105105
.DS_Store
106+
107+
#kubernetes stuff
108+
kubernetes/jobs/

kubernetes/create_kube_job.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
import sys
3+
from boto3 import Session
4+
5+
if __name__ == "__main__":
6+
if len(sys.argv) > 1:
7+
subject = sys.argv[1]
8+
9+
session = Session()
10+
credentials = session.get_credentials()
11+
# Credentials are refreshable, so accessing your access key / secret key
12+
# separately can lead to a race condition. Use this to get an actual matched
13+
# set.
14+
current_credentials = credentials.get_frozen_credentials()
15+
16+
access_key = current_credentials.access_key
17+
secret_key = current_credentials.secret_key
18+
19+
with open("run_dmriprep.yml.tmpl", 'r') as template:
20+
with open("jobs/job_{}.yml".format(subject), 'w') as f:
21+
all_text = "\n".join(template.readlines())
22+
all_text = all_text.replace("{{subject}}", subject)
23+
all_text = all_text.replace("{{access_key}}", access_key)
24+
all_text = all_text.replace("{{secret_key}}", secret_key)
25+
f.write(all_text)
26+

0 commit comments

Comments
 (0)