flyte 2.0.0b32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flyte might be problematic. Click here for more details.
- flyte/__init__.py +108 -0
- flyte/_bin/__init__.py +0 -0
- flyte/_bin/debug.py +38 -0
- flyte/_bin/runtime.py +195 -0
- flyte/_bin/serve.py +178 -0
- flyte/_build.py +26 -0
- flyte/_cache/__init__.py +12 -0
- flyte/_cache/cache.py +147 -0
- flyte/_cache/defaults.py +9 -0
- flyte/_cache/local_cache.py +216 -0
- flyte/_cache/policy_function_body.py +42 -0
- flyte/_code_bundle/__init__.py +8 -0
- flyte/_code_bundle/_ignore.py +121 -0
- flyte/_code_bundle/_packaging.py +218 -0
- flyte/_code_bundle/_utils.py +347 -0
- flyte/_code_bundle/bundle.py +266 -0
- flyte/_constants.py +1 -0
- flyte/_context.py +155 -0
- flyte/_custom_context.py +73 -0
- flyte/_debug/__init__.py +0 -0
- flyte/_debug/constants.py +38 -0
- flyte/_debug/utils.py +17 -0
- flyte/_debug/vscode.py +307 -0
- flyte/_deploy.py +408 -0
- flyte/_deployer.py +109 -0
- flyte/_doc.py +29 -0
- flyte/_docstring.py +32 -0
- flyte/_environment.py +122 -0
- flyte/_excepthook.py +37 -0
- flyte/_group.py +32 -0
- flyte/_hash.py +8 -0
- flyte/_image.py +1055 -0
- flyte/_initialize.py +628 -0
- flyte/_interface.py +119 -0
- flyte/_internal/__init__.py +3 -0
- flyte/_internal/controllers/__init__.py +129 -0
- flyte/_internal/controllers/_local_controller.py +239 -0
- flyte/_internal/controllers/_trace.py +48 -0
- flyte/_internal/controllers/remote/__init__.py +58 -0
- flyte/_internal/controllers/remote/_action.py +211 -0
- flyte/_internal/controllers/remote/_client.py +47 -0
- flyte/_internal/controllers/remote/_controller.py +583 -0
- flyte/_internal/controllers/remote/_core.py +465 -0
- flyte/_internal/controllers/remote/_informer.py +381 -0
- flyte/_internal/controllers/remote/_service_protocol.py +50 -0
- flyte/_internal/imagebuild/__init__.py +3 -0
- flyte/_internal/imagebuild/docker_builder.py +706 -0
- flyte/_internal/imagebuild/image_builder.py +277 -0
- flyte/_internal/imagebuild/remote_builder.py +386 -0
- flyte/_internal/imagebuild/utils.py +78 -0
- flyte/_internal/resolvers/__init__.py +0 -0
- flyte/_internal/resolvers/_task_module.py +21 -0
- flyte/_internal/resolvers/common.py +31 -0
- flyte/_internal/resolvers/default.py +28 -0
- flyte/_internal/runtime/__init__.py +0 -0
- flyte/_internal/runtime/convert.py +486 -0
- flyte/_internal/runtime/entrypoints.py +204 -0
- flyte/_internal/runtime/io.py +188 -0
- flyte/_internal/runtime/resources_serde.py +152 -0
- flyte/_internal/runtime/reuse.py +125 -0
- flyte/_internal/runtime/rusty.py +193 -0
- flyte/_internal/runtime/task_serde.py +362 -0
- flyte/_internal/runtime/taskrunner.py +209 -0
- flyte/_internal/runtime/trigger_serde.py +160 -0
- flyte/_internal/runtime/types_serde.py +54 -0
- flyte/_keyring/__init__.py +0 -0
- flyte/_keyring/file.py +115 -0
- flyte/_logging.py +300 -0
- flyte/_map.py +312 -0
- flyte/_module.py +72 -0
- flyte/_pod.py +30 -0
- flyte/_resources.py +473 -0
- flyte/_retry.py +32 -0
- flyte/_reusable_environment.py +102 -0
- flyte/_run.py +724 -0
- flyte/_secret.py +96 -0
- flyte/_task.py +550 -0
- flyte/_task_environment.py +316 -0
- flyte/_task_plugins.py +47 -0
- flyte/_timeout.py +47 -0
- flyte/_tools.py +27 -0
- flyte/_trace.py +119 -0
- flyte/_trigger.py +1000 -0
- flyte/_utils/__init__.py +30 -0
- flyte/_utils/asyn.py +121 -0
- flyte/_utils/async_cache.py +139 -0
- flyte/_utils/coro_management.py +27 -0
- flyte/_utils/docker_credentials.py +173 -0
- flyte/_utils/file_handling.py +72 -0
- flyte/_utils/helpers.py +134 -0
- flyte/_utils/lazy_module.py +54 -0
- flyte/_utils/module_loader.py +104 -0
- flyte/_utils/org_discovery.py +57 -0
- flyte/_utils/uv_script_parser.py +49 -0
- flyte/_version.py +34 -0
- flyte/app/__init__.py +22 -0
- flyte/app/_app_environment.py +157 -0
- flyte/app/_deploy.py +125 -0
- flyte/app/_input.py +160 -0
- flyte/app/_runtime/__init__.py +3 -0
- flyte/app/_runtime/app_serde.py +347 -0
- flyte/app/_types.py +101 -0
- flyte/app/extras/__init__.py +3 -0
- flyte/app/extras/_fastapi.py +151 -0
- flyte/cli/__init__.py +12 -0
- flyte/cli/_abort.py +28 -0
- flyte/cli/_build.py +114 -0
- flyte/cli/_common.py +468 -0
- flyte/cli/_create.py +371 -0
- flyte/cli/_delete.py +45 -0
- flyte/cli/_deploy.py +293 -0
- flyte/cli/_gen.py +176 -0
- flyte/cli/_get.py +370 -0
- flyte/cli/_option.py +33 -0
- flyte/cli/_params.py +554 -0
- flyte/cli/_plugins.py +209 -0
- flyte/cli/_run.py +597 -0
- flyte/cli/_serve.py +64 -0
- flyte/cli/_update.py +37 -0
- flyte/cli/_user.py +17 -0
- flyte/cli/main.py +221 -0
- flyte/config/__init__.py +3 -0
- flyte/config/_config.py +248 -0
- flyte/config/_internal.py +73 -0
- flyte/config/_reader.py +225 -0
- flyte/connectors/__init__.py +11 -0
- flyte/connectors/_connector.py +270 -0
- flyte/connectors/_server.py +197 -0
- flyte/connectors/utils.py +135 -0
- flyte/errors.py +243 -0
- flyte/extend.py +19 -0
- flyte/extras/__init__.py +5 -0
- flyte/extras/_container.py +286 -0
- flyte/git/__init__.py +3 -0
- flyte/git/_config.py +21 -0
- flyte/io/__init__.py +29 -0
- flyte/io/_dataframe/__init__.py +131 -0
- flyte/io/_dataframe/basic_dfs.py +223 -0
- flyte/io/_dataframe/dataframe.py +1026 -0
- flyte/io/_dir.py +910 -0
- flyte/io/_file.py +914 -0
- flyte/io/_hashing_io.py +342 -0
- flyte/models.py +479 -0
- flyte/py.typed +0 -0
- flyte/remote/__init__.py +35 -0
- flyte/remote/_action.py +738 -0
- flyte/remote/_app.py +57 -0
- flyte/remote/_client/__init__.py +0 -0
- flyte/remote/_client/_protocols.py +189 -0
- flyte/remote/_client/auth/__init__.py +12 -0
- flyte/remote/_client/auth/_auth_utils.py +14 -0
- flyte/remote/_client/auth/_authenticators/__init__.py +0 -0
- flyte/remote/_client/auth/_authenticators/base.py +403 -0
- flyte/remote/_client/auth/_authenticators/client_credentials.py +73 -0
- flyte/remote/_client/auth/_authenticators/device_code.py +117 -0
- flyte/remote/_client/auth/_authenticators/external_command.py +79 -0
- flyte/remote/_client/auth/_authenticators/factory.py +200 -0
- flyte/remote/_client/auth/_authenticators/pkce.py +516 -0
- flyte/remote/_client/auth/_channel.py +213 -0
- flyte/remote/_client/auth/_client_config.py +85 -0
- flyte/remote/_client/auth/_default_html.py +32 -0
- flyte/remote/_client/auth/_grpc_utils/__init__.py +0 -0
- flyte/remote/_client/auth/_grpc_utils/auth_interceptor.py +288 -0
- flyte/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +151 -0
- flyte/remote/_client/auth/_keyring.py +152 -0
- flyte/remote/_client/auth/_token_client.py +260 -0
- flyte/remote/_client/auth/errors.py +16 -0
- flyte/remote/_client/controlplane.py +128 -0
- flyte/remote/_common.py +30 -0
- flyte/remote/_console.py +19 -0
- flyte/remote/_data.py +161 -0
- flyte/remote/_logs.py +185 -0
- flyte/remote/_project.py +88 -0
- flyte/remote/_run.py +386 -0
- flyte/remote/_secret.py +142 -0
- flyte/remote/_task.py +527 -0
- flyte/remote/_trigger.py +306 -0
- flyte/remote/_user.py +33 -0
- flyte/report/__init__.py +3 -0
- flyte/report/_report.py +182 -0
- flyte/report/_template.html +124 -0
- flyte/storage/__init__.py +36 -0
- flyte/storage/_config.py +237 -0
- flyte/storage/_parallel_reader.py +274 -0
- flyte/storage/_remote_fs.py +34 -0
- flyte/storage/_storage.py +456 -0
- flyte/storage/_utils.py +5 -0
- flyte/syncify/__init__.py +56 -0
- flyte/syncify/_api.py +375 -0
- flyte/types/__init__.py +52 -0
- flyte/types/_interface.py +40 -0
- flyte/types/_pickle.py +145 -0
- flyte/types/_renderer.py +162 -0
- flyte/types/_string_literals.py +119 -0
- flyte/types/_type_engine.py +2254 -0
- flyte/types/_utils.py +80 -0
- flyte-2.0.0b32.data/scripts/debug.py +38 -0
- flyte-2.0.0b32.data/scripts/runtime.py +195 -0
- flyte-2.0.0b32.dist-info/METADATA +351 -0
- flyte-2.0.0b32.dist-info/RECORD +204 -0
- flyte-2.0.0b32.dist-info/WHEEL +5 -0
- flyte-2.0.0b32.dist-info/entry_points.txt +7 -0
- flyte-2.0.0b32.dist-info/licenses/LICENSE +201 -0
- flyte-2.0.0b32.dist-info/top_level.txt +1 -0
flyte/cli/_user.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import rich_click as click
|
|
2
|
+
|
|
3
|
+
import flyte.remote as remote
|
|
4
|
+
|
|
5
|
+
from . import _common as common
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.command()
|
|
9
|
+
@click.pass_obj
|
|
10
|
+
def whoami(
|
|
11
|
+
cfg: common.CLIConfig,
|
|
12
|
+
):
|
|
13
|
+
"""Display the current user information."""
|
|
14
|
+
cfg.init()
|
|
15
|
+
console = common.get_console()
|
|
16
|
+
user_info = remote.User.get()
|
|
17
|
+
console.print(user_info.to_json())
|
flyte/cli/main.py
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import rich_click as click
|
|
2
|
+
from typing_extensions import get_args
|
|
3
|
+
|
|
4
|
+
from flyte._logging import LogFormat, initialize_logger, logger
|
|
5
|
+
|
|
6
|
+
from . import _common as common
|
|
7
|
+
from ._abort import abort
|
|
8
|
+
from ._build import build
|
|
9
|
+
from ._common import CLIConfig
|
|
10
|
+
from ._create import create
|
|
11
|
+
from ._delete import delete
|
|
12
|
+
from ._deploy import deploy
|
|
13
|
+
from ._gen import gen
|
|
14
|
+
from ._get import get
|
|
15
|
+
from ._plugins import discover_and_register_plugins
|
|
16
|
+
from ._run import run
|
|
17
|
+
from ._serve import serve
|
|
18
|
+
from ._update import update
|
|
19
|
+
from ._user import whoami
|
|
20
|
+
|
|
21
|
+
help_config = click.RichHelpConfiguration(
|
|
22
|
+
use_markdown=True,
|
|
23
|
+
use_markdown_emoji=True,
|
|
24
|
+
command_groups={
|
|
25
|
+
"flyte": [
|
|
26
|
+
{
|
|
27
|
+
"name": "Run and stop tasks",
|
|
28
|
+
"commands": ["run", "abort"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Management of various objects.",
|
|
32
|
+
"commands": ["create", "get", "delete", "update"],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Build and deploy environments, tasks and images.",
|
|
36
|
+
"commands": ["build", "deploy"],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "Documentation generation",
|
|
40
|
+
"commands": ["gen"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "User information",
|
|
44
|
+
"commands": ["whoami"],
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _verbosity_to_loglevel(verbosity: int) -> int | None:
|
|
52
|
+
"""
|
|
53
|
+
Converts a verbosity level from the CLI to a logging level.
|
|
54
|
+
|
|
55
|
+
:param verbosity: verbosity level from the CLI
|
|
56
|
+
:return: logging level
|
|
57
|
+
"""
|
|
58
|
+
import logging
|
|
59
|
+
|
|
60
|
+
match verbosity:
|
|
61
|
+
case 0:
|
|
62
|
+
return None
|
|
63
|
+
case 1:
|
|
64
|
+
return logging.WARNING
|
|
65
|
+
case 2:
|
|
66
|
+
return logging.INFO
|
|
67
|
+
case _:
|
|
68
|
+
return logging.DEBUG
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@click.group(cls=click.RichGroup)
|
|
72
|
+
@click.option(
|
|
73
|
+
"--endpoint",
|
|
74
|
+
type=str,
|
|
75
|
+
required=False,
|
|
76
|
+
help="The endpoint to connect to. This will override any configuration file and simply use `pkce` to connect.",
|
|
77
|
+
)
|
|
78
|
+
@click.option(
|
|
79
|
+
"--insecure",
|
|
80
|
+
is_flag=True,
|
|
81
|
+
required=False,
|
|
82
|
+
help="Use an insecure connection to the endpoint. If not specified, the CLI will use TLS.",
|
|
83
|
+
type=bool,
|
|
84
|
+
default=None,
|
|
85
|
+
show_default=True,
|
|
86
|
+
)
|
|
87
|
+
@click.option(
|
|
88
|
+
"--auth-type",
|
|
89
|
+
type=click.Choice(common.ALL_AUTH_OPTIONS, case_sensitive=False),
|
|
90
|
+
default=None,
|
|
91
|
+
help="Authentication type to use for the Flyte backend. Defaults to 'pkce'.",
|
|
92
|
+
show_default=True,
|
|
93
|
+
required=False,
|
|
94
|
+
)
|
|
95
|
+
@click.option(
|
|
96
|
+
"-v",
|
|
97
|
+
"--verbose",
|
|
98
|
+
required=False,
|
|
99
|
+
help="Show verbose messages and exception traces. Repeating multiple times increases the verbosity (e.g., -vvv).",
|
|
100
|
+
count=True,
|
|
101
|
+
default=0,
|
|
102
|
+
type=int,
|
|
103
|
+
)
|
|
104
|
+
@click.option(
|
|
105
|
+
"--org",
|
|
106
|
+
type=str,
|
|
107
|
+
required=False,
|
|
108
|
+
help="The organization to which the command applies.",
|
|
109
|
+
)
|
|
110
|
+
@click.option(
|
|
111
|
+
"-c",
|
|
112
|
+
"--config",
|
|
113
|
+
"config_file",
|
|
114
|
+
required=False,
|
|
115
|
+
type=click.Path(exists=True),
|
|
116
|
+
help="Path to the configuration file to use. If not specified, the default configuration file is used.",
|
|
117
|
+
)
|
|
118
|
+
@click.option(
|
|
119
|
+
"--output-format",
|
|
120
|
+
"-of",
|
|
121
|
+
type=click.Choice(get_args(common.OutputFormat), case_sensitive=False),
|
|
122
|
+
default="table",
|
|
123
|
+
help="Output format for commands that support it. Defaults to 'table'.",
|
|
124
|
+
show_default=True,
|
|
125
|
+
required=False,
|
|
126
|
+
)
|
|
127
|
+
@click.option(
|
|
128
|
+
"--log-format",
|
|
129
|
+
type=click.Choice(get_args(LogFormat), case_sensitive=False),
|
|
130
|
+
envvar="LOG_FORMAT",
|
|
131
|
+
default="console",
|
|
132
|
+
help="Formatting for logs, defaults to 'console' which is meant to be human readable."
|
|
133
|
+
" 'json' is meant for machine parsing.",
|
|
134
|
+
show_default=True,
|
|
135
|
+
required=False,
|
|
136
|
+
)
|
|
137
|
+
@click.rich_config(help_config=help_config)
|
|
138
|
+
@click.pass_context
|
|
139
|
+
def main(
|
|
140
|
+
ctx: click.Context,
|
|
141
|
+
endpoint: str | None,
|
|
142
|
+
insecure: bool,
|
|
143
|
+
verbose: int,
|
|
144
|
+
log_format: LogFormat,
|
|
145
|
+
org: str | None,
|
|
146
|
+
config_file: str | None,
|
|
147
|
+
auth_type: str | None = None,
|
|
148
|
+
output_format: common.OutputFormat = "table",
|
|
149
|
+
):
|
|
150
|
+
"""
|
|
151
|
+
The Flyte CLI is the command line interface for working with the Flyte SDK and backend.
|
|
152
|
+
|
|
153
|
+
It follows a simple verb/noun structure,
|
|
154
|
+
where the top-level commands are verbs that describe the action to be taken,
|
|
155
|
+
and the subcommands are nouns that describe the object of the action.
|
|
156
|
+
|
|
157
|
+
The root command can be used to configure the CLI for persistent settings,
|
|
158
|
+
such as the endpoint, organization, and verbosity level.
|
|
159
|
+
|
|
160
|
+
Set endpoint and organization:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
$ flyte --endpoint <endpoint> --org <org> get project <project_name>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Increase verbosity level (This is useful for debugging,
|
|
167
|
+
this will show more logs and exception traces):
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
$ flyte -vvv get logs <run-name>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Override the default config file:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
$ flyte --config /path/to/config.yaml run ...
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
* [Documentation](https://www.union.ai/docs/flyte/user-guide/)
|
|
180
|
+
* [GitHub](https://github.com/flyteorg/flyte): Please leave a star if you like Flyte!
|
|
181
|
+
* [Slack](https://slack.flyte.org): Join the community and ask questions.
|
|
182
|
+
* [Issues](https://github.com/flyteorg/flyte/issues)
|
|
183
|
+
|
|
184
|
+
"""
|
|
185
|
+
import flyte.config as config
|
|
186
|
+
|
|
187
|
+
log_level = _verbosity_to_loglevel(verbose)
|
|
188
|
+
if log_level is not None or log_format != "console":
|
|
189
|
+
initialize_logger(log_level=log_level, log_format=log_format)
|
|
190
|
+
|
|
191
|
+
cfg = config.auto(config_file=config_file)
|
|
192
|
+
if cfg.source:
|
|
193
|
+
logger.debug(f"Using config file discovered at location `{cfg.source.absolute()}`")
|
|
194
|
+
|
|
195
|
+
ctx.obj = CLIConfig(
|
|
196
|
+
log_level=log_level,
|
|
197
|
+
log_format=log_format,
|
|
198
|
+
endpoint=endpoint,
|
|
199
|
+
insecure=insecure,
|
|
200
|
+
org=org,
|
|
201
|
+
config=cfg,
|
|
202
|
+
ctx=ctx,
|
|
203
|
+
auth_type=auth_type,
|
|
204
|
+
output_format=output_format,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
main.add_command(run)
|
|
209
|
+
main.add_command(deploy)
|
|
210
|
+
main.add_command(get) # type: ignore
|
|
211
|
+
main.add_command(create) # type: ignore
|
|
212
|
+
main.add_command(abort) # type: ignore
|
|
213
|
+
main.add_command(gen) # type: ignore
|
|
214
|
+
main.add_command(delete) # type: ignore
|
|
215
|
+
main.add_command(build)
|
|
216
|
+
main.add_command(whoami) # type: ignore
|
|
217
|
+
main.add_command(update) # type: ignore
|
|
218
|
+
main.add_command(serve) # type: ignore
|
|
219
|
+
|
|
220
|
+
# Discover and register CLI plugins from installed packages
|
|
221
|
+
discover_and_register_plugins(main)
|
flyte/config/__init__.py
ADDED
flyte/config/_config.py
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import os
|
|
5
|
+
import pathlib
|
|
6
|
+
import typing
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
import rich.repr
|
|
11
|
+
|
|
12
|
+
from flyte._logging import logger
|
|
13
|
+
from flyte.config import _internal
|
|
14
|
+
from flyte.config._reader import ConfigFile, get_config_file, read_file_if_exists
|
|
15
|
+
|
|
16
|
+
_all__ = ["ConfigFile", "PlatformConfig", "TaskConfig", "ImageConfig"]
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from flyte.remote._client.auth import AuthType
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@rich.repr.auto
|
|
23
|
+
@dataclass(init=True, repr=True, eq=True, frozen=True)
|
|
24
|
+
class PlatformConfig(object):
|
|
25
|
+
"""
|
|
26
|
+
This object contains the settings to talk to a Flyte backend (the DNS location of your Admin server basically).
|
|
27
|
+
|
|
28
|
+
:param endpoint: DNS for Flyte backend
|
|
29
|
+
:param insecure: Whether or not to use SSL
|
|
30
|
+
:param insecure_skip_verify: Whether to skip SSL certificate verification
|
|
31
|
+
:param console_endpoint: endpoint for console if different from Flyte backend
|
|
32
|
+
:param command: This command is executed to return a token using an external process
|
|
33
|
+
:param proxy_command: This command is executed to return a token for proxy authorization using an external process
|
|
34
|
+
:param client_id: This is the public identifier for the app which handles authorization for a Flyte deployment.
|
|
35
|
+
More details here: https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/.
|
|
36
|
+
:param client_credentials_secret: Used for service auth, which is automatically called during pyflyte. This will
|
|
37
|
+
allow the Flyte engine to read the password directly from the environment variable. Note that this is
|
|
38
|
+
less secure! Please only use this if mounting the secret as a file is impossible
|
|
39
|
+
:param scopes: List of scopes to request. This is only applicable to the client credentials flow
|
|
40
|
+
:param auth_mode: The OAuth mode to use. Defaults to pkce flow
|
|
41
|
+
:param ca_cert_file_path: [optional] str Root Cert to be loaded and used to verify admin
|
|
42
|
+
:param http_proxy_url: [optional] HTTP Proxy to be used for OAuth requests
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
endpoint: str | None = None
|
|
46
|
+
insecure: bool = False
|
|
47
|
+
insecure_skip_verify: bool = False
|
|
48
|
+
ca_cert_file_path: typing.Optional[str] = None
|
|
49
|
+
console_endpoint: typing.Optional[str] = None
|
|
50
|
+
command: typing.Optional[typing.List[str]] = None
|
|
51
|
+
proxy_command: typing.Optional[typing.List[str]] = None
|
|
52
|
+
client_id: typing.Optional[str] = None
|
|
53
|
+
client_credentials_secret: typing.Optional[str] = None
|
|
54
|
+
scopes: typing.List[str] = field(default_factory=list)
|
|
55
|
+
auth_mode: "AuthType" = "Pkce"
|
|
56
|
+
audience: typing.Optional[str] = None
|
|
57
|
+
rpc_retries: int = 3
|
|
58
|
+
http_proxy_url: typing.Optional[str] = None
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def auto(cls, config_file: typing.Optional[typing.Union[str, ConfigFile]] = None) -> "PlatformConfig":
|
|
62
|
+
"""
|
|
63
|
+
Reads from a config file, and overrides from Environment variables. Refer to ConfigEntry for details
|
|
64
|
+
:param config_file:
|
|
65
|
+
:return:
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
config_file = get_config_file(config_file)
|
|
69
|
+
kwargs: typing.Dict[str, typing.Any] = {}
|
|
70
|
+
kwargs = set_if_exists(kwargs, "insecure", _internal.Platform.INSECURE.read(config_file))
|
|
71
|
+
kwargs = set_if_exists(
|
|
72
|
+
kwargs, "insecure_skip_verify", _internal.Platform.INSECURE_SKIP_VERIFY.read(config_file)
|
|
73
|
+
)
|
|
74
|
+
kwargs = set_if_exists(kwargs, "ca_cert_file_path", _internal.Platform.CA_CERT_FILE_PATH.read(config_file))
|
|
75
|
+
kwargs = set_if_exists(kwargs, "command", _internal.Credentials.COMMAND.read(config_file))
|
|
76
|
+
kwargs = set_if_exists(kwargs, "proxy_command", _internal.Credentials.PROXY_COMMAND.read(config_file))
|
|
77
|
+
kwargs = set_if_exists(kwargs, "client_id", _internal.Credentials.CLIENT_ID.read(config_file))
|
|
78
|
+
|
|
79
|
+
is_client_secret = False
|
|
80
|
+
client_credentials_secret = read_file_if_exists(
|
|
81
|
+
_internal.Credentials.CLIENT_CREDENTIALS_SECRET_LOCATION.read(config_file)
|
|
82
|
+
)
|
|
83
|
+
if client_credentials_secret:
|
|
84
|
+
is_client_secret = True
|
|
85
|
+
if client_credentials_secret.endswith("\n"):
|
|
86
|
+
logger.info("Newline stripped from client secret")
|
|
87
|
+
client_credentials_secret = client_credentials_secret.strip()
|
|
88
|
+
kwargs = set_if_exists(
|
|
89
|
+
kwargs,
|
|
90
|
+
"client_credentials_secret",
|
|
91
|
+
client_credentials_secret,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
client_credentials_secret_env_var = _internal.Credentials.CLIENT_CREDENTIALS_SECRET_ENV_VAR.read(config_file)
|
|
95
|
+
if client_credentials_secret_env_var:
|
|
96
|
+
client_credentials_secret = os.getenv(client_credentials_secret_env_var)
|
|
97
|
+
if client_credentials_secret:
|
|
98
|
+
is_client_secret = True
|
|
99
|
+
kwargs = set_if_exists(kwargs, "client_credentials_secret", client_credentials_secret)
|
|
100
|
+
kwargs = set_if_exists(kwargs, "scopes", _internal.Credentials.SCOPES.read(config_file))
|
|
101
|
+
kwargs = set_if_exists(kwargs, "auth_mode", _internal.Credentials.AUTH_MODE.read(config_file))
|
|
102
|
+
if is_client_secret:
|
|
103
|
+
kwargs = set_if_exists(kwargs, "auth_mode", "ClientSecret")
|
|
104
|
+
kwargs = set_if_exists(kwargs, "endpoint", _internal.Platform.URL.read(config_file))
|
|
105
|
+
kwargs = set_if_exists(kwargs, "console_endpoint", _internal.Platform.CONSOLE_ENDPOINT.read(config_file))
|
|
106
|
+
|
|
107
|
+
kwargs = set_if_exists(kwargs, "http_proxy_url", _internal.Platform.HTTP_PROXY_URL.read(config_file))
|
|
108
|
+
return PlatformConfig(**kwargs)
|
|
109
|
+
|
|
110
|
+
def replace(self, **kwargs: typing.Any) -> "PlatformConfig":
|
|
111
|
+
"""
|
|
112
|
+
Returns a new PlatformConfig instance with the values from the kwargs overriding the current instance.
|
|
113
|
+
"""
|
|
114
|
+
return dataclasses.replace(self, **kwargs)
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def for_endpoint(cls, endpoint: str, insecure: bool = False) -> "PlatformConfig":
|
|
118
|
+
return PlatformConfig(endpoint=endpoint, insecure=insecure)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@rich.repr.auto
|
|
122
|
+
@dataclass(init=True, repr=True, eq=True, frozen=True)
|
|
123
|
+
class TaskConfig(object):
|
|
124
|
+
org: str | None = None
|
|
125
|
+
project: str | None = None
|
|
126
|
+
domain: str | None = None
|
|
127
|
+
|
|
128
|
+
@classmethod
|
|
129
|
+
def auto(cls, config_file: typing.Optional[typing.Union[str, ConfigFile]] = None) -> "TaskConfig":
|
|
130
|
+
"""
|
|
131
|
+
Reads from a config file, and overrides from Environment variables. Refer to ConfigEntry for details
|
|
132
|
+
:param config_file:
|
|
133
|
+
:return:
|
|
134
|
+
"""
|
|
135
|
+
config_file = get_config_file(config_file)
|
|
136
|
+
kwargs: typing.Dict[str, typing.Any] = {}
|
|
137
|
+
kwargs = set_if_exists(kwargs, "org", _internal.Task.ORG.read(config_file))
|
|
138
|
+
kwargs = set_if_exists(kwargs, "project", _internal.Task.PROJECT.read(config_file))
|
|
139
|
+
kwargs = set_if_exists(kwargs, "domain", _internal.Task.DOMAIN.read(config_file))
|
|
140
|
+
return TaskConfig(**kwargs)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@rich.repr.auto
|
|
144
|
+
@dataclass(init=True, repr=True, eq=True, frozen=True)
|
|
145
|
+
class ImageConfig(object):
|
|
146
|
+
"""
|
|
147
|
+
Configuration for Docker image settings.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
builder: str | None = None
|
|
151
|
+
image_refs: typing.Dict[str, str] = field(default_factory=dict)
|
|
152
|
+
|
|
153
|
+
@classmethod
|
|
154
|
+
def auto(cls, config_file: typing.Optional[typing.Union[str, ConfigFile]] = None) -> "ImageConfig":
|
|
155
|
+
"""
|
|
156
|
+
Reads from a config file, and overrides from Environment variables. Refer to ConfigEntry for details
|
|
157
|
+
:param config_file:
|
|
158
|
+
:return:
|
|
159
|
+
"""
|
|
160
|
+
config_file = get_config_file(config_file)
|
|
161
|
+
kwargs: typing.Dict[str, typing.Any] = {}
|
|
162
|
+
kwargs = set_if_exists(kwargs, "builder", _internal.Image.BUILDER.read(config_file))
|
|
163
|
+
kwargs = set_if_exists(kwargs, "image_refs", _internal.Image.IMAGE_REFS.read(config_file))
|
|
164
|
+
return ImageConfig(**kwargs)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@rich.repr.auto
|
|
168
|
+
@dataclass(init=True, repr=True, eq=True, frozen=True)
|
|
169
|
+
class Config(object):
|
|
170
|
+
"""
|
|
171
|
+
This the parent configuration object and holds all the underlying configuration object types. An instance of
|
|
172
|
+
this object holds all the config necessary to
|
|
173
|
+
|
|
174
|
+
1. Interactive session with Flyte backend
|
|
175
|
+
2. Some parts are required for Serialization, for example Platform Config is not required
|
|
176
|
+
3. Runtime of a task
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
platform: PlatformConfig = field(default=PlatformConfig())
|
|
180
|
+
task: TaskConfig = field(default=TaskConfig())
|
|
181
|
+
image: ImageConfig = field(default=ImageConfig())
|
|
182
|
+
source: pathlib.Path | None = None
|
|
183
|
+
|
|
184
|
+
def with_params(
|
|
185
|
+
self,
|
|
186
|
+
platform: PlatformConfig | None = None,
|
|
187
|
+
task: TaskConfig | None = None,
|
|
188
|
+
image: ImageConfig | None = None,
|
|
189
|
+
) -> "Config":
|
|
190
|
+
return Config(
|
|
191
|
+
platform=platform or self.platform,
|
|
192
|
+
task=task or self.task,
|
|
193
|
+
image=image or self.image,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
@classmethod
|
|
197
|
+
def auto(cls, config_file: typing.Union[str, pathlib.Path, ConfigFile, None] = None) -> "Config":
|
|
198
|
+
"""
|
|
199
|
+
Automatically constructs the Config Object. The order of precedence is as follows
|
|
200
|
+
1. first try to find any env vars that match the config vars specified in the FLYTE_CONFIG format.
|
|
201
|
+
2. If not found in environment then values ar read from the config file
|
|
202
|
+
3. If not found in the file, then the default values are used.
|
|
203
|
+
|
|
204
|
+
:param config_file: file path to read the config from, if not specified default locations are searched
|
|
205
|
+
:return: Config
|
|
206
|
+
"""
|
|
207
|
+
config_file = get_config_file(config_file)
|
|
208
|
+
if config_file is None:
|
|
209
|
+
logger.debug("No config file found, using default values")
|
|
210
|
+
return Config()
|
|
211
|
+
return Config(
|
|
212
|
+
platform=PlatformConfig.auto(config_file),
|
|
213
|
+
task=TaskConfig.auto(config_file),
|
|
214
|
+
image=ImageConfig.auto(config_file),
|
|
215
|
+
source=config_file.path,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def set_if_exists(d: dict, k: str, val: typing.Any) -> dict:
|
|
220
|
+
"""
|
|
221
|
+
Given a dict ``d`` sets the key ``k`` with value of config ``v``, if the config value ``v`` is set
|
|
222
|
+
and return the updated dictionary.
|
|
223
|
+
"""
|
|
224
|
+
exists = isinstance(val, bool) or bool(val is not None and val)
|
|
225
|
+
if exists:
|
|
226
|
+
d[k] = val
|
|
227
|
+
return d
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def auto(config_file: typing.Union[str, pathlib.Path, ConfigFile, None] = None) -> Config:
|
|
231
|
+
"""
|
|
232
|
+
Automatically constructs the Config Object. The order of precedence is as follows
|
|
233
|
+
1. If specified, read the config from the provided file path.
|
|
234
|
+
2. If not specified, the config file is searched in the default locations.
|
|
235
|
+
a. ./config.yaml if it exists (current working directory)
|
|
236
|
+
b. ./.flyte/config.yaml if it exists (current working directory)
|
|
237
|
+
c. <git_root>/.flyte/config.yaml if it exists
|
|
238
|
+
d. `UCTL_CONFIG` environment variable
|
|
239
|
+
e. `FLYTECTL_CONFIG` environment variable
|
|
240
|
+
f. ~/.union/config.yaml if it exists
|
|
241
|
+
g. ~/.flyte/config.yaml if it exists
|
|
242
|
+
3. If any value is not found in the config file, the default value is used.
|
|
243
|
+
4. For any value there are environment variables that match the config variable names, those will override
|
|
244
|
+
|
|
245
|
+
:param config_file: file path to read the config from, if not specified default locations are searched
|
|
246
|
+
:return: Config
|
|
247
|
+
"""
|
|
248
|
+
return Config.auto(config_file)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from flyte.config._reader import ConfigEntry, YamlConfigEntry
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Platform(object):
|
|
5
|
+
URL = ConfigEntry(YamlConfigEntry("admin.endpoint"))
|
|
6
|
+
INSECURE = ConfigEntry(YamlConfigEntry("admin.insecure", bool))
|
|
7
|
+
INSECURE_SKIP_VERIFY = ConfigEntry(YamlConfigEntry("admin.insecureSkipVerify", bool))
|
|
8
|
+
CONSOLE_ENDPOINT = ConfigEntry(YamlConfigEntry("console.endpoint"))
|
|
9
|
+
CA_CERT_FILE_PATH = ConfigEntry(YamlConfigEntry("admin.caCertFilePath"))
|
|
10
|
+
HTTP_PROXY_URL = ConfigEntry(YamlConfigEntry("admin.httpProxyURL"))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Credentials(object):
|
|
14
|
+
SECTION = "credentials"
|
|
15
|
+
COMMAND = ConfigEntry(YamlConfigEntry("admin.command", list))
|
|
16
|
+
"""
|
|
17
|
+
This command is executed to return a token using an external process.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
PROXY_COMMAND = ConfigEntry(YamlConfigEntry("admin.proxyCommand", list))
|
|
21
|
+
"""
|
|
22
|
+
This command is executed to return a token for authorization with a proxy
|
|
23
|
+
in front of Flyte using an external process.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
CLIENT_ID = ConfigEntry(YamlConfigEntry("admin.clientId"))
|
|
27
|
+
"""
|
|
28
|
+
This is the public identifier for the app which handles authorization for a Flyte deployment.
|
|
29
|
+
More details here: https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
CLIENT_CREDENTIALS_SECRET_LOCATION = ConfigEntry(YamlConfigEntry("admin.clientSecretLocation"))
|
|
33
|
+
"""
|
|
34
|
+
Used for basic auth, which is automatically called during pyflyte. This will allow the Flyte engine to read the
|
|
35
|
+
password from a mounted file.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
CLIENT_CREDENTIALS_SECRET_ENV_VAR = ConfigEntry(YamlConfigEntry("admin.clientSecretEnvVar"))
|
|
39
|
+
"""
|
|
40
|
+
Used for basic auth, which is automatically called during pyflyte. This will allow the Flyte engine to read the
|
|
41
|
+
password from a mounted environment variable.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
SCOPES = ConfigEntry(YamlConfigEntry("admin.scopes", list))
|
|
45
|
+
"""
|
|
46
|
+
This setting can be used to manually pass in scopes into authenticator flows - eg.) for Auth0 compatibility
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
AUTH_MODE = ConfigEntry(YamlConfigEntry("admin.authType"))
|
|
50
|
+
"""
|
|
51
|
+
The auth mode defines the behavior used to request and refresh credentials. The currently supported modes include:
|
|
52
|
+
- 'standard' or 'Pkce': This uses the pkce-enhanced authorization code flow by opening a browser window to initiate
|
|
53
|
+
credentials access.
|
|
54
|
+
- "DeviceFlow": This uses the Device Authorization Flow
|
|
55
|
+
- 'basic', 'client_credentials' or 'clientSecret': This uses symmetric key auth in which the end user enters a
|
|
56
|
+
client id and a client secret and public key encryption is used to facilitate authentication.
|
|
57
|
+
- None: No auth will be attempted.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Task(object):
|
|
62
|
+
ORG = ConfigEntry(YamlConfigEntry("task.org"))
|
|
63
|
+
PROJECT = ConfigEntry(YamlConfigEntry("task.project"))
|
|
64
|
+
DOMAIN = ConfigEntry(YamlConfigEntry("task.domain"))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class Image(object):
|
|
68
|
+
"""
|
|
69
|
+
Defines the configuration for the image builder.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
BUILDER = ConfigEntry(YamlConfigEntry("image.builder"))
|
|
73
|
+
IMAGE_REFS = ConfigEntry(YamlConfigEntry("image.image_refs"))
|