|
@@ -1,16 +1,17 @@
|
|
|
"""Common objects and base classes in the CI hierarchy"""
|
|
"""Common objects and base classes in the CI hierarchy"""
|
|
|
|
|
|
|
|
import abc
|
|
import abc
|
|
|
|
|
+import dataclasses
|
|
|
import os
|
|
import os
|
|
|
|
|
|
|
|
from contextlib import contextmanager
|
|
from contextlib import contextmanager
|
|
|
-from dataclasses import dataclass, field
|
|
|
|
|
from enum import Enum, auto
|
|
from enum import Enum, auto
|
|
|
from functools import reduce
|
|
from functools import reduce
|
|
|
from types import SimpleNamespace
|
|
from types import SimpleNamespace
|
|
|
from typing import Any, Callable, Iterator, Literal, overload
|
|
from typing import Any, Callable, Iterator, Literal, overload
|
|
|
|
|
|
|
|
from pydantic import BaseModel, Field
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
+from pydantic_core import core_schema
|
|
|
|
|
|
|
|
|
|
|
|
|
class Status(Enum):
|
|
class Status(Enum):
|
|
@@ -37,8 +38,15 @@ class Outputs(BaseModel):
|
|
|
class Ref(str):
|
|
class Ref(str):
|
|
|
"""Annotation class describing a reference into Context or another place"""
|
|
"""Annotation class describing a reference into Context or another place"""
|
|
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
|
+ # pylint: disable=unused-argument
|
|
|
|
|
+ def __get_pydantic_core_schema__(cls, source, handler) -> core_schema.CoreSchema:
|
|
|
|
|
+ return core_schema.general_plain_validator_function(
|
|
|
|
|
+ lambda s: s and all(t for t in s.split("."))
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
|
|
|
-@dataclass
|
|
|
|
|
|
|
+@dataclasses.dataclass
|
|
|
class Factory:
|
|
class Factory:
|
|
|
"""Annotation class describing a non-trivial synthesized property"""
|
|
"""Annotation class describing a non-trivial synthesized property"""
|
|
|
|
|
|
|
@@ -50,12 +58,12 @@ class Results(SimpleNamespace):
|
|
|
Holder object for tracking the result of an action for Composite/Workflow actions
|
|
Holder object for tracking the result of an action for Composite/Workflow actions
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
- @dataclass
|
|
|
|
|
|
|
+ @dataclasses.dataclass
|
|
|
class Item:
|
|
class Item:
|
|
|
"""Result of a single action that needs to be tracked"""
|
|
"""Result of a single action that needs to be tracked"""
|
|
|
|
|
|
|
|
conclusion: Status = Status.NOT_RUN
|
|
conclusion: Status = Status.NOT_RUN
|
|
|
- outputs: Outputs = field(default_factory=Outputs)
|
|
|
|
|
|
|
+ outputs: Outputs = dataclasses.field(default_factory=Outputs)
|
|
|
|
|
|
|
|
def __contains__(self, subscript: str) -> bool:
|
|
def __contains__(self, subscript: str) -> bool:
|
|
|
return hasattr(self, subscript)
|
|
return hasattr(self, subscript)
|