xmipp3-installer 1.0.0__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.
Files changed (60) hide show
  1. xmipp3_installer/__main__.py +1 -1
  2. xmipp3_installer/api_client/api_client.py +35 -34
  3. xmipp3_installer/api_client/assembler/installation_info_assembler.py +140 -145
  4. xmipp3_installer/application/cli/arguments/__init__.py +3 -2
  5. xmipp3_installer/application/cli/arguments/modes.py +112 -95
  6. xmipp3_installer/application/cli/arguments/params.py +63 -53
  7. xmipp3_installer/application/cli/cli.py +171 -190
  8. xmipp3_installer/application/cli/parsers/base_help_formatter.py +256 -235
  9. xmipp3_installer/application/cli/parsers/error_handler_parser.py +53 -53
  10. xmipp3_installer/application/cli/parsers/format.py +22 -22
  11. xmipp3_installer/application/cli/parsers/general_help_formatter.py +102 -84
  12. xmipp3_installer/application/cli/parsers/mode_help_formatter.py +144 -105
  13. xmipp3_installer/application/logger/__init__.py +5 -0
  14. xmipp3_installer/application/logger/errors.py +8 -8
  15. xmipp3_installer/application/logger/logger.py +218 -215
  16. xmipp3_installer/application/logger/predefined_messages.py +42 -35
  17. xmipp3_installer/application/user_interactions.py +6 -0
  18. xmipp3_installer/installer/constants/paths.py +6 -1
  19. xmipp3_installer/installer/handlers/cmake/cmake_handler.py +49 -53
  20. xmipp3_installer/installer/handlers/conda_handler.py +6 -6
  21. xmipp3_installer/installer/handlers/generic_package_handler.py +9 -9
  22. xmipp3_installer/installer/handlers/git_handler.py +152 -153
  23. xmipp3_installer/installer/handlers/shell_handler.py +87 -88
  24. xmipp3_installer/installer/handlers/versions_manager.py +20 -6
  25. xmipp3_installer/installer/installer_service.py +22 -8
  26. xmipp3_installer/installer/modes/mode_all_executor.py +61 -51
  27. xmipp3_installer/installer/modes/mode_clean/mode_clean_all_executor.py +44 -36
  28. xmipp3_installer/installer/modes/mode_clean/mode_clean_bin_executor.py +84 -74
  29. xmipp3_installer/installer/modes/mode_clean/mode_clean_executor.py +48 -34
  30. xmipp3_installer/installer/modes/mode_cmake/mode_cmake_executor.py +60 -47
  31. xmipp3_installer/installer/modes/mode_cmake/mode_compile_and_install_executor.py +52 -39
  32. xmipp3_installer/installer/modes/mode_cmake/mode_config_build_executor.py +68 -49
  33. xmipp3_installer/installer/modes/mode_config_executor.py +44 -33
  34. xmipp3_installer/installer/modes/mode_executor.py +14 -13
  35. xmipp3_installer/installer/modes/mode_get_sources_executor.py +121 -112
  36. xmipp3_installer/installer/modes/mode_git_executor.py +43 -31
  37. xmipp3_installer/installer/modes/mode_selector.py +6 -0
  38. xmipp3_installer/installer/modes/mode_sync/mode_add_model_executor.py +97 -83
  39. xmipp3_installer/installer/modes/mode_sync/mode_get_models_executor.py +53 -41
  40. xmipp3_installer/installer/modes/mode_sync/mode_sync_executor.py +41 -35
  41. xmipp3_installer/installer/modes/mode_sync/mode_test_executor.py +144 -77
  42. xmipp3_installer/installer/modes/mode_version_executor.py +161 -150
  43. xmipp3_installer/installer/orquestrator.py +24 -24
  44. xmipp3_installer/installer/urls.py +4 -3
  45. xmipp3_installer/repository/config.py +225 -227
  46. xmipp3_installer/repository/config_vars/__init__.py +5 -0
  47. xmipp3_installer/repository/config_vars/config_values_adapter.py +97 -91
  48. xmipp3_installer/repository/config_vars/default_values.py +24 -24
  49. xmipp3_installer/repository/config_vars/variables.py +9 -9
  50. xmipp3_installer/repository/invalid_config_line.py +17 -0
  51. xmipp3_installer/shared/file_operations.py +14 -12
  52. xmipp3_installer/shared/singleton.py +16 -17
  53. xmipp3_installer-1.1.0.dist-info/METADATA +86 -0
  54. xmipp3_installer-1.1.0.dist-info/RECORD +70 -0
  55. {xmipp3_installer-1.0.0.dist-info → xmipp3_installer-1.1.0.dist-info}/WHEEL +1 -1
  56. xmipp3_installer-1.0.0.dist-info/METADATA +0 -729
  57. xmipp3_installer-1.0.0.dist-info/RECORD +0 -70
  58. {xmipp3_installer-1.0.0.dist-info → xmipp3_installer-1.1.0.dist-info}/entry_points.txt +0 -0
  59. /xmipp3_installer-1.0.0.dist-info/LICENSE → /xmipp3_installer-1.1.0.dist-info/licenses/LICENSE.txt +0 -0
  60. {xmipp3_installer-1.0.0.dist-info → xmipp3_installer-1.1.0.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,8 @@
1
+ """
2
+ ### Mode Version Executor Module.
3
+
4
+ This module contains the class to collect and display version information.
5
+ """
1
6
  import os
2
7
  from typing import Dict, Tuple
3
8
 
@@ -12,153 +17,159 @@ from xmipp3_installer.installer.handlers.cmake import cmake_handler
12
17
  from xmipp3_installer.repository.config_vars import variables
13
18
 
14
19
  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
- ])
20
+ """
21
+ ### Mode Version Executor.
22
+
23
+ Collects and displays version information for the installation.
24
+ """
25
+
26
+ __LEFT_TEXT_LEN = 25
27
+
28
+ def __init__(self, context: Dict):
29
+ """
30
+ ### Constructor.
31
+
32
+ #### Params:
33
+ - context (dict): Dictionary containing the installation context variables.
34
+ """
35
+ super().__init__(context)
36
+ self.short = context.pop(params.PARAM_SHORT)
37
+ config_exists = os.path.exists(paths.CONFIG_FILE)
38
+ self.version_file_exists = os.path.exists(paths.LIBRARY_VERSIONS_FILE)
39
+ self.is_configured = config_exists and self.version_file_exists
40
+ versions: versions_manager.VersionsManager = context[constants.VERSIONS_CONTEXT_KEY]
41
+ self.xmipp_version_number = versions.xmipp_version_number
42
+ self.xmipp_version_name = versions.xmipp_version_name
43
+ self.release_date = versions.xmipp_release_date
44
+
45
+ def run(self) -> Tuple[int, str]:
46
+ """
47
+ ### Collects all the version information available and displays it.
48
+
49
+ #### Returns:
50
+ - (tuple(int, str)): Tuple containing the error status and an error message if there was an error.
51
+ """
52
+ installation_info = self.xmipp_version_name if self.short else self.__get_long_version()
53
+ logger(installation_info)
54
+ return 0, ""
55
+
56
+ def __get_long_version(self) -> str:
57
+ """
58
+ ### Returns the long version of the installation info.
59
+
60
+ #### Returns:
61
+ - (str): Long version of the installation info.
62
+ """
63
+ installation_info_lines = []
64
+ version_type = 'release' if git_handler.is_tag() else git_handler.get_current_branch()
65
+ title = f"Xmipp {self.xmipp_version_number} ({version_type})"
66
+ installation_info_lines.append(f"{logger.bold(title)}\n")
67
+ installation_info_lines.append(self.__get_dates_section())
68
+ system_version_left_text = self.__add_padding_spaces("System version: ")
69
+ installation_info_lines.append(f"{system_version_left_text}{installation_info_assembler.get_os_release_name()}")
70
+ installation_info_lines.append(self.__get_sources_info())
71
+ if self.version_file_exists:
72
+ installation_info_lines.append(f"\n{self.__get_library_versions_section()}")
73
+ if not self.is_configured or not _are_all_sources_present():
74
+ installation_info_lines.append(f"\n{_get_configuration_warning_message()}")
75
+ return '\n'.join(installation_info_lines)
76
+
77
+ def __get_dates_section(self) -> str:
78
+ """
79
+ ### Returns the message section related to dates.
80
+
81
+ #### Returns:
82
+ - (str): Dates related message section.
83
+ """
84
+ dates_section = f"{self.__add_padding_spaces('Release date: ')}{self.release_date}\n"
85
+ dates_section += f"{self.__add_padding_spaces('Compilation date: ')}"
86
+ last_modified = self.context.get(variables.LAST_MODIFIED_KEY)
87
+ dates_section += last_modified if last_modified else '-'
88
+ return dates_section
89
+
90
+ def __get_sources_info(self) -> str:
91
+ """
92
+ ### Returns the message section related to sources.
93
+
94
+ #### Returns:
95
+ - (str): Sources related message section.
96
+ """
97
+ sources_message_lines = []
98
+ for source_package in constants.XMIPP_SOURCES:
99
+ sources_message_lines.append(self.__get_source_info(source_package))
100
+ return '\n'.join(sources_message_lines)
101
+
102
+ def __get_source_info(self, source: str) -> str:
103
+ """
104
+ ### Returns the info message related to a given source.
105
+
106
+ #### Params:
107
+ - source (str): Source to get the message about.
108
+
109
+ #### Returns:
110
+ - (str): Info message about the given source.
111
+ """
112
+ source_path = paths.get_source_path(source)
113
+ source_left_text = self.__add_padding_spaces(f"{source} branch: ")
114
+ if not os.path.exists(source_path):
115
+ return f"{source_left_text}{logger.yellow('Not found')}"
116
+ current_commit = git_handler.get_current_commit(dir=source_path)
117
+ commit_branch = git_handler.get_commit_branch(current_commit, dir=source_path)
118
+ current_branch = git_handler.get_current_branch(dir=source_path)
119
+ display_name = commit_branch if git_handler.is_tag(dir=source_path) else current_branch
120
+ return f"{source_left_text}{display_name} ({current_commit})"
121
+
122
+ def __add_padding_spaces(self, left_text: str) -> str:
123
+ """
124
+ ### Adds right padding as spaces to the given text until it reaches the desired length.
125
+
126
+ #### Params:
127
+ - left_text (str): Text to add padding to.
128
+
129
+ #### Returns:
130
+ - (str): Padded string.
131
+ """
132
+ text_len = len(left_text)
133
+ if text_len >= self.__LEFT_TEXT_LEN:
134
+ return left_text
135
+ spaces = ''.join([' ' for _ in range(self.__LEFT_TEXT_LEN - text_len)])
136
+ return f"{left_text}{spaces}"
137
+
138
+ def __get_library_versions_section(self) -> str:
139
+ """
140
+ ### Retrieves the version of the libraries used in the project.
141
+
142
+ #### Returns:
143
+ - (str): Libraries with their version.
144
+ """
145
+ version_lines = []
146
+ for library, version in cmake_handler.get_library_versions_from_cmake_file(
147
+ paths.LIBRARY_VERSIONS_FILE
148
+ ).items():
149
+ library_left_text = self.__add_padding_spaces(f"{library}: ")
150
+ version_lines.append(f"{library_left_text}{version}")
151
+ return '\n'.join(version_lines)
152
+
153
+ def _are_all_sources_present() -> bool:
154
+ """
155
+ ### Check if all required source packages are present.
156
+
157
+ #### Returns:
158
+ - (bool): True if all source packages are present, False otherwise.
159
+ """
160
+ for source_package in paths.XMIPP_SOURCE_PATHS:
161
+ if not os.path.exists(source_package):
162
+ return False
163
+ return True
164
+
165
+ def _get_configuration_warning_message() -> str:
166
+ """
167
+ ### Returns a message indicating configuration is not complete.
168
+
169
+ #### Returns:
170
+ - (str):
171
+ """
172
+ return '\n'.join([
173
+ logger.yellow("This project has not yet been configured, so some detectable dependencies have not been properly detected."),
174
+ logger.yellow("Run mode 'getSources' and then 'configBuild' to be able to show all detectable ones.")
175
+ ])
@@ -5,33 +5,33 @@ from typing import List, Tuple, Callable, Any
5
5
 
6
6
  def run_parallel_jobs(
7
7
  funcs: List[Callable],
8
- func_args: List[Tuple[Any]],
8
+ func_args: List[Tuple[Any, ...]],
9
9
  n_jobs: int=multiprocessing.cpu_count()
10
10
  ) -> List:
11
- """
12
- ### Runs the given command list in parallel.
11
+ """
12
+ ### Runs the given command list in parallel.
13
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.
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
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
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
25
 
26
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)
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)
@@ -1,8 +1,9 @@
1
- """### URLs """
1
+ """### URLs."""
2
2
 
3
3
  DOCUMENTATION_URL = 'https://i2pc.github.io/docs/'
4
- CMAKE_INSTALL_DOCS_URL = 'https://i2pc.github.io/docs/Installation/InstallationNotes/index.html#cmake'
4
+ CMAKE_INSTALL_DOCS_URL = 'https://i2pc.github.io/docs/Installation/Requirements/index.html#cmake'
5
5
  API_URL = 'https://xmipp.i2pc.es/api/attempts/'
6
- MODELS_URL= "http://campins.cnb.csic.es/deep_cons/"
6
+ MODELS_URL= "http://scipion.cnb.csic.es/downloads/scipion/software/em"
7
7
  SCIPION_TESTS_URL = "http://scipion.cnb.csic.es/downloads/scipion/data/tests"
8
8
  I2PC_REPOSITORY_URL = "https://github.com/i2pc/"
9
+ DLTK_DOCS_URL = "https://i2pc.github.io/docs/Installation/Optionals/index.html#deeplearningtoolkit"