Skip to content
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
11 changes: 7 additions & 4 deletions flytekit/clis/sdk_in_container/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
from rich.syntax import Syntax
from rich.traceback import Traceback

from flytekit.configuration import TaskConfig
from flytekit.core.constants import SOURCE_CODE
from flytekit.exceptions.base import FlyteException
from flytekit.exceptions.user import FlyteCompilationException, FlyteInvalidInputException
from flytekit.exceptions.utils import annotate_exception_with_code
from flytekit.loggers import get_level_from_cli_verbosity, logger

task_config = TaskConfig.auto()

project_option = click.Option(
param_decls=["-p", "--project"],
required=False,
type=str,
default=os.getenv("FLYTE_DEFAULT_PROJECT", "flytesnacks"),
default=os.getenv("FLYTE_DEFAULT_PROJECT") or task_config.project,
show_default=True,
help="Project to register and run this workflow in. Can also be set through envvar " "``FLYTE_DEFAULT_PROJECT``",
)
Expand All @@ -30,7 +33,7 @@
param_decls=["-d", "--domain"],
required=False,
type=str,
default=os.getenv("FLYTE_DEFAULT_DOMAIN", "development"),
default=os.getenv("FLYTE_DEFAULT_DOMAIN") or task_config.domain,
show_default=True,
help="Domain to register and run this workflow in, can also be set through envvar " "``FLYTE_DEFAULT_DOMAIN``",
)
Expand All @@ -40,7 +43,7 @@
"--project",
required=False,
type=str,
default=os.getenv("FLYTE_DEFAULT_PROJECT", "flytesnacks"),
default=os.getenv("FLYTE_DEFAULT_PROJECT") or task_config.project,
show_default=True,
help="Project for workflow/launchplan. Can also be set through envvar " "``FLYTE_DEFAULT_PROJECT``",
)
Expand All @@ -50,7 +53,7 @@
"--domain",
required=False,
type=str,
default=os.getenv("FLYTE_DEFAULT_DOMAIN", "development"),
default=os.getenv("FLYTE_DEFAULT_DOMAIN") or task_config.domain,
show_default=True,
help="Domain for workflow/launchplan, can also be set through envvar " "``FLYTE_DEFAULT_DOMAIN``",
)
Expand Down
30 changes: 26 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 TaskConfig(object):
"""
Any Project/Domain/Org configuration.
"""

project: Optional[str] = field(default="flytesnacks")
domain: Optional[str] = field(default="development")
org: Optional[str] = field(default="None")

@classmethod
def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> TaskConfig:
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 TaskConfig(**kwargs)


@dataclass(init=True, repr=True, eq=True, frozen=True)
class Config(object):
"""
Expand All @@ -673,10 +693,12 @@ 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.
"""

platform: PlatformConfig = PlatformConfig()
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
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