annotate toolfactory/install_tf_demos.py @ 6:efefe43f23c8 draft default tip

Uploaded
author fubar
date Fri, 30 Apr 2021 02:10:32 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
1 import argparse
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
2 import urllib.request
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
3
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
4 from bioblend import galaxy
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
5
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
6 WF = "https://drive.google.com/uc?export=download&id=13xE8o7tucHGNA0qYkEP98FfUGl2wdOU5"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
7 HIST = (
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
8 "https://zenodo.org/record/4686436/files/TFdemo_wf_april13_planemo.ga?download=1"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
9 )
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
10 WF_FILE = "tf_workflow.ga"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
11 HIST_FILE = "tf_history.tgz"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
12
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
13
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
14 def _parser():
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
15 parser = argparse.ArgumentParser()
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
16 parser.add_argument(
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
17 "-g", "--galaxy", help="URL of target galaxy", default="http://localhost:8080"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
18 )
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
19 parser.add_argument("-a", "--key", help="Galaxy admin key", default="8993d65865e6d6d1773c2c34a1cc207d")
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
20 return parser
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
21
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
22
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
23 def main():
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
24 """
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
25 load the planemo tool_factory demonstration history and tool generating workflow
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
26 fails in planemo served galaxies because there seems to be no user in trans?
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
27 """
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
28 args = _parser().parse_args()
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
29 urllib.request.urlretrieve(WF, WF_FILE)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
30 urllib.request.urlretrieve(HIST, HIST_FILE)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
31 assert args.key, "Need an administrative key for the target Galaxy supplied please"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
32 gi = galaxy.GalaxyInstance(
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
33 url=args.galaxy, key=args.key, email="planemo@galaxyproject.org"
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
34 )
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
35 x = gi.workflows.import_workflow_from_local_path(WF_FILE, publish=True)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
36 print(f"installed {WF_FILE} Returned = {x}\n")
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
37 x = gi.histories.import_history(file_path=HIST_FILE)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
38 print(f"installed {HIST_FILE} Returned = {x}\n")
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
39
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
40
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
41 if __name__ == "__main__":
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
42 main()