Skip to content

Commit 3140996

Browse files
committed
Support run_args for ScriptAutomation
1 parent de6f1d9 commit 3140996

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.15
1+
1.1.16

mlc/index.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _save_modified_times(self):
5858
"""
5959
Save updated mtimes in modified_times json file.
6060
"""
61-
logger.debug(f"Saving modified times to {self.modified_times_file}")
61+
#logger.debug(f"Saving modified times to {self.modified_times_file}")
6262
with open(self.modified_times_file, "w") as f:
6363
json.dump(self.modified_times, f, indent=4)
6464

@@ -164,11 +164,11 @@ def build_index(self):
164164
#file does not exist, rebuild
165165
if not os.path.exists(index_json_path):
166166
logger.warning("index_script.json missing. Forcing full index rebuild...")
167-
logger.debug("Resetting modified_times...")
167+
#logger.debug("Resetting modified_times...")
168168
self.modified_times = {}
169169
self._save_modified_times()
170-
else:
171-
logger.debug("index_script.json exists. Skipping forced rebuild.")
170+
#else:
171+
# logger.debug("index_script.json exists. Skipping forced rebuild.")
172172

173173
#check repos.json mtime
174174
repos_json_path = os.path.join(self.repos_path, "repos.json")
@@ -178,8 +178,8 @@ def build_index(self):
178178
old = self.modified_times.get(key)
179179
repo_old_mtime = old["mtime"] if isinstance(old, dict) else old
180180

181-
logger.debug(f"Current repos.json mtime: {repos_mtime}")
182-
logger.debug(f"Old repos.json mtime: {repo_old_mtime}")
181+
#logger.debug(f"Current repos.json mtime: {repos_mtime}")
182+
#logger.debug(f"Old repos.json mtime: {repo_old_mtime}")
183183
current_item_keys.add(key)
184184

185185
# if changed, reset indexes
@@ -197,8 +197,8 @@ def build_index(self):
197197
self._save_indices()
198198
self._save_modified_times()
199199
repos_changed = True
200-
else:
201-
logger.debug("Repos.json not modified")
200+
#else:
201+
# logger.debug("Repos.json not modified")
202202

203203
for repo in self.repos:
204204
repo_path = repo.path #os.path.join(self.repos_path, repo)
@@ -230,7 +230,7 @@ def build_index(self):
230230
# logger.debug(f"Found JSON config file: {json_path}")
231231
config_path = json_path
232232
else:
233-
logger.debug(f"No config file found in {automation_path}, skipping")
233+
#logger.debug(f"No config file found in {automation_path}, skipping")
234234
delete_flag = False
235235
if automation_dir in self.modified_times:
236236
del self.modified_times[automation_dir]
@@ -251,18 +251,19 @@ def build_index(self):
251251
if old_mtime == mtime and repos_changed != 1:
252252
# logger.debug(f"No changes detected for {config_path}, skipping reindexing.")
253253
continue
254-
if(old_mtime is None):
255-
logger.debug(f"New config file detected: {config_path}. Adding to index.")
254+
#if(old_mtime is None):
255+
# logger.debug(f"New meta.yaml file detected: {config_path}. Adding to index.")
256+
256257
# update mtime
257-
logger.debug(f"{config_path} is modified, index getting updated")
258-
if config_path not in self.modified_times:
259-
logger.debug(f"*************{config_path} not found in modified_times; creating new entry***************")
258+
#logger.debug(f"{config_path} is modified, index getting updated")
259+
#if config_path not in self.modified_times:
260+
# logger.debug(f"*************{config_path} not found in modified_times; creating new entry***************")
260261

261262
self.modified_times[config_path] = {
262263
"mtime": mtime,
263264
"date_time": datetime.fromtimestamp(mtime).strftime("%Y-%m-%d %H:%M:%S")
264265
}
265-
logger.debug(f"Modified time for {config_path} updated to {mtime}")
266+
#logger.debug(f"Modified time for {config_path} updated to {mtime}")
266267
changed = True
267268
# meta file changed, so reindex
268269
self._process_config_file(config_path, folder_type, automation_path, repo)
@@ -271,21 +272,22 @@ def build_index(self):
271272
old_keys = set(self.modified_times.keys())
272273
deleted_keys = old_keys - current_item_keys
273274
for key in deleted_keys:
274-
logger.warning(f"Detected deleted item, removing entry form modified times: {key}")
275+
logger.warning(f"Detected deleted item, removing entry from modified times: {key}")
275276
del self.modified_times[key]
276277
folder_key = os.path.dirname(key)
277-
logger.warning(f"Removing index entry for folder: {folder_key}")
278+
#logger.warning(f"Removing index entry for folder: {folder_key}")
278279
self._remove_index_entry(folder_key)
279280
changed = True
280-
logger.debug(f"Deleted keys removed from modified times and indices: {deleted_keys}")
281+
if deleted_keys:
282+
logger.debug(f"Deleted keys removed from modified times and indices: {deleted_keys}")
281283

282284
if changed:
283285
logger.debug("Changes detected, saving updated index and modified times.")
284286
self._save_modified_times()
285287
self._save_indices()
286-
logger.debug("**************Index updated (changes detected).*************************")
287-
else:
288-
logger.debug("**************Index unchanged (no changes detected).********************")
288+
#logger.debug("**************Index updated (changes detected).*************************")
289+
#else:
290+
#logger.debug("**************Index unchanged (no changes detected).********************")
289291

290292
def _remove_index_entry(self, key):
291293
logger.debug(f"Removing index entry for {key}")
@@ -299,7 +301,7 @@ def _delete_by_uid(self, folder_type, uid, alias):
299301
"""
300302
Delete old index entry using UID (prevents duplicates).
301303
"""
302-
logger.debug(f"Deleting and updating index entry for the script {alias} with UID {uid}")
304+
#logger.debug(f"Deleting and updating index entry for the script {alias} with UID {uid}")
303305
self.indices[folder_type] = [
304306
item for item in self.indices[folder_type]
305307
if item["uid"] != uid

mlc/script_action.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import importlib
55
import json
6+
import inspect
67
from .index import Index
78
from . import utils
89
from .logger import logger
@@ -249,7 +250,15 @@ def call_script_module_function(self, function_name, run_args):
249250

250251
# Check if ScriptAutomation is defined in the module
251252
if hasattr(module, 'ScriptAutomation'):
252-
automation_instance = module.ScriptAutomation(self, module_path)
253+
ctor = module.ScriptAutomation.__init__
254+
params = inspect.signature(ctor).parameters
255+
256+
if 'run_args' in params:
257+
automation_instance = module.ScriptAutomation(self, module_path, run_args)
258+
else:
259+
automation_instance = module.ScriptAutomation(self, module_path)
260+
261+
automation_instance = module.ScriptAutomation(self, module_path, run_args)
253262
if function_name == "run":
254263
result = automation_instance.run(run_args) # Pass args to the run method
255264
elif function_name == "docker":

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mlcflow"
7-
version = "1.1.15"
7+
version = "1.1.16"
88

99
description = "An automation interface tailored for CPU/GPU benchmarking"
1010
authors = [

0 commit comments

Comments
 (0)