mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
don't allow loading stages without cmd (#5373)
* don't allow loading stages without `cmd` This was loosened when introducing parametrization. But, `foreach`..`do` should be considered first before stage's regular structure. And, cmd is made required (as it should have been) Related: #5371, #5370, #5312 * fix schema
This commit is contained in:
+2
-2
@@ -79,7 +79,7 @@ PARAM_PSTAGE_NON_DEFAULT_SCHEMA = {str: [str]}
|
||||
VARS_SCHEMA = [str, dict]
|
||||
|
||||
STAGE_DEFINITION = {
|
||||
StageParams.PARAM_CMD: Any(str, list),
|
||||
Required(StageParams.PARAM_CMD): Any(str, list),
|
||||
Optional(StageParams.PARAM_WDIR): str,
|
||||
Optional(StageParams.PARAM_DEPS): [str],
|
||||
Optional(StageParams.PARAM_PARAMS): [Any(str, dict)],
|
||||
@@ -100,7 +100,7 @@ FOREACH_IN = {
|
||||
Required(FOREACH_KWD): Any(dict, list, str),
|
||||
Required(DO_KWD): STAGE_DEFINITION,
|
||||
}
|
||||
SINGLE_PIPELINE_STAGE_SCHEMA = {str: Any(STAGE_DEFINITION, FOREACH_IN)}
|
||||
SINGLE_PIPELINE_STAGE_SCHEMA = {str: Any(FOREACH_IN, STAGE_DEFINITION)}
|
||||
MULTI_STAGE_SCHEMA = {
|
||||
STAGES: SINGLE_PIPELINE_STAGE_SCHEMA,
|
||||
VARS_KWD: VARS_SCHEMA,
|
||||
|
||||
@@ -129,6 +129,12 @@ def to_pipeline_file(stage: "PipelineStage"):
|
||||
params = _serialize_params_keys(params)
|
||||
|
||||
outs, metrics, plots, live = _serialize_outs(stage.outs)
|
||||
|
||||
cmd = stage.cmd
|
||||
assert cmd, (
|
||||
f"'{stage.PARAM_CMD}' cannot be empty for stage '{stage.name}', "
|
||||
f"got: '{cmd}'(type: '{type(cmd).__name__}')"
|
||||
)
|
||||
res = [
|
||||
(stage.PARAM_DESC, stage.desc),
|
||||
(stage.PARAM_CMD, stage.cmd),
|
||||
|
||||
+2
-1
@@ -145,8 +145,9 @@ def dummy_stage(tmp_dir, dvc):
|
||||
def make(path="dvc.yaml", name="dummy_stage", **kwargs):
|
||||
from dvc.stage import PipelineStage, create_stage
|
||||
|
||||
cmd = kwargs.get("cmd", "command")
|
||||
stage = create_stage(
|
||||
PipelineStage, dvc, path, name=name, cmd="", **kwargs
|
||||
PipelineStage, dvc, path, name=name, cmd=cmd, **kwargs
|
||||
)
|
||||
stage.dump()
|
||||
return stage
|
||||
|
||||
@@ -6,7 +6,7 @@ from dvc.cli import parse_args
|
||||
from dvc.command.status import CmdDataStatus
|
||||
|
||||
|
||||
def test_cloud_status(mocker):
|
||||
def test_cloud_status(tmp_dir, dvc, mocker):
|
||||
cli_args = parse_args(
|
||||
[
|
||||
"status",
|
||||
|
||||
Reference in New Issue
Block a user