Skip to content

Commit 8b8af15

Browse files
committed
Support experiment action
1 parent 064199c commit 8b8af15

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

mlc/action.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def add(self, i):
261261

262262
target_name = i.get('target_name', self.action_type)
263263
target_path = os.path.join(repo_path, target_name)
264-
if target_name == "cache":
264+
if target_name in ["cache", "experiment"]:
265265
folder_name = f"""{i["script_alias"]}_{item_name or item_id[:8]}""" if i.get("script_alias") else item_name or item_id
266266
else:
267267
folder_name = item_name or item_id
@@ -424,7 +424,7 @@ def update(self, i):
424424
dict: Return code and message.
425425
"""
426426
# Step 1: Search for items based on input tags
427-
target_name = i.get('target_name',"cache")
427+
target_name = i.get('target_name', i.get('target', "cache"))
428428
i['target_name'] = target_name
429429
ii = i.copy()
430430

@@ -712,7 +712,7 @@ def search(self, i):
712712
if target == "script":
713713
non_variation_tags = [t for t in tags_split if not t.startswith("_")]
714714
tags_to_match = non_variation_tags
715-
elif target =="cache":
715+
elif target in ["cache", "experiment"]:
716716
tags_to_match = tags_split
717717
else:
718718
return {'return': 1, 'error': f"""Target {target} not handled in mlc yet"""}

mlc/action_factory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .repo_action import RepoAction
22
from .script_action import ScriptAction
33
from .cache_action import CacheAction
4+
from .experiment_action import ExperimentAction
45

56

67
# Factory to get the appropriate action class
@@ -11,5 +12,6 @@ def get_action(target, parent):
1112
actions = {
1213
'repo': RepoAction,
1314
'script': ScriptAction,
14-
'cache': CacheAction
15+
'cache': CacheAction,
16+
'experiment': ExperimentAction
1517
}

mlc/experiment_action.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
class ExperimentAction(Action):
77
def __init__(self, parent=None):
8-
if parent is None:
9-
parent = default_parent
108
#super().__init__(parent)
119
self.parent = parent
1210
self.__dict__.update(vars(parent))

0 commit comments

Comments
 (0)