Support requirements detection using pip freeze (development.detect_with_pip_freeze configuration setting)

This commit is contained in:
allegroai 2020-07-11 01:31:47 +03:00
parent d642639890
commit 25fd425bf7
3 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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']:

View File

@ -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