annotate toolfactory/install_tf_demos.py @ 4:2a46da701dde draft

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