Skip to content

Commit 26ac2f9

Browse files
authored
Merge pull request #177 from GATEOverflow/dev
Support cache expiry, export mlc_run_cmd to script runs
2 parents 50ec2bb + 17dc8d4 commit 26ac2f9

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

mlc/cache_action.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,30 @@ def search(self, i):
4242
"""
4343
i['target_name'] = "cache"
4444
#logger.debug(f"Searching for cache with input: {i}")
45-
return self.parent.search(i)
45+
r = self.parent.search(i)
46+
if r['return'] > 0:
47+
return r
48+
cleaned_list = []
49+
50+
for item in r['list']:
51+
item_meta = item.meta
52+
dep = item_meta.get('dependent_cached_path')
53+
if dep and not os.path.exists(dep):
54+
continue # skip item
55+
56+
deps = item_meta.get('dependent_cached_paths', '').split(',')
57+
if any(d and not os.path.exists(d) for d in deps):
58+
continue # skip item
59+
60+
expiration_time = item_meta.get('expiration_time')
61+
if expiration_time is not None and expiration_time < time.time():
62+
continue # skip expired item
63+
64+
cleaned_list.append(item)
65+
66+
r['list'] = cleaned_list
67+
68+
return r
4669

4770
find = search
4871

@@ -98,6 +121,9 @@ def show(self, run_args):
98121
"""
99122
self.action_type = "cache"
100123
res = self.search(run_args)
124+
if res['return'] > 0:
125+
return res
126+
101127
logger.info(f"Showing cache with tags: {run_args.get('tags')}")
102128
cached_meta_keys_to_show = ["uid", "tags", "dependent_cached_path", "associated_script_item"]
103129
cached_state_keys_to_show = ["new_env", "new_state", "version"]

mlc/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def main():
200200
return res
201201

202202
run_args = res['args_dict']
203+
run_args['mlc_run_cmd'] = " ".join(sys.argv)
203204

204205
# handle help in mlcflow
205206
if args.command in ['help']:

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.0.20"
7+
version = "1.0.21"
88

99

1010

0 commit comments

Comments
 (0)