Fix auto-detect git repository

This commit is contained in:
allegroai 2019-08-01 12:54:11 +03:00
parent bcaf4ce6c8
commit fb7dfc49a9
2 changed files with 16 additions and 13 deletions

View File

@ -211,10 +211,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
# overwrite it before we have a chance to call edit)
self._edit(script=result.script)
self.reload()
self._update_requirements(result.script.get('requirements') if result.script.get('requirements') else '')
self._update_requirements(result.script.get('requirements') if result.script and
result.script.get('requirements') else '')
check_package_update_thread.join()
except Exception as e:
get_logger('task').warning(str(e))
get_logger('task').debug(str(e))
def _auto_generate(self, project_name=None, task_name=None, task_type=TaskTypes.training):
created_msg = make_message('Auto-generated at %(time)s by %(user)s@%(host)s')

View File

@ -334,17 +334,19 @@ class Task(_Task):
if not default_project_name or not default_task_name:
# get project name and task name from repository name and entry_point
result = ScriptInfo.get(create_requirements=False, check_uncommitted=False)
if result:
if not default_project_name:
try:
default_project_name = re.sub(r"\.git$", "", result.script.get('repository')) or "Untitled"
except TypeError:
default_project_name = 'Untitled'
if not default_task_name:
try:
default_task_name = Path(result.script.get("entry_point")).stem
except TypeError:
pass
if not default_project_name:
# noinspection PyBroadException
try:
parts = result.script['repository'].split('/')
default_project_name = (parts[-1] or parts[-2]).replace('.git', '') or 'Untitled'
except Exception:
default_project_name = 'Untitled'
if not default_task_name:
# noinspection PyBroadException
try:
default_task_name = os.path.splitext(os.path.basename(result.script['entry_point']))[0]
except Exception:
pass
# if we force no task reuse from os environment
if DEV_TASK_NO_REUSE.get() or not reuse_last_task_id: