output/dep: specify schema as a dictionary (#6061)

This commit is contained in:
Saugat Pachhai
2021-05-26 14:58:51 +03:00
committed by GitHub
parent e28726c057
commit d818e70bf3
2 changed files with 24 additions and 19 deletions
+7 -8
View File
@@ -1,7 +1,7 @@
from collections import defaultdict
from typing import Any, Mapping
import dvc.output as output
from dvc.output import Output
from dvc.output import ARTIFACT_SCHEMA, Output
from .base import Dependency
from .param import ParamsDependency
@@ -11,12 +11,11 @@ from .repo import RepoDependency
# without output-specific entries like 'cache' (whether or not output is
# cached, see -o and -O flags for `dvc run`) and 'metric' (whether or not
# output is a metrics file and how to parse it, see `-M` flag for `dvc run`).
SCHEMA = output.SCHEMA.copy()
del SCHEMA[Output.PARAM_CACHE]
del SCHEMA[Output.PARAM_METRIC]
del SCHEMA[Output.PARAM_DESC]
SCHEMA.update(RepoDependency.REPO_SCHEMA)
SCHEMA.update(ParamsDependency.PARAM_SCHEMA)
SCHEMA: Mapping[str, Any] = {
**ARTIFACT_SCHEMA,
**RepoDependency.REPO_SCHEMA,
**ParamsDependency.PARAM_SCHEMA,
}
def _get(stage, p, info):
+17 -11
View File
@@ -976,14 +976,20 @@ class Output:
return self.path_info.fspath
SCHEMA = CHECKSUMS_SCHEMA.copy()
SCHEMA[Required(Output.PARAM_PATH)] = str
SCHEMA[Output.PARAM_CACHE] = bool
SCHEMA[Output.PARAM_METRIC] = Output.METRIC_SCHEMA
SCHEMA[Output.PARAM_PLOT] = bool
SCHEMA[Output.PARAM_PERSIST] = bool
SCHEMA[Output.PARAM_CHECKPOINT] = bool
SCHEMA[HashInfo.PARAM_SIZE] = int
SCHEMA[HashInfo.PARAM_NFILES] = int
SCHEMA[Output.PARAM_DESC] = str
SCHEMA[Output.PARAM_ISEXEC] = bool
ARTIFACT_SCHEMA = {
**CHECKSUMS_SCHEMA,
Required(Output.PARAM_PATH): str,
Output.PARAM_PLOT: bool,
Output.PARAM_PERSIST: bool,
Output.PARAM_CHECKPOINT: bool,
HashInfo.PARAM_SIZE: int,
HashInfo.PARAM_NFILES: int,
Output.PARAM_ISEXEC: bool,
}
SCHEMA = {
**ARTIFACT_SCHEMA,
Output.PARAM_CACHE: bool,
Output.PARAM_METRIC: Output.METRIC_SCHEMA,
Output.PARAM_DESC: str,
}