Warn when calling Task.force_requirements_env_freeze()/Task.force_store_standalone_script() after Task.init() (#1425)
Some checks failed
CodeQL / Analyze (python) (push) Has been cancelled

This commit is contained in:
clearml 2025-06-12 14:23:25 +03:00
parent 52e0538182
commit ecfd2b46f4

View File

@ -2539,6 +2539,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
:param requirements_file: (Optional) Pass a requirements.txt file to specify the required packages (instead of
``pip freeze`` or automatic analysis). This will overwrite any existing requirement listing.
"""
if not running_remotely() and hasattr(cls, "current_task") and cls.current_task():
get_logger("task").warning(
"Requirements env freeze ignored, "
"Task.force_requirements_env_freeze() must be called before Task.init()"
)
cls._force_use_pip_freeze = requirements_file if requirements_file else bool(force)
@classmethod
@ -2551,6 +2556,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
:param force: Set force storing the main python file as a single standalone script
"""
if not running_remotely() and hasattr(cls, "current_task") and cls.current_task():
get_logger("task").warning(
"Store standalone script ignored, "
"Task.force_store_standalone_script() must be called before Task.init()"
)
cls._force_store_standalone_script = bool(force)
def _set_random_seed_used(self, random_seed: Optional[int]) -> ():