annotate generate_test.py @ 4:bd5ffc799c16 draft default tip

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