Source code for sagemaker.core.workflow.entities

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Defines the base entities used in workflow."""
from __future__ import absolute_import

import abc

from enum import EnumMeta
from typing import Any, Dict, List, Union, TYPE_CHECKING

try:
    from pydantic_core import core_schema
except ImportError:
    core_schema = None

if TYPE_CHECKING:
    pass

# Import PipelineVariable from the migrated location
from sagemaker.core.helper.pipeline_variable import PipelineVariable  # noqa: F401

PrimitiveType = Union[str, int, bool, float, None]
RequestType = Union[Dict[str, Any], List[Dict[str, Any]]]


[docs] class Entity(abc.ABC): """Base object for workflow entities. Entities must implement the to_request method. """
[docs] @abc.abstractmethod def to_request(self) -> RequestType: """Get the request structure for workflow service calls."""
[docs] class DefaultEnumMeta(EnumMeta): """An EnumMeta which defaults to the first value in the Enum list.""" default = object() def __call__(cls, *args, value=default, **kwargs): """Defaults to the first value in the Enum list.""" if value is DefaultEnumMeta.default: return next(iter(cls)) return super().__call__(value, *args, **kwargs) factory = __call__