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

Update default config to work out-of-the-box with flytectl demo #1384

Merged
merged 13 commits into from
Jan 10, 2023
8 changes: 4 additions & 4 deletions flytekit/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class PlatformConfig(object):
:param endpoint: DNS for Flyte backend
:param insecure: Whether or not to use SSL
:param insecure_skip_verify: Wether to skip SSL certificate verification
:param console_endpoint: endpoint for console if differenet than Flyte backend
:param console_endpoint: endpoint for console if different than Flyte backend
:param command: This command is executed to return a token using an external process.
:param client_id: This is the public identifier for the app which handles authorization for a Flyte deployment.
More details here: https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/.
Expand All @@ -311,8 +311,8 @@ class PlatformConfig(object):
:param auth_mode: The OAuth mode to use. Defaults to pkce flow.
"""

endpoint: str = "localhost:30081"
insecure: bool = False
endpoint: str = "localhost:30080"
insecure: bool = True
insecure_skip_verify: bool = False
console_endpoint: typing.Optional[str] = None
command: typing.Optional[typing.List[str]] = None
Expand Down Expand Up @@ -558,7 +558,7 @@ def for_sandbox(cls) -> Config:
:return: Config
"""
return Config(
platform=PlatformConfig(endpoint="localhost:30081", auth_mode="Pkce", insecure=True),
platform=PlatformConfig(endpoint="localhost:30080", auth_mode="Pkce", insecure=True),
data_config=DataConfig(
s3=S3Config(endpoint="http://localhost:30084", access_key_id="minio", secret_access_key="miniostorage")
),
Expand Down
17 changes: 12 additions & 5 deletions flytekit/configuration/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
FLYTECTL_CONFIG_ENV_VAR = "FLYTECTL_CONFIG"


def _exists(v: typing.Any) -> bool:
"""Check if a value is defined."""
return isinstance(v, bool) or (v is not None and v)


@dataclass
class LegacyConfigEntry(object):
"""
Expand Down Expand Up @@ -54,7 +59,8 @@ def read_from_file(
return None
try:
v = cfg.get(self)
return transform(v) if transform else v
if _exists(v):
cosmicBboy marked this conversation as resolved.
Show resolved Hide resolved
return transform(v) if transform else v
except configparser.Error:
pass
return None
Expand All @@ -63,7 +69,7 @@ def read_from_file(
@dataclass
class YamlConfigEntry(object):
"""
Creates a record for the config entry. contains
Creates a record for the config entry.
Args:
switch: dot-delimited string that should match flytectl args. Leaving it as dot-delimited instead of a list
of strings because it's easier to maintain alignment with flytectl.
Expand All @@ -80,10 +86,11 @@ def read_from_file(
return None
try:
v = cfg.get(self)
if v:
if _exists(v):
wild-endeavor marked this conversation as resolved.
Show resolved Hide resolved
return transform(v) if transform else v
except Exception:
...

return None


Expand Down Expand Up @@ -224,7 +231,7 @@ def legacy_config(self) -> _configparser.ConfigParser:
return self._legacy_config

@property
def yaml_config(self) -> typing.Dict[str, Any]:
def yaml_config(self) -> typing.Dict[str, typing.Any]:
return self._yaml_config


Expand Down Expand Up @@ -273,7 +280,7 @@ def set_if_exists(d: dict, k: str, v: typing.Any) -> dict:

The input dictionary ``d`` will be mutated.
"""
if v:
if _exists(v):
d[k] = v
return d

Expand Down
2 changes: 1 addition & 1 deletion tests/flytekit/unit/remote/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def test_generate_console_http_domain_sandbox_rewrite(mock_client):
remote = FlyteRemote(
config=Config.auto(config_file=temp_filename), default_project="project", default_domain="domain"
)
assert remote.generate_console_http_domain() == "http://localhost:30080"
assert remote.generate_console_http_domain() == "http://localhost:30081"

with open(temp_filename, "w") as f:
# This string is similar to the relevant configuration emitted by flytectl in the cases of both demo and sandbox.
Expand Down