Skip to content

Commit d7f0ab3

Browse files
committed
add list action for script and cache
1 parent 4993121 commit d7f0ab3

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.github/workflows/test-mlc-core-actions.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,13 @@ jobs:
185185
mlc rm script get-ipol-src -f
186186
mlc rm script --tags=app,image,corner-detection -f
187187
mlc rm script 63080407db4d4ac4 -f
188+
189+
- name: Test 19 - list script
190+
run: |
191+
mlc list script
192+
193+
- name: Test 20 - list cache
194+
run: |
195+
mlc list cache
196+
188197

mlc/main.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,21 @@ def test(self, run_args):
15151515

15161516

15171517
def list(self, args):
1518-
logger.info("Listing all scripts.")
1518+
self.action_type = "script"
1519+
run_args = {"fetch_all": True} # to fetch the details of all the scripts present in repos registered in mlc
1520+
1521+
res = self.search(run_args)
1522+
if res['return'] > 0:
1523+
return res
1524+
1525+
logger.info(f"Listing all the scripts and their paths present in repos which are registered in MLC")
1526+
print("......................................................")
1527+
for item in res['list']:
1528+
print(f"alias: {item.meta['alias'] if item.meta.get('alias') else 'None'}")
1529+
print(f"Location: {item.path}")
1530+
print("......................................................")
1531+
1532+
return {"return": 0}
15191533

15201534

15211535
class ScriptExecutionError(Exception):
@@ -1579,7 +1593,20 @@ def show(self, run_args):
15791593
return {'return': 0}
15801594

15811595
def list(self, args):
1582-
logger.info("Listing all caches.")
1596+
self.action_type = "cache"
1597+
run_args = {"fetch_all": True} # to fetch the details of all the caches generated
1598+
1599+
res = self.search(run_args)
1600+
if res['return'] > 0:
1601+
return res
1602+
1603+
logger.info(f"Listing all the caches and their paths")
1604+
print("......................................................")
1605+
for item in res['list']:
1606+
print(f"tags: {item.meta['tags'] if item.meta.get('tags') else 'None'}")
1607+
print(f"Location: {item.path}")
1608+
print("......................................................")
1609+
15831610
return {'return': 0}
15841611

15851612
class ExperimentAction(Action):

0 commit comments

Comments
 (0)