xmipp3-installer 1.0.1__py3-none-any.whl → 1.1.0__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.
- xmipp3_installer/__main__.py +1 -1
- xmipp3_installer/api_client/api_client.py +35 -34
- xmipp3_installer/api_client/assembler/installation_info_assembler.py +140 -145
- xmipp3_installer/application/cli/arguments/__init__.py +3 -2
- xmipp3_installer/application/cli/arguments/modes.py +112 -95
- xmipp3_installer/application/cli/arguments/params.py +63 -53
- xmipp3_installer/application/cli/cli.py +171 -190
- xmipp3_installer/application/cli/parsers/base_help_formatter.py +256 -235
- xmipp3_installer/application/cli/parsers/error_handler_parser.py +53 -53
- xmipp3_installer/application/cli/parsers/format.py +22 -22
- xmipp3_installer/application/cli/parsers/general_help_formatter.py +102 -84
- xmipp3_installer/application/cli/parsers/mode_help_formatter.py +144 -105
- xmipp3_installer/application/logger/__init__.py +5 -0
- xmipp3_installer/application/logger/errors.py +8 -8
- xmipp3_installer/application/logger/logger.py +218 -215
- xmipp3_installer/application/logger/predefined_messages.py +42 -35
- xmipp3_installer/application/user_interactions.py +6 -0
- xmipp3_installer/installer/constants/paths.py +6 -0
- xmipp3_installer/installer/handlers/cmake/cmake_handler.py +49 -53
- xmipp3_installer/installer/handlers/conda_handler.py +6 -6
- xmipp3_installer/installer/handlers/generic_package_handler.py +9 -9
- xmipp3_installer/installer/handlers/git_handler.py +152 -153
- xmipp3_installer/installer/handlers/shell_handler.py +87 -88
- xmipp3_installer/installer/handlers/versions_manager.py +20 -6
- xmipp3_installer/installer/installer_service.py +22 -8
- xmipp3_installer/installer/modes/mode_all_executor.py +61 -51
- xmipp3_installer/installer/modes/mode_clean/mode_clean_all_executor.py +44 -36
- xmipp3_installer/installer/modes/mode_clean/mode_clean_bin_executor.py +84 -74
- xmipp3_installer/installer/modes/mode_clean/mode_clean_executor.py +48 -34
- xmipp3_installer/installer/modes/mode_cmake/mode_cmake_executor.py +60 -47
- xmipp3_installer/installer/modes/mode_cmake/mode_compile_and_install_executor.py +52 -39
- xmipp3_installer/installer/modes/mode_cmake/mode_config_build_executor.py +68 -49
- xmipp3_installer/installer/modes/mode_config_executor.py +44 -33
- xmipp3_installer/installer/modes/mode_executor.py +14 -13
- xmipp3_installer/installer/modes/mode_get_sources_executor.py +121 -112
- xmipp3_installer/installer/modes/mode_git_executor.py +43 -31
- xmipp3_installer/installer/modes/mode_selector.py +6 -0
- xmipp3_installer/installer/modes/mode_sync/mode_add_model_executor.py +97 -83
- xmipp3_installer/installer/modes/mode_sync/mode_get_models_executor.py +53 -41
- xmipp3_installer/installer/modes/mode_sync/mode_sync_executor.py +41 -35
- xmipp3_installer/installer/modes/mode_sync/mode_test_executor.py +144 -77
- xmipp3_installer/installer/modes/mode_version_executor.py +161 -150
- xmipp3_installer/installer/orquestrator.py +24 -24
- xmipp3_installer/installer/urls.py +4 -3
- xmipp3_installer/repository/config.py +225 -227
- xmipp3_installer/repository/config_vars/__init__.py +5 -0
- xmipp3_installer/repository/config_vars/config_values_adapter.py +97 -91
- xmipp3_installer/repository/config_vars/default_values.py +24 -24
- xmipp3_installer/repository/config_vars/variables.py +9 -9
- xmipp3_installer/repository/invalid_config_line.py +17 -0
- xmipp3_installer/shared/file_operations.py +14 -12
- xmipp3_installer/shared/singleton.py +16 -17
- xmipp3_installer-1.1.0.dist-info/METADATA +86 -0
- xmipp3_installer-1.1.0.dist-info/RECORD +70 -0
- {xmipp3_installer-1.0.1.dist-info → xmipp3_installer-1.1.0.dist-info}/WHEEL +1 -1
- xmipp3_installer-1.0.1.dist-info/METADATA +0 -729
- xmipp3_installer-1.0.1.dist-info/RECORD +0 -70
- {xmipp3_installer-1.0.1.dist-info → xmipp3_installer-1.1.0.dist-info}/entry_points.txt +0 -0
- /xmipp3_installer-1.0.1.dist-info/LICENSE → /xmipp3_installer-1.1.0.dist-info/licenses/LICENSE.txt +0 -0
- {xmipp3_installer-1.0.1.dist-info → xmipp3_installer-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""### Containis all param constants needed for the argument parsing part of Xmipp's installation."""
|
|
2
2
|
|
|
3
|
-
from xmipp3_installer.application.cli
|
|
3
|
+
from xmipp3_installer.application.cli import arguments
|
|
4
4
|
|
|
5
5
|
# Definition of all params found in the
|
|
6
6
|
SHORT_VERSION = 'short'
|
|
@@ -14,6 +14,8 @@ PARAM_BRANCH = 'branch'
|
|
|
14
14
|
PARAM_MODELS_DIRECTORY = 'directory'
|
|
15
15
|
PARAM_TEST_NAMES = 'testNames'
|
|
16
16
|
PARAM_SHOW_TESTS = 'show'
|
|
17
|
+
PARAM_ALL_FUNCTIONS = 'all_functions'
|
|
18
|
+
PARAM_ALL_PROGRAMS = 'all_programs'
|
|
17
19
|
PARAM_GIT_COMMAND = 'command'
|
|
18
20
|
PARAM_LOGIN = 'login'
|
|
19
21
|
PARAM_MODEL_PATH = 'modelPath'
|
|
@@ -21,56 +23,64 @@ PARAM_UPDATE = 'update'
|
|
|
21
23
|
PARAM_OVERWRITE = 'overwrite'
|
|
22
24
|
PARAM_KEEP_OUTPUT = "keep_output"
|
|
23
25
|
PARAMS = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
26
|
+
PARAM_SHORT: {
|
|
27
|
+
LONG_VERSION: "--short",
|
|
28
|
+
DESCRIPTION: "If set, only version number is shown."
|
|
29
|
+
},
|
|
30
|
+
PARAM_JOBS: {
|
|
31
|
+
SHORT_VERSION: "-j",
|
|
32
|
+
LONG_VERSION: "--jobs",
|
|
33
|
+
DESCRIPTION: "Number of jobs. Defaults to all available."
|
|
34
|
+
},
|
|
35
|
+
PARAM_BRANCH: {
|
|
36
|
+
SHORT_VERSION: "-b",
|
|
37
|
+
LONG_VERSION: "--branch",
|
|
38
|
+
DESCRIPTION: "Branch for the source repositories."
|
|
39
|
+
},
|
|
40
|
+
PARAM_MODELS_DIRECTORY: {
|
|
41
|
+
SHORT_VERSION: "-d",
|
|
42
|
+
LONG_VERSION: "--directory",
|
|
43
|
+
DESCRIPTION: f"Directory where models will be saved. Default is \"{arguments.DEFAULT_MODELS_DIR}\"."
|
|
44
|
+
},
|
|
45
|
+
PARAM_TEST_NAMES: {
|
|
46
|
+
SHORT_VERSION: PARAM_TEST_NAMES,
|
|
47
|
+
DESCRIPTION: "Name of the tests to run."
|
|
48
|
+
},
|
|
49
|
+
PARAM_SHOW_TESTS: {
|
|
50
|
+
LONG_VERSION: "--show",
|
|
51
|
+
DESCRIPTION: "Shows the tests available and how to invoke those."
|
|
52
|
+
},
|
|
53
|
+
PARAM_ALL_FUNCTIONS : {
|
|
54
|
+
LONG_VERSION: "--all-functions",
|
|
55
|
+
DESCRIPTION: "If set, all function tests will be run."
|
|
56
|
+
},
|
|
57
|
+
PARAM_ALL_PROGRAMS : {
|
|
58
|
+
LONG_VERSION: "--all-programs",
|
|
59
|
+
DESCRIPTION: "If set, all program tests will be run."
|
|
60
|
+
},
|
|
61
|
+
PARAM_GIT_COMMAND: {
|
|
62
|
+
SHORT_VERSION: PARAM_GIT_COMMAND,
|
|
63
|
+
DESCRIPTION: "Git command to run on all source repositories."
|
|
64
|
+
},
|
|
65
|
+
PARAM_LOGIN: {
|
|
66
|
+
SHORT_VERSION: "login",
|
|
67
|
+
DESCRIPTION: "Login (usr@server) for remote host to upload the model with. Must have write permissions to such machine."
|
|
68
|
+
},
|
|
69
|
+
PARAM_MODEL_PATH: {
|
|
70
|
+
SHORT_VERSION: PARAM_MODEL_PATH,
|
|
71
|
+
DESCRIPTION: "Path to the model to upload to remote host."
|
|
72
|
+
},
|
|
73
|
+
PARAM_UPDATE: {
|
|
74
|
+
LONG_VERSION: "--update",
|
|
75
|
+
DESCRIPTION: "Flag to update an existing model"
|
|
76
|
+
},
|
|
77
|
+
PARAM_OVERWRITE: {
|
|
78
|
+
SHORT_VERSION: "-o",
|
|
79
|
+
LONG_VERSION: "--overwrite",
|
|
80
|
+
DESCRIPTION: "If set, current config file will be overwritten with a new one."
|
|
81
|
+
},
|
|
82
|
+
PARAM_KEEP_OUTPUT: {
|
|
83
|
+
LONG_VERSION: "--keep-output",
|
|
84
|
+
DESCRIPTION: "If set, output sent through the terminal won't substitute lines, looking more like the log."
|
|
85
|
+
}
|
|
76
86
|
}
|
|
@@ -16,256 +16,237 @@ from xmipp3_installer.application.logger.logger import logger
|
|
|
16
16
|
from xmipp3_installer.installer import installer_service
|
|
17
17
|
|
|
18
18
|
def main():
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
"""### Main entry point function that starts the execution."""
|
|
20
|
+
parser = __generate_parser()
|
|
21
|
+
parser = __add_params(parser)
|
|
22
|
+
__add_default_usage_mode()
|
|
23
|
+
args = vars(parser.parse_args())
|
|
24
|
+
__validate_args(args, parser)
|
|
25
|
+
installation_manager = installer_service.InstallationManager(args)
|
|
26
|
+
ret_code = installation_manager.run_installer()
|
|
27
|
+
sys.exit(ret_code)
|
|
28
28
|
|
|
29
29
|
def __generate_parser() -> argparse.ArgumentParser:
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
"""
|
|
31
|
+
### Generates an argument parser for the installer.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
#### Returns:
|
|
34
|
+
- (ArgumentParser): Argument parser.
|
|
35
|
+
"""
|
|
36
|
+
return ErrorHandlerArgumentParser(
|
|
37
|
+
prog=arguments.XMIPP_PROGRAM_NAME,
|
|
38
|
+
formatter_class=GeneralHelpFormatter,
|
|
39
|
+
)
|
|
40
40
|
|
|
41
41
|
def __add_params(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
"""
|
|
43
|
+
### Inserts the params into the given parser.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
#### Params:
|
|
46
|
+
- parser (ArgumentParser): Argument parser.
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
#### Returns:
|
|
49
|
+
- (ArgumentParser): Argument parser with inserted params.
|
|
50
|
+
"""
|
|
51
|
+
subparsers = parser.add_subparsers(dest=modes.MODE)
|
|
52
|
+
default_jobs = __get_default_job_number()
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
add_model_subparser = subparsers.add_parser(modes.MODE_ADD_MODEL, formatter_class=ModeHelpFormatter)
|
|
55
|
+
__add_params_mode_add_model(add_model_subparser)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
all_subparser = subparsers.add_parser(modes.MODE_ALL, formatter_class=ModeHelpFormatter)
|
|
58
|
+
__add_params_mode_all(all_subparser, default_jobs)
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
subparsers.add_parser(modes.MODE_CLEAN_ALL, formatter_class=ModeHelpFormatter)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
subparsers.add_parser(modes.MODE_CLEAN_BIN, formatter_class=ModeHelpFormatter)
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
compile_and_install_subparser = subparsers.add_parser(modes.MODE_COMPILE_AND_INSTALL, formatter_class=ModeHelpFormatter)
|
|
65
|
+
__add_params_mode_compile_and_install(compile_and_install_subparser, default_jobs)
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
build_config_subparser = subparsers.add_parser(modes.MODE_CONFIG_BUILD, formatter_class=ModeHelpFormatter)
|
|
68
|
+
__add_params_mode_config_build(build_config_subparser)
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
config_subparser = subparsers.add_parser(modes.MODE_CONFIG, formatter_class=ModeHelpFormatter)
|
|
71
|
+
__add_params_mode_config(config_subparser)
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
get_models_subparser = subparsers.add_parser(modes.MODE_GET_MODELS, formatter_class=ModeHelpFormatter)
|
|
74
|
+
__add_params_mode_get_models(get_models_subparser)
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
get_sources_subparser = subparsers.add_parser(modes.MODE_GET_SOURCES, formatter_class=ModeHelpFormatter)
|
|
77
|
+
__add_params_mode_get_sources(get_sources_subparser)
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
git_subparser = subparsers.add_parser(modes.MODE_GIT, formatter_class=ModeHelpFormatter)
|
|
80
|
+
__add_params_mode_git(git_subparser)
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
test_subparser = subparsers.add_parser(modes.MODE_TEST, formatter_class=ModeHelpFormatter)
|
|
83
|
+
__add_params_mode_test(test_subparser)
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
version_subparser = subparsers.add_parser(modes.MODE_VERSION, formatter_class=ModeHelpFormatter)
|
|
86
|
+
__add_params_mode_version(version_subparser)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
return parser
|
|
89
89
|
|
|
90
90
|
def __add_params_mode_add_model(subparser: argparse.ArgumentParser):
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
"""
|
|
92
|
+
### Adds params for mode "addModel".
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
#### Params:
|
|
95
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
96
|
+
"""
|
|
97
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_LOGIN))
|
|
98
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_MODEL_PATH))
|
|
99
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_UPDATE), action='store_true')
|
|
100
100
|
|
|
101
101
|
def __add_params_mode_all(subparser: argparse.ArgumentParser, default_jobs: int):
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
"""
|
|
103
|
+
### Adds params for mode "all".
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
#### Params:
|
|
106
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
107
|
+
- default_jobs (int): Default number of jobs to run the task.
|
|
108
|
+
"""
|
|
109
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_JOBS), type=int, default=default_jobs)
|
|
110
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_BRANCH))
|
|
111
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_KEEP_OUTPUT), action='store_true')
|
|
112
112
|
|
|
113
113
|
def __add_params_mode_compile_and_install(subparser: argparse.ArgumentParser, default_jobs: int):
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
"""
|
|
115
|
+
### Adds params for mode "compileAndInstall".
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
#### Params:
|
|
118
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
119
|
+
- default_jobs (int): Default number of jobs to run the task.
|
|
120
|
+
"""
|
|
121
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_JOBS), type=int, default=default_jobs)
|
|
122
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_BRANCH))
|
|
123
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_KEEP_OUTPUT), action='store_true')
|
|
124
124
|
|
|
125
125
|
def __add_params_mode_config_build(subparser: argparse.ArgumentParser):
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
"""
|
|
127
|
+
### Adds params for mode "configBuild".
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
#### Params:
|
|
130
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
131
|
+
"""
|
|
132
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_KEEP_OUTPUT), action='store_true')
|
|
133
133
|
|
|
134
134
|
def __add_params_mode_config(subparser: argparse.ArgumentParser):
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
"""
|
|
136
|
+
### Adds params for mode "config".
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
#### Params:
|
|
139
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
140
|
+
"""
|
|
141
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_OVERWRITE), action='store_true')
|
|
142
142
|
|
|
143
143
|
def __add_params_mode_get_models(subparser: argparse.ArgumentParser):
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
"""
|
|
145
|
+
### Adds params for mode "getModels".
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
#### Params:
|
|
148
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
149
|
+
"""
|
|
150
|
+
subparser.add_argument(
|
|
151
|
+
*format.get_param_names(params.PARAM_MODELS_DIRECTORY),
|
|
152
|
+
default=os.path.abspath(arguments.DEFAULT_MODELS_DIR)
|
|
153
|
+
)
|
|
154
154
|
|
|
155
155
|
def __add_params_mode_get_sources(subparser: argparse.ArgumentParser):
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
"""
|
|
157
|
+
### Adds params for mode "getSources".
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
#### Params:
|
|
160
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
161
|
+
"""
|
|
162
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_BRANCH))
|
|
163
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_KEEP_OUTPUT), action='store_true')
|
|
164
164
|
|
|
165
165
|
def __add_params_mode_git(subparser: argparse.ArgumentParser):
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
"""
|
|
167
|
+
### Adds params for mode "git".
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
#### Params:
|
|
170
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
171
|
+
"""
|
|
172
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_GIT_COMMAND), nargs='+')
|
|
173
173
|
|
|
174
174
|
def __add_params_mode_test(subparser: argparse.ArgumentParser):
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
"""
|
|
176
|
+
### Adds params for mode "test".
|
|
177
|
+
|
|
178
|
+
#### Params:
|
|
179
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
180
|
+
"""
|
|
181
|
+
group = subparser.add_mutually_exclusive_group(required=True)
|
|
182
|
+
group.add_argument(*format.get_param_names(params.PARAM_TEST_NAMES), nargs='*', default=[])
|
|
183
|
+
group.add_argument(*format.get_param_names(params.PARAM_SHOW_TESTS), action='store_true')
|
|
184
|
+
group.add_argument(*format.get_param_names(params.PARAM_ALL_FUNCTIONS), action='store_true')
|
|
185
|
+
group.add_argument(*format.get_param_names(params.PARAM_ALL_PROGRAMS), action='store_true')
|
|
183
186
|
|
|
184
187
|
def __add_params_mode_version(subparser: argparse.ArgumentParser):
|
|
185
|
-
|
|
186
|
-
|
|
188
|
+
"""
|
|
189
|
+
### Adds params for mode "version".
|
|
187
190
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
#### Params:
|
|
192
|
+
- subparser (ArgumentParser): Subparser to add the params to.
|
|
193
|
+
"""
|
|
194
|
+
subparser.add_argument(*format.get_param_names(params.PARAM_SHORT), action='store_true')
|
|
192
195
|
|
|
193
196
|
def __get_default_job_number() -> int:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
Returned number will be 120% of CPU cores, due to not all jobs taking
|
|
197
|
-
100% of CPU time continuously.
|
|
198
|
-
|
|
199
|
-
#### Returns:
|
|
200
|
-
- (int): Default number of jobs.
|
|
201
|
-
"""
|
|
202
|
-
return multiprocessing.cpu_count() + int(multiprocessing.cpu_count() * 0.2)
|
|
203
|
-
|
|
204
|
-
def __get_project_root_subpath(subpath: str) -> str:
|
|
205
|
-
"""
|
|
206
|
-
### Returns a subpath of Xmipp's root directory.
|
|
207
|
-
|
|
208
|
-
#### Params:
|
|
209
|
-
- subpath (str): Subpath inside the root directory.
|
|
210
|
-
|
|
211
|
-
#### Returns:
|
|
212
|
-
- (str): Absolute path to given subpath.
|
|
213
|
-
"""
|
|
214
|
-
return os.path.join(__get_project_root_dir(), subpath)
|
|
197
|
+
"""
|
|
198
|
+
### Gets the default number of jobs to be used by parallelizable tasks.
|
|
215
199
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
### Returns the root directory of Xmipp.
|
|
200
|
+
Returned number will be 120% of CPU cores, due to not all jobs taking
|
|
201
|
+
100% of CPU time continuously.
|
|
219
202
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
203
|
+
#### Returns:
|
|
204
|
+
- (int): Default number of jobs.
|
|
205
|
+
"""
|
|
206
|
+
return multiprocessing.cpu_count() + int(multiprocessing.cpu_count() * 0.2)
|
|
224
207
|
|
|
225
208
|
def __add_default_usage_mode():
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
):
|
|
234
|
-
sys.argv.insert(1, modes.MODE_ALL)
|
|
209
|
+
"""### Sets the usage mode as the default one when a mode has not been specifically provided."""
|
|
210
|
+
no_args_provided = len(sys.argv) == 1
|
|
211
|
+
args_provided = len(sys.argv) > 1
|
|
212
|
+
if no_args_provided or (
|
|
213
|
+
args_provided and __is_first_arg_optional() and not __help_requested()
|
|
214
|
+
):
|
|
215
|
+
sys.argv.insert(1, modes.MODE_ALL)
|
|
235
216
|
|
|
236
217
|
def __is_first_arg_optional() -> bool:
|
|
237
|
-
|
|
238
|
-
|
|
218
|
+
"""
|
|
219
|
+
### Returns True if the first argument provided is optional.
|
|
239
220
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
221
|
+
#### Returns:
|
|
222
|
+
- (bool): True if the first argument received is optional.
|
|
223
|
+
"""
|
|
224
|
+
return sys.argv[1].startswith('-')
|
|
244
225
|
|
|
245
226
|
def __help_requested() -> bool:
|
|
246
|
-
|
|
247
|
-
|
|
227
|
+
"""
|
|
228
|
+
### Returns True if help is at least one of the args.
|
|
248
229
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
230
|
+
#### Returns:
|
|
231
|
+
- (bool): True if help is at least one of the args.
|
|
232
|
+
"""
|
|
233
|
+
return '-h' in sys.argv or '--help' in sys.argv
|
|
253
234
|
|
|
254
235
|
def __validate_args(args: Dict[str, Any], parser: argparse.ArgumentParser):
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
236
|
+
"""
|
|
237
|
+
### Performs validations on the arguments.
|
|
238
|
+
|
|
239
|
+
#### Params:
|
|
240
|
+
- args (dict(str, any)): Arguments to be validated.
|
|
241
|
+
- parser (ArgumentParser): Argument parser.
|
|
242
|
+
"""
|
|
243
|
+
jobs = args.get('jobs', 1)
|
|
244
|
+
if jobs < 1:
|
|
245
|
+
parser.error(f"Wrong job number \"{jobs}\". Number of jobs has to be 1 or greater.")
|
|
246
|
+
|
|
247
|
+
branch = args.get('branch')
|
|
248
|
+
if branch is not None and len(branch.split(' ')) > 1:
|
|
249
|
+
parser.error(f"Incorrect branch name \"{branch}\". Branch names can only be one word long.")
|
|
250
|
+
|
|
251
|
+
if args.get('keep_output', False):
|
|
252
|
+
logger.set_allow_substitution(False)
|