annotate toolfactory/install_tf_demos.py @ 0:f288fab71d8b draft default tip

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