Skip to content

Commit

Permalink
allow executor in debug mode (#184)
Browse files Browse the repository at this point in the history
Signed-off-by: zjgemi <liuxin_zijian@163.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
zjgemi and pre-commit-ci[bot] committed Jan 30, 2024
1 parent 71f2918 commit 0f843bf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dpgen2/utils/step_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def gen_doc(*, make_anchor=True, make_link=True, **kwargs):
def init_executor(
executor_dict,
):
if executor_dict is None or config["mode"] == "debug":
if executor_dict is None:
return None
etype = executor_dict.pop("type")
if etype == "dispatcher":
Expand Down
29 changes: 29 additions & 0 deletions tests/entrypoint/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,36 @@ def tearDown(self):

def test(self):
wf_config = json.loads(input_std)
remove_executor_if_debug(wf_config)
submit_concurrent_learning(wf_config, no_submission=True)


def remove_executor_if_debug(conf):
from dflow.config import (
config,
)

if config["mode"] == "debug":
if "default_step_config" in conf and "executor" in conf["default_step_config"]:
del conf["default_step_config"]["executor"]
if "step_configs" in conf:
if (
"run_train_config" in conf["step_configs"]
and "executor" in conf["step_configs"]["run_train_config"]
):
del conf["step_configs"]["run_train_config"]["executor"]
if (
"run_explore_config" in conf["step_configs"]
and "executor" in conf["step_configs"]["run_explore_config"]
):
del conf["step_configs"]["run_explore_config"]["executor"]
if (
"run_fp_config" in conf["step_configs"]
and "executor" in conf["step_configs"]["run_fp_config"]
):
del conf["step_configs"]["run_fp_config"]["executor"]


class TestSubmitCmdDist(unittest.TestCase):
def setUp(self):
from dflow.config import (
Expand Down Expand Up @@ -408,6 +435,7 @@ def tearDown(self):

def test(self):
wf_config = json.loads(input_dist)
remove_executor_if_debug(wf_config)
submit_concurrent_learning(wf_config, no_submission=True)


Expand Down Expand Up @@ -444,6 +472,7 @@ def tearDown(self):

def test(self):
wf_config = json.loads(input_finetune)
remove_executor_if_debug(wf_config)
submit_concurrent_learning(wf_config, no_submission=True)


Expand Down
6 changes: 0 additions & 6 deletions tests/utils/test_step_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ def test_init_executor(self):
},
}
odict = normalize(idict)
with dflow_mode("debug"):
ret = init_executor(deepcopy(odict).pop("executor"))
self.assertTrue(ret is None)

with dflow_mode("default"):
ret = init_executor(deepcopy(odict).pop("executor"))
Expand All @@ -136,9 +133,6 @@ def test_init_executor_dispatcher(self):
}
odict = normalize(idict)
self.assertEqual(odict["executor"], idict["executor"])
with dflow_mode("debug"):
ret = init_executor(deepcopy(odict).pop("executor"))
self.assertTrue(ret is None)

with dflow_mode("default"):
ret = init_executor(deepcopy(odict).pop("executor"))
Expand Down

0 comments on commit 0f843bf

Please sign in to comment.