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 # this value can be overwritten with os environment variable TRAINS_SUPPRESS_UPDATE_MESSAGE=1
suppress_update_message: false 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 # Development mode worker
worker { worker {
# Status report period in seconds # Status report period in seconds

View File

@ -42,6 +42,7 @@ from ...storage.helper import StorageHelper, StorageError
from .access import AccessMixin from .access import AccessMixin
from .log import TaskHandler from .log import TaskHandler
from .repo import ScriptInfo 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 from ...config import config, PROC_MASTER_ID_ENV_VAR, SUPPRESS_UPDATE_MESSAGE_ENV_VAR
@ -287,6 +288,11 @@ 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):
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( requirements, conda_requirements = script_requirements.get_requirements(
entry_point_filename=entry_point_filename) entry_point_filename=entry_point_filename)

View File

@ -151,6 +151,9 @@
# this value can be overwritten with os environment variable TRAINS_SUPPRESS_UPDATE_MESSAGE=1 # this value can be overwritten with os environment variable TRAINS_SUPPRESS_UPDATE_MESSAGE=1
suppress_update_message: false 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 # Development mode worker
worker { worker {
# Status report period in seconds # Status report period in seconds