flyte 0.0.1b0__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 +62 -0
- flyte/_api_commons.py +3 -0
- flyte/_bin/__init__.py +0 -0
- flyte/_bin/runtime.py +126 -0
- flyte/_build.py +25 -0
- flyte/_cache/__init__.py +12 -0
- flyte/_cache/cache.py +146 -0
- flyte/_cache/defaults.py +9 -0
- flyte/_cache/policy_function_body.py +42 -0
- flyte/_cli/__init__.py +0 -0
- flyte/_cli/_common.py +287 -0
- flyte/_cli/_create.py +42 -0
- flyte/_cli/_delete.py +23 -0
- flyte/_cli/_deploy.py +140 -0
- flyte/_cli/_get.py +235 -0
- flyte/_cli/_run.py +152 -0
- flyte/_cli/main.py +72 -0
- flyte/_code_bundle/__init__.py +8 -0
- flyte/_code_bundle/_ignore.py +113 -0
- flyte/_code_bundle/_packaging.py +187 -0
- flyte/_code_bundle/_utils.py +339 -0
- flyte/_code_bundle/bundle.py +178 -0
- flyte/_context.py +146 -0
- flyte/_datastructures.py +342 -0
- flyte/_deploy.py +202 -0
- flyte/_doc.py +29 -0
- flyte/_docstring.py +32 -0
- flyte/_environment.py +43 -0
- flyte/_group.py +31 -0
- flyte/_hash.py +23 -0
- flyte/_image.py +760 -0
- flyte/_initialize.py +634 -0
- flyte/_interface.py +84 -0
- flyte/_internal/__init__.py +3 -0
- flyte/_internal/controllers/__init__.py +115 -0
- flyte/_internal/controllers/_local_controller.py +118 -0
- flyte/_internal/controllers/_trace.py +40 -0
- flyte/_internal/controllers/pbhash.py +39 -0
- flyte/_internal/controllers/remote/__init__.py +40 -0
- flyte/_internal/controllers/remote/_action.py +141 -0
- flyte/_internal/controllers/remote/_client.py +43 -0
- flyte/_internal/controllers/remote/_controller.py +361 -0
- flyte/_internal/controllers/remote/_core.py +402 -0
- flyte/_internal/controllers/remote/_informer.py +361 -0
- flyte/_internal/controllers/remote/_service_protocol.py +50 -0
- flyte/_internal/imagebuild/__init__.py +11 -0
- flyte/_internal/imagebuild/docker_builder.py +416 -0
- flyte/_internal/imagebuild/image_builder.py +241 -0
- flyte/_internal/imagebuild/remote_builder.py +0 -0
- flyte/_internal/resolvers/__init__.py +0 -0
- flyte/_internal/resolvers/_task_module.py +54 -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 +199 -0
- flyte/_internal/runtime/entrypoints.py +135 -0
- flyte/_internal/runtime/io.py +136 -0
- flyte/_internal/runtime/resources_serde.py +138 -0
- flyte/_internal/runtime/task_serde.py +210 -0
- flyte/_internal/runtime/taskrunner.py +190 -0
- flyte/_internal/runtime/types_serde.py +54 -0
- flyte/_logging.py +124 -0
- flyte/_protos/__init__.py +0 -0
- flyte/_protos/common/authorization_pb2.py +66 -0
- flyte/_protos/common/authorization_pb2.pyi +108 -0
- flyte/_protos/common/authorization_pb2_grpc.py +4 -0
- flyte/_protos/common/identifier_pb2.py +71 -0
- flyte/_protos/common/identifier_pb2.pyi +82 -0
- flyte/_protos/common/identifier_pb2_grpc.py +4 -0
- flyte/_protos/common/identity_pb2.py +48 -0
- flyte/_protos/common/identity_pb2.pyi +72 -0
- flyte/_protos/common/identity_pb2_grpc.py +4 -0
- flyte/_protos/common/list_pb2.py +36 -0
- flyte/_protos/common/list_pb2.pyi +69 -0
- flyte/_protos/common/list_pb2_grpc.py +4 -0
- flyte/_protos/common/policy_pb2.py +37 -0
- flyte/_protos/common/policy_pb2.pyi +27 -0
- flyte/_protos/common/policy_pb2_grpc.py +4 -0
- flyte/_protos/common/role_pb2.py +37 -0
- flyte/_protos/common/role_pb2.pyi +53 -0
- flyte/_protos/common/role_pb2_grpc.py +4 -0
- flyte/_protos/common/runtime_version_pb2.py +28 -0
- flyte/_protos/common/runtime_version_pb2.pyi +24 -0
- flyte/_protos/common/runtime_version_pb2_grpc.py +4 -0
- flyte/_protos/logs/dataplane/payload_pb2.py +96 -0
- flyte/_protos/logs/dataplane/payload_pb2.pyi +168 -0
- flyte/_protos/logs/dataplane/payload_pb2_grpc.py +4 -0
- flyte/_protos/secret/definition_pb2.py +49 -0
- flyte/_protos/secret/definition_pb2.pyi +93 -0
- flyte/_protos/secret/definition_pb2_grpc.py +4 -0
- flyte/_protos/secret/payload_pb2.py +62 -0
- flyte/_protos/secret/payload_pb2.pyi +94 -0
- flyte/_protos/secret/payload_pb2_grpc.py +4 -0
- flyte/_protos/secret/secret_pb2.py +38 -0
- flyte/_protos/secret/secret_pb2.pyi +6 -0
- flyte/_protos/secret/secret_pb2_grpc.py +198 -0
- flyte/_protos/secret/secret_pb2_grpc_grpc.py +198 -0
- flyte/_protos/validate/validate/validate_pb2.py +76 -0
- flyte/_protos/workflow/node_execution_service_pb2.py +26 -0
- flyte/_protos/workflow/node_execution_service_pb2.pyi +4 -0
- flyte/_protos/workflow/node_execution_service_pb2_grpc.py +32 -0
- flyte/_protos/workflow/queue_service_pb2.py +106 -0
- flyte/_protos/workflow/queue_service_pb2.pyi +141 -0
- flyte/_protos/workflow/queue_service_pb2_grpc.py +172 -0
- flyte/_protos/workflow/run_definition_pb2.py +128 -0
- flyte/_protos/workflow/run_definition_pb2.pyi +310 -0
- flyte/_protos/workflow/run_definition_pb2_grpc.py +4 -0
- flyte/_protos/workflow/run_logs_service_pb2.py +41 -0
- flyte/_protos/workflow/run_logs_service_pb2.pyi +28 -0
- flyte/_protos/workflow/run_logs_service_pb2_grpc.py +69 -0
- flyte/_protos/workflow/run_service_pb2.py +133 -0
- flyte/_protos/workflow/run_service_pb2.pyi +175 -0
- flyte/_protos/workflow/run_service_pb2_grpc.py +412 -0
- flyte/_protos/workflow/state_service_pb2.py +58 -0
- flyte/_protos/workflow/state_service_pb2.pyi +71 -0
- flyte/_protos/workflow/state_service_pb2_grpc.py +138 -0
- flyte/_protos/workflow/task_definition_pb2.py +72 -0
- flyte/_protos/workflow/task_definition_pb2.pyi +65 -0
- flyte/_protos/workflow/task_definition_pb2_grpc.py +4 -0
- flyte/_protos/workflow/task_service_pb2.py +44 -0
- flyte/_protos/workflow/task_service_pb2.pyi +31 -0
- flyte/_protos/workflow/task_service_pb2_grpc.py +104 -0
- flyte/_resources.py +226 -0
- flyte/_retry.py +32 -0
- flyte/_reusable_environment.py +25 -0
- flyte/_run.py +411 -0
- flyte/_secret.py +61 -0
- flyte/_task.py +367 -0
- flyte/_task_environment.py +200 -0
- flyte/_timeout.py +47 -0
- flyte/_tools.py +27 -0
- flyte/_trace.py +128 -0
- flyte/_utils/__init__.py +20 -0
- flyte/_utils/asyn.py +119 -0
- flyte/_utils/coro_management.py +25 -0
- flyte/_utils/file_handling.py +72 -0
- flyte/_utils/helpers.py +108 -0
- flyte/_utils/lazy_module.py +54 -0
- flyte/_utils/uv_script_parser.py +49 -0
- flyte/_version.py +21 -0
- flyte/connectors/__init__.py +0 -0
- flyte/errors.py +143 -0
- flyte/extras/__init__.py +5 -0
- flyte/extras/_container.py +273 -0
- flyte/io/__init__.py +11 -0
- flyte/io/_dataframe.py +0 -0
- flyte/io/_dir.py +448 -0
- flyte/io/_file.py +468 -0
- flyte/io/pickle/__init__.py +0 -0
- flyte/io/pickle/transformer.py +117 -0
- flyte/io/structured_dataset/__init__.py +129 -0
- flyte/io/structured_dataset/basic_dfs.py +219 -0
- flyte/io/structured_dataset/structured_dataset.py +1061 -0
- flyte/py.typed +0 -0
- flyte/remote/__init__.py +25 -0
- flyte/remote/_client/__init__.py +0 -0
- flyte/remote/_client/_protocols.py +131 -0
- flyte/remote/_client/auth/__init__.py +12 -0
- flyte/remote/_client/auth/_authenticators/__init__.py +0 -0
- flyte/remote/_client/auth/_authenticators/base.py +397 -0
- flyte/remote/_client/auth/_authenticators/client_credentials.py +73 -0
- flyte/remote/_client/auth/_authenticators/device_code.py +118 -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 +184 -0
- flyte/remote/_client/auth/_client_config.py +83 -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 +143 -0
- flyte/remote/_client/auth/_token_client.py +260 -0
- flyte/remote/_client/auth/errors.py +16 -0
- flyte/remote/_client/controlplane.py +95 -0
- flyte/remote/_console.py +18 -0
- flyte/remote/_data.py +155 -0
- flyte/remote/_logs.py +116 -0
- flyte/remote/_project.py +86 -0
- flyte/remote/_run.py +873 -0
- flyte/remote/_secret.py +132 -0
- flyte/remote/_task.py +227 -0
- flyte/report/__init__.py +3 -0
- flyte/report/_report.py +178 -0
- flyte/report/_template.html +124 -0
- flyte/storage/__init__.py +24 -0
- flyte/storage/_remote_fs.py +34 -0
- flyte/storage/_storage.py +251 -0
- flyte/storage/_utils.py +5 -0
- flyte/types/__init__.py +13 -0
- flyte/types/_interface.py +25 -0
- flyte/types/_renderer.py +162 -0
- flyte/types/_string_literals.py +120 -0
- flyte/types/_type_engine.py +2210 -0
- flyte/types/_utils.py +80 -0
- flyte-0.0.1b0.dist-info/METADATA +179 -0
- flyte-0.0.1b0.dist-info/RECORD +390 -0
- flyte-0.0.1b0.dist-info/WHEEL +5 -0
- flyte-0.0.1b0.dist-info/entry_points.txt +3 -0
- flyte-0.0.1b0.dist-info/top_level.txt +1 -0
- union/__init__.py +54 -0
- union/_api_commons.py +3 -0
- union/_bin/__init__.py +0 -0
- union/_bin/runtime.py +113 -0
- union/_build.py +25 -0
- union/_cache/__init__.py +12 -0
- union/_cache/cache.py +141 -0
- union/_cache/defaults.py +9 -0
- union/_cache/policy_function_body.py +42 -0
- union/_cli/__init__.py +0 -0
- union/_cli/_common.py +263 -0
- union/_cli/_create.py +40 -0
- union/_cli/_delete.py +23 -0
- union/_cli/_deploy.py +120 -0
- union/_cli/_get.py +162 -0
- union/_cli/_params.py +579 -0
- union/_cli/_run.py +150 -0
- union/_cli/main.py +72 -0
- union/_code_bundle/__init__.py +8 -0
- union/_code_bundle/_ignore.py +113 -0
- union/_code_bundle/_packaging.py +187 -0
- union/_code_bundle/_utils.py +342 -0
- union/_code_bundle/bundle.py +176 -0
- union/_context.py +146 -0
- union/_datastructures.py +295 -0
- union/_deploy.py +185 -0
- union/_doc.py +29 -0
- union/_docstring.py +26 -0
- union/_environment.py +43 -0
- union/_group.py +31 -0
- union/_hash.py +23 -0
- union/_image.py +760 -0
- union/_initialize.py +585 -0
- union/_interface.py +84 -0
- union/_internal/__init__.py +3 -0
- union/_internal/controllers/__init__.py +77 -0
- union/_internal/controllers/_local_controller.py +77 -0
- union/_internal/controllers/pbhash.py +39 -0
- union/_internal/controllers/remote/__init__.py +40 -0
- union/_internal/controllers/remote/_action.py +131 -0
- union/_internal/controllers/remote/_client.py +43 -0
- union/_internal/controllers/remote/_controller.py +169 -0
- union/_internal/controllers/remote/_core.py +341 -0
- union/_internal/controllers/remote/_informer.py +260 -0
- union/_internal/controllers/remote/_service_protocol.py +44 -0
- union/_internal/imagebuild/__init__.py +11 -0
- union/_internal/imagebuild/docker_builder.py +416 -0
- union/_internal/imagebuild/image_builder.py +243 -0
- union/_internal/imagebuild/remote_builder.py +0 -0
- union/_internal/resolvers/__init__.py +0 -0
- union/_internal/resolvers/_task_module.py +31 -0
- union/_internal/resolvers/common.py +24 -0
- union/_internal/resolvers/default.py +27 -0
- union/_internal/runtime/__init__.py +0 -0
- union/_internal/runtime/convert.py +163 -0
- union/_internal/runtime/entrypoints.py +121 -0
- union/_internal/runtime/io.py +136 -0
- union/_internal/runtime/resources_serde.py +134 -0
- union/_internal/runtime/task_serde.py +202 -0
- union/_internal/runtime/taskrunner.py +179 -0
- union/_internal/runtime/types_serde.py +53 -0
- union/_logging.py +124 -0
- union/_protos/__init__.py +0 -0
- union/_protos/common/authorization_pb2.py +66 -0
- union/_protos/common/authorization_pb2.pyi +106 -0
- union/_protos/common/authorization_pb2_grpc.py +4 -0
- union/_protos/common/identifier_pb2.py +71 -0
- union/_protos/common/identifier_pb2.pyi +82 -0
- union/_protos/common/identifier_pb2_grpc.py +4 -0
- union/_protos/common/identity_pb2.py +48 -0
- union/_protos/common/identity_pb2.pyi +72 -0
- union/_protos/common/identity_pb2_grpc.py +4 -0
- union/_protos/common/list_pb2.py +36 -0
- union/_protos/common/list_pb2.pyi +69 -0
- union/_protos/common/list_pb2_grpc.py +4 -0
- union/_protos/common/policy_pb2.py +37 -0
- union/_protos/common/policy_pb2.pyi +27 -0
- union/_protos/common/policy_pb2_grpc.py +4 -0
- union/_protos/common/role_pb2.py +37 -0
- union/_protos/common/role_pb2.pyi +51 -0
- union/_protos/common/role_pb2_grpc.py +4 -0
- union/_protos/common/runtime_version_pb2.py +28 -0
- union/_protos/common/runtime_version_pb2.pyi +24 -0
- union/_protos/common/runtime_version_pb2_grpc.py +4 -0
- union/_protos/logs/dataplane/payload_pb2.py +96 -0
- union/_protos/logs/dataplane/payload_pb2.pyi +168 -0
- union/_protos/logs/dataplane/payload_pb2_grpc.py +4 -0
- union/_protos/secret/definition_pb2.py +49 -0
- union/_protos/secret/definition_pb2.pyi +93 -0
- union/_protos/secret/definition_pb2_grpc.py +4 -0
- union/_protos/secret/payload_pb2.py +62 -0
- union/_protos/secret/payload_pb2.pyi +94 -0
- union/_protos/secret/payload_pb2_grpc.py +4 -0
- union/_protos/secret/secret_pb2.py +38 -0
- union/_protos/secret/secret_pb2.pyi +6 -0
- union/_protos/secret/secret_pb2_grpc.py +198 -0
- union/_protos/validate/validate/validate_pb2.py +76 -0
- union/_protos/workflow/node_execution_service_pb2.py +26 -0
- union/_protos/workflow/node_execution_service_pb2.pyi +4 -0
- union/_protos/workflow/node_execution_service_pb2_grpc.py +32 -0
- union/_protos/workflow/queue_service_pb2.py +75 -0
- union/_protos/workflow/queue_service_pb2.pyi +103 -0
- union/_protos/workflow/queue_service_pb2_grpc.py +172 -0
- union/_protos/workflow/run_definition_pb2.py +100 -0
- union/_protos/workflow/run_definition_pb2.pyi +256 -0
- union/_protos/workflow/run_definition_pb2_grpc.py +4 -0
- union/_protos/workflow/run_logs_service_pb2.py +41 -0
- union/_protos/workflow/run_logs_service_pb2.pyi +28 -0
- union/_protos/workflow/run_logs_service_pb2_grpc.py +69 -0
- union/_protos/workflow/run_service_pb2.py +133 -0
- union/_protos/workflow/run_service_pb2.pyi +173 -0
- union/_protos/workflow/run_service_pb2_grpc.py +412 -0
- union/_protos/workflow/state_service_pb2.py +58 -0
- union/_protos/workflow/state_service_pb2.pyi +69 -0
- union/_protos/workflow/state_service_pb2_grpc.py +138 -0
- union/_protos/workflow/task_definition_pb2.py +72 -0
- union/_protos/workflow/task_definition_pb2.pyi +65 -0
- union/_protos/workflow/task_definition_pb2_grpc.py +4 -0
- union/_protos/workflow/task_service_pb2.py +44 -0
- union/_protos/workflow/task_service_pb2.pyi +31 -0
- union/_protos/workflow/task_service_pb2_grpc.py +104 -0
- union/_resources.py +226 -0
- union/_retry.py +32 -0
- union/_reusable_environment.py +25 -0
- union/_run.py +374 -0
- union/_secret.py +61 -0
- union/_task.py +354 -0
- union/_task_environment.py +186 -0
- union/_timeout.py +47 -0
- union/_tools.py +27 -0
- union/_utils/__init__.py +11 -0
- union/_utils/asyn.py +119 -0
- union/_utils/file_handling.py +71 -0
- union/_utils/helpers.py +46 -0
- union/_utils/lazy_module.py +54 -0
- union/_utils/uv_script_parser.py +49 -0
- union/_version.py +21 -0
- union/connectors/__init__.py +0 -0
- union/errors.py +128 -0
- union/extras/__init__.py +5 -0
- union/extras/_container.py +263 -0
- union/io/__init__.py +11 -0
- union/io/_dataframe.py +0 -0
- union/io/_dir.py +425 -0
- union/io/_file.py +418 -0
- union/io/pickle/__init__.py +0 -0
- union/io/pickle/transformer.py +117 -0
- union/io/structured_dataset/__init__.py +122 -0
- union/io/structured_dataset/basic_dfs.py +219 -0
- union/io/structured_dataset/structured_dataset.py +1057 -0
- union/py.typed +0 -0
- union/remote/__init__.py +23 -0
- union/remote/_client/__init__.py +0 -0
- union/remote/_client/_protocols.py +129 -0
- union/remote/_client/auth/__init__.py +12 -0
- union/remote/_client/auth/_authenticators/__init__.py +0 -0
- union/remote/_client/auth/_authenticators/base.py +391 -0
- union/remote/_client/auth/_authenticators/client_credentials.py +73 -0
- union/remote/_client/auth/_authenticators/device_code.py +120 -0
- union/remote/_client/auth/_authenticators/external_command.py +77 -0
- union/remote/_client/auth/_authenticators/factory.py +200 -0
- union/remote/_client/auth/_authenticators/pkce.py +515 -0
- union/remote/_client/auth/_channel.py +184 -0
- union/remote/_client/auth/_client_config.py +83 -0
- union/remote/_client/auth/_default_html.py +32 -0
- union/remote/_client/auth/_grpc_utils/__init__.py +0 -0
- union/remote/_client/auth/_grpc_utils/auth_interceptor.py +204 -0
- union/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +144 -0
- union/remote/_client/auth/_keyring.py +154 -0
- union/remote/_client/auth/_token_client.py +258 -0
- union/remote/_client/auth/errors.py +16 -0
- union/remote/_client/controlplane.py +86 -0
- union/remote/_data.py +149 -0
- union/remote/_logs.py +74 -0
- union/remote/_project.py +86 -0
- union/remote/_run.py +820 -0
- union/remote/_secret.py +132 -0
- union/remote/_task.py +193 -0
- union/report/__init__.py +3 -0
- union/report/_report.py +178 -0
- union/report/_template.html +124 -0
- union/storage/__init__.py +24 -0
- union/storage/_remote_fs.py +34 -0
- union/storage/_storage.py +247 -0
- union/storage/_utils.py +5 -0
- union/types/__init__.py +11 -0
- union/types/_renderer.py +162 -0
- union/types/_string_literals.py +120 -0
- union/types/_type_engine.py +2131 -0
- union/types/_utils.py +80 -0
flyte/remote/_secret.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import AsyncGenerator, Iterator, Literal, Union
|
|
5
|
+
|
|
6
|
+
import rich.repr
|
|
7
|
+
|
|
8
|
+
from flyte._api_commons import syncer
|
|
9
|
+
from flyte._initialize import get_client, get_common_config, requires_client
|
|
10
|
+
from flyte._protos.secret import definition_pb2, payload_pb2
|
|
11
|
+
|
|
12
|
+
SecretTypes = Literal["regular", "image_pull"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Secret:
|
|
17
|
+
pb2: definition_pb2.Secret
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
@requires_client
|
|
21
|
+
@syncer.wrap
|
|
22
|
+
async def create(cls, name: str, value: Union[str, bytes], type: SecretTypes = "regular"):
|
|
23
|
+
cfg = get_common_config()
|
|
24
|
+
secret_type = (
|
|
25
|
+
definition_pb2.SecretType.SECRET_TYPE_GENERIC
|
|
26
|
+
if type == "regular"
|
|
27
|
+
else definition_pb2.SecretType.SECRET_TYPE_IMAGE_PULL_SECRET
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if isinstance(value, str):
|
|
31
|
+
secret = definition_pb2.SecretSpec(
|
|
32
|
+
type=secret_type,
|
|
33
|
+
string_value=value,
|
|
34
|
+
)
|
|
35
|
+
else:
|
|
36
|
+
secret = definition_pb2.SecretSpec(
|
|
37
|
+
type=secret_type,
|
|
38
|
+
binary_value=value,
|
|
39
|
+
)
|
|
40
|
+
await get_client().secrets_service.CreateSecret( # type: ignore
|
|
41
|
+
request=payload_pb2.CreateSecretRequest(
|
|
42
|
+
id=definition_pb2.SecretIdentifier(
|
|
43
|
+
organization=cfg.org,
|
|
44
|
+
project=cfg.project,
|
|
45
|
+
domain=cfg.domain,
|
|
46
|
+
name=name,
|
|
47
|
+
),
|
|
48
|
+
secret_spec=secret,
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
@requires_client
|
|
54
|
+
@syncer.wrap
|
|
55
|
+
async def get(cls, name: str) -> Secret:
|
|
56
|
+
cfg = get_common_config()
|
|
57
|
+
resp = await get_client().secrets_service.GetSecret(
|
|
58
|
+
request=payload_pb2.GetSecretRequest(
|
|
59
|
+
id=definition_pb2.SecretIdentifier(
|
|
60
|
+
organization=cfg.org,
|
|
61
|
+
project=cfg.project,
|
|
62
|
+
domain=cfg.domain,
|
|
63
|
+
name=name,
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
return Secret(pb2=resp.secret)
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
@requires_client
|
|
71
|
+
@syncer.wrap
|
|
72
|
+
async def listall(cls, limit: int = 100) -> Union[Iterator[Secret], AsyncGenerator[Secret, None]]:
|
|
73
|
+
cfg = get_common_config()
|
|
74
|
+
token = None
|
|
75
|
+
while True:
|
|
76
|
+
resp = await get_client().secrets_service.ListSecrets( # type: ignore
|
|
77
|
+
request=payload_pb2.ListSecretsRequest(
|
|
78
|
+
organization=cfg.org,
|
|
79
|
+
project=cfg.project,
|
|
80
|
+
domain=cfg.domain,
|
|
81
|
+
token=token,
|
|
82
|
+
limit=limit,
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
token = resp.token
|
|
86
|
+
for r in resp.secrets:
|
|
87
|
+
yield cls(r)
|
|
88
|
+
if not token:
|
|
89
|
+
break
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
@requires_client
|
|
93
|
+
@syncer.wrap
|
|
94
|
+
async def delete(cls, name):
|
|
95
|
+
cfg = get_common_config()
|
|
96
|
+
await get_client().secrets_service.DeleteSecret( # type: ignore
|
|
97
|
+
request=payload_pb2.DeleteSecretRequest(
|
|
98
|
+
id=definition_pb2.SecretIdentifier(
|
|
99
|
+
organization=cfg.org,
|
|
100
|
+
project=cfg.project,
|
|
101
|
+
domain=cfg.domain,
|
|
102
|
+
name=name,
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def name(self) -> str:
|
|
109
|
+
return self.pb2.id.name
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def type(self) -> str:
|
|
113
|
+
if self.pb2.secret_metadata.type == definition_pb2.SecretType.SECRET_TYPE_GENERIC:
|
|
114
|
+
return "regular"
|
|
115
|
+
elif self.pb2.secret_metadata.type == definition_pb2.SecretType.SECRET_TYPE_IMAGE_PULL_SECRET:
|
|
116
|
+
return "image_pull"
|
|
117
|
+
raise ValueError("unknown type")
|
|
118
|
+
|
|
119
|
+
def __rich_repr__(self) -> rich.repr.Result:
|
|
120
|
+
yield "project", self.pb2.id.project or "-"
|
|
121
|
+
yield "domain", self.pb2.id.domain or "-"
|
|
122
|
+
yield "name", self.name
|
|
123
|
+
yield "type", self.type
|
|
124
|
+
yield "created_time", self.pb2.secret_metadata.created_time.ToDatetime().isoformat()
|
|
125
|
+
yield "status", definition_pb2.OverallStatus.Name(self.pb2.secret_metadata.secret_status.overall_status)
|
|
126
|
+
yield (
|
|
127
|
+
"cluster_status",
|
|
128
|
+
{
|
|
129
|
+
s.cluster.name: definition_pb2.SecretPresenceStatus.Name(s.presence_status)
|
|
130
|
+
for s in self.pb2.secret_metadata.secret_status.cluster_status
|
|
131
|
+
},
|
|
132
|
+
)
|
flyte/remote/_task.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import functools
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from threading import Lock
|
|
6
|
+
from typing import Any, Callable, Coroutine, Dict, Literal, Optional, Union
|
|
7
|
+
|
|
8
|
+
import rich.repr
|
|
9
|
+
|
|
10
|
+
import flyte
|
|
11
|
+
import flyte.errors
|
|
12
|
+
from flyte._api_commons import syncer
|
|
13
|
+
from flyte._context import internal_ctx
|
|
14
|
+
from flyte._datastructures import NativeInterface
|
|
15
|
+
from flyte._initialize import get_client, get_common_config
|
|
16
|
+
from flyte._protos.workflow import task_definition_pb2, task_service_pb2
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class LazyEntity:
|
|
20
|
+
"""
|
|
21
|
+
Fetches the entity when the entity is called or when the entity is retrieved.
|
|
22
|
+
The entity is derived from RemoteEntity so that it behaves exactly like the mimicked entity.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, name: str, getter: Callable[..., Coroutine[Any, Any, Task]], *args, **kwargs):
|
|
26
|
+
self._task: Optional[Task] = None
|
|
27
|
+
self._getter = getter
|
|
28
|
+
self._name = name
|
|
29
|
+
self._mutex = Lock()
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def name(self) -> str:
|
|
33
|
+
return self._name
|
|
34
|
+
|
|
35
|
+
@syncer.wrap
|
|
36
|
+
async def fetch(self) -> Task:
|
|
37
|
+
"""
|
|
38
|
+
Forwards all other attributes to task, causing the task to be fetched!
|
|
39
|
+
"""
|
|
40
|
+
with self._mutex:
|
|
41
|
+
if self._task is None:
|
|
42
|
+
self._task = await self._getter()
|
|
43
|
+
if self._task is None:
|
|
44
|
+
raise RuntimeError(f"Error downloading the task {self._name}, (check original exception...)")
|
|
45
|
+
return self._task
|
|
46
|
+
|
|
47
|
+
async def __call__(self, *args, **kwargs):
|
|
48
|
+
"""
|
|
49
|
+
Forwards the call to the underlying task. The entity will be fetched if not already present
|
|
50
|
+
"""
|
|
51
|
+
tk = await self.fetch.aio(self)
|
|
52
|
+
return await tk(*args, **kwargs)
|
|
53
|
+
|
|
54
|
+
def __repr__(self) -> str:
|
|
55
|
+
return str(self)
|
|
56
|
+
|
|
57
|
+
def __str__(self) -> str:
|
|
58
|
+
return f"Future for task with name {self._name}"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
AutoVersioning = Literal["latest", "current"]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass
|
|
65
|
+
class Task:
|
|
66
|
+
pb2: task_definition_pb2.TaskDetails
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def get(cls, name: str, version: str | None = None, auto_version: AutoVersioning | None = None) -> LazyEntity:
|
|
70
|
+
"""
|
|
71
|
+
Get a task by its ID or name. If both are provided, the ID will take precedence.
|
|
72
|
+
|
|
73
|
+
Either version or auto_version are required parameters.
|
|
74
|
+
|
|
75
|
+
:param uri: The URI of the task. If provided, do not provide the rest of the parameters.
|
|
76
|
+
:param name: The name of the task.
|
|
77
|
+
:param version: The version of the task.
|
|
78
|
+
:param auto_version: If set to "latest", the latest-by-time ordered from now, version of the task will be used.
|
|
79
|
+
If set to "current", the version will be derived from the callee tasks context. This is useful if you are
|
|
80
|
+
deploying all environments with the same version. If auto_version is current, you can only access the task from
|
|
81
|
+
within a task context.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
if version is None and auto_version is None:
|
|
85
|
+
raise ValueError("Either version or auto_version must be provided.")
|
|
86
|
+
|
|
87
|
+
if version is None and auto_version not in ["latest", "current"]:
|
|
88
|
+
raise ValueError("auto_version must be either 'latest' or 'current'.")
|
|
89
|
+
|
|
90
|
+
async def deferred_get(_version: str | None, _auto_version: AutoVersioning | None) -> Task:
|
|
91
|
+
if _version is None:
|
|
92
|
+
if _auto_version == "latest":
|
|
93
|
+
raise NotImplementedError("auto_version=latest is not yet implemented.")
|
|
94
|
+
elif _auto_version == "current":
|
|
95
|
+
ctx = flyte.ctx()
|
|
96
|
+
if ctx is None:
|
|
97
|
+
raise ValueError("auto_version=current can only be used within a task context.")
|
|
98
|
+
_version = ctx.version
|
|
99
|
+
cfg = get_common_config()
|
|
100
|
+
task_id = task_definition_pb2.TaskIdentifier(
|
|
101
|
+
org=cfg.org,
|
|
102
|
+
project=cfg.project,
|
|
103
|
+
domain=cfg.domain,
|
|
104
|
+
name=name,
|
|
105
|
+
version=_version,
|
|
106
|
+
)
|
|
107
|
+
resp = await get_client().task_service.GetTaskDetails(
|
|
108
|
+
task_service_pb2.GetTaskDetailsRequest(
|
|
109
|
+
task_id=task_id,
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
return cls(resp.details)
|
|
113
|
+
|
|
114
|
+
return LazyEntity(
|
|
115
|
+
name=name, getter=functools.partial(deferred_get, _version=version, _auto_version=auto_version)
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def name(self) -> str:
|
|
120
|
+
"""
|
|
121
|
+
The name of the task.
|
|
122
|
+
"""
|
|
123
|
+
return self.pb2.task_id.name
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def version(self) -> str:
|
|
127
|
+
"""
|
|
128
|
+
The version of the task.
|
|
129
|
+
"""
|
|
130
|
+
return self.pb2.task_id.version
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def task_type(self) -> str:
|
|
134
|
+
"""
|
|
135
|
+
The type of the task.
|
|
136
|
+
"""
|
|
137
|
+
return self.pb2.spec.task_template.type
|
|
138
|
+
|
|
139
|
+
@functools.cached_property
|
|
140
|
+
def interface(self) -> NativeInterface:
|
|
141
|
+
"""
|
|
142
|
+
The interface of the task.
|
|
143
|
+
"""
|
|
144
|
+
import flyte.types as types
|
|
145
|
+
|
|
146
|
+
return types.guess_interface(self.pb2.spec.task_template.interface)
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def cache(self) -> flyte.Cache:
|
|
150
|
+
"""
|
|
151
|
+
The cache policy of the task.
|
|
152
|
+
"""
|
|
153
|
+
return flyte.Cache(
|
|
154
|
+
behavior="enabled" if self.pb2.spec.task_template.metadata.discoverable else "disable",
|
|
155
|
+
version_override=self.pb2.spec.task_template.metadata.discovery_version,
|
|
156
|
+
serialize=self.pb2.spec.task_template.metadata.cache_serializable,
|
|
157
|
+
ignored_inputs=tuple(self.pb2.spec.task_template.metadata.cache_ignore_input_vars),
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def secrets(self):
|
|
162
|
+
"""
|
|
163
|
+
The secrets of the task.
|
|
164
|
+
"""
|
|
165
|
+
return [s.key for s in self.pb2.spec.task_template.security_context.secrets]
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def resources(self):
|
|
169
|
+
"""
|
|
170
|
+
The resources of the task.
|
|
171
|
+
"""
|
|
172
|
+
if self.pb2.spec.task_template.container is None:
|
|
173
|
+
return ()
|
|
174
|
+
return (
|
|
175
|
+
self.pb2.spec.task_template.container.resources.requests,
|
|
176
|
+
self.pb2.spec.task_template.container.resources.limits,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
async def __call__(self, *args, **kwargs):
|
|
180
|
+
"""
|
|
181
|
+
Forwards the call to the underlying task. The entity will be fetched if not already present
|
|
182
|
+
"""
|
|
183
|
+
ctx = internal_ctx()
|
|
184
|
+
if ctx.is_task_context():
|
|
185
|
+
# If we are in a task context, that implies we are executing a Run.
|
|
186
|
+
# In this scenario, we should submit the task to the controller.
|
|
187
|
+
# We will also check if we are not initialized, It is not expected to be not initialized
|
|
188
|
+
from flyte._internal.controllers import get_controller
|
|
189
|
+
|
|
190
|
+
controller = await get_controller()
|
|
191
|
+
if controller:
|
|
192
|
+
return await controller.submit_task_ref(self.pb2, *args, **kwargs)
|
|
193
|
+
raise flyte.errors
|
|
194
|
+
|
|
195
|
+
def override(
|
|
196
|
+
self,
|
|
197
|
+
*,
|
|
198
|
+
local: Optional[bool] = None,
|
|
199
|
+
ref: Optional[bool] = None,
|
|
200
|
+
resources: Optional[flyte.Resources] = None,
|
|
201
|
+
cache: flyte.CacheRequest = "auto",
|
|
202
|
+
retries: Union[int, flyte.RetryStrategy] = 0,
|
|
203
|
+
timeout: Optional[flyte.TimeoutType] = None,
|
|
204
|
+
reusable: Union[flyte.ReusePolicy, Literal["auto"], None] = None,
|
|
205
|
+
env: Optional[Dict[str, str]] = None,
|
|
206
|
+
secrets: Optional[flyte.SecretRequest] = None,
|
|
207
|
+
**kwargs: Any,
|
|
208
|
+
) -> Task:
|
|
209
|
+
raise NotImplementedError
|
|
210
|
+
|
|
211
|
+
def __rich_repr__(self) -> rich.repr.Result:
|
|
212
|
+
"""
|
|
213
|
+
Rich representation of the task.
|
|
214
|
+
"""
|
|
215
|
+
yield "project", self.pb2.task_id.project
|
|
216
|
+
yield "domain", self.pb2.task_id.domain
|
|
217
|
+
yield "name", self.name
|
|
218
|
+
yield "version", self.version
|
|
219
|
+
yield "task_type", self.task_type
|
|
220
|
+
yield "cache", self.cache
|
|
221
|
+
yield "interface", self.name + str(self.interface)
|
|
222
|
+
yield "secrets", self.secrets
|
|
223
|
+
yield "resources", self.resources
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if __name__ == "__main__":
|
|
227
|
+
tk = Task.get(name="example_task")
|
flyte/report/__init__.py
ADDED
flyte/report/_report.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import html
|
|
2
|
+
import pathlib
|
|
3
|
+
import string
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from typing import TYPE_CHECKING, Dict, List, Union
|
|
6
|
+
|
|
7
|
+
from flyte._api_commons import syncer
|
|
8
|
+
from flyte._internal.runtime import io
|
|
9
|
+
from flyte._logging import logger
|
|
10
|
+
from flyte._tools import ipython_check
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from IPython.core.display import HTML
|
|
14
|
+
|
|
15
|
+
_MAIN_TAB_NAME = "main"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class Tab:
|
|
20
|
+
name: str
|
|
21
|
+
content: List[str] = field(default_factory=list, init=False)
|
|
22
|
+
|
|
23
|
+
def log(self, content: str):
|
|
24
|
+
"""
|
|
25
|
+
Add content to the tab.
|
|
26
|
+
The content should be a valid HTML string, but not a complete HTML document, as it will be inserted into a div.
|
|
27
|
+
|
|
28
|
+
:param content: The content to add.
|
|
29
|
+
"""
|
|
30
|
+
self.content.append(content)
|
|
31
|
+
|
|
32
|
+
def replace(self, content: str):
|
|
33
|
+
"""
|
|
34
|
+
Replace the content of the tab.
|
|
35
|
+
The content should be a valid HTML string, but not a complete HTML document, as it will be inserted into a div.
|
|
36
|
+
|
|
37
|
+
:param content: The content to replace.
|
|
38
|
+
"""
|
|
39
|
+
self.content = [content]
|
|
40
|
+
|
|
41
|
+
def get_html(self) -> str:
|
|
42
|
+
"""
|
|
43
|
+
Get the HTML representation of the tab.
|
|
44
|
+
|
|
45
|
+
:return: The HTML representation of the tab.
|
|
46
|
+
"""
|
|
47
|
+
return "\n".join(self.content)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class Report:
|
|
52
|
+
name: str
|
|
53
|
+
tabs: Dict[str, Tab] = field(default_factory=dict)
|
|
54
|
+
template_path: pathlib.Path = field(default_factory=lambda: pathlib.Path(__file__).parent / "_template.html")
|
|
55
|
+
|
|
56
|
+
def __post_init__(self):
|
|
57
|
+
self.tabs[_MAIN_TAB_NAME] = Tab(_MAIN_TAB_NAME)
|
|
58
|
+
|
|
59
|
+
def get_tab(self, name: str, create_if_missing: bool = True) -> Tab:
|
|
60
|
+
"""
|
|
61
|
+
Get a tab by name. If the tab does not exist, create it.
|
|
62
|
+
|
|
63
|
+
:param name: The name of the tab.
|
|
64
|
+
:param create_if_missing: Whether to create the tab if it does not exist.
|
|
65
|
+
:return: The tab.
|
|
66
|
+
"""
|
|
67
|
+
if name not in self.tabs:
|
|
68
|
+
if create_if_missing:
|
|
69
|
+
self.tabs[name] = Tab(name)
|
|
70
|
+
else:
|
|
71
|
+
raise ValueError(f"Tab {name} does not exist.")
|
|
72
|
+
return self.tabs[name]
|
|
73
|
+
|
|
74
|
+
def get_final_report(self) -> Union[str, "HTML"]:
|
|
75
|
+
"""
|
|
76
|
+
Get the final report as a string.
|
|
77
|
+
|
|
78
|
+
:return: The final report.
|
|
79
|
+
"""
|
|
80
|
+
tabs = {n: t.get_html() for n, t in self.tabs.items()}
|
|
81
|
+
nav_htmls = []
|
|
82
|
+
body_htmls = []
|
|
83
|
+
|
|
84
|
+
for key, value in tabs.items():
|
|
85
|
+
nav_htmls.append(f'<li onclick="handleLinkClick(this)">{html.escape(key)}</li>')
|
|
86
|
+
# Can not escape here because this is HTML. Escaping it will present the HTML as text.
|
|
87
|
+
# The renderer must ensure that the HTML is safe.
|
|
88
|
+
body_htmls.append(f"<div>{value}</div>")
|
|
89
|
+
|
|
90
|
+
template = string.Template(self.template_path.open("r").read())
|
|
91
|
+
|
|
92
|
+
raw_html = template.substitute(NAV_HTML="".join(nav_htmls), BODY_HTML="".join(body_htmls))
|
|
93
|
+
if ipython_check():
|
|
94
|
+
try:
|
|
95
|
+
from IPython.core.display import HTML
|
|
96
|
+
|
|
97
|
+
return HTML(raw_html)
|
|
98
|
+
except ImportError:
|
|
99
|
+
...
|
|
100
|
+
return raw_html
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def get_tab(name: str, /, create_if_missing: bool = True) -> Tab:
|
|
104
|
+
"""
|
|
105
|
+
Get a tab by name. If the tab does not exist, create it.
|
|
106
|
+
|
|
107
|
+
:param name: The name of the tab.
|
|
108
|
+
:param create_if_missing: Whether to create the tab if it does not exist.
|
|
109
|
+
:return: The tab.
|
|
110
|
+
"""
|
|
111
|
+
report = current_report()
|
|
112
|
+
return report.get_tab(name, create_if_missing=create_if_missing)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@syncer.wrap
|
|
116
|
+
async def log(content: str, do_flush: bool = False):
|
|
117
|
+
"""
|
|
118
|
+
Log content to the main tab. The content should be a valid HTML string, but not a complete HTML document,
|
|
119
|
+
as it will be inserted into a div.
|
|
120
|
+
|
|
121
|
+
:param content: The content to log.
|
|
122
|
+
:param do_flush: flush the report after logging.
|
|
123
|
+
"""
|
|
124
|
+
get_tab(_MAIN_TAB_NAME).log(content)
|
|
125
|
+
if do_flush:
|
|
126
|
+
await flush.aio()
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@syncer.wrap
|
|
130
|
+
async def flush():
|
|
131
|
+
"""
|
|
132
|
+
Flush the report.
|
|
133
|
+
"""
|
|
134
|
+
import flyte.storage as storage
|
|
135
|
+
from flyte._context import internal_ctx
|
|
136
|
+
|
|
137
|
+
if not internal_ctx().is_task_context():
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
report = internal_ctx().get_report()
|
|
141
|
+
if report is None:
|
|
142
|
+
return
|
|
143
|
+
|
|
144
|
+
report_html = report.get_final_report()
|
|
145
|
+
assert report_html is not None
|
|
146
|
+
assert isinstance(report_html, str)
|
|
147
|
+
report_path = io.report_path(internal_ctx().data.task_context.output_path)
|
|
148
|
+
final_path = await storage.put_stream(report_html.encode("utf-8"), to_path=report_path)
|
|
149
|
+
logger.debug(f"Report flushed to {final_path}")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@syncer.wrap
|
|
153
|
+
async def replace(content: str, do_flush: bool = False):
|
|
154
|
+
"""
|
|
155
|
+
Get the report. Replaces the content of the main tab.
|
|
156
|
+
|
|
157
|
+
:return: The report.
|
|
158
|
+
"""
|
|
159
|
+
report = current_report()
|
|
160
|
+
if report is None:
|
|
161
|
+
return
|
|
162
|
+
report.get_tab(_MAIN_TAB_NAME).replace(content)
|
|
163
|
+
if do_flush:
|
|
164
|
+
await flush.aio()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def current_report() -> Report:
|
|
168
|
+
"""
|
|
169
|
+
Get the current report. This is a dummy report if not in a task context.
|
|
170
|
+
|
|
171
|
+
:return: The current report.
|
|
172
|
+
"""
|
|
173
|
+
from flyte._context import internal_ctx
|
|
174
|
+
|
|
175
|
+
report = internal_ctx().get_report()
|
|
176
|
+
if report is None:
|
|
177
|
+
report = Report("dummy")
|
|
178
|
+
return report
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>User Content</title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700%7COpen+Sans:400,700" rel="stylesheet">
|
|
8
|
+
<style>
|
|
9
|
+
ol, ul {
|
|
10
|
+
list-style: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
table {
|
|
14
|
+
border-collapse: collapse;
|
|
15
|
+
border-spacing: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#flyte-frame-nav {
|
|
19
|
+
display: flex;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#flyte-frame-tabs {
|
|
24
|
+
display: flex;
|
|
25
|
+
width: 100%;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
margin-block: 0;
|
|
28
|
+
padding-inline-start: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#flyte-frame-tabs li {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
padding: 8px;
|
|
34
|
+
margin: 0;
|
|
35
|
+
margin-right: 12px;
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
line-height: 20px;
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
font-style: normal;
|
|
40
|
+
font-family: Open Sans, helvetica, arial, sans-serif;
|
|
41
|
+
color: #666666;
|
|
42
|
+
width: 126px;
|
|
43
|
+
text-align: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#flyte-frame-tabs li:last-child {
|
|
47
|
+
margin-right: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#flyte-frame-tabs li.active {
|
|
51
|
+
border-bottom: 4px solid rgb(163, 26, 255);
|
|
52
|
+
color: #333333;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#flyte-frame-container {
|
|
56
|
+
width: auto;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#flyte-frame-container > div {
|
|
60
|
+
display: None;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#flyte-frame-container > div.active {
|
|
64
|
+
display: block;
|
|
65
|
+
padding: 2rem 2rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
</style>
|
|
69
|
+
|
|
70
|
+
</head>
|
|
71
|
+
<body>
|
|
72
|
+
<nav id="flyte-frame-nav">
|
|
73
|
+
<ul id="flyte-frame-tabs">
|
|
74
|
+
$NAV_HTML
|
|
75
|
+
</ul>
|
|
76
|
+
</nav>
|
|
77
|
+
<div id="flyte-frame-container">
|
|
78
|
+
$BODY_HTML
|
|
79
|
+
</div>
|
|
80
|
+
</body>
|
|
81
|
+
<script>
|
|
82
|
+
const setTabs = index => {
|
|
83
|
+
const container = document.getElementById('flyte-frame-tabs')
|
|
84
|
+
for (let i = 0; i < container.children.length; i++) {
|
|
85
|
+
const tabIndex = container.children[i].getAttribute('link_index')
|
|
86
|
+
if (tabIndex === index) {
|
|
87
|
+
container.children[i].classList.add('active')
|
|
88
|
+
} else {
|
|
89
|
+
container.children[i].className = ''
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const setContent = index => {
|
|
94
|
+
const container = document.getElementById('flyte-frame-container')
|
|
95
|
+
for (let i = 0; i < container.children.length; i++) {
|
|
96
|
+
const tabIndex = container.children[i].getAttribute('link_index')
|
|
97
|
+
if (tabIndex === index) {
|
|
98
|
+
container.children[i].classList.add('active')
|
|
99
|
+
} else {
|
|
100
|
+
container.children[i].className = ''
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const setLinkIndex = index => {
|
|
105
|
+
setTabs(index)
|
|
106
|
+
setContent(index)
|
|
107
|
+
}
|
|
108
|
+
const handleLinkClick = e => {
|
|
109
|
+
const linkIndex = e.getAttribute('link_index');
|
|
110
|
+
setLinkIndex(linkIndex)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const tabs = document.getElementById('flyte-frame-tabs');
|
|
114
|
+
const containers = document.getElementById('flyte-frame-container');
|
|
115
|
+
for(var i = 0; i < tabs.children.length; i++) {
|
|
116
|
+
if (i === 0) {
|
|
117
|
+
tabs.children[i].classList.add('active')
|
|
118
|
+
containers.children[i].classList.add('active')
|
|
119
|
+
}
|
|
120
|
+
tabs.children[i].setAttribute("link_index", i+1)
|
|
121
|
+
containers.children[i].setAttribute("link_index", i+1)
|
|
122
|
+
}
|
|
123
|
+
</script>
|
|
124
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
__all__ = [
|
|
2
|
+
"get",
|
|
3
|
+
"get_random_local_directory",
|
|
4
|
+
"get_random_local_path",
|
|
5
|
+
"get_stream",
|
|
6
|
+
"get_underlying_filesystem",
|
|
7
|
+
"is_remote",
|
|
8
|
+
"join",
|
|
9
|
+
"put",
|
|
10
|
+
"put_stream",
|
|
11
|
+
"put_stream",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
from ._storage import (
|
|
15
|
+
get,
|
|
16
|
+
get_random_local_directory,
|
|
17
|
+
get_random_local_path,
|
|
18
|
+
get_stream,
|
|
19
|
+
get_underlying_filesystem,
|
|
20
|
+
is_remote,
|
|
21
|
+
join,
|
|
22
|
+
put,
|
|
23
|
+
put_stream,
|
|
24
|
+
)
|