mirror of
https://github.com/clearml/clearml
synced 2025-04-07 06:04:25 +00:00
Add Task.force_requirements_env_freeze() forcing pip freeze
instead of package analysis (issue #304)
This commit is contained in:
parent
2a299c51db
commit
fa77d0f380
@ -71,6 +71,9 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
_store_diff = config.get('development.store_uncommitted_code_diff', False)
|
_store_diff = config.get('development.store_uncommitted_code_diff', False)
|
||||||
_store_remote_diff = config.get('development.store_code_diff_from_remote', False)
|
_store_remote_diff = config.get('development.store_code_diff_from_remote', False)
|
||||||
_report_subprocess_enabled = config.get('development.report_use_subprocess', sys.platform == 'linux')
|
_report_subprocess_enabled = config.get('development.report_use_subprocess', sys.platform == 'linux')
|
||||||
|
_force_use_pip_freeze = \
|
||||||
|
config.get('development.detect_with_pip_freeze', False) or \
|
||||||
|
config.get('development.detect_with_conda_freeze', False)
|
||||||
_offline_filename = 'task.json'
|
_offline_filename = 'task.json'
|
||||||
|
|
||||||
class TaskTypes(Enum):
|
class TaskTypes(Enum):
|
||||||
@ -273,10 +276,9 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
if result.script and script_requirements:
|
if result.script and script_requirements:
|
||||||
entry_point_filename = None if config.get('development.force_analyze_entire_repo', False) else \
|
entry_point_filename = None if config.get('development.force_analyze_entire_repo', False) else \
|
||||||
os.path.join(result.script['working_dir'], entry_point)
|
os.path.join(result.script['working_dir'], entry_point)
|
||||||
if config.get('development.detect_with_pip_freeze', False) or \
|
if self._force_use_pip_freeze:
|
||||||
config.get('development.detect_with_conda_freeze', False):
|
|
||||||
requirements, conda_requirements = pip_freeze(
|
requirements, conda_requirements = pip_freeze(
|
||||||
config.get('development.detect_with_conda_freeze', False))
|
combine_conda_with_pip=config.get('development.detect_with_conda_freeze', True))
|
||||||
requirements = '# Python ' + sys.version.replace('\n', ' ').replace('\r', ' ') + '\n\n'\
|
requirements = '# Python ' + sys.version.replace('\n', ' ').replace('\r', ' ') + '\n\n'\
|
||||||
+ requirements
|
+ requirements
|
||||||
else:
|
else:
|
||||||
@ -1624,6 +1626,18 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
'Requirement ignored, Task.add_requirements() must be called before Task.init()')
|
'Requirement ignored, Task.add_requirements() must be called before Task.init()')
|
||||||
cls._force_requirements[package_name] = package_version
|
cls._force_requirements[package_name] = package_version
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def force_requirements_env_freeze(cls, force=True):
|
||||||
|
# type: (bool) -> None
|
||||||
|
"""
|
||||||
|
Force using `pip freeze` / `conda list` to store the full requirements of the active environment
|
||||||
|
(instead of statically analyzing the running code and listing directly imported packages)
|
||||||
|
Notice: Must be called before `Task.init` !
|
||||||
|
|
||||||
|
:param force: Set force using `pip freeze` flag on/off
|
||||||
|
"""
|
||||||
|
cls._force_use_pip_freeze = bool(force)
|
||||||
|
|
||||||
def _get_models(self, model_type='output'):
|
def _get_models(self, model_type='output'):
|
||||||
# type: (str) -> Sequence[Model]
|
# type: (str) -> Sequence[Model]
|
||||||
# model_type is either 'output' or 'input'
|
# model_type is either 'output' or 'input'
|
||||||
|
Loading…
Reference in New Issue
Block a user