Skip to content

Commit d2911e7

Browse files
authored
Fix cache_expiration, support mlc prune cache (#213)
1 parent 4cf7dff commit d2911e7

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

VERSION

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

mlc/cache_action.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .action import Action
22
import os
33
import json
4+
import time
45
from . import utils
56
from .logger import logger
67

@@ -59,7 +60,7 @@ def search(self, i):
5960
continue # skip item
6061
'''
6162

62-
expiration_time = item_meta.get('expiration_time')
63+
expiration_time = item_meta.get('cache_expiration')
6364
if expiration_time is not None and expiration_time < time.time():
6465
continue # skip expired item
6566

@@ -158,6 +159,42 @@ def show(self, run_args):
158159

159160
return {'return': 0}
160161

162+
163+
164+
def prune(self, args):
165+
"""
166+
####################################################################################################################
167+
Target: Cache
168+
Action: Prune
169+
####################################################################################################################
170+
171+
Prune all expired cached items
172+
173+
Example Command:
174+
175+
mlc prune cache
176+
177+
"""
178+
self.action_type = "cache"
179+
run_args = {"fetch_all": True} # to fetch the details of all the caches generated
180+
181+
res = self.search(run_args)
182+
if res['return'] > 0:
183+
return res
184+
185+
for item in res['list']:
186+
expiration_time = item.meta.get('cache_expiration')
187+
if expiration_time is not None and expiration_time < time.time():
188+
ii = {}
189+
ii['f'] = True
190+
ii['item'] = item.meta.get('uid')
191+
if ii['item']:
192+
self.rm(ii)
193+
194+
return {'return': 0}
195+
196+
197+
161198
def list(self, args):
162199
"""
163200
####################################################################################################################

mlc/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def build_parser(pre_args):
155155
subparsers = parser.add_subparsers(dest="command", required=not pre_args.help)
156156

157157
# General commands
158-
for action in ['run', 'pull', 'test', 'add', 'show', 'list', 'find', 'search', 'rm', 'cp', 'mv', 'help']:
158+
for action in ['run', 'pull', 'test', 'add', 'show', 'list', 'find', 'search', 'rm', 'cp', 'mv', 'help', 'prune']:
159159
p = subparsers.add_parser(action, add_help=False)
160160
p.add_argument('target', choices=['repo', 'repos', 'script', 'cache'])
161161
p.add_argument('details', nargs='?', help='Details or identifier (optional)')

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.16"
7+
version = "1.1.17"
88

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

0 commit comments

Comments
 (0)