From 91bc4b92cd497e1d1257c3bd43b26ddac662845f Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 22 May 2020 11:02:52 +0300 Subject: [PATCH] Limit max requirement size to 0.5mb --- trains/backend_interface/task/repo/scriptinfo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/trains/backend_interface/task/repo/scriptinfo.py b/trains/backend_interface/task/repo/scriptinfo.py index 527eabe2..20425c40 100644 --- a/trains/backend_interface/task/repo/scriptinfo.py +++ b/trains/backend_interface/task/repo/scriptinfo.py @@ -24,6 +24,8 @@ class ScriptInfoError(Exception): class ScriptRequirements(object): + _max_requirements_size = 512*1024 + def __init__(self, root_folder): self._root_folder = root_folder @@ -158,6 +160,9 @@ class ScriptRequirements(object): else: requirements_txt += '{0}\n'.format(k) + requirements_txt_packages_only = \ + requirements_txt + '\n# Skipping detailed import analysis, it is too large\n' + # requirements details (in comments) requirements_txt += '\n' + \ '# Detailed import analysis\n' \ @@ -177,7 +182,10 @@ class ScriptRequirements(object): requirements_txt += '# IMPORT PACKAGE {0}\n'.format(k) requirements_txt += ''.join(['# {0}\n'.format(c) for c in v.comments.sorted_items()]) - return requirements_txt, conda_requirements + # make sure we do not exceed the size a size limit + return (requirements_txt if len(requirements_txt) < ScriptRequirements._max_requirements_size + else requirements_txt_packages_only, + conda_requirements) class _JupyterObserver(object):