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 top-level access to FlyteRemote, FlyteFile, and FlyteDirectory and convenience class methods for FlyteRemote (#2836) #2904

Merged
merged 1 commit into from
Nov 5, 2024
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
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 @@
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(

Check warning on line 2527 in flytekit/remote/remote.py

View check run for this annotation

Codecov / codecov/patch

flytekit/remote/remote.py#L2527

Added line #L2527 was not covered by tests
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(

Check warning on line 2551 in flytekit/remote/remote.py

View check run for this annotation

Codecov / codecov/patch

flytekit/remote/remote.py#L2551

Added line #L2551 was not covered by tests
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(

Check warning on line 2569 in flytekit/remote/remote.py

View check run for this annotation

Codecov / codecov/patch

flytekit/remote/remote.py#L2569

Added line #L2569 was not covered by tests
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,
)
Loading