xmipp3-installer 1.0.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/__init__.py +1 -0
- xmipp3_installer/__main__.py +6 -0
- xmipp3_installer/api_client/api_client.py +50 -0
- xmipp3_installer/api_client/assembler/installation_info_assembler.py +181 -0
- xmipp3_installer/application/__init__.py +1 -0
- xmipp3_installer/application/cli/__init__.py +1 -0
- xmipp3_installer/application/cli/arguments/__init__.py +8 -0
- xmipp3_installer/application/cli/arguments/modes.py +130 -0
- xmipp3_installer/application/cli/arguments/params.py +76 -0
- xmipp3_installer/application/cli/cli.py +271 -0
- xmipp3_installer/application/cli/parsers/base_help_formatter.py +244 -0
- xmipp3_installer/application/cli/parsers/error_handler_parser.py +68 -0
- xmipp3_installer/application/cli/parsers/format.py +35 -0
- xmipp3_installer/application/cli/parsers/general_help_formatter.py +92 -0
- xmipp3_installer/application/cli/parsers/mode_help_formatter.py +115 -0
- xmipp3_installer/application/logger/__init__.py +0 -0
- xmipp3_installer/application/logger/errors.py +28 -0
- xmipp3_installer/application/logger/logger.py +230 -0
- xmipp3_installer/application/logger/predefined_messages.py +66 -0
- xmipp3_installer/application/user_interactions.py +16 -0
- xmipp3_installer/installer/__init__.py +1 -0
- xmipp3_installer/installer/constants/__init__.py +17 -0
- xmipp3_installer/installer/constants/paths.py +32 -0
- xmipp3_installer/installer/handlers/__init__.py +1 -0
- xmipp3_installer/installer/handlers/cmake/__init__.py +1 -0
- xmipp3_installer/installer/handlers/cmake/cmake_constants.py +27 -0
- xmipp3_installer/installer/handlers/cmake/cmake_handler.py +69 -0
- xmipp3_installer/installer/handlers/conda_handler.py +13 -0
- xmipp3_installer/installer/handlers/generic_package_handler.py +18 -0
- xmipp3_installer/installer/handlers/git_handler.py +185 -0
- xmipp3_installer/installer/handlers/shell_handler.py +114 -0
- xmipp3_installer/installer/handlers/versions_manager.py +98 -0
- xmipp3_installer/installer/installer_service.py +66 -0
- xmipp3_installer/installer/modes/__init__.py +1 -0
- xmipp3_installer/installer/modes/mode_all_executor.py +63 -0
- xmipp3_installer/installer/modes/mode_clean/__init__.py +1 -0
- xmipp3_installer/installer/modes/mode_clean/mode_clean_all_executor.py +44 -0
- xmipp3_installer/installer/modes/mode_clean/mode_clean_bin_executor.py +94 -0
- xmipp3_installer/installer/modes/mode_clean/mode_clean_executor.py +45 -0
- xmipp3_installer/installer/modes/mode_cmake/__init__.py +1 -0
- xmipp3_installer/installer/modes/mode_cmake/mode_cmake_executor.py +55 -0
- xmipp3_installer/installer/modes/mode_cmake/mode_compile_and_install_executor.py +49 -0
- xmipp3_installer/installer/modes/mode_cmake/mode_config_build_executor.py +64 -0
- xmipp3_installer/installer/modes/mode_config_executor.py +46 -0
- xmipp3_installer/installer/modes/mode_executor.py +43 -0
- xmipp3_installer/installer/modes/mode_get_sources_executor.py +132 -0
- xmipp3_installer/installer/modes/mode_git_executor.py +41 -0
- xmipp3_installer/installer/modes/mode_selector.py +25 -0
- xmipp3_installer/installer/modes/mode_sync/mode_add_model_executor.py +104 -0
- xmipp3_installer/installer/modes/mode_sync/mode_get_models_executor.py +51 -0
- xmipp3_installer/installer/modes/mode_sync/mode_sync_executor.py +48 -0
- xmipp3_installer/installer/modes/mode_sync/mode_test_executor.py +91 -0
- xmipp3_installer/installer/modes/mode_version_executor.py +164 -0
- xmipp3_installer/installer/orquestrator.py +37 -0
- xmipp3_installer/installer/urls.py +8 -0
- xmipp3_installer/repository/__init__.py +1 -0
- xmipp3_installer/repository/config.py +241 -0
- xmipp3_installer/repository/config_vars/__init__.py +0 -0
- xmipp3_installer/repository/config_vars/config_values_adapter.py +107 -0
- xmipp3_installer/repository/config_vars/default_values.py +36 -0
- xmipp3_installer/repository/config_vars/variables.py +48 -0
- xmipp3_installer/repository/invalid_config_line.py +15 -0
- xmipp3_installer/shared/file_operations.py +18 -0
- xmipp3_installer/shared/singleton.py +25 -0
- xmipp3_installer-1.0.0.dist-info/LICENSE +674 -0
- xmipp3_installer-1.0.0.dist-info/METADATA +729 -0
- xmipp3_installer-1.0.0.dist-info/RECORD +70 -0
- xmipp3_installer-1.0.0.dist-info/WHEEL +5 -0
- xmipp3_installer-1.0.0.dist-info/entry_points.txt +2 -0
- xmipp3_installer-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""### Main package containing the installer."""
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""### Contains an API client that registers the installation attempts."""
|
|
2
|
+
|
|
3
|
+
import http.client
|
|
4
|
+
import json
|
|
5
|
+
from typing import Dict
|
|
6
|
+
from urllib.parse import urlparse, ParseResult
|
|
7
|
+
|
|
8
|
+
from xmipp3_installer.installer import urls
|
|
9
|
+
from xmipp3_installer.application.logger.logger import logger
|
|
10
|
+
|
|
11
|
+
def send_installation_attempt(installation_info: Dict):
|
|
12
|
+
"""
|
|
13
|
+
### Sends a POST request to Xmipp's metrics's API.
|
|
14
|
+
|
|
15
|
+
#### Params:
|
|
16
|
+
- installation_info (dict): Dictionary containing all the installation information.
|
|
17
|
+
"""
|
|
18
|
+
if installation_info is None:
|
|
19
|
+
return
|
|
20
|
+
params = json.dumps(installation_info)
|
|
21
|
+
headers = {"Content-type": "application/json"}
|
|
22
|
+
parsed_url = urlparse(urls.API_URL)
|
|
23
|
+
conn = None
|
|
24
|
+
try:
|
|
25
|
+
conn = __get_https_connection(parsed_url, 2)
|
|
26
|
+
conn.request("POST", parsed_url.path, body=params, headers=headers)
|
|
27
|
+
conn.getresponse()
|
|
28
|
+
except TimeoutError:
|
|
29
|
+
logger(
|
|
30
|
+
logger.yellow("There was a timeout while sending installation data."),
|
|
31
|
+
show_in_terminal=False
|
|
32
|
+
)
|
|
33
|
+
finally:
|
|
34
|
+
if conn is not None:
|
|
35
|
+
conn.close()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def __get_https_connection(parsed_url: ParseResult, timeout_seconds: int) -> http.client.HTTPSConnection:
|
|
39
|
+
"""
|
|
40
|
+
### Establishes the connection needed to send the API call.
|
|
41
|
+
Separated to enable integration & E2E tests.
|
|
42
|
+
|
|
43
|
+
#### Params:
|
|
44
|
+
- parsed_url (ParseResult): Object containing all elements of the url.
|
|
45
|
+
- timeout_seconds (int): Number of seconds to wait until a timeout.
|
|
46
|
+
|
|
47
|
+
#### Returns:
|
|
48
|
+
- (HTTPSConnection): Established connection.
|
|
49
|
+
"""
|
|
50
|
+
return http.client.HTTPSConnection(parsed_url.hostname, parsed_url.port, timeout=timeout_seconds)
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""### Contains functions to assemble the data dictionary required by the API client."""
|
|
2
|
+
|
|
3
|
+
import getpass
|
|
4
|
+
import hashlib
|
|
5
|
+
import platform
|
|
6
|
+
import re
|
|
7
|
+
import os
|
|
8
|
+
from typing import Optional, List, Dict
|
|
9
|
+
|
|
10
|
+
import distro
|
|
11
|
+
|
|
12
|
+
from xmipp3_installer.installer import constants, orquestrator
|
|
13
|
+
from xmipp3_installer.installer.constants import paths
|
|
14
|
+
from xmipp3_installer.installer.handlers import shell_handler, git_handler, versions_manager
|
|
15
|
+
from xmipp3_installer.installer.handlers.cmake import cmake_constants, cmake_handler
|
|
16
|
+
|
|
17
|
+
def get_installation_info(version_manager: versions_manager.VersionsManager, ret_code: int=0) -> Optional[Dict]:
|
|
18
|
+
"""
|
|
19
|
+
### Creates a dictionary with the necessary data for the API POST message.
|
|
20
|
+
|
|
21
|
+
#### Params:
|
|
22
|
+
- version_manager (VersionsManager): Object containing all the version-related info.
|
|
23
|
+
- ret_code (int): Optional. Return code for the API request.
|
|
24
|
+
|
|
25
|
+
#### Return:
|
|
26
|
+
- (dict | None): Dictionary with the required info or None if user id could not be produced.
|
|
27
|
+
"""
|
|
28
|
+
library_versions = cmake_handler.get_library_versions_from_cmake_file(
|
|
29
|
+
paths.LIBRARY_VERSIONS_FILE
|
|
30
|
+
)
|
|
31
|
+
environment_info = orquestrator.run_parallel_jobs(
|
|
32
|
+
[
|
|
33
|
+
__get_cpu_flags,
|
|
34
|
+
git_handler.get_current_branch,
|
|
35
|
+
git_handler.is_branch_up_to_date,
|
|
36
|
+
__is_installed_by_scipion,
|
|
37
|
+
__get_log_tail
|
|
38
|
+
],
|
|
39
|
+
[(), (), (), (), ()]
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
"user": {
|
|
44
|
+
"userId": __get_user_id()
|
|
45
|
+
},
|
|
46
|
+
"version": {
|
|
47
|
+
"os": get_os_release_name(),
|
|
48
|
+
"cpuFlags": environment_info[0],
|
|
49
|
+
"cuda": library_versions.get(cmake_constants.CMAKE_CUDA),
|
|
50
|
+
"cmake": library_versions.get(cmake_constants.CMAKE_CMAKE),
|
|
51
|
+
"gcc": library_versions.get(cmake_constants.CMAKE_GCC),
|
|
52
|
+
"gpp": library_versions.get(cmake_constants.CMAKE_GPP),
|
|
53
|
+
"mpi": library_versions.get(cmake_constants.CMAKE_MPI),
|
|
54
|
+
"python": library_versions.get(cmake_constants.CMAKE_PYTHON),
|
|
55
|
+
"sqlite": library_versions.get(cmake_constants.CMAKE_SQLITE),
|
|
56
|
+
"java": library_versions.get(cmake_constants.CMAKE_JAVA),
|
|
57
|
+
"hdf5": library_versions.get(cmake_constants.CMAKE_HDF5),
|
|
58
|
+
"jpeg": library_versions.get(cmake_constants.CMAKE_JPEG)
|
|
59
|
+
},
|
|
60
|
+
"xmipp": {
|
|
61
|
+
"branch": __get_installation_branch_name(
|
|
62
|
+
environment_info[1], version_manager
|
|
63
|
+
),
|
|
64
|
+
"updated": environment_info[2],
|
|
65
|
+
"installedByScipion": environment_info[3]
|
|
66
|
+
},
|
|
67
|
+
"returnCode": ret_code,
|
|
68
|
+
"logTail": environment_info[4] if ret_code else None # Only needed if something went wrong
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def get_os_release_name() -> str:
|
|
72
|
+
"""
|
|
73
|
+
### Returns the name of the current system OS release.
|
|
74
|
+
|
|
75
|
+
#### Returns:
|
|
76
|
+
- (str): OS release name.
|
|
77
|
+
"""
|
|
78
|
+
platform_system = platform.system()
|
|
79
|
+
if platform_system == "Linux":
|
|
80
|
+
return f"{distro.name()} {distro.version()}"
|
|
81
|
+
return f"{platform_system} {platform.release()}"
|
|
82
|
+
|
|
83
|
+
def __get_installation_branch_name(branch_name: str, version_manager: versions_manager.VersionsManager) -> str:
|
|
84
|
+
"""
|
|
85
|
+
### Returns the branch or release name of Xmipp.
|
|
86
|
+
|
|
87
|
+
#### Params:
|
|
88
|
+
- branch_name (str): Retrieved branch name.
|
|
89
|
+
- version_manager (VersionsManager): Object containing all the version-related info.
|
|
90
|
+
|
|
91
|
+
#### Return:
|
|
92
|
+
- (str): Release name if Xmipp is in a release branch, or the branch name otherwise.
|
|
93
|
+
"""
|
|
94
|
+
if not branch_name or branch_name == constants.MASTER_BRANCHNAME:
|
|
95
|
+
return version_manager.xmipp_version_number
|
|
96
|
+
return branch_name
|
|
97
|
+
|
|
98
|
+
def __get_user_id() -> str:
|
|
99
|
+
"""
|
|
100
|
+
### Returns the unique user id for this machine.
|
|
101
|
+
|
|
102
|
+
#### Returns:
|
|
103
|
+
- (str): User id, or 'Anoymous' if there were any errors.
|
|
104
|
+
"""
|
|
105
|
+
identifier = __get_mac_address()
|
|
106
|
+
if not identifier:
|
|
107
|
+
identifier = getpass.getuser()
|
|
108
|
+
if not identifier:
|
|
109
|
+
return "Anonymous"
|
|
110
|
+
|
|
111
|
+
sha256 = hashlib.sha256()
|
|
112
|
+
sha256.update(identifier.encode())
|
|
113
|
+
return sha256.hexdigest()
|
|
114
|
+
|
|
115
|
+
def __get_cpu_flags() -> List[str]:
|
|
116
|
+
"""
|
|
117
|
+
### This function obtains the list of compilation flags supported by the CPU.
|
|
118
|
+
|
|
119
|
+
#### Returns:
|
|
120
|
+
- (list(str)): List of flags supported by the CPU.
|
|
121
|
+
"""
|
|
122
|
+
flags_header = "Flags:"
|
|
123
|
+
ret_code, flags_line = shell_handler.run_shell_command(f'lscpu | grep \"{flags_header}\"')
|
|
124
|
+
if ret_code:
|
|
125
|
+
return []
|
|
126
|
+
flags_line = flags_line.replace(flags_header, "").strip()
|
|
127
|
+
return [flag for flag in flags_line.split(" ") if flag]
|
|
128
|
+
|
|
129
|
+
def __get_log_tail() -> Optional[str]:
|
|
130
|
+
"""
|
|
131
|
+
### Returns the last lines of the installation log.
|
|
132
|
+
|
|
133
|
+
#### Returns:
|
|
134
|
+
- (str | None): Installation log's last lines, or None if there were any errors.
|
|
135
|
+
"""
|
|
136
|
+
ret_code, output = shell_handler.run_shell_command(
|
|
137
|
+
f"tail -n {constants.TAIL_LOG_NCHARS} {paths.LOG_FILE}"
|
|
138
|
+
)
|
|
139
|
+
return output if ret_code == 0 else None
|
|
140
|
+
|
|
141
|
+
def __get_mac_address() -> Optional[str]:
|
|
142
|
+
"""
|
|
143
|
+
### Returns a physical MAC address for this machine. It prioritizes ethernet over wireless.
|
|
144
|
+
|
|
145
|
+
#### Returns:
|
|
146
|
+
- (str | None): MAC address, or None if there were any errors.
|
|
147
|
+
"""
|
|
148
|
+
ret_code, output = shell_handler.run_shell_command("ip addr")
|
|
149
|
+
return __find_mac_address_in_lines(output.split('\n')) if ret_code == 0 else None
|
|
150
|
+
|
|
151
|
+
def __find_mac_address_in_lines(lines: List[str]) -> Optional[str]:
|
|
152
|
+
"""
|
|
153
|
+
### Returns a physical MAC address within the text lines provided.
|
|
154
|
+
|
|
155
|
+
#### Params:
|
|
156
|
+
- lines (list(str)): Lines of text where MAC address should be looked for.
|
|
157
|
+
|
|
158
|
+
#### Returns:
|
|
159
|
+
- (str | None): MAC address if found, None otherwise.
|
|
160
|
+
"""
|
|
161
|
+
for line_index in range(len(lines) - 1):
|
|
162
|
+
line = lines[line_index]
|
|
163
|
+
match = re.match(r"^\d+: (enp|wlp|eth|ens|eno)\w+", line)
|
|
164
|
+
if not match:
|
|
165
|
+
continue
|
|
166
|
+
interface_name = match.group(1)
|
|
167
|
+
if interface_name.startswith(('enp', 'wlp', 'eth', 'ens', 'eno')):
|
|
168
|
+
return re.search(
|
|
169
|
+
r"link/ether ([0-9a-f:]{17})",
|
|
170
|
+
lines[line_index + 1]
|
|
171
|
+
).group(1)
|
|
172
|
+
return None
|
|
173
|
+
|
|
174
|
+
def __is_installed_by_scipion() -> bool:
|
|
175
|
+
"""
|
|
176
|
+
### Checks if the current xmipp installation is being carried out from Scipion.
|
|
177
|
+
|
|
178
|
+
#### Returns:
|
|
179
|
+
- (bool): True if the installation is executed by Scipion, False otherwise.
|
|
180
|
+
"""
|
|
181
|
+
return bool(os.getenv("SCIPION_SOFTWARE"))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""### Contains application modules that are used or interact with the main package."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""### CLI related modules."""
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""### Containis all common constants needed for the argument parsing part of Xmipp's installation."""
|
|
2
|
+
|
|
3
|
+
XMIPP_PROGRAM_NAME = "xmipp"
|
|
4
|
+
|
|
5
|
+
# Other variables
|
|
6
|
+
COMMON_USAGE_HELP_MESSAGE = 'Run \"./xmipp -h\" for usage help.'
|
|
7
|
+
DEFAULT_BUILD_DIR = 'build'
|
|
8
|
+
DEFAULT_MODELS_DIR = DEFAULT_BUILD_DIR
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""### Containis all mode constants needed for the argument parsing part of Xmipp's installation."""
|
|
2
|
+
|
|
3
|
+
from xmipp3_installer.application.cli import arguments
|
|
4
|
+
from xmipp3_installer.application.cli.arguments.params import (
|
|
5
|
+
PARAM_SHORT, PARAM_JOBS, PARAM_BRANCH, PARAM_KEEP_OUTPUT, PARAM_OVERWRITE,
|
|
6
|
+
PARAM_MODELS_DIRECTORY, PARAM_TEST_NAMES, PARAM_SHOW_TESTS, PARAM_GIT_COMMAND,
|
|
7
|
+
PARAM_LOGIN, PARAM_MODEL_PATH, PARAM_UPDATE, PARAMS, SHORT_VERSION, LONG_VERSION
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
MODE = "mode"
|
|
11
|
+
|
|
12
|
+
# Mode list (alphabetical order)
|
|
13
|
+
MODE_ADD_MODEL = 'addModel'
|
|
14
|
+
MODE_ALL = 'all'
|
|
15
|
+
MODE_CLEAN_ALL = 'cleanAll'
|
|
16
|
+
MODE_CLEAN_BIN = 'cleanBin'
|
|
17
|
+
MODE_COMPILE_AND_INSTALL = 'compileAndInstall'
|
|
18
|
+
MODE_CONFIG_BUILD = 'configBuild'
|
|
19
|
+
MODE_CONFIG = 'config'
|
|
20
|
+
MODE_GET_MODELS = 'getModels'
|
|
21
|
+
MODE_GET_SOURCES = 'getSources'
|
|
22
|
+
MODE_GIT = 'git'
|
|
23
|
+
MODE_TEST = 'test'
|
|
24
|
+
MODE_VERSION = 'version'
|
|
25
|
+
|
|
26
|
+
# Modes with help message
|
|
27
|
+
MODES = {
|
|
28
|
+
'General': {
|
|
29
|
+
MODE_VERSION: ['Returns the version information. Add \'--short\' to print only the version number.'],
|
|
30
|
+
MODE_COMPILE_AND_INSTALL: ['Compiles and installs Xmipp based on already obtained sources.'],
|
|
31
|
+
MODE_ALL: [f'Default param. Runs {MODE_CONFIG}, {MODE_CONFIG_BUILD}, and {MODE_COMPILE_AND_INSTALL}.'],
|
|
32
|
+
MODE_CONFIG_BUILD: ['Configures the project with CMake.']
|
|
33
|
+
},
|
|
34
|
+
'Config': {
|
|
35
|
+
MODE_CONFIG: ['Generates a config file template with default values.'],
|
|
36
|
+
},
|
|
37
|
+
'Downloads': {
|
|
38
|
+
MODE_GET_MODELS: [f'Download the DeepLearning Models at dir/models ({arguments.DEFAULT_MODELS_DIR} by default).'],
|
|
39
|
+
MODE_GET_SOURCES: ['Clone all Xmipp\'s sources.']
|
|
40
|
+
},
|
|
41
|
+
'Clean': {
|
|
42
|
+
MODE_CLEAN_BIN: ['Removes all compiled binaries.'],
|
|
43
|
+
MODE_CLEAN_ALL: ['Removes all compiled binaries and sources, leaves the repository as if freshly cloned (without pulling).']
|
|
44
|
+
},
|
|
45
|
+
'Test': {
|
|
46
|
+
MODE_TEST: ['Runs a given test.']
|
|
47
|
+
},
|
|
48
|
+
'Developers': {
|
|
49
|
+
MODE_GIT: ['Runs the given git action for all source repositories.'],
|
|
50
|
+
MODE_ADD_MODEL: [
|
|
51
|
+
"Takes a DeepLearning model from the modelPath, makes a tgz of it and uploads the .tgz according to the <login>.",
|
|
52
|
+
"This mode is used to upload a model folder to the Scipion/Xmipp server.",
|
|
53
|
+
"Usually the model folder contains big files used to fed deep learning procedures"
|
|
54
|
+
"with pretrained data. All the models stored in the server will be downloads"
|
|
55
|
+
"using the 'get_models' mode or during the compilation/installation time"
|
|
56
|
+
"or with scipion3 installb deepLearningToolkit modelsPath must be the absolute path.",
|
|
57
|
+
"",
|
|
58
|
+
"Usage: -> ./xmipp addModel <usr@server> <modelsPath> [--update]",
|
|
59
|
+
"Steps: 0. modelName = basename(modelsPath) <- Please, check the folders name!",
|
|
60
|
+
" 1. Packing in 'xmipp_model_modelName.tgz'",
|
|
61
|
+
" 2. Check if that model already exists (use --update to override an existing model)",
|
|
62
|
+
" 3. Upload the model to the server.",
|
|
63
|
+
" 4. Update the MANIFEST file.",
|
|
64
|
+
"",
|
|
65
|
+
"The model name will be the folder name in <modelsPath>",
|
|
66
|
+
"Must have write permisions to such machine."
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Arguments of each mode, sorted by group
|
|
72
|
+
MODE_ARGS = {
|
|
73
|
+
MODE_VERSION: [PARAM_SHORT],
|
|
74
|
+
MODE_COMPILE_AND_INSTALL: [PARAM_JOBS, PARAM_KEEP_OUTPUT],
|
|
75
|
+
MODE_ALL: [PARAM_JOBS, PARAM_BRANCH, PARAM_KEEP_OUTPUT],
|
|
76
|
+
MODE_CONFIG_BUILD: [PARAM_KEEP_OUTPUT],
|
|
77
|
+
MODE_CONFIG: [PARAM_OVERWRITE],
|
|
78
|
+
MODE_GET_MODELS: [PARAM_MODELS_DIRECTORY],
|
|
79
|
+
MODE_GET_SOURCES: [PARAM_BRANCH, PARAM_KEEP_OUTPUT],
|
|
80
|
+
MODE_CLEAN_BIN: [],
|
|
81
|
+
MODE_CLEAN_ALL: [],
|
|
82
|
+
MODE_TEST: [PARAM_TEST_NAMES, PARAM_SHOW_TESTS],
|
|
83
|
+
MODE_GIT: [PARAM_GIT_COMMAND],
|
|
84
|
+
MODE_ADD_MODEL: [PARAM_LOGIN, PARAM_MODEL_PATH, PARAM_UPDATE]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# Examples for the help message of each mode
|
|
88
|
+
MODE_EXAMPLES = {
|
|
89
|
+
MODE_VERSION: [
|
|
90
|
+
f'./xmipp {MODE_VERSION}',
|
|
91
|
+
f'./xmipp {MODE_VERSION} {PARAMS[PARAM_SHORT][LONG_VERSION]}',
|
|
92
|
+
],
|
|
93
|
+
MODE_COMPILE_AND_INSTALL: [
|
|
94
|
+
f'./xmipp {MODE_COMPILE_AND_INSTALL}',
|
|
95
|
+
f'./xmipp {MODE_COMPILE_AND_INSTALL} {PARAMS[PARAM_JOBS][SHORT_VERSION]} 20',
|
|
96
|
+
],
|
|
97
|
+
MODE_ALL: [
|
|
98
|
+
'./xmipp',
|
|
99
|
+
f'./xmipp {MODE_ALL}',
|
|
100
|
+
f'./xmipp {PARAMS[PARAM_JOBS][SHORT_VERSION]} 20',
|
|
101
|
+
f'./xmipp {PARAMS[PARAM_BRANCH][SHORT_VERSION]} devel',
|
|
102
|
+
f'./xmipp {MODE_ALL} {PARAMS[PARAM_JOBS][SHORT_VERSION]} 20 '
|
|
103
|
+
f'{PARAMS[PARAM_BRANCH][SHORT_VERSION]} devel'
|
|
104
|
+
],
|
|
105
|
+
MODE_CONFIG_BUILD: [],
|
|
106
|
+
MODE_CONFIG: [
|
|
107
|
+
f'./xmipp {MODE_CONFIG} {PARAMS[PARAM_OVERWRITE][LONG_VERSION]}'
|
|
108
|
+
],
|
|
109
|
+
MODE_GET_MODELS: [
|
|
110
|
+
f'./xmipp {MODE_GET_MODELS}',
|
|
111
|
+
f'./xmipp {MODE_GET_MODELS} {PARAMS[PARAM_MODELS_DIRECTORY][SHORT_VERSION]} /path/to/my/model/directory'
|
|
112
|
+
],
|
|
113
|
+
MODE_GET_SOURCES: [
|
|
114
|
+
f'./xmipp {MODE_GET_SOURCES}'
|
|
115
|
+
f'./xmipp {MODE_GET_SOURCES} {PARAMS[PARAM_BRANCH][SHORT_VERSION]} devel'
|
|
116
|
+
],
|
|
117
|
+
MODE_CLEAN_BIN: [],
|
|
118
|
+
MODE_CLEAN_ALL: [],
|
|
119
|
+
MODE_TEST: [
|
|
120
|
+
f'./xmipp {MODE_TEST} xmipp_sample_test',
|
|
121
|
+
f'./xmipp {MODE_TEST} {PARAMS[PARAM_SHORT][LONG_VERSION]}',
|
|
122
|
+
],
|
|
123
|
+
MODE_GIT: [
|
|
124
|
+
f'./xmipp {MODE_GIT} pull',
|
|
125
|
+
f'./xmipp {MODE_GIT} checkout devel'
|
|
126
|
+
],
|
|
127
|
+
MODE_ADD_MODEL: [
|
|
128
|
+
f'./xmipp {MODE_ADD_MODEL} myuser@127.0.0.1 /home/myuser/mymodel'
|
|
129
|
+
]
|
|
130
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""### Containis all param constants needed for the argument parsing part of Xmipp's installation."""
|
|
2
|
+
|
|
3
|
+
from xmipp3_installer.application.cli.arguments import DEFAULT_BUILD_DIR
|
|
4
|
+
|
|
5
|
+
# Definition of all params found in the
|
|
6
|
+
SHORT_VERSION = 'short'
|
|
7
|
+
LONG_VERSION = 'long'
|
|
8
|
+
DESCRIPTION = 'description'
|
|
9
|
+
|
|
10
|
+
# Possible param list
|
|
11
|
+
PARAM_SHORT = 'short'
|
|
12
|
+
PARAM_JOBS = 'jobs'
|
|
13
|
+
PARAM_BRANCH = 'branch'
|
|
14
|
+
PARAM_MODELS_DIRECTORY = 'directory'
|
|
15
|
+
PARAM_TEST_NAMES = 'testNames'
|
|
16
|
+
PARAM_SHOW_TESTS = 'show'
|
|
17
|
+
PARAM_GIT_COMMAND = 'command'
|
|
18
|
+
PARAM_LOGIN = 'login'
|
|
19
|
+
PARAM_MODEL_PATH = 'modelPath'
|
|
20
|
+
PARAM_UPDATE = 'update'
|
|
21
|
+
PARAM_OVERWRITE = 'overwrite'
|
|
22
|
+
PARAM_KEEP_OUTPUT = "keep_output"
|
|
23
|
+
PARAMS = {
|
|
24
|
+
PARAM_SHORT: {
|
|
25
|
+
LONG_VERSION: "--short",
|
|
26
|
+
DESCRIPTION: "If set, only version number is shown."
|
|
27
|
+
},
|
|
28
|
+
PARAM_JOBS: {
|
|
29
|
+
SHORT_VERSION: "-j",
|
|
30
|
+
LONG_VERSION: "--jobs",
|
|
31
|
+
DESCRIPTION: "Number of jobs. Defaults to all available."
|
|
32
|
+
},
|
|
33
|
+
PARAM_BRANCH: {
|
|
34
|
+
SHORT_VERSION: "-b",
|
|
35
|
+
LONG_VERSION: "--branch",
|
|
36
|
+
DESCRIPTION: "Branch for the source repositories."
|
|
37
|
+
},
|
|
38
|
+
PARAM_MODELS_DIRECTORY: {
|
|
39
|
+
SHORT_VERSION: "-d",
|
|
40
|
+
LONG_VERSION: "--directory",
|
|
41
|
+
DESCRIPTION: f"Directory where models will be saved. Default is \"{DEFAULT_BUILD_DIR}\"."
|
|
42
|
+
},
|
|
43
|
+
PARAM_TEST_NAMES: {
|
|
44
|
+
SHORT_VERSION: PARAM_TEST_NAMES,
|
|
45
|
+
DESCRIPTION: "Name of the tests to run. If combined with --show, greps the test names from the test list."
|
|
46
|
+
},
|
|
47
|
+
PARAM_SHOW_TESTS: {
|
|
48
|
+
LONG_VERSION: "--show",
|
|
49
|
+
DESCRIPTION: "Shows the tests available and how to invoke those."
|
|
50
|
+
},
|
|
51
|
+
PARAM_GIT_COMMAND: {
|
|
52
|
+
SHORT_VERSION: PARAM_GIT_COMMAND,
|
|
53
|
+
DESCRIPTION: "Git command to run on all source repositories."
|
|
54
|
+
},
|
|
55
|
+
PARAM_LOGIN: {
|
|
56
|
+
SHORT_VERSION: "login",
|
|
57
|
+
DESCRIPTION: "Login (usr@server) for remote host to upload the model with. Must have write permisions to such machine."
|
|
58
|
+
},
|
|
59
|
+
PARAM_MODEL_PATH: {
|
|
60
|
+
SHORT_VERSION: PARAM_MODEL_PATH,
|
|
61
|
+
DESCRIPTION: "Path to the model to upload to remote host."
|
|
62
|
+
},
|
|
63
|
+
PARAM_UPDATE: {
|
|
64
|
+
LONG_VERSION: "--update",
|
|
65
|
+
DESCRIPTION: "Flag to update an existing model"
|
|
66
|
+
},
|
|
67
|
+
PARAM_OVERWRITE: {
|
|
68
|
+
SHORT_VERSION: "-o",
|
|
69
|
+
LONG_VERSION: "--overwrite",
|
|
70
|
+
DESCRIPTION: "If set, current config file will be overwritten with a new one."
|
|
71
|
+
},
|
|
72
|
+
PARAM_KEEP_OUTPUT: {
|
|
73
|
+
LONG_VERSION: "--keep-output",
|
|
74
|
+
DESCRIPTION: "If set, output sent through the terminal won't substitute lines, looking more like the log."
|
|
75
|
+
}
|
|
76
|
+
}
|