annotate generate_test.py @ 4:815748762646 draft default tip

planemo upload for repository https://github.com/brsynth/galaxytools commit d7030c1af6fe06a1d45af115756ee775721e39b5
author tduigou
date Thu, 02 Oct 2025 14:27:31 +0000
parents 95b4196b4ded
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
1 import hashlib
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
2 import subprocess
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
3 import tempfile
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
4 from typing import List
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
5
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
6
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
7 def compute_md5(path: str):
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
8 hash_md5 = hashlib.md5()
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
9 with open(path, "rb") as f:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
10 for chunk in iter(lambda: f.read(4096), b""):
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
11 hash_md5.update(chunk)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
12 return hash_md5.hexdigest()
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
13
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
14
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
15 def run_cmd(subcommand: str, sub_cmd: List):
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
16 with tempfile.NamedTemporaryFile() as fd:
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
17 cmd = ["python", "query.py"]
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
18 cmd.append(subcommand)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
19 cmd.append("--output-data-json")
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
20 cmd.append(fd.name)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
21 cmd.extend(sub_cmd)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
22
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
23 print("Cmd:", " ".join(cmd))
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
24 ret = subprocess.run(cmd)
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
25 if ret.returncode != 0:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
26 msg = f"Command failed: {' '.join(cmd)}\n"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
27 if ret.stdout:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
28 msg += "Stdout:", ret.stdout + "\n"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
29 if ret.stderr:
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
30 msg += "Stderr:", ret.stderr + "\n"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
31 raise Exception()
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
32
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
33 return compute_md5(path=fd.name)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
34
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
35
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
36 if __name__ == "__main__":
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
37
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
38 print("=" * 50)
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
39 print("templates")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
40 smarts_str = "[O]-[C](=[O])"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
41 cmd = ["--input-smarts-str", smarts_str, "--input-limit-int", "5"]
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
42 value = run_cmd(subcommand="templates", sub_cmd=cmd)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
43 print("Test:", " ".join(cmd), "md5:", value)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
44
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
45 print("=" * 50)
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
46
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
47 print("templates-summary")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
48 template_id = "RR:03-27BC85-19184A-A71018"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
49 cmd = ["--input-template-id-str", template_id]
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
50 value = run_cmd(subcommand="templates-summary", sub_cmd=cmd)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
51 print("Test:", " ".join(cmd), "md5:", value)
4
815748762646 planemo upload for repository https://github.com/brsynth/galaxytools commit d7030c1af6fe06a1d45af115756ee775721e39b5
tduigou
parents: 3
diff changeset
52
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
53 print("=" * 50)
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
54
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
55 print("templates-sources")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
56 template_id = "RR:03-27BC85-19184A-A71018"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
57 cmd = ["--input-template-id-str", template_id]
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
58 value = run_cmd(subcommand="templates-sources", sub_cmd=cmd)
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
59 print("Test:", " ".join(cmd), "md5:", value)
4
815748762646 planemo upload for repository https://github.com/brsynth/galaxytools commit d7030c1af6fe06a1d45af115756ee775721e39b5
tduigou
parents: 3
diff changeset
60
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
61 print("=" * 50)
4
815748762646 planemo upload for repository https://github.com/brsynth/galaxytools commit d7030c1af6fe06a1d45af115756ee775721e39b5
tduigou
parents: 3
diff changeset
62
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
63 print("templates-count")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
64 smarts_str = "[O]-[C](=[O])"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
65 cmd = ["--input-smarts-str", smarts_str]
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
66 value = run_cmd(subcommand="templates-count", sub_cmd=cmd)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
67 print("Test:", " ".join(cmd), "md5:", value)
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
68
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
69 print("=" * 50)
3
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
70 """
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
71 print("templates-export")
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
72 smarts_str = "[O]-[C](=[O])"
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
73 cmd = ["--input-smarts-str", smarts_str]
95b4196b4ded planemo upload for repository https://github.com/brsynth/galaxytools commit 5e85823d729e9e09adf66ccfb7c47701077dccff-dirty
tduigou
parents: 0
diff changeset
74 value = run_cmd(subcommand="templates-export", sub_cmd=cmd)
0
6d20407d9a72 planemo upload for repository https://github.com/brsynth/galaxytools commit ccd77691de09b70e3048dca6be832dd93964c635-dirty
tduigou
parents:
diff changeset
75 print("Test:", " ".join(cmd), "md5:", value)
4
815748762646 planemo upload for repository https://github.com/brsynth/galaxytools commit d7030c1af6fe06a1d45af115756ee775721e39b5
tduigou
parents: 3
diff changeset
76 """