diff --git a/docs/trains.conf b/docs/trains.conf index d37cdce1..9770e035 100644 --- a/docs/trains.conf +++ b/docs/trains.conf @@ -161,6 +161,9 @@ sdk { # this value can be overwritten with os environment variable TRAINS_SUPPRESS_UPDATE_MESSAGE=1 suppress_update_message: false + # If this flag is true (default is false), instead of analyzing the code with Pigar, analyze with `pip freeze` + detect_with_pip_freeze: false + # Development mode worker worker { # Status report period in seconds diff --git a/trains/backend_interface/task/task.py b/trains/backend_interface/task/task.py index d6165ab6..90f570e4 100644 --- a/trains/backend_interface/task/task.py +++ b/trains/backend_interface/task/task.py @@ -42,6 +42,7 @@ from ...storage.helper import StorageHelper, StorageError from .access import AccessMixin from .log import TaskHandler from .repo import ScriptInfo +from .repo.util import get_command_output from ...config import config, PROC_MASTER_ID_ENV_VAR, SUPPRESS_UPDATE_MESSAGE_ENV_VAR @@ -287,8 +288,13 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin): if result.script and script_requirements: entry_point_filename = None if config.get('development.force_analyze_entire_repo', False) else \ os.path.join(result.script['working_dir'], entry_point) - requirements, conda_requirements = script_requirements.get_requirements( - entry_point_filename=entry_point_filename) + if config.get('development.detect_with_pip_freeze', False): + conda_requirements = "" + requirements = '# Python ' + sys.version.replace('\n', ' ').replace('\r', ' ') + '\n\n'\ + + get_command_output([sys.executable, "-m", "pip", "freeze"]) + else: + requirements, conda_requirements = script_requirements.get_requirements( + entry_point_filename=entry_point_filename) if requirements: if not result.script['requirements']: diff --git a/trains/config/default/sdk.conf b/trains/config/default/sdk.conf index 8b67eed8..51fdb1b8 100644 --- a/trains/config/default/sdk.conf +++ b/trains/config/default/sdk.conf @@ -151,6 +151,9 @@ # this value can be overwritten with os environment variable TRAINS_SUPPRESS_UPDATE_MESSAGE=1 suppress_update_message: false + # If this flag is true (default is false), instead of analyzing the code with Pigar, analyze with `pip freeze` + detect_with_pip_freeze: false + # Development mode worker worker { # Status report period in seconds