mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-04 15:28:27 +01:00
* update ruff and enable flake8-logging-format and flake8-type-checking check * Update dvc/external_repo.py * Update dvc/fs/dvc.py * Update dvc/repo/experiments/__init__.py * Update dvc/repo/experiments/queue/base.py * Update pyproject.toml
36 lines
1020 B
Python
36 lines
1020 B
Python
from dataclasses import asdict, dataclass, field, fields
|
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
|
|
from funcy import compact
|
|
|
|
|
|
@dataclass
|
|
class Annotation:
|
|
PARAM_DESC: ClassVar[str] = "desc"
|
|
PARAM_TYPE: ClassVar[str] = "type"
|
|
PARAM_LABELS: ClassVar[str] = "labels"
|
|
PARAM_META: ClassVar[str] = "meta"
|
|
|
|
desc: Optional[str] = None
|
|
type: Optional[str] = None # noqa: A003
|
|
labels: List[str] = field(default_factory=list)
|
|
meta: Dict[str, Any] = field(default_factory=dict)
|
|
|
|
def update(self, **kwargs) -> "Annotation":
|
|
for attr, value in kwargs.items():
|
|
if value and hasattr(self, attr):
|
|
setattr(self, attr, value)
|
|
return self
|
|
|
|
def to_dict(self) -> Dict[str, str]:
|
|
return compact(asdict(self))
|
|
|
|
|
|
ANNOTATION_FIELDS = [field.name for field in fields(Annotation)]
|
|
ANNOTATION_SCHEMA = {
|
|
Annotation.PARAM_DESC: str,
|
|
Annotation.PARAM_TYPE: str,
|
|
Annotation.PARAM_LABELS: [str],
|
|
Annotation.PARAM_META: object,
|
|
}
|