Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 2 additions & 3 deletions flytekit/clis/sdk_in_container/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ def run_remote(
execution = remote.execute(
entity,
inputs=inputs,
project=project,
domain=domain,
project=remote.default_project or project,
domain=remote.default_domain or domain,
execution_name=run_level_params.name,
options=options_from_run_params(run_level_params),
type_hints=type_hints,
Expand Down Expand Up @@ -762,7 +762,6 @@ def _run(*args, **kwargs):
fg="red",
)
)

with context_manager.FlyteContextManager.with_context(remote.context.new_builder()):
show_files = run_level_params.verbose > 0
fast_package_options = FastPackageOptions(
Expand Down
35 changes: 31 additions & 4 deletions flytekit/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,26 @@ def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> LocalConfig:
return LocalConfig(**kwargs)


@dataclass(init=True, repr=True, eq=True, frozen=True)
class FieldConfig(object):
"""
Any Project/Domain/Org configuration.
"""

project: Optional[str] = None
domain: Optional[str] = None
org: Optional[str] = None

@classmethod
def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> FieldConfig:
config_file = get_config_file(config_file)
kwargs = {}
kwargs = set_if_exists(kwargs, "project", _internal.Local.USER_PROJECT.read(config_file))
kwargs = set_if_exists(kwargs, "domain", _internal.Local.USER_DOMAIN.read(config_file))
kwargs = set_if_exists(kwargs, "org", _internal.Local.USER_ORG.read(config_file))
return FieldConfig(**kwargs)


@dataclass(init=True, repr=True, eq=True, frozen=True)
class Config(object):
"""
Expand All @@ -673,17 +693,21 @@ class Config(object):
2. Some parts are required for Serialization, for example Platform Config is not required
3. Runtime of a task

Args:
entrypoint_settings: EntrypointSettings object for use with Spark tasks. If supplied, this will be
used when serializing Spark tasks, which need to know the path to the flytekit entrypoint.py file,
inside the container.
Attributes:
platform (PlatformConfig): Settings to connect to a Flyte backend.
secrets (SecretsConfig): Configuration for secrets management.
stats (StatsConfig): Configuration for statsd metrics.
data_config (DataConfig): Data storage configuration.
local_sandbox_path (str): Path for local sandbox runs.
field_config (FieldConfig): Project/Domain/Org configuration.
"""

platform: PlatformConfig = PlatformConfig()
secrets: SecretsConfig = SecretsConfig()
stats: StatsConfig = StatsConfig()
data_config: DataConfig = DataConfig()
local_sandbox_path: str = tempfile.mkdtemp(prefix="flyte")
field_config: FieldConfig = FieldConfig()

def with_params(
self,
Expand All @@ -692,13 +716,15 @@ def with_params(
stats: StatsConfig = None,
data_config: DataConfig = None,
local_sandbox_path: str = None,
field_config: FieldConfig = None,
) -> Config:
return Config(
platform=platform or self.platform,
secrets=secrets or self.secrets,
stats=stats or self.stats,
data_config=data_config or self.data_config,
local_sandbox_path=local_sandbox_path or self.local_sandbox_path,
field_config=field_config or self.field_config,
)

@classmethod
Expand All @@ -720,6 +746,7 @@ def auto(cls, config_file: typing.Union[str, ConfigFile, None] = None) -> Config
secrets=SecretsConfig.auto(config_file),
stats=StatsConfig.auto(config_file),
data_config=DataConfig.auto(config_file),
field_config=FieldConfig.auto(config_file),
**kwargs,
)

Expand Down
21 changes: 21 additions & 0 deletions flytekit/configuration/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ class Local(object):
SECTION = "local"
CACHE_ENABLED = ConfigEntry(LegacyConfigEntry(SECTION, "cache_enabled", bool))
CACHE_OVERWRITE = ConfigEntry(LegacyConfigEntry(SECTION, "cache_overwrite", bool))
USER_PROJECT = ConfigEntry(
LegacyConfigEntry(
SECTION,
"project",
),
YamlConfigEntry("task.project"),
)
USER_DOMAIN = ConfigEntry(
LegacyConfigEntry(
SECTION,
"domain",
),
YamlConfigEntry("task.domain"),
)
USER_ORG = ConfigEntry(
LegacyConfigEntry(
SECTION,
"org",
),
YamlConfigEntry("task.org"),
)


class Credentials(object):
Expand Down
8 changes: 6 additions & 2 deletions flytekit/remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ def __init__(
# read config files, env vars, host, ssl options for admin client
self._default_project = default_project
self._default_domain = default_domain
if config.field_config.project is not None:
self._default_project = config.field_config.project
if config.field_config.domain is not None:
self._default_domain = config.field_config.domain

fsspec.register_implementation("flyte", get_flyte_fs(remote=self), clobber=True)

Expand Down Expand Up @@ -1421,8 +1425,8 @@ def register_script(
)

serialization_settings = SerializationSettings(
project=project or self.default_project,
domain=domain or self.default_domain,
project=self.default_project or project,
domain=self.default_domain or domain,
image_config=image_config,
git_repo=_get_git_repo_url(source_path),
env=envs,
Expand Down
2 changes: 0 additions & 2 deletions pydoclint-errors-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ flytekit/configuration/__init__.py
DOC103: Function `_parse_image_identifier`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [image_identifier: str].
DOC203: Function `_parse_image_identifier` return type(s) in docstring not consistent with the return annotation. Return annotation types: ['typing.Tuple[str, Optional[str], Optional[str]]']; docstring return section types: ['Tuple[str, str, str]']
DOC605: Class `ImageConfig`: Attribute names match, but type hints in these attributes do not match: images (Please read https://jsh9.github.io/pydoclint/checking_class_attributes.html on how to correctly document class attributes.)
DOC601: Class `Config`: Class docstring contains fewer class attributes than actual class attributes. (Please read https://jsh9.github.io/pydoclint/checking_class_attributes.html on how to correctly document class attributes.)
DOC603: Class `Config`: Class docstring attributes are different from actual class attributes. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Attributes in the class definition but not in the docstring: [data_config: DataConfig, local_sandbox_path: str, platform: PlatformConfig, secrets: SecretsConfig, stats: StatsConfig]. (Please read https://jsh9.github.io/pydoclint/checking_class_attributes.html on how to correctly document class attributes.)
DOC603: Class `SerializationSettings`: Class docstring attributes are different from actual class attributes. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Attributes in the class definition but not in the docstring: [git_repo: Optional[str]]. Arguments in the docstring but not in the actual class attributes: [entrypoint_settings: Optional[EntrypointSettings]]. (Please read https://jsh9.github.io/pydoclint/checking_class_attributes.html on how to correctly document class attributes.)
--------------------
flytekit/configuration/file.py
Expand Down
Loading