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,104 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import tarfile
|
|
3
|
+
from typing import Dict, Tuple
|
|
4
|
+
|
|
5
|
+
from xmipp3_installer.application import user_interactions
|
|
6
|
+
from xmipp3_installer.application.logger import errors
|
|
7
|
+
from xmipp3_installer.application.cli.arguments import params
|
|
8
|
+
from xmipp3_installer.application.logger.logger import logger
|
|
9
|
+
from xmipp3_installer.installer.constants import paths
|
|
10
|
+
from xmipp3_installer.installer.handlers import shell_handler
|
|
11
|
+
from xmipp3_installer.installer.modes.mode_sync.mode_sync_executor import ModeSyncExecutor
|
|
12
|
+
|
|
13
|
+
class ModeAddModelExecutor(ModeSyncExecutor):
|
|
14
|
+
def __init__(self, context: Dict):
|
|
15
|
+
"""
|
|
16
|
+
### Constructor.
|
|
17
|
+
|
|
18
|
+
#### Params:
|
|
19
|
+
- context (dict): Dictionary containing the installation context variables.
|
|
20
|
+
"""
|
|
21
|
+
super().__init__(context)
|
|
22
|
+
self.login = context.pop(params.PARAM_LOGIN)
|
|
23
|
+
self.model_path = context.pop(params.PARAM_MODEL_PATH)
|
|
24
|
+
self.update = context.pop(params.PARAM_UPDATE)
|
|
25
|
+
self.model_dir = os.path.dirname(self.model_path)
|
|
26
|
+
self.model_name = os.path.basename(self.model_path)
|
|
27
|
+
self.tar_file_name = f"xmipp_model_{self.model_name}.tgz"
|
|
28
|
+
self.tar_file_path = os.path.join(self.model_dir, self.tar_file_name)
|
|
29
|
+
|
|
30
|
+
def _sync_operation(self) -> Tuple[int, str]:
|
|
31
|
+
"""
|
|
32
|
+
### Uploads the model to the remote server.
|
|
33
|
+
|
|
34
|
+
#### Returns:
|
|
35
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
36
|
+
"""
|
|
37
|
+
if not os.path.isdir(self.model_path):
|
|
38
|
+
logger('\n'.join([
|
|
39
|
+
logger.red(f"{self.model_path} is not a directory. Please, check the path."),
|
|
40
|
+
logger.red("The name of the model will be the name of that folder.")
|
|
41
|
+
]))
|
|
42
|
+
return errors.IO_ERROR, ""
|
|
43
|
+
|
|
44
|
+
ret_code, output = self.__generate_compressed_file()
|
|
45
|
+
if ret_code:
|
|
46
|
+
return ret_code, output
|
|
47
|
+
|
|
48
|
+
if not self.__get_confirmation():
|
|
49
|
+
return errors.INTERRUPTED_ERROR, ""
|
|
50
|
+
|
|
51
|
+
return self.__upload_model()
|
|
52
|
+
|
|
53
|
+
def __generate_compressed_file(self) -> Tuple[int, str]:
|
|
54
|
+
"""
|
|
55
|
+
### Generates the model's compressed file.
|
|
56
|
+
|
|
57
|
+
#### Returns:
|
|
58
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
59
|
+
"""
|
|
60
|
+
logger(f"Creating the {self.tar_file_name} model.")
|
|
61
|
+
try:
|
|
62
|
+
with tarfile.open(self.tar_file_path, "w:gz") as tar:
|
|
63
|
+
tar.add(self.model_path, arcname=self.model_name)
|
|
64
|
+
except (tarfile.ReadError, tarfile.CompressionError) as ex:
|
|
65
|
+
return errors.IO_ERROR, str(ex)
|
|
66
|
+
return 0, ""
|
|
67
|
+
|
|
68
|
+
def __get_confirmation(self) -> bool:
|
|
69
|
+
"""
|
|
70
|
+
### Asks the user for confirmation.
|
|
71
|
+
|
|
72
|
+
#### Returns:
|
|
73
|
+
- (bool): True if the user confirms, False otherwise.
|
|
74
|
+
"""
|
|
75
|
+
logger('\n'.join([
|
|
76
|
+
logger.yellow("Warning: Uploading, please BE CAREFUL! This can be dangerous."),
|
|
77
|
+
f"You are going to be connected to {self.login} to write in folder {paths.SCIPION_SOFTWARE_EM}.",
|
|
78
|
+
"Continue? YES/no (case sensitive)"
|
|
79
|
+
]))
|
|
80
|
+
return user_interactions.get_user_confirmation("YES")
|
|
81
|
+
|
|
82
|
+
def __upload_model(self) -> Tuple[int, str]:
|
|
83
|
+
"""
|
|
84
|
+
### Uploads the model to the remote server.
|
|
85
|
+
|
|
86
|
+
#### Returns:
|
|
87
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
88
|
+
"""
|
|
89
|
+
update = '--update' if self.update else ''
|
|
90
|
+
args = f"{self.login}, {os.path.abspath(self.tar_file_path)}, {paths.SCIPION_SOFTWARE_EM}, {update}"
|
|
91
|
+
logger(f"Trying to upload the model using {self.login} as login")
|
|
92
|
+
sync_program_relative_call = os.path.join(
|
|
93
|
+
".",
|
|
94
|
+
os.path.basename(self.sync_program_path)
|
|
95
|
+
)
|
|
96
|
+
ret_code, output = shell_handler.run_shell_command(
|
|
97
|
+
f"{sync_program_relative_call} upload {args}",
|
|
98
|
+
cwd=os.path.dirname(self.sync_program_path)
|
|
99
|
+
)
|
|
100
|
+
if not ret_code:
|
|
101
|
+
output = ""
|
|
102
|
+
logger(logger.green(f"{self.model_name} model successfully uploaded! Removing the local .tgz"))
|
|
103
|
+
os.remove(self.tar_file_path)
|
|
104
|
+
return ret_code, output
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Dict, Tuple
|
|
3
|
+
|
|
4
|
+
from xmipp3_installer.application.cli.arguments import params
|
|
5
|
+
from xmipp3_installer.application.logger.logger import logger
|
|
6
|
+
from xmipp3_installer.installer import constants, urls
|
|
7
|
+
from xmipp3_installer.installer.constants import paths
|
|
8
|
+
from xmipp3_installer.installer.handlers import shell_handler
|
|
9
|
+
from xmipp3_installer.installer.modes.mode_sync.mode_sync_executor import ModeSyncExecutor
|
|
10
|
+
|
|
11
|
+
class ModeGetModelsExecutor(ModeSyncExecutor):
|
|
12
|
+
def __init__(self, context: Dict):
|
|
13
|
+
"""
|
|
14
|
+
### Constructor.
|
|
15
|
+
|
|
16
|
+
#### Params:
|
|
17
|
+
- context (dict): Dictionary containing the installation context variables.
|
|
18
|
+
"""
|
|
19
|
+
super().__init__(context)
|
|
20
|
+
self.models_directory = context.pop(params.PARAM_MODELS_DIRECTORY)
|
|
21
|
+
self.dist_path = paths.get_source_path(constants.XMIPP)
|
|
22
|
+
if self.models_directory == self.dist_path:
|
|
23
|
+
self.models_directory = os.path.join(self.models_directory, 'models')
|
|
24
|
+
|
|
25
|
+
def _sync_operation(self) -> Tuple[int, str]:
|
|
26
|
+
"""
|
|
27
|
+
### Downloads deep learning models.
|
|
28
|
+
|
|
29
|
+
#### Returns:
|
|
30
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
31
|
+
"""
|
|
32
|
+
if os.path.isdir(self.models_directory):
|
|
33
|
+
task = "update"
|
|
34
|
+
in_progress_task = "Updating"
|
|
35
|
+
completed_task = "updated"
|
|
36
|
+
else:
|
|
37
|
+
task = "download"
|
|
38
|
+
in_progress_task = "Downloading"
|
|
39
|
+
completed_task = "downloaded"
|
|
40
|
+
|
|
41
|
+
logger(f"{in_progress_task} Deep Learning models (in background)")
|
|
42
|
+
ret_code, output = shell_handler.run_shell_command(
|
|
43
|
+
f"{self.sync_program_path} {task} {self.models_directory} {urls.MODELS_URL} DLmodels",
|
|
44
|
+
show_command=True,
|
|
45
|
+
show_output=True,
|
|
46
|
+
show_error=True
|
|
47
|
+
)
|
|
48
|
+
if not ret_code:
|
|
49
|
+
logger(logger.green(f"Models successfully {completed_task}!"))
|
|
50
|
+
|
|
51
|
+
return ret_code, output
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from abc import abstractmethod
|
|
3
|
+
from typing import Dict, Tuple
|
|
4
|
+
|
|
5
|
+
from xmipp3_installer.application.logger import errors
|
|
6
|
+
from xmipp3_installer.application.logger.logger import logger
|
|
7
|
+
from xmipp3_installer.installer.constants import paths
|
|
8
|
+
from xmipp3_installer.installer.modes import mode_executor
|
|
9
|
+
|
|
10
|
+
_SYNC_PROGRAM_PATH = os.path.join(".", paths.BINARIES_PATH)
|
|
11
|
+
_SYNC_PROGRAM_NAME = "xmipp_sync_data"
|
|
12
|
+
|
|
13
|
+
class ModeSyncExecutor(mode_executor.ModeExecutor):
|
|
14
|
+
"""Base class for mode executors with sync operations."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, context: Dict):
|
|
17
|
+
"""
|
|
18
|
+
### Constructor.
|
|
19
|
+
|
|
20
|
+
#### Params:
|
|
21
|
+
- context (dict): Dictionary containing the installation context variables.
|
|
22
|
+
"""
|
|
23
|
+
super().__init__(context)
|
|
24
|
+
self.sync_program_path = os.path.join(_SYNC_PROGRAM_PATH, _SYNC_PROGRAM_NAME)
|
|
25
|
+
|
|
26
|
+
def run(self) -> Tuple[int, str]:
|
|
27
|
+
"""
|
|
28
|
+
### Executes the sync operation.
|
|
29
|
+
|
|
30
|
+
#### Returns:
|
|
31
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
32
|
+
"""
|
|
33
|
+
if not os.path.exists(self.sync_program_path):
|
|
34
|
+
logger('\n'.join([
|
|
35
|
+
logger.red(f"{self.sync_program_path} does not exist."),
|
|
36
|
+
logger.red("Xmipp needs to be compiled successfully before running this command!")
|
|
37
|
+
]))
|
|
38
|
+
return errors.IO_ERROR, ""
|
|
39
|
+
return self._sync_operation()
|
|
40
|
+
|
|
41
|
+
@abstractmethod
|
|
42
|
+
def _sync_operation(self) -> Tuple[int, str]:
|
|
43
|
+
"""
|
|
44
|
+
### Executes the specific sync operation.
|
|
45
|
+
|
|
46
|
+
#### Returns:
|
|
47
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
48
|
+
"""
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Dict, Tuple
|
|
3
|
+
|
|
4
|
+
from xmipp3_installer.application.cli.arguments import params
|
|
5
|
+
from xmipp3_installer.application.logger.logger import logger
|
|
6
|
+
from xmipp3_installer.installer import urls
|
|
7
|
+
from xmipp3_installer.installer.constants import paths
|
|
8
|
+
from xmipp3_installer.installer.handlers import shell_handler
|
|
9
|
+
from xmipp3_installer.installer.modes.mode_sync.mode_sync_executor import ModeSyncExecutor
|
|
10
|
+
from xmipp3_installer.repository.config_vars import variables
|
|
11
|
+
|
|
12
|
+
_DATASET_NAME = "xmipp_programs"
|
|
13
|
+
_PYTHON_TEST_SCRIPT_NAME = "test.py"
|
|
14
|
+
_PYTHON_TEST_SCRIPT_PATH = os.path.join(paths.BINARIES_PATH, "tests")
|
|
15
|
+
_DEFAULT_PYTHON_HOME = "python3"
|
|
16
|
+
_DATASET_PATH = os.path.join(_PYTHON_TEST_SCRIPT_PATH, 'data')
|
|
17
|
+
|
|
18
|
+
class ModeTestExecutor(ModeSyncExecutor):
|
|
19
|
+
"""Class to execute Xmipp tests."""
|
|
20
|
+
|
|
21
|
+
def __init__(self, context: Dict):
|
|
22
|
+
"""
|
|
23
|
+
### Constructor.
|
|
24
|
+
|
|
25
|
+
#### Params:
|
|
26
|
+
- context (dict): Dictionary containing the installation context variables.
|
|
27
|
+
"""
|
|
28
|
+
super().__init__(context)
|
|
29
|
+
self.test_names = context.pop(params.PARAM_TEST_NAMES)
|
|
30
|
+
self.cuda = context.pop(variables.CUDA)
|
|
31
|
+
self.show = context.pop(params.PARAM_SHOW_TESTS)
|
|
32
|
+
python_home = context.pop(variables.PYTHON_HOME, None)
|
|
33
|
+
self.python_home = python_home if python_home else _DEFAULT_PYTHON_HOME
|
|
34
|
+
|
|
35
|
+
def run(self) -> Tuple[int, str]:
|
|
36
|
+
"""
|
|
37
|
+
### Runs the provided tests.
|
|
38
|
+
|
|
39
|
+
#### Returns:
|
|
40
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
41
|
+
"""
|
|
42
|
+
ret_code, output = super().run()
|
|
43
|
+
if ret_code:
|
|
44
|
+
return ret_code, output
|
|
45
|
+
return self.__run_tests()
|
|
46
|
+
|
|
47
|
+
def _sync_operation(self) -> Tuple[int, str]:
|
|
48
|
+
"""
|
|
49
|
+
### Executes the test operation.
|
|
50
|
+
|
|
51
|
+
#### Returns:
|
|
52
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
53
|
+
"""
|
|
54
|
+
if os.path.isdir(_DATASET_PATH):
|
|
55
|
+
task_message = "Updating"
|
|
56
|
+
task = "update"
|
|
57
|
+
show_output = False
|
|
58
|
+
else:
|
|
59
|
+
task_message = "Downloading"
|
|
60
|
+
task = "download"
|
|
61
|
+
show_output = True
|
|
62
|
+
logger(logger.blue(f"{task_message} the test files"))
|
|
63
|
+
|
|
64
|
+
args = f"{_DATASET_PATH} {urls.SCIPION_TESTS_URL} {_DATASET_NAME}"
|
|
65
|
+
sync_program_relative_call = os.path.join(
|
|
66
|
+
".",
|
|
67
|
+
os.path.basename(self.sync_program_path)
|
|
68
|
+
)
|
|
69
|
+
return shell_handler.run_shell_command(
|
|
70
|
+
f"{sync_program_relative_call} {task} {args}",
|
|
71
|
+
cwd=os.path.dirname(self.sync_program_path),
|
|
72
|
+
show_output=show_output
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def __run_tests(self) -> Tuple[int, str]:
|
|
76
|
+
"""
|
|
77
|
+
### Runs the specified tests.
|
|
78
|
+
|
|
79
|
+
#### Returns:
|
|
80
|
+
- (tuple(int, str)): Tuple containing the return code and an error message if there was an error.
|
|
81
|
+
"""
|
|
82
|
+
no_cuda_str = "--noCuda" if not self.cuda else ""
|
|
83
|
+
show_str = "--show" if self.show else ""
|
|
84
|
+
logger(f" Tests to run: {', '.join(self.test_names)}")
|
|
85
|
+
|
|
86
|
+
return shell_handler.run_shell_command(
|
|
87
|
+
f"{self.python_home} {_PYTHON_TEST_SCRIPT_NAME} {' '.join(self.test_names)} {no_cuda_str}{show_str}",
|
|
88
|
+
cwd=_PYTHON_TEST_SCRIPT_PATH,
|
|
89
|
+
show_output=True,
|
|
90
|
+
show_error=True
|
|
91
|
+
)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Dict, Tuple
|
|
3
|
+
|
|
4
|
+
from xmipp3_installer.application.cli.arguments import params
|
|
5
|
+
from xmipp3_installer.application.logger.logger import logger
|
|
6
|
+
from xmipp3_installer.api_client.assembler import installation_info_assembler
|
|
7
|
+
from xmipp3_installer.installer import constants
|
|
8
|
+
from xmipp3_installer.installer.constants import paths
|
|
9
|
+
from xmipp3_installer.installer.modes import mode_executor
|
|
10
|
+
from xmipp3_installer.installer.handlers import git_handler, versions_manager
|
|
11
|
+
from xmipp3_installer.installer.handlers.cmake import cmake_handler
|
|
12
|
+
from xmipp3_installer.repository.config_vars import variables
|
|
13
|
+
|
|
14
|
+
class ModeVersionExecutor(mode_executor.ModeExecutor):
|
|
15
|
+
__LEFT_TEXT_LEN = 25
|
|
16
|
+
|
|
17
|
+
def __init__(self, context: Dict):
|
|
18
|
+
"""
|
|
19
|
+
### Constructor.
|
|
20
|
+
|
|
21
|
+
#### Params:
|
|
22
|
+
- context (dict): Dictionary containing the installation context variables.
|
|
23
|
+
"""
|
|
24
|
+
super().__init__(context)
|
|
25
|
+
self.short = context.pop(params.PARAM_SHORT)
|
|
26
|
+
config_exists = os.path.exists(paths.CONFIG_FILE)
|
|
27
|
+
self.version_file_exists = os.path.exists(paths.LIBRARY_VERSIONS_FILE)
|
|
28
|
+
self.is_configured = config_exists and self.version_file_exists
|
|
29
|
+
versions: versions_manager.VersionsManager = context[constants.VERSIONS_CONTEXT_KEY]
|
|
30
|
+
self.xmipp_version_number = versions.xmipp_version_number
|
|
31
|
+
self.xmipp_version_name = versions.xmipp_version_name
|
|
32
|
+
self.release_date = versions.xmipp_release_date
|
|
33
|
+
|
|
34
|
+
def run(self) -> Tuple[int, str]:
|
|
35
|
+
"""
|
|
36
|
+
### Collects all the version information available and displays it.
|
|
37
|
+
|
|
38
|
+
#### Returns:
|
|
39
|
+
- (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
|
|
40
|
+
"""
|
|
41
|
+
installation_info = self.xmipp_version_name if self.short else self.__get_long_version()
|
|
42
|
+
logger(installation_info)
|
|
43
|
+
return 0, ""
|
|
44
|
+
|
|
45
|
+
def __get_long_version(self) -> str:
|
|
46
|
+
"""
|
|
47
|
+
### Returns the long version of the installation info.
|
|
48
|
+
|
|
49
|
+
#### Returns:
|
|
50
|
+
- (str): Long version of the installation info.
|
|
51
|
+
"""
|
|
52
|
+
installation_info_lines = []
|
|
53
|
+
version_type = 'release' if git_handler.is_tag() else git_handler.get_current_branch()
|
|
54
|
+
title = f"Xmipp {self.xmipp_version_number} ({version_type})"
|
|
55
|
+
installation_info_lines.append(f"{logger.bold(title)}\n")
|
|
56
|
+
installation_info_lines.append(self.__get_dates_section())
|
|
57
|
+
system_version_left_text = self.__add_padding_spaces("System version: ")
|
|
58
|
+
installation_info_lines.append(f"{system_version_left_text}{installation_info_assembler.get_os_release_name()}")
|
|
59
|
+
installation_info_lines.append(self.__get_sources_info())
|
|
60
|
+
if self.version_file_exists:
|
|
61
|
+
installation_info_lines.append(f"\n{self.__get_library_versions_section()}")
|
|
62
|
+
if not self.is_configured or not self.__are_all_sources_present():
|
|
63
|
+
installation_info_lines.append(f"\n{self.__get_configuration_warning_message()}")
|
|
64
|
+
return '\n'.join(installation_info_lines)
|
|
65
|
+
|
|
66
|
+
def __get_dates_section(self) -> str:
|
|
67
|
+
"""
|
|
68
|
+
### Returns the message section related to dates.
|
|
69
|
+
|
|
70
|
+
#### Returns:
|
|
71
|
+
- (str): Dates related message section.
|
|
72
|
+
"""
|
|
73
|
+
dates_section = f"{self.__add_padding_spaces('Release date: ')}{self.release_date}\n"
|
|
74
|
+
dates_section += f"{self.__add_padding_spaces('Compilation date: ')}"
|
|
75
|
+
last_modified = self.context.get(variables.LAST_MODIFIED_KEY)
|
|
76
|
+
dates_section += last_modified if last_modified else '-'
|
|
77
|
+
return dates_section
|
|
78
|
+
|
|
79
|
+
def __get_sources_info(self) -> str:
|
|
80
|
+
"""
|
|
81
|
+
### Returns the message section related to sources.
|
|
82
|
+
|
|
83
|
+
#### Returns:
|
|
84
|
+
- (str): Sources related message section.
|
|
85
|
+
"""
|
|
86
|
+
sources_message_lines = []
|
|
87
|
+
for source_package in constants.XMIPP_SOURCES:
|
|
88
|
+
sources_message_lines.append(self.__get_source_info(source_package))
|
|
89
|
+
return '\n'.join(sources_message_lines)
|
|
90
|
+
|
|
91
|
+
def __get_source_info(self, source: str) -> str:
|
|
92
|
+
"""
|
|
93
|
+
### Returns the info message related to a given source.
|
|
94
|
+
|
|
95
|
+
#### Params:
|
|
96
|
+
- source (str): Source to get the message about.
|
|
97
|
+
|
|
98
|
+
#### Returns:
|
|
99
|
+
- (str): Info message about the given source.
|
|
100
|
+
"""
|
|
101
|
+
source_path = paths.get_source_path(source)
|
|
102
|
+
source_left_text = self.__add_padding_spaces(f"{source} branch: ")
|
|
103
|
+
if not os.path.exists(source_path):
|
|
104
|
+
return f"{source_left_text}{logger.yellow('Not found')}"
|
|
105
|
+
current_commit = git_handler.get_current_commit(dir=source_path)
|
|
106
|
+
commit_branch = git_handler.get_commit_branch(current_commit, dir=source_path)
|
|
107
|
+
current_branch = git_handler.get_current_branch(dir=source_path)
|
|
108
|
+
display_name = commit_branch if git_handler.is_tag(dir=source_path) else current_branch
|
|
109
|
+
return f"{source_left_text}{display_name} ({current_commit})"
|
|
110
|
+
|
|
111
|
+
def __add_padding_spaces(self, left_text: str) -> str:
|
|
112
|
+
"""
|
|
113
|
+
### Adds right padding as spaces to the given text until it reaches the desired length.
|
|
114
|
+
|
|
115
|
+
#### Params:
|
|
116
|
+
- left_text (str): Text to add padding to.
|
|
117
|
+
|
|
118
|
+
#### Returns:
|
|
119
|
+
- (str): Padded string.
|
|
120
|
+
"""
|
|
121
|
+
text_len = len(left_text)
|
|
122
|
+
if text_len >= self.__LEFT_TEXT_LEN:
|
|
123
|
+
return left_text
|
|
124
|
+
spaces = ''.join([' ' for _ in range(self.__LEFT_TEXT_LEN - text_len)])
|
|
125
|
+
return f"{left_text}{spaces}"
|
|
126
|
+
|
|
127
|
+
def __get_library_versions_section(self) -> str:
|
|
128
|
+
"""
|
|
129
|
+
### Retrieves the version of the libraries used in the project.
|
|
130
|
+
|
|
131
|
+
#### Returns:
|
|
132
|
+
- (str): Libraries with their version.
|
|
133
|
+
"""
|
|
134
|
+
version_lines = []
|
|
135
|
+
for library, version in cmake_handler.get_library_versions_from_cmake_file(
|
|
136
|
+
paths.LIBRARY_VERSIONS_FILE
|
|
137
|
+
).items():
|
|
138
|
+
library_left_text = self.__add_padding_spaces(f"{library}: ")
|
|
139
|
+
version_lines.append(f"{library_left_text}{version}")
|
|
140
|
+
return '\n'.join(version_lines)
|
|
141
|
+
|
|
142
|
+
def __are_all_sources_present(self) -> bool:
|
|
143
|
+
"""
|
|
144
|
+
### Check if all required source packages are present.
|
|
145
|
+
|
|
146
|
+
#### Returns:
|
|
147
|
+
- (bool): True if all source packages are present, False otherwise.
|
|
148
|
+
"""
|
|
149
|
+
for source_package in paths.XMIPP_SOURCE_PATHS:
|
|
150
|
+
if not os.path.exists(source_package):
|
|
151
|
+
return False
|
|
152
|
+
return True
|
|
153
|
+
|
|
154
|
+
def __get_configuration_warning_message(self) -> str:
|
|
155
|
+
"""
|
|
156
|
+
### Returns a message indicating configuration is not complete.
|
|
157
|
+
|
|
158
|
+
#### Returns:
|
|
159
|
+
- (str):
|
|
160
|
+
"""
|
|
161
|
+
return '\n'.join([
|
|
162
|
+
logger.yellow("This project has not yet been configured, so some detectable dependencies have not been properly detected."),
|
|
163
|
+
logger.yellow("Run mode 'getSources' and then 'configBuild' to be able to show all detectable ones.")
|
|
164
|
+
])
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""### Contains functions that orquestrate other function executions."""
|
|
2
|
+
|
|
3
|
+
import multiprocessing
|
|
4
|
+
from typing import List, Tuple, Callable, Any
|
|
5
|
+
|
|
6
|
+
def run_parallel_jobs(
|
|
7
|
+
funcs: List[Callable],
|
|
8
|
+
func_args: List[Tuple[Any]],
|
|
9
|
+
n_jobs: int=multiprocessing.cpu_count()
|
|
10
|
+
) -> List:
|
|
11
|
+
"""
|
|
12
|
+
### Runs the given command list in parallel.
|
|
13
|
+
|
|
14
|
+
#### Params:
|
|
15
|
+
- funcs (list(callable)): Functions to run.
|
|
16
|
+
- func_args (list(tuple(any))): Arguments for each function.
|
|
17
|
+
- n_jobs (int): Optional. Number of parallel jobs.
|
|
18
|
+
|
|
19
|
+
#### Returns:
|
|
20
|
+
- (list): List containing the return of each function.
|
|
21
|
+
"""
|
|
22
|
+
with multiprocessing.Pool(n_jobs) as p:
|
|
23
|
+
results = p.starmap(__run_lambda, zip(funcs, func_args))
|
|
24
|
+
return results
|
|
25
|
+
|
|
26
|
+
def __run_lambda(func: Callable, args: Tuple[Any]) -> Any:
|
|
27
|
+
"""
|
|
28
|
+
### Runs the given function with its args.
|
|
29
|
+
|
|
30
|
+
#### Params:
|
|
31
|
+
- func (callable): Function to run.
|
|
32
|
+
- args (tuple(any)): Arguments for the function.
|
|
33
|
+
|
|
34
|
+
#### Returns:
|
|
35
|
+
- (any): Return of the called function.
|
|
36
|
+
"""
|
|
37
|
+
return func(*args)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""### URLs """
|
|
2
|
+
|
|
3
|
+
DOCUMENTATION_URL = 'https://i2pc.github.io/docs/'
|
|
4
|
+
CMAKE_INSTALL_DOCS_URL = 'https://i2pc.github.io/docs/Installation/InstallationNotes/index.html#cmake'
|
|
5
|
+
API_URL = 'https://xmipp.i2pc.es/api/attempts/'
|
|
6
|
+
MODELS_URL= "http://campins.cnb.csic.es/deep_cons/"
|
|
7
|
+
SCIPION_TESTS_URL = "http://scipion.cnb.csic.es/downloads/scipion/data/tests"
|
|
8
|
+
I2PC_REPOSITORY_URL = "https://github.com/i2pc/"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""### Contains functions that interact with the config file."""
|