From cd5b4d2186e0e55569203e6a023f6cd5313e1f77 Mon Sep 17 00:00:00 2001
From: allegroai <>
Date: Wed, 24 Jul 2024 17:43:21 +0300
Subject: [PATCH] Add "-m module args" in script entry now supports standalone
script, standalone script is converted to "untitled.py" by default or if
specified in working_dir such as
: for example
".:standalone.py"
---
clearml_agent/commands/worker.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/clearml_agent/commands/worker.py b/clearml_agent/commands/worker.py
index a207cfd..b0c5f91 100644
--- a/clearml_agent/commands/worker.py
+++ b/clearml_agent/commands/worker.py
@@ -224,6 +224,17 @@ class LiteralScriptManager(object):
:return: directory and script path
"""
log = logging.getLogger(__name__)
+ target_file_name_module_call = None
+ if execution.entry_point and execution.entry_point.strip().startswith("-m "):
+ # this is a module we cannot use it as file name
+ target_file_name_module_call = 'untitled.py'
+ # let's [arse the working_dir
+ if execution.working_dir and ":" in execution.working_dir:
+ execution.working_dir, target_file_name_module_call = execution.working_dir.split(":", 1)
+ log.warning(
+ "found task with `script.entry_point` "
+ "using a module defaulting to: {}".format(target_file_name_module_call))
+
if repo_info and repo_info.root:
location = Path(repo_info.root, execution.working_dir)
else:
@@ -234,7 +245,7 @@ class LiteralScriptManager(object):
)
if not execution.entry_point:
execution.entry_point = 'untitled.py'
- else:
+ elif not target_file_name_module_call:
# ignore any folders in the entry point we only need the file name
execution.entry_point = execution.entry_point.split(os.path.sep)[-1]
location = None
@@ -243,7 +254,8 @@ class LiteralScriptManager(object):
location = Path(self.venv_folder, WORKING_STANDALONE_DIR)
location.mkdir(exist_ok=True, parents=True)
log.debug("selected execution directory: %s", location)
- return Text(location), self.write(task, location, execution.entry_point)
+ target_file = self.write(task, location, target_file_name_module_call or execution.entry_point)
+ return Text(location), execution.entry_point if target_file_name_module_call else target_file
def get_repo_auth_string(user, password):