Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common models to flytekit __init__ #729

Merged
merged 4 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions flytekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@
Secret
SecurityContext


Common Flyte IDL Objects
=========================

.. autosummary::
:nosignatures:
:template: custom.rst
:toctree: generated/

AuthRole
Labels
Annotations
WorkflowExecutionPhase
Blob
BlobMetadata
Literal
Scalar
LiteralType
BlobType
"""

import sys
Expand Down Expand Up @@ -162,6 +181,10 @@
from flytekit.core.workflow import WorkflowFailurePolicy, reference_workflow, workflow
from flytekit.extras.persistence import GCSPersistence, HttpPersistence, S3Persistence
from flytekit.loggers import logger
from flytekit.models.admin.common import Annotations, AuthRole, Labels
from flytekit.models.core.execution import WorkflowExecutionPhase
from flytekit.models.core.literals import Blob, BlobMetadata, Literal, Scalar
from flytekit.models.core.types import BlobType, LiteralType
from flytekit.types import directory, file, schema

__version__ = "0.0.0+develop"
Expand Down
8 changes: 5 additions & 3 deletions flytekit/models/admin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,12 @@ def from_flyte_idl(cls, p):
class AuthRole(FlyteIdlEntity):
def __init__(self, assumable_iam_role=None, kubernetes_service_account=None):
"""
At most one of assumable_iam_role or kubernetes_service_account can be set.
Either one or both of the assumable IAM role and/or the K8s service account can be set.

:param Text assumable_iam_role: IAM identity with set permissions policies.
:param Text kubernetes_service_account: Provides an identity for workflow execution resources. Flyte deployment
administrators are responsible for handling permissions as they relate to the service account.
:param Text kubernetes_service_account: Provides an identity for workflow execution resources.
Flyte deployment administrators are responsible for handling permissions as they
relate to the service account.
"""
self._assumable_iam_role = assumable_iam_role
self._kubernetes_service_account = kubernetes_service_account
Expand Down
5 changes: 5 additions & 0 deletions flytekit/models/core/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@


class WorkflowExecutionPhase(object):
"""
This class holds enum values used for setting notifications. See :py:class:`flytekit.Email`
for sample usage.
"""

UNDEFINED = _execution_pb2.WorkflowExecution.UNDEFINED
QUEUED = _execution_pb2.WorkflowExecution.QUEUED
RUNNING = _execution_pb2.WorkflowExecution.RUNNING
Expand Down
9 changes: 9 additions & 0 deletions flytekit/models/core/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ def from_flyte_idl(cls, pb2_object):


class BlobMetadata(_common.FlyteIdlEntity):
"""
This is metadata for the Blob literal.
"""

def __init__(self, type):
"""
:param flytekit.models.core.types.BlobType type: The type of the underlying blob
Expand Down Expand Up @@ -237,6 +241,9 @@ def from_flyte_idl(cls, proto):
class Blob(_common.FlyteIdlEntity):
def __init__(self, metadata, uri):
"""
This literal model is used to represent binary data offloaded to some storage location which is
identifiable with a unique string. See :py:class:`flytekit.FlyteFile` as an example.

:param BlobMetadata metadata:
:param Text uri: The location of this blob
"""
Expand Down Expand Up @@ -721,6 +728,8 @@ def from_flyte_idl(cls, pb2_object):
class Literal(_common.FlyteIdlEntity):
def __init__(self, scalar: Scalar = None, collection: LiteralCollection = None, map: LiteralMap = None):
"""
This IDL message represents a literal value in the Flyte ecosystem.

:param Scalar scalar:
:param LiteralCollection collection:
:param LiteralMap map:
Expand Down
7 changes: 6 additions & 1 deletion flytekit/models/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def from_flyte_idl(cls, proto: _types_pb2.EnumType):


class BlobType(_common.FlyteIdlEntity):
"""
This type represents offloaded data and is typically used for things like files.
"""

class BlobDimensionality(object):
SINGLE = _types_pb2.BlobType.SINGLE
MULTIPART = _types_pb2.BlobType.MULTIPART
Expand Down Expand Up @@ -176,7 +180,8 @@ def __init__(
metadata=None,
):
"""
Only one of the kwargs may be set.
This is a oneof message, only one of the kwargs may be set, representing one of the Flyte types.

:param int simple: Enum type from SimpleType
:param flytekit.models.core.types.SchemaType schema: Type definition for a dataframe-like object.
:param LiteralType collection_type: For list-like objects, this is the type of each entry in the list.
Expand Down