Skip to content

Commit

Permalink
Add top-level access to FlyteRemote, FlyteFile, and FlyteDirectory an…
Browse files Browse the repository at this point in the history
…d convenience class methods for FlyteRemote (#2836) (#2904)

Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Grantham Taylor <[email protected]>
  • Loading branch information
eapolinario and granthamtaylor authored Nov 5, 2024
1 parent e14f5a9 commit 61c066c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
4 changes: 4 additions & 0 deletions flytekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
from importlib.metadata import entry_points

from flytekit._version import __version__
from flytekit.configuration import Config
from flytekit.core.array_node_map_task import map_task
from flytekit.core.artifact import Artifact
from flytekit.core.base_sql_task import SQLTask
Expand Down Expand Up @@ -249,8 +250,11 @@
from flytekit.models.documentation import Description, Documentation, SourceCode
from flytekit.models.literals import Blob, BlobMetadata, Literal, Scalar
from flytekit.models.types import LiteralType
from flytekit.remote import FlyteRemote
from flytekit.sensor.sensor_engine import SensorEngine
from flytekit.types import directory, file, iterator
from flytekit.types.directory import FlyteDirectory
from flytekit.types.file import FlyteFile
from flytekit.types.structured.structured_dataset import (
StructuredDataset,
StructuredDatasetFormat,
Expand Down
67 changes: 66 additions & 1 deletion flytekit/remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from flytekit import ImageSpec
from flytekit.clients.friendly import SynchronousFlyteClient
from flytekit.clients.helpers import iterate_node_executions, iterate_task_executions
from flytekit.configuration import Config, FastSerializationSettings, ImageConfig, SerializationSettings
from flytekit.configuration import Config, DataConfig, FastSerializationSettings, ImageConfig, SerializationSettings
from flytekit.configuration.file import ConfigFile
from flytekit.constants import CopyFileDetection
from flytekit.core import constants, utils
from flytekit.core.artifact import Artifact
Expand Down Expand Up @@ -2509,3 +2510,67 @@ def download(
lm = data
for var, literal in lm.items():
download_literal(self.file_access, var, literal, download_to)

@classmethod
def for_endpoint(
cls,
endpoint: str,
insecure: bool = False,
data_config: typing.Optional[DataConfig] = None,
config_file: typing.Union[str, ConfigFile] = None,
default_project: typing.Optional[str] = None,
default_domain: typing.Optional[str] = None,
data_upload_location: str = "flyte://my-s3-bucket/",
interactive_mode_enabled: bool = False,
**kwargs,
) -> "FlyteRemote":
return cls(
config=Config.for_endpoint(
endpoint=endpoint,
insecure=insecure,
data_config=data_config,
config_file=config_file,
),
default_project=default_project,
default_domain=default_domain,
data_upload_location=data_upload_location,
interactive_mode_enabled=interactive_mode_enabled,
**kwargs,
)

@classmethod
def auto(
cls,
config_file: typing.Union[str, ConfigFile] = None,
default_project: typing.Optional[str] = None,
default_domain: typing.Optional[str] = None,
data_upload_location: str = "flyte://my-s3-bucket/",
interactive_mode_enabled: bool = False,
**kwargs,
) -> "FlyteRemote":
return cls(
config=Config.auto(config_file=config_file),
default_project=default_project,
default_domain=default_domain,
data_upload_location=data_upload_location,
interactive_mode_enabled=interactive_mode_enabled,
**kwargs,
)

@classmethod
def for_sandbox(
cls,
default_project: typing.Optional[str] = None,
default_domain: typing.Optional[str] = None,
data_upload_location: str = "flyte://my-s3-bucket/",
interactive_mode_enabled: bool = False,
**kwargs,
) -> "FlyteRemote":
return cls(
config=Config.for_sandbox(),
default_project=default_project,
default_domain=default_domain,
data_upload_location=data_upload_location,
interactive_mode_enabled=interactive_mode_enabled,
**kwargs,
)

0 comments on commit 61c066c

Please sign in to comment.