Fix IDE info when running in pure python console

This commit is contained in:
allegroai 2022-12-29 13:12:58 +02:00
parent af79ee7839
commit 3371a58bcb
2 changed files with 12 additions and 5 deletions

View File

@ -873,6 +873,10 @@ class ScriptInfo(object):
scripts_path = [Path(cls._absolute_path(os.path.normpath(f), cwd)) for f in filepaths if f]
scripts_path = [f for f in scripts_path if f.exists()]
if not scripts_path:
for f in (filepaths or []):
if f and f.endswith("/<stdin>"):
raise ScriptInfoError("python console detected")
raise ScriptInfoError(
"Script file {} could not be found".format(filepaths)
)
@ -1056,6 +1060,8 @@ class ScriptInfo(object):
@classmethod
def detect_running_module(cls, script_dict):
if not script_dict:
return script_dict
# noinspection PyBroadException
try:
# If this is jupyter, do not try to detect the running module, we know what we have.

View File

@ -275,11 +275,12 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
)
# add ide info into task runtime_properties
# noinspection PyBroadException
try:
self._set_runtime_properties(runtime_properties={"ide": result.script["ide"]})
except Exception as ex:
self.log.info("Failed logging ide information: {}".format(ex))
if result.script and result.script.get("ide"):
# noinspection PyBroadException
try:
self._set_runtime_properties(runtime_properties={"ide": result.script["ide"]})
except Exception as ex:
self.log.info("Failed logging ide information: {}".format(ex))
# store original entry point
entry_point = result.script.get('entry_point') if result.script else None