pycompss-cli 3.3.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. pycompss_cli/__init__.py +16 -0
  2. pycompss_cli/assets/__init__.py +16 -0
  3. pycompss_cli/assets/enqueue_compss_args.txt +317 -0
  4. pycompss_cli/assets/runcompss_args.txt +188 -0
  5. pycompss_cli/cli/__init__.py +16 -0
  6. pycompss_cli/cli/compss.py +27 -0
  7. pycompss_cli/cli/dislib.py +28 -0
  8. pycompss_cli/cli/pycompss.py +49 -0
  9. pycompss_cli/core/__init__.py +16 -0
  10. pycompss_cli/core/actions.py +173 -0
  11. pycompss_cli/core/actions_dispatcher.py +113 -0
  12. pycompss_cli/core/arguments.py +313 -0
  13. pycompss_cli/core/cmd_helpers.py +56 -0
  14. pycompss_cli/core/docker/__init__.py +16 -0
  15. pycompss_cli/core/docker/actions.py +241 -0
  16. pycompss_cli/core/docker/arguments.py +65 -0
  17. pycompss_cli/core/docker/cmd.py +636 -0
  18. pycompss_cli/core/local/__init__.py +16 -0
  19. pycompss_cli/core/local/actions.py +338 -0
  20. pycompss_cli/core/local/arguments.py +51 -0
  21. pycompss_cli/core/local/cmd.py +464 -0
  22. pycompss_cli/core/remote/__init__.py +16 -0
  23. pycompss_cli/core/remote/actions.py +443 -0
  24. pycompss_cli/core/remote/arguments.py +215 -0
  25. pycompss_cli/core/remote/cmd.py +217 -0
  26. pycompss_cli/core/remote/interactive_sc/__init__.py +16 -0
  27. pycompss_cli/core/remote/interactive_sc/core.py +342 -0
  28. pycompss_cli/core/remote/interactive_sc/defaults.py +132 -0
  29. pycompss_cli/core/remote/job_scripts/__init__.py +16 -0
  30. pycompss_cli/core/remote/job_scripts/cancel.py +77 -0
  31. pycompss_cli/core/remote/job_scripts/commons.py +273 -0
  32. pycompss_cli/core/remote/job_scripts/find.py +74 -0
  33. pycompss_cli/core/remote/job_scripts/info.py +103 -0
  34. pycompss_cli/core/remote/job_scripts/status.py +67 -0
  35. pycompss_cli/core/unicore/__init__.py +21 -0
  36. pycompss_cli/core/unicore/actions.py +317 -0
  37. pycompss_cli/core/unicore/arguments.py +69 -0
  38. pycompss_cli/core/utils.py +143 -0
  39. pycompss_cli/models/__init__.py +16 -0
  40. pycompss_cli/models/app.py +22 -0
  41. pycompss_cli-3.3.6.dist-info/LICENSE.txt +202 -0
  42. pycompss_cli-3.3.6.dist-info/METADATA +138 -0
  43. pycompss_cli-3.3.6.dist-info/RECORD +46 -0
  44. pycompss_cli-3.3.6.dist-info/WHEEL +5 -0
  45. pycompss_cli-3.3.6.dist-info/entry_points.txt +4 -0
  46. pycompss_cli-3.3.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Copyright 2002-2025 Barcelona Supercomputing Center (www.bsc.es)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ from pycompss_cli.core.arguments import parse_sys_argv
