annotate main_file.py @ 0:27e7e4d38e44 draft

planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
author siwaa
date Tue, 12 Dec 2023 17:33:05 +0000
parents
children 9e8f5f220917
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
1 # -*- coding: UTF-8 -*-
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
2 """
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
3 main_file
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
4
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
5 Requests having as OUTput : 1 json data + maybe 1 more file (xls or zip)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
6
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
7 Accepts actions (all) :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
8 'help'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
9 'get_pkg_list' 'get_pkg_vpz_list' 'get_pkg_data_list'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
10 'get_vpz_input' 'post_vpz_input'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
11 'get_vpz_output' 'post_vpz_output'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
12 'get_vpz_inout' 'post_vpz_inout'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
13 'get_vpz_experiment' 'post_vpz_experiment'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
14 'get_vpz_report_conditions' 'post_vpz_report_conditions'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
15 'get_vpz_report' 'post_vpz_report'
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
16
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
17 Parameters (Inputs) :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
18 - '-action' parameter : action value (mandatory)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
19 - '-data' parameter : data (JSON format) (optional)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
20 - '-datafolder' parameter : datafolder file path (optional,
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
21 available only in some cases)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
22 - '-experimentfile' parameter : experimentfile path (optional,
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
23 available only in some cases) :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
24
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
25 If there is an action value into data, then this one is ignored.
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
26
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
27 Outputs :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
28 - output.json data file
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
29 - 1 other file in following cases :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
30 - experiment.xls file
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
31 if 'action' == get_vpz_experiment, post_vpz_experiment
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
32 - conditions.xls file
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
33 if 'action' == get_vpz_report_conditions,
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
34 post_vpz_report_conditions
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
35 - report.zip file
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
36 if 'action' == get_vpz_report, post_vpz_report
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
37 """
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
38
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
39 MAIN_DEBUG=False # True for more information returned
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
40
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
41 import argparse
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
42 import json
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
43 import erecord.api.erecord as erecord_api
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
44 from erecord.api.cmn.views_mixins import ActionViewMixin
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
45 import os
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
46 import shutil
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
47 from erecord.api.cmn.utils.dir_and_file import create_dir_if_absent
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
48 from erecord.api.cmn.configs.config import PROJECT_HOME
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
49 from erecord.api.cmn.configs.config import out_path
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
50
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
51 PM = "[main_file.py]"
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
52
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
53 jsonoutput_filepath = os.path.join(out_path, "output.json") # tool.xml uses it
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
54
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
55 r = dict()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
56
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
57 import sys
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
58 if MAIN_DEBUG: r["sys.path"] = sys.path # debug
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
59 if MAIN_DEBUG: r["sys.argv"] = sys.argv # debug
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
60 if MAIN_DEBUG: r["out_path"] = out_path # debug
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
61
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
62 data = dict()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
63 json_response = dict()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
64
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
65 create_dir_if_absent(PROJECT_HOME) # required
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
66
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
67 try :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
68 parser = argparse.ArgumentParser()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
69
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
70 # -action
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
71 available_action_list = ActionViewMixin.get_action_list()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
72 htext = "action value among : " + str(available_action_list)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
73 parser.add_argument("-action", default='help', help=htext,
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
74 choices=available_action_list)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
75
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
76 # -data
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
77 parser.add_argument("-data", type=str, help="data json file path")
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
78
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
79 # -datafolder
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
80 htext = "datafolder file path, available for action : "
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
81 htext +="post_vpz_output, post_vpz_inout,"
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
82 htext +="post_vpz_experiment, post_vpz_report"
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
83 parser.add_argument("-datafolder", type=str, help=htext)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
84
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
85 # -experimentfile
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
86 htext = "experimentfile path, available for action : post_vpz_experiment"
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
87 parser.add_argument("-experimentfile", type=str, help=htext)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
88
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
89 args = parser.parse_args()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
90
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
91 if (args.action is None) or (args.action == 'None') :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
92 warn = "NO action given => enforced to 'help'"
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
93 r["warning"] = warn
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
94 action = 'help' # enforced (default)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
95 else :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
96 action = args.action
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
97
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
98 if (args.data is None) or (args.data == 'None') :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
99 data = dict() # NO data (JSON format) given as argument
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
100 else :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
101 jsoninput_filename = args.data
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
102 inputfile = open(jsoninput_filename, 'r')
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
103 data = json.load(inputfile) # get data
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
104
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
105 if (args.datafolder is None) or (args.datafolder == 'None') :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
106 pass # NO datafolder given
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
107 else :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
108 data['datafolder'] = args.datafolder
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
109
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
110 if (args.experimentfile is None) or (args.experimentfile == 'None') :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
111 pass # NO experimentfile given
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
112 else :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
113 data['experimentfile'] = args.experimentfile
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
114
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
115 data['action'] = action
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
116
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
117 r["data"] = data
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
118 r_init = erecord_api.init()
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
119 if MAIN_DEBUG: r["init"] = r_init # debug
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
120 response = erecord_api.action(data)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
121 json_response = json.loads(response)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
122
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
123 # Restitution : file (experiment.xls, conditions.xls, report.zip)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
124 if action in ['get_vpz_experiment', 'post_vpz_experiment',
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
125 'get_vpz_report_conditions', 'post_vpz_report_conditions',
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
126 'get_vpz_report', 'post_vpz_report']:
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
127
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
128 filename = json_response["outputfile_name"]
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
129 outputfile_path = json_response["outputfile_path"]
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
130 shutil.copyfile(src=outputfile_path,
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
131 dst=os.path.join(out_path,filename)) # tool.xml uses them
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
132
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
133 if not MAIN_DEBUG: # some response information not kept
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
134 for k in ('outputfile_name', 'outputfile_path', 'zip_file_path'):
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
135 if k in json_response.keys():
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
136 del(json_response[k])
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
137
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
138 except Exception as e :
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
139
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
140 response = erecord_api.error_case(data=data, msg=PM, e=e)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
141 json_response = json.loads(response)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
142
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
143 r["response"] = json_response
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
144
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
145 # Restitution : json file
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
146 with open(jsonoutput_filepath, "w") as outfile:
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
147 json.dump(r, outfile)
27e7e4d38e44 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/erecord-deploy/-/tree/main/galaxy-tools/erecord_file commit 88beb443a737b4c4d42bb0011a26a0acf535c366
siwaa
parents:
diff changeset
148