-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschedule.py
44 lines (35 loc) · 1.31 KB
/
schedule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import subprocess
import tempfile
import time
import click
import yaml
@click.command()
@click.option("--repo-path", default="[email protected]:cswinter/DeepCodeCraft.git", help="Path to git code repository to execute.")
@click.option("--revision", default="HEAD", help="Git revision to execute.")
@click.option("--params-file", default=None, help="Path to parameter file.")
@click.option("--hps", default=None, help="List of hyperparameters in format name1:value1,name2:value2")
@click.option("--queue-dir", default="192.168.0.101:/home/clemens/xprun/queue")
def main(repo_path, revision, params_file, hps, queue_dir):
commit = subprocess.check_output(["git", "rev-parse", revision]).decode("UTF-8")[:-1]
if params_file:
with open(params_file, "r") as f:
params = yaml.safe_load(f)
elif hps:
params = [{}]
for param in hps.split(","):
key, value = param.split(":")
params[0][key] = value
else:
params = [{}]
job = {
"repo-path": repo_path,
"revision": commit,
"params": params,
}
fd, path = tempfile.mkstemp()
with open(fd, 'w') as f:
f.write(yaml.dump(job))
subprocess.check_call(["rsync", path, os.path.join(queue_dir, f"{int(time.time())}.yaml")])
if __name__ == "__main__":
main()