19
+ from pycompss_cli.core.actions_dispatcher import ActionsDispatcher
20
+ import sys
21
+
22
+ # Globals
23
+ LINE_LENGTH = 79
24
+ LINE = "-" * LINE_LENGTH
25
+
26
+
27
+ def main():
28
+ """
29
+ MAIN ENTRY POINT
30
+ """
31
+
32
+ arguments = parse_sys_argv()
33
+
34
+ if arguments.debug:
35
+ print(LINE)
36
+
37
+ if 'enqueue_args' in arguments:
38
+ del arguments.enqueue_args
39
+ if 'runcompss_args' in arguments:
40
+ del arguments.runcompss_args
41
+ print("Calling pycompss-cli for action: " + arguments.action)
42
+ print()
43
+ print("Arguments: " + str(arguments))
44
+
45
+ ActionsDispatcher().run_action(arguments)
46
+
47
+
48
+ if __name__ == "__main__":
49
+ main()
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Copyright 2002-2025 Barcelona Supercomputing Center (www.bsc.es)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Copyright 2002-2025 Barcelona Supercomputing Center (www.bsc.es)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ """
18
+ This file contains the actions supported by pycompss-cli.
19
+ They are invoked from cli/pycompss.py and uses core/cmd.py.
20
+ """
21
+ from abc import ABC, abstractmethod
22
+ import json
23
+ import os
24
+ import shutil
25
+ from pathlib import Path
26
+ from glob import glob
27
+ from pycompss_cli.core import utils
28
+ from uuid import uuid4 as uuid
29
+
30
+ class Actions(ABC):
31
+
32
+ def __init__(self, arguments, debug=False, env_conf=None) -> None:
33
+ super().__init__()
34
+ self.arguments = arguments
35
+ self.debug = debug
36
+ self.env_conf = env_conf
37
+ self.home_path = str(Path.home())
38
+
39
+ if self.env_conf:
40
+ self.env_conf['env_path'] = self.home_path + '/.COMPSs/envs/' + self.env_conf['name']
41
+
42
+ if 'name' in self.arguments and self.arguments.name == 'unique uuid':
43
+ self.arguments.name = ''.join(str(uuid()).split('-')[:2])
44
+
45
+
46
+ def env_add_conf(self, extra_conf):
47
+ current_env, env_conf_path = utils.get_current_env_conf(env_id=self.arguments.name, return_path=True)
48
+ new_conf = {**current_env, **extra_conf}
49
+ with open(env_conf_path, 'w') as f:
50
+ json.dump(new_conf, f)
51
+
52
+
53
+ @abstractmethod
54
+ def init(self):
55
+ if not self.arguments.env:
56
+ self.arguments.func()
57
+ exit(0)
58
+
59
+ del self.arguments.func
60
+
61
+ if os.path.isdir(self.home_path + '/.COMPSs/envs'):
62
+ envs = os.listdir(self.home_path + '/.COMPSs/envs')
63
+
64
+ if self.arguments.name in envs:
65
+ print("ERROR: There's already another environment named " + self.arguments.name)
66
+ exit(1)
67
+
68
+ env_path = self.home_path + '/.COMPSs/envs/' + self.arguments.name
69
+ self.arguments.env_path = env_path
70
+
71
+ os.makedirs(env_path)
72
+
73
+ with open(env_path + '/env.json', 'w') as env_conf:
74
+ json.dump(vars(self.arguments), env_conf)
75
+ self.env_conf = vars(self.arguments)
76
+
77
+ if self.arguments.config:
78
+ shutil.copy2(self.arguments.config, env_path)
79
+
80
+ print('Environment created ID:', self.arguments.name)
81
+
82
+ @abstractmethod
83
+ def exec(self):
84
+ pass
85
+
86
+ @abstractmethod
87
+ def run(self):
88
+ pass
89
+
90
+ @abstractmethod
91
+ def job(self):
92
+ if not self.arguments.job:
93
+ self.arguments.func()
94
+ exit(0)
95
+
96
+ def job_submit(self):
97
+ if not self.arguments.rest_args:
98
+ print(self.arguments.enqueue_args)
99
+ exit(0)
100
+
101
+ @abstractmethod
102
+ def app(self):
103
+ raise NotImplementedError("Wrong Environment! Try switching to a `remote` environment")
104
+
105
+ @abstractmethod
106
+ def jupyter(self):
107
+ pass
108
+
109
+ @abstractmethod
110
+ def monitor(self):
111
+ pass
112
+
113
+ @abstractmethod
114
+ def gengraph(self):
115
+ pass
116
+
117
+ @abstractmethod
118
+ def gentrace(self):
119
+ pass
120
+
121
+ @abstractmethod
122
+ def components(self):
123
+ pass
124
+
125
+ def environment(self):
126
+ action_name = 'list'
127
+
128
+ if self.arguments.environment:
129
+ action_name = self.arguments.environment
130
+
131
+ action_name = utils.get_object_method_by_name(self, 'env_' + action_name, include_in_name=True)
132
+ getattr(self, action_name)()
133
+
134
+ def env_list(self):
135
+ envs_path = self.home_path + '/.COMPSs/envs'
136
+ envs_files = os.listdir(envs_path)
137
+
138
+ env_info = []
139
+ for env_name in envs_files:
140
+ env_type = json.load(open(envs_path + f'/{env_name}/env.json'))['env']
141
+ env_current = '*' if 'current' in os.listdir(envs_path + f'/{env_name}') else ''
142
+ env_info.append([env_name, env_type, env_current])
143
+
144
+ col_names = ['ID', 'Type', 'Active']
145
+ utils.table_print(col_names, env_info)
146
+
147
+
148
+ def env_change(self, env_id=None):
149
+ env_id = self.arguments.env_id if env_id is None else env_id
150
+ if not os.path.isdir(self.home_path + '/.COMPSs/envs/' + env_id):
151
+ print("ERROR: There's no environment named " + env_id)
152
+ exit(1)
153
+
154
+ current_files = glob(self.home_path + '/.COMPSs/envs/*/current')
155
+ if current_files:
156
+ os.remove(current_files[0])
157
+ env_dir_name = self.home_path + '/.COMPSs/envs/' + env_id
158
+ open(env_dir_name + '/current', 'a').close()
159
+ print(f'Environment `{env_id}` is now active')
160
+
161
+ @abstractmethod
162
+ def env_remove(self, eid=None):
163
+ self.env_change(env_id='default')
164
+ env_id = self.arguments.env_id if eid is None else eid
165
+
166
+ env_dir_name = self.home_path + '/.COMPSs/envs/' + env_id
167
+
168
+ print(f'Deleting environment `{env_id}`...')
169
+ shutil.rmtree(env_dir_name)
170
+
171
+ @abstractmethod
172
+ def inspect(self):
173
+ pass
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Copyright 2002-2025 Barcelona Supercomputing Center (www.bsc.es)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ from pycompss_cli.core import utils
18
+ from pycompss_cli.core.cmd_helpers import command_runner
19
+ from copy import deepcopy
20
+ import os
21
+ from pathlib import Path
22
+ import json
23
+
24
+ class ActionsDispatcher(object):
25
+ def __init__(self) -> None:
26
+ super().__init__()
27
+ self.home_path = str(Path.home())
28
+
29
+ def run_action(self, arguments):
30
+ self.__ensure_default_env()
31
+
32
+ if arguments.version:
33
+ exit_code = command_runner(["runcompss", "-v"], silent=True)
34
+ exit(exit_code)
35
+
36
+ if 'env' in arguments and arguments.env:
37
+ env_type = arguments.env
38
+ env_conf = None
39
+ else:
40
+ envs_path = self.home_path + '/.COMPSs/envs'
41
+ if not os.path.isdir(envs_path) or len(list(os.walk(envs_path))) == 1:
42
+ print("There are no environments created. Try using `pycompss init`")
43
+ exit(1)
44
+
45
+ if arguments.action == 'environment':
46
+ if arguments.environment and arguments.environment.startswith('r'):
47
+ self.__delete_envs(arguments.env_id, arguments)
48
+
49
+ env_id = arguments.env_id if arguments.env_id else None
50
+
51
+ env_conf = utils.get_current_env_conf(env_id=env_id)
52
+ env_type = env_conf['env']
53
+
54
+ self.__actions_cmd = self.__getactions_cmd(env_type, arguments, env_conf)
55
+
56
+ action_name = utils.get_object_method_by_name(self.__actions_cmd, arguments.action)
57
+ action_func = getattr(self.__actions_cmd, action_name)
58
+ action_func()
59
+
60
+ def __delete_envs(self, envs_ids, arguments):
61
+ for env_id in envs_ids:
62
+ env_type = self.__get_env_type_from_name(env_id)
63
+ if env_type is None:
64
+ print("ERROR: There's no environment named " + env_id)
65
+ continue
66
+ if env_id == 'default':
67
+ print('ERROR: `default` environment is required and cannot be deleted')
68
+ continue
69
+ env_conf = utils.get_env_conf_by_name(env_id)
70
+ env_arguments = deepcopy(arguments)
71
+ env_arguments.env_id = env_id
72
+ action_cmd = self.__getactions_cmd(env_type, env_arguments, env_conf=env_conf)
73
+ action_cmd.env_remove()
74
+ exit(0)
75
+
76
+ def __get_env_type_from_name(self, env_name):
77
+ envs_path = self.home_path + '/.COMPSs/envs'
78
+ env_dir_tree = list(os.walk(envs_path))
79
+ envs_names = env_dir_tree[0][1]
80
+ env_dir_tree = env_dir_tree[1:]
81
+ for i in range(len(env_dir_tree)):
82
+ if env_name == envs_names[i]:
83
+ return json.load(open(env_dir_tree[i][0] + '/env.json'))['env']
84
+ return None
85
+
86
+ def __getactions_cmd(self, env_type, arguments, env_conf=None):
87
+ debug = arguments.debug
88
+
89
+ if env_type == "local":
90
+ from pycompss_cli.core.local.actions import LocalActions
91
+ return LocalActions(arguments, debug, env_conf)
92
+ elif env_type == "docker":
93
+ from pycompss_cli.core.docker.actions import DockerActions
94
+ return DockerActions(arguments, debug, env_conf)
95
+ elif env_type == "remote":
96
+ from pycompss_cli.core.remote.actions import RemoteActions
97
+ return RemoteActions(arguments, debug, env_conf)
98
+ elif env_type == "unicore":
99
+ from pycompss_cli.core.unicore.actions import UnicoreActions
100
+ return UnicoreActions(arguments, debug, env_conf)
101
+ else:
102
+ raise NotImplementedError(f"Environment `{env_type}` not implemented")
103
+
104
+
105
+ def __ensure_default_env(self):
106
+ default_env = self.home_path + '/.COMPSs/envs/default'
107
+ if not os.path.isdir(default_env):
108
+ os.makedirs(default_env)
109
+ open(default_env + '/current', 'a').close()
110
+ with open(default_env + '/env.json', 'w') as def_env:
111
+ json.dump({ 'env': 'local', 'name': 'default' }, def_env)
112
+ with open(default_env + '/modules.sh', 'w') as mod_file:
113
+ mod_file.write('module load COMPSS')
@@ -0,0 +1,313 @@
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Copyright 2002-2025 Barcelona Supercomputing Center (www.bsc.es)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ import os
18
+ import sys
19
+ import argparse
20
+ import subprocess
21
+
22
+ from pycompss_cli.core.docker.arguments import docker_init_parser
23
+ from pycompss_cli.core.local.arguments import local_init_parser
24
+ from pycompss_cli.core.remote.arguments import remote_init_parser
25
+ from pycompss_cli.core.remote.arguments import remote_parser_job
26
+ from pycompss_cli.core.remote.arguments import remote_parser_app
27
+ from pycompss_cli.core.unicore.arguments import unicore_init_parser
28
+ from pycompss_cli.core import utils
29
+
30
+ FORMATTER_CLASS = argparse.RawTextHelpFormatter
31
+
32
+ def parse_sys_argv():
33
+ """ Parses the sys.argv.
34
+
35
+ :returns: All arguments as namespace.
36
+ """
37
+ parser = argparse.ArgumentParser(formatter_class=FORMATTER_CLASS)
38
+ parser.add_argument("-d", "--debug",
39
+ help="Enable debug mode. Overrides log_level",
40
+ action="store_true")
41
+
42
+ parser.add_argument("-eid", "--env_id",
43
+ default="",
44
+ type=str,
45
+ help="Environment ID")
46
+ parser.add_argument("-v", "--version",
47
+ help="Get version",
48
+ action="store_true")
49
+
50
+ # Parent parser - includes all arguments which are common to all actions
51
+ parent_parser = argparse.ArgumentParser(add_help=False,
52
+ formatter_class=FORMATTER_CLASS)
53
+ # Action sub-parser
54
+ subparsers = parser.add_subparsers(dest="action")
55
+ # INIT
56
+ parser_init = subparsers.add_parser("init",
57
+ aliases=["i"],
58
+ help="Initialize COMPSs environment (default local).",
59
+ parents=[parent_parser],
60
+ formatter_class=FORMATTER_CLASS)
61
+
62
+ parser_init.set_defaults(func=lambda: print(parser_init.format_help()))
63
+
64
+ parser_init.add_argument("-cfg", "--config",
65
+ default="",
66
+ type=str,
67
+ help="Configuration file")
68
+
69
+ parser_init.add_argument("-n", "--name",
70
+ default='unique uuid',
71
+ type=str,
72
+ help="Environment name")
73
+
74
+ init_env_subparser = parser_init.add_subparsers(title="environment", dest="env")
75
+ # init_env_subparser.default = "local"
76
+
77
+ init_env_subparser.add_parser("docker", add_help=False,
78
+ parents=[docker_init_parser()])
79
+
80
+ init_env_subparser.add_parser("local", add_help=False,
81
+ parents=[local_init_parser()])
82
+
83
+ init_env_subparser.add_parser("remote", add_help=False,
84
+ parents=[remote_init_parser()])
85
+
86
+ init_env_subparser.add_parser("unicore", add_help=False,
87
+ parents=[unicore_init_parser()])
88
+
89
+ # EXEC
90
+ parser_exec = subparsers.add_parser("exec",
91
+ aliases=["ex"],
92
+ help="Execute the given command within the COMPSs\' environment.", # noqa: E501
93
+ parents=[parent_parser],
94
+ formatter_class=FORMATTER_CLASS)
95
+ parser_exec.set_defaults(action='exec')
96
+
97
+
98
+ parser_exec.add_argument('exec_cmd',
99
+ nargs=argparse.REMAINDER,
100
+ help="Exec program arguments")
101
+ # RUN
102
+ parser_run = subparsers.add_parser("run",
103
+ aliases=["r"],
104
+ help="Run the application (with runcompss) within the COMPSs\' environment.", # noqa: E501
105
+ parents=[parent_parser],
106
+ formatter_class=FORMATTER_CLASS)
107
+ parser_run.set_defaults(action='run')
108
+
109
+ if utils.check_exit_code('runcompss -h') == 0:
110
+ parser_run.epilog = subprocess.check_output('runcompss -h', shell=True).decode()
111
+ else:
112
+ assets_folder = os.path.dirname(os.path.abspath(__file__)) + '/..'
113
+ with open(assets_folder + '/assets/runcompss_args.txt', 'r', encoding='utf-8') as f:
114
+ parser_run.epilog = f.read()
115
+
116
+
117
+ parser_run.add_argument("-app", "--app_name",
118
+ default="",
119
+ type=str,
120
+ help="Name of the app where to execute runcompss. Only required for `remote` type environment")
121
+ parser_run.add_argument('rest_args',
122
+ nargs=argparse.REMAINDER,
123
+ help="Runcompss program arguments")
124
+
125
+ # APP remote_parser_app
126
+ parser_app = subparsers.add_parser("app", aliases=["a"], add_help=False,
127
+ help="Manage applications within remote environments.", # noqa: E501
128
+ parents=[remote_parser_app()],
129
+ formatter_class=FORMATTER_CLASS)
130
+ parser_app.set_defaults(action='app')
131
+
132
+
133
+ # JOB
134
+ parser_job = subparsers.add_parser("job", aliases=["j"], add_help=False,
135
+ help="Manage jobs within remote environments.", # noqa: E501
136
+ parents=[remote_parser_job()],
137
+ formatter_class=FORMATTER_CLASS)
138
+ parser_job.set_defaults(action='job')
139
+
140
+
141
+ # MONITOR
142
+ parser_monitor = subparsers.add_parser("monitor",
143
+ aliases=["m"],
144
+ help="Start the monitor within the COMPSs\' environment.", # noqa: E501
145
+ parents=[parent_parser],
146
+ formatter_class=FORMATTER_CLASS)
147
+ parser_monitor.set_defaults(action='monitor')
148
+
149
+ parser_monitor.add_argument("option",
150
+ help="Start or stop de monitoring service.",
151
+ choices=["start", "stop"],
152
+ default="start",
153
+ type=str)
154
+
155
+ # JUPYTER
156
+ parser_jupyter = subparsers.add_parser("jupyter",
157
+ aliases=["jpy"],
158
+ help="Starts Jupyter within the COMPSs\' environment.", # noqa: E501
159
+ parents=[parent_parser],
160
+ formatter_class=FORMATTER_CLASS)
161
+ parser_jupyter.set_defaults(action='jupyter')
162
+
163
+ parser_jupyter.add_argument("-lab",
164
+ action="store_true",
165
+ help="Run Jupyter Lab")
166
+
167
+
168
+ parser_jupyter.add_argument("-app", "--app_name",
169
+ default="",
170
+ type=str,
171
+ help="Name of the app where the notebook will be deployed. Only required for `remote` type environment")
172
+ parser_jupyter.add_argument('rest_args',
173
+ nargs=argparse.REMAINDER,
174
+ help="Jupyter arguments")
175
+
176
+ # GENGRAPH
177
+ parser_gengraph = subparsers.add_parser("gengraph",
178
+ aliases=["gg"],
179
+ help="Converts the given graph into pdf.", # noqa: E501
180
+ parents=[parent_parser],
181
+ formatter_class=FORMATTER_CLASS)
182
+ parser_gengraph.set_defaults(action='gengraph')
183
+
184
+ parser_gengraph.add_argument("dot_file",
185
+ type=str,
186
+ help="Dot file to convert to pdf")
187
+
188
+
189
+ # GENTRACE
190
+ parser_gentrace = subparsers.add_parser("gentrace",
191
+ aliases=["gt"],
192
+ help="Merges traces from all nodes into a Paraver trace.", # noqa: E501
193
+ parents=[parent_parser],
194
+ formatter_class=FORMATTER_CLASS)
195
+ parser_gentrace.set_defaults(action='gentrace')
196
+
197
+ parser_gentrace.add_argument("trace_dir",
198
+ type=str,
199
+ help="Directory where the traces are located.")
200
+
201
+ parser_gentrace.add_argument("--download_dir",
202
+ type=str,
203
+ help="Directory where the traces will be downloaded.")
204
+
205
+ parser_gentrace.add_argument('rest_args',
206
+ nargs=argparse.REMAINDER,
207
+ help="compss_gentrace arguments")
208
+
209
+ # COMPONENTS
210
+ parser_components = subparsers.add_parser("components",
211
+ aliases=["c"],
212
+ help="Manage infrastructure components.", # noqa: E501
213
+ parents=[parent_parser],
214
+ formatter_class=FORMATTER_CLASS)
215
+ parser_components.set_defaults(action='components')
216
+
217
+
218
+ subparsers_components = parser_components.add_subparsers(dest="components")
219
+
220
+ subparsers_components.add_parser("list",
221
+ aliases=["l"],
222
+ help="List COMPSs active components.", # noqa: E501
223
+ formatter_class=FORMATTER_CLASS) # noqa: E501
224
+ parser_components_add = subparsers_components.add_parser("add",
225
+ aliases=["a"],
226
+ help="Adds the RESOURCE to the pool of workers of the COMPSs.", # noqa: E501
227
+ formatter_class=FORMATTER_CLASS) # noqa: E501
228
+ subparsers_components_add = parser_components_add.add_subparsers(dest="add") # noqa: E501
229
+ parser_components_add_worker = subparsers_components_add.add_parser("worker", # noqa: E501
230
+ aliases=["w"], # noqa: E501
231
+ help="Add a worker.", # noqa: E501
232
+ formatter_class=FORMATTER_CLASS) # noqa: E501
233
+ parser_components_add_worker.add_argument("worker",
234
+ type=str,
235
+ default="1",
236
+ help="Number of workers to add (can be integer or <IP>:<CORES> to add remote workers).") # noqa: E501
237
+ parser_components_remove = subparsers_components.add_parser("remove",
238
+ aliases=["r"],
239
+ help="Removes the RESOURCE to the pool of workers of the COMPSs.", # noqa: E501
240
+ formatter_class=FORMATTER_CLASS) # noqa: E501
241
+ subparsers_components_remove = parser_components_remove.add_subparsers(dest="remove") # noqa: E501
242
+ parser_components_remove_worker = subparsers_components_remove.add_parser("worker", # noqa: E501
243
+ aliases=["w"], # noqa: E501
244
+ help="Remove a worker.", # noqa: E501
245
+ formatter_class=FORMATTER_CLASS) # noqa: E501
246
+ parser_components_remove_worker.add_argument("worker",
247
+ type=str,
248
+ default="1",
249
+ help="Number of workers to remove (can be integer or <IP>:<CORES> to add remote workers).") # noqa: E501
250
+
251
+
252
+ # ENVIRONMENT
253
+ parser_environment = subparsers.add_parser("environment",
254
+ aliases=["env"],
255
+ help="Manage COMPSs environments.", # noqa: E501
256
+ parents=[parent_parser],
257
+ formatter_class=FORMATTER_CLASS)
258
+
259
+ parser_environment.set_defaults(action='environment')
260
+
261
+ subparsers_environment = parser_environment.add_subparsers(dest="environment")
262
+
263
+ subparsers_environment.add_parser("list",
264
+ aliases=["l"],
265
+ help="List COMPSs active environments.", # noqa: E501
266
+ formatter_class=FORMATTER_CLASS) # noqa: E501
267
+ parser_environment_change = subparsers_environment.add_parser("change",
268
+ aliases=["c"],
269
+ help="Change current COMPSs environment.", # noqa: E501
270
+ formatter_class=FORMATTER_CLASS)
271
+ parser_environment_change.add_argument("env_id",
272
+ type=str,
273
+ help="ID of the environment to set as active") # noqa: E501
274
+
275
+ parser_environment_remove = subparsers_environment.add_parser("remove",
276
+ aliases=["r"],
277
+ help="Removes COMPSs environment.", # noqa: E501
278
+ formatter_class=FORMATTER_CLASS) # noqa: E501
279
+
280
+ parser_environment_remove.add_argument("-f", "--force",
281
+ action='store_true',
282
+ default=False,
283
+ help="Force deleting de environment and the applications")
284
+
285
+ parser_environment_remove.add_argument("env_id",
286
+ nargs="+",
287
+ type=str,
288
+ help="ID of the environment to remove") # noqa: E501
289
+
290
+ # INSPECT
291
+ parser_environment = subparsers.add_parser("inspect",
292
+ aliases=["ins"],
293
+ help="Inspect RO-Crate(s) from a COMPSs application run.", # noqa: E501
294
+ parents=[parent_parser],
295
+ formatter_class=FORMATTER_CLASS)
296
+
297
+ parser_environment.set_defaults(action='inspect')
298
+
299
+ parser_environment.add_argument("ro_crate",
300
+ type=str,
301
+ nargs='+',
302
+ help="Folder or zip file(s) containing the RO-Crate(s)")
303
+
304
+ # Check if the user does not include any argument
305
+ if len(sys.argv) < 2:
306
+ print(parser.print_help())
307
+ sys.exit(1)
308
+
309
+ arguments, leftovers = parser.parse_known_args()
310
+ if leftovers:
311
+ arguments.rest_args = leftovers + arguments.rest_args
312
+
313
+ return arguments