Skip to content

Commit 429a47e

Browse files
committed
override task config in the begining
Signed-off-by: Nelson Chen <asd3431090@gmail.com>
1 parent ed4584e commit 429a47e

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

flytekit/clis/sdk_in_container/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ def run_remote(
585585
execution = remote.execute(
586586
entity,
587587
inputs=inputs,
588-
project=remote.default_project or project,
589-
domain=remote.default_domain or domain,
588+
project=project or remote.default_project,
589+
domain=domain or remote.default_domain,
590590
execution_name=run_level_params.name,
591591
options=options_from_run_params(run_level_params),
592592
type_hints=type_hints,

flytekit/clis/sdk_in_container/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@
1111
from rich.syntax import Syntax
1212
from rich.traceback import Traceback
1313

14+
from flytekit.configuration import TaskConfig
1415
from flytekit.core.constants import SOURCE_CODE
1516
from flytekit.exceptions.base import FlyteException
1617
from flytekit.exceptions.user import FlyteCompilationException, FlyteInvalidInputException
1718
from flytekit.exceptions.utils import annotate_exception_with_code
1819
from flytekit.loggers import get_level_from_cli_verbosity, logger
1920

21+
task_config = TaskConfig.auto()
22+
2023
project_option = click.Option(
2124
param_decls=["-p", "--project"],
2225
required=False,
2326
type=str,
24-
default=os.getenv("FLYTE_DEFAULT_PROJECT", "flytesnacks"),
27+
default=os.getenv("FLYTE_DEFAULT_PROJECT") or task_config.project,
2528
show_default=True,
2629
help="Project to register and run this workflow in. Can also be set through envvar " "``FLYTE_DEFAULT_PROJECT``",
2730
)
@@ -30,7 +33,7 @@
3033
param_decls=["-d", "--domain"],
3134
required=False,
3235
type=str,
33-
default=os.getenv("FLYTE_DEFAULT_DOMAIN", "development"),
36+
default=os.getenv("FLYTE_DEFAULT_DOMAIN") or task_config.domain,
3437
show_default=True,
3538
help="Domain to register and run this workflow in, can also be set through envvar " "``FLYTE_DEFAULT_DOMAIN``",
3639
)
@@ -40,7 +43,7 @@
4043
"--project",
4144
required=False,
4245
type=str,
43-
default=os.getenv("FLYTE_DEFAULT_PROJECT", "flytesnacks"),
46+
default=os.getenv("FLYTE_DEFAULT_PROJECT") or task_config.project,
4447
show_default=True,
4548
help="Project for workflow/launchplan. Can also be set through envvar " "``FLYTE_DEFAULT_PROJECT``",
4649
)
@@ -50,7 +53,7 @@
5053
"--domain",
5154
required=False,
5255
type=str,
53-
default=os.getenv("FLYTE_DEFAULT_DOMAIN", "development"),
56+
default=os.getenv("FLYTE_DEFAULT_DOMAIN") or task_config.domain,
5457
show_default=True,
5558
help="Domain for workflow/launchplan, can also be set through envvar " "``FLYTE_DEFAULT_DOMAIN``",
5659
)

flytekit/configuration/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ class TaskConfig(object):
669669
Any Project/Domain/Org configuration.
670670
"""
671671

672-
project: Optional[str] = None
673-
domain: Optional[str] = None
672+
project: Optional[str] = "flytesnacks"
673+
domain: Optional[str] = "development"
674674
org: Optional[str] = None
675675

676676
@classmethod
@@ -699,15 +699,13 @@ class Config(object):
699699
stats (StatsConfig): Configuration for statsd metrics.
700700
data_config (DataConfig): Data storage configuration.
701701
local_sandbox_path (str): Path for local sandbox runs.
702-
task_config (TaskConfig): Project/Domain/Org configuration.
703702
"""
704703

705704
platform: PlatformConfig = PlatformConfig()
706705
secrets: SecretsConfig = SecretsConfig()
707706
stats: StatsConfig = StatsConfig()
708707
data_config: DataConfig = DataConfig()
709708
local_sandbox_path: str = tempfile.mkdtemp(prefix="flyte")
710-
task_config: TaskConfig = TaskConfig()
711709

712710
def with_params(
713711
self,
@@ -716,15 +714,13 @@ def with_params(
716714
stats: StatsConfig = None,
717715
data_config: DataConfig = None,
718716
local_sandbox_path: str = None,
719-
task_config: TaskConfig = None,
720717
) -> Config:
721718
return Config(
722719
platform=platform or self.platform,
723720
secrets=secrets or self.secrets,
724721
stats=stats or self.stats,
725722
data_config=data_config or self.data_config,
726723
local_sandbox_path=local_sandbox_path or self.local_sandbox_path,
727-
task_config=task_config or self.task_config,
728724
)
729725

730726
@classmethod
@@ -746,7 +742,6 @@ def auto(cls, config_file: typing.Union[str, ConfigFile, None] = None) -> Config
746742
secrets=SecretsConfig.auto(config_file),
747743
stats=StatsConfig.auto(config_file),
748744
data_config=DataConfig.auto(config_file),
749-
task_config=TaskConfig.auto(config_file),
750745
**kwargs,
751746
)
752747

flytekit/remote/remote.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,6 @@ def __init__(
308308
# read config files, env vars, host, ssl options for admin client
309309
self._default_project = default_project
310310
self._default_domain = default_domain
311-
if config.task_config.project is not None:
312-
self._default_project = config.task_config.project
313-
if config.task_config.domain is not None:
314-
self._default_domain = config.task_config.domain
315311

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

0 commit comments

Comments
 (0)