Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow executor in debug mode #184

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading