flyte 0.0.1b0__py3-none-any.whl → 2.0.0b46__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.
- flyte/__init__.py +83 -30
- flyte/_bin/connect.py +61 -0
- flyte/_bin/debug.py +38 -0
- flyte/_bin/runtime.py +87 -19
- flyte/_bin/serve.py +351 -0
- flyte/_build.py +3 -2
- flyte/_cache/cache.py +6 -5
- flyte/_cache/local_cache.py +216 -0
- flyte/_code_bundle/_ignore.py +31 -5
- flyte/_code_bundle/_packaging.py +42 -11
- flyte/_code_bundle/_utils.py +57 -34
- flyte/_code_bundle/bundle.py +130 -27
- flyte/_constants.py +1 -0
- flyte/_context.py +21 -5
- flyte/_custom_context.py +73 -0
- flyte/_debug/constants.py +37 -0
- flyte/_debug/utils.py +17 -0
- flyte/_debug/vscode.py +315 -0
- flyte/_deploy.py +396 -75
- flyte/_deployer.py +109 -0
- flyte/_environment.py +94 -11
- flyte/_excepthook.py +37 -0
- flyte/_group.py +2 -1
- flyte/_hash.py +1 -16
- flyte/_image.py +544 -234
- flyte/_initialize.py +443 -294
- flyte/_interface.py +40 -5
- flyte/_internal/controllers/__init__.py +22 -8
- flyte/_internal/controllers/_local_controller.py +159 -35
- flyte/_internal/controllers/_trace.py +18 -10
- flyte/_internal/controllers/remote/__init__.py +38 -9
- flyte/_internal/controllers/remote/_action.py +82 -12
- flyte/_internal/controllers/remote/_client.py +6 -2
- flyte/_internal/controllers/remote/_controller.py +290 -64
- flyte/_internal/controllers/remote/_core.py +155 -95
- flyte/_internal/controllers/remote/_informer.py +40 -20
- flyte/_internal/controllers/remote/_service_protocol.py +2 -2
- flyte/_internal/imagebuild/__init__.py +2 -10
- flyte/_internal/imagebuild/docker_builder.py +391 -84
- flyte/_internal/imagebuild/image_builder.py +111 -55
- flyte/_internal/imagebuild/remote_builder.py +409 -0
- flyte/_internal/imagebuild/utils.py +79 -0
- flyte/_internal/resolvers/_app_env_module.py +92 -0
- flyte/_internal/resolvers/_task_module.py +5 -38
- flyte/_internal/resolvers/app_env.py +26 -0
- flyte/_internal/resolvers/common.py +8 -1
- flyte/_internal/resolvers/default.py +2 -2
- flyte/_internal/runtime/convert.py +322 -33
- flyte/_internal/runtime/entrypoints.py +106 -18
- flyte/_internal/runtime/io.py +71 -23
- flyte/_internal/runtime/resources_serde.py +21 -7
- flyte/_internal/runtime/reuse.py +125 -0
- flyte/_internal/runtime/rusty.py +196 -0
- flyte/_internal/runtime/task_serde.py +239 -66
- flyte/_internal/runtime/taskrunner.py +48 -8
- flyte/_internal/runtime/trigger_serde.py +162 -0
- flyte/_internal/runtime/types_serde.py +7 -16
- flyte/_keyring/file.py +115 -0
- flyte/_link.py +30 -0
- flyte/_logging.py +241 -42
- flyte/_map.py +312 -0
- flyte/_metrics.py +59 -0
- flyte/_module.py +74 -0
- flyte/_pod.py +30 -0
- flyte/_resources.py +296 -33
- flyte/_retry.py +1 -7
- flyte/_reusable_environment.py +72 -7
- flyte/_run.py +461 -132
- flyte/_secret.py +47 -11
- flyte/_serve.py +333 -0
- flyte/_task.py +245 -56
- flyte/_task_environment.py +219 -97
- flyte/_task_plugins.py +47 -0
- flyte/_tools.py +8 -8
- flyte/_trace.py +15 -24
- flyte/_trigger.py +1027 -0
- flyte/_utils/__init__.py +12 -1
- flyte/_utils/asyn.py +3 -1
- flyte/_utils/async_cache.py +139 -0
- flyte/_utils/coro_management.py +5 -4
- flyte/_utils/description_parser.py +19 -0
- flyte/_utils/docker_credentials.py +173 -0
- flyte/_utils/helpers.py +45 -19
- flyte/_utils/module_loader.py +123 -0
- flyte/_utils/org_discovery.py +57 -0
- flyte/_utils/uv_script_parser.py +8 -1
- flyte/_version.py +16 -3
- flyte/app/__init__.py +27 -0
- flyte/app/_app_environment.py +362 -0
- flyte/app/_connector_environment.py +40 -0
- flyte/app/_deploy.py +130 -0
- flyte/app/_parameter.py +343 -0
- flyte/app/_runtime/__init__.py +3 -0
- flyte/app/_runtime/app_serde.py +383 -0
- flyte/app/_types.py +113 -0
- flyte/app/extras/__init__.py +9 -0
- flyte/app/extras/_auth_middleware.py +217 -0
- flyte/app/extras/_fastapi.py +93 -0
- flyte/app/extras/_model_loader/__init__.py +3 -0
- flyte/app/extras/_model_loader/config.py +7 -0
- flyte/app/extras/_model_loader/loader.py +288 -0
- flyte/cli/__init__.py +12 -0
- flyte/cli/_abort.py +28 -0
- flyte/cli/_build.py +114 -0
- flyte/cli/_common.py +493 -0
- flyte/cli/_create.py +371 -0
- flyte/cli/_delete.py +45 -0
- flyte/cli/_deploy.py +401 -0
- flyte/cli/_gen.py +316 -0
- flyte/cli/_get.py +446 -0
- flyte/cli/_option.py +33 -0
- {union/_cli → flyte/cli}/_params.py +152 -153
- flyte/cli/_plugins.py +209 -0
- flyte/cli/_prefetch.py +292 -0
- flyte/cli/_run.py +690 -0
- flyte/cli/_serve.py +338 -0
- flyte/cli/_update.py +86 -0
- flyte/cli/_user.py +20 -0
- flyte/cli/main.py +246 -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 +330 -0
- flyte/connectors/_server.py +194 -0
- flyte/connectors/utils.py +159 -0
- flyte/errors.py +134 -2
- flyte/extend.py +24 -0
- flyte/extras/_container.py +69 -56
- flyte/git/__init__.py +3 -0
- flyte/git/_config.py +279 -0
- flyte/io/__init__.py +8 -1
- flyte/io/{structured_dataset → _dataframe}/__init__.py +32 -30
- flyte/io/{structured_dataset → _dataframe}/basic_dfs.py +75 -68
- flyte/io/{structured_dataset/structured_dataset.py → _dataframe/dataframe.py} +207 -242
- flyte/io/_dir.py +575 -113
- flyte/io/_file.py +587 -141
- flyte/io/_hashing_io.py +342 -0
- flyte/io/extend.py +7 -0
- flyte/models.py +635 -0
- flyte/prefetch/__init__.py +22 -0
- flyte/prefetch/_hf_model.py +563 -0
- flyte/remote/__init__.py +14 -3
- flyte/remote/_action.py +879 -0
- flyte/remote/_app.py +346 -0
- flyte/remote/_auth_metadata.py +42 -0
- flyte/remote/_client/_protocols.py +62 -4
- flyte/remote/_client/auth/_auth_utils.py +19 -0
- flyte/remote/_client/auth/_authenticators/base.py +8 -2
- flyte/remote/_client/auth/_authenticators/device_code.py +4 -5
- flyte/remote/_client/auth/_authenticators/factory.py +4 -0
- flyte/remote/_client/auth/_authenticators/passthrough.py +79 -0
- flyte/remote/_client/auth/_authenticators/pkce.py +17 -18
- flyte/remote/_client/auth/_channel.py +47 -18
- flyte/remote/_client/auth/_client_config.py +5 -3
- flyte/remote/_client/auth/_keyring.py +15 -2
- flyte/remote/_client/auth/_token_client.py +3 -3
- flyte/remote/_client/controlplane.py +206 -18
- flyte/remote/_common.py +66 -0
- flyte/remote/_data.py +107 -22
- flyte/remote/_logs.py +116 -33
- flyte/remote/_project.py +21 -19
- flyte/remote/_run.py +164 -631
- flyte/remote/_secret.py +72 -29
- flyte/remote/_task.py +387 -46
- flyte/remote/_trigger.py +368 -0
- flyte/remote/_user.py +43 -0
- flyte/report/_report.py +10 -6
- flyte/storage/__init__.py +13 -1
- flyte/storage/_config.py +237 -0
- flyte/storage/_parallel_reader.py +289 -0
- flyte/storage/_storage.py +268 -59
- flyte/syncify/__init__.py +56 -0
- flyte/syncify/_api.py +414 -0
- flyte/types/__init__.py +39 -0
- flyte/types/_interface.py +22 -7
- flyte/{io/pickle/transformer.py → types/_pickle.py} +37 -9
- flyte/types/_string_literals.py +8 -9
- flyte/types/_type_engine.py +230 -129
- flyte/types/_utils.py +1 -1
- flyte-2.0.0b46.data/scripts/debug.py +38 -0
- flyte-2.0.0b46.data/scripts/runtime.py +194 -0
- flyte-2.0.0b46.dist-info/METADATA +352 -0
- flyte-2.0.0b46.dist-info/RECORD +221 -0
- flyte-2.0.0b46.dist-info/entry_points.txt +8 -0
- flyte-2.0.0b46.dist-info/licenses/LICENSE +201 -0
- flyte/_api_commons.py +0 -3
- flyte/_cli/_common.py +0 -287
- flyte/_cli/_create.py +0 -42
- flyte/_cli/_delete.py +0 -23
- flyte/_cli/_deploy.py +0 -140
- flyte/_cli/_get.py +0 -235
- flyte/_cli/_run.py +0 -152
- flyte/_cli/main.py +0 -72
- flyte/_datastructures.py +0 -342
- flyte/_internal/controllers/pbhash.py +0 -39
- flyte/_protos/common/authorization_pb2.py +0 -66
- flyte/_protos/common/authorization_pb2.pyi +0 -108
- flyte/_protos/common/authorization_pb2_grpc.py +0 -4
- flyte/_protos/common/identifier_pb2.py +0 -71
- flyte/_protos/common/identifier_pb2.pyi +0 -82
- flyte/_protos/common/identifier_pb2_grpc.py +0 -4
- flyte/_protos/common/identity_pb2.py +0 -48
- flyte/_protos/common/identity_pb2.pyi +0 -72
- flyte/_protos/common/identity_pb2_grpc.py +0 -4
- flyte/_protos/common/list_pb2.py +0 -36
- flyte/_protos/common/list_pb2.pyi +0 -69
- flyte/_protos/common/list_pb2_grpc.py +0 -4
- flyte/_protos/common/policy_pb2.py +0 -37
- flyte/_protos/common/policy_pb2.pyi +0 -27
- flyte/_protos/common/policy_pb2_grpc.py +0 -4
- flyte/_protos/common/role_pb2.py +0 -37
- flyte/_protos/common/role_pb2.pyi +0 -53
- flyte/_protos/common/role_pb2_grpc.py +0 -4
- flyte/_protos/common/runtime_version_pb2.py +0 -28
- flyte/_protos/common/runtime_version_pb2.pyi +0 -24
- flyte/_protos/common/runtime_version_pb2_grpc.py +0 -4
- flyte/_protos/logs/dataplane/payload_pb2.py +0 -96
- flyte/_protos/logs/dataplane/payload_pb2.pyi +0 -168
- flyte/_protos/logs/dataplane/payload_pb2_grpc.py +0 -4
- flyte/_protos/secret/definition_pb2.py +0 -49
- flyte/_protos/secret/definition_pb2.pyi +0 -93
- flyte/_protos/secret/definition_pb2_grpc.py +0 -4
- flyte/_protos/secret/payload_pb2.py +0 -62
- flyte/_protos/secret/payload_pb2.pyi +0 -94
- flyte/_protos/secret/payload_pb2_grpc.py +0 -4
- flyte/_protos/secret/secret_pb2.py +0 -38
- flyte/_protos/secret/secret_pb2.pyi +0 -6
- flyte/_protos/secret/secret_pb2_grpc.py +0 -198
- flyte/_protos/secret/secret_pb2_grpc_grpc.py +0 -198
- flyte/_protos/validate/validate/validate_pb2.py +0 -76
- flyte/_protos/workflow/node_execution_service_pb2.py +0 -26
- flyte/_protos/workflow/node_execution_service_pb2.pyi +0 -4
- flyte/_protos/workflow/node_execution_service_pb2_grpc.py +0 -32
- flyte/_protos/workflow/queue_service_pb2.py +0 -106
- flyte/_protos/workflow/queue_service_pb2.pyi +0 -141
- flyte/_protos/workflow/queue_service_pb2_grpc.py +0 -172
- flyte/_protos/workflow/run_definition_pb2.py +0 -128
- flyte/_protos/workflow/run_definition_pb2.pyi +0 -310
- flyte/_protos/workflow/run_definition_pb2_grpc.py +0 -4
- flyte/_protos/workflow/run_logs_service_pb2.py +0 -41
- flyte/_protos/workflow/run_logs_service_pb2.pyi +0 -28
- flyte/_protos/workflow/run_logs_service_pb2_grpc.py +0 -69
- flyte/_protos/workflow/run_service_pb2.py +0 -133
- flyte/_protos/workflow/run_service_pb2.pyi +0 -175
- flyte/_protos/workflow/run_service_pb2_grpc.py +0 -412
- flyte/_protos/workflow/state_service_pb2.py +0 -58
- flyte/_protos/workflow/state_service_pb2.pyi +0 -71
- flyte/_protos/workflow/state_service_pb2_grpc.py +0 -138
- flyte/_protos/workflow/task_definition_pb2.py +0 -72
- flyte/_protos/workflow/task_definition_pb2.pyi +0 -65
- flyte/_protos/workflow/task_definition_pb2_grpc.py +0 -4
- flyte/_protos/workflow/task_service_pb2.py +0 -44
- flyte/_protos/workflow/task_service_pb2.pyi +0 -31
- flyte/_protos/workflow/task_service_pb2_grpc.py +0 -104
- flyte/io/_dataframe.py +0 -0
- flyte/io/pickle/__init__.py +0 -0
- flyte/remote/_console.py +0 -18
- flyte-0.0.1b0.dist-info/METADATA +0 -179
- flyte-0.0.1b0.dist-info/RECORD +0 -390
- flyte-0.0.1b0.dist-info/entry_points.txt +0 -3
- union/__init__.py +0 -54
- union/_api_commons.py +0 -3
- union/_bin/__init__.py +0 -0
- union/_bin/runtime.py +0 -113
- union/_build.py +0 -25
- union/_cache/__init__.py +0 -12
- union/_cache/cache.py +0 -141
- union/_cache/defaults.py +0 -9
- union/_cache/policy_function_body.py +0 -42
- union/_cli/__init__.py +0 -0
- union/_cli/_common.py +0 -263
- union/_cli/_create.py +0 -40
- union/_cli/_delete.py +0 -23
- union/_cli/_deploy.py +0 -120
- union/_cli/_get.py +0 -162
- union/_cli/_run.py +0 -150
- union/_cli/main.py +0 -72
- union/_code_bundle/__init__.py +0 -8
- union/_code_bundle/_ignore.py +0 -113
- union/_code_bundle/_packaging.py +0 -187
- union/_code_bundle/_utils.py +0 -342
- union/_code_bundle/bundle.py +0 -176
- union/_context.py +0 -146
- union/_datastructures.py +0 -295
- union/_deploy.py +0 -185
- union/_doc.py +0 -29
- union/_docstring.py +0 -26
- union/_environment.py +0 -43
- union/_group.py +0 -31
- union/_hash.py +0 -23
- union/_image.py +0 -760
- union/_initialize.py +0 -585
- union/_interface.py +0 -84
- union/_internal/__init__.py +0 -3
- union/_internal/controllers/__init__.py +0 -77
- union/_internal/controllers/_local_controller.py +0 -77
- union/_internal/controllers/pbhash.py +0 -39
- union/_internal/controllers/remote/__init__.py +0 -40
- union/_internal/controllers/remote/_action.py +0 -131
- union/_internal/controllers/remote/_client.py +0 -43
- union/_internal/controllers/remote/_controller.py +0 -169
- union/_internal/controllers/remote/_core.py +0 -341
- union/_internal/controllers/remote/_informer.py +0 -260
- union/_internal/controllers/remote/_service_protocol.py +0 -44
- union/_internal/imagebuild/__init__.py +0 -11
- union/_internal/imagebuild/docker_builder.py +0 -416
- union/_internal/imagebuild/image_builder.py +0 -243
- union/_internal/imagebuild/remote_builder.py +0 -0
- union/_internal/resolvers/__init__.py +0 -0
- union/_internal/resolvers/_task_module.py +0 -31
- union/_internal/resolvers/common.py +0 -24
- union/_internal/resolvers/default.py +0 -27
- union/_internal/runtime/__init__.py +0 -0
- union/_internal/runtime/convert.py +0 -163
- union/_internal/runtime/entrypoints.py +0 -121
- union/_internal/runtime/io.py +0 -136
- union/_internal/runtime/resources_serde.py +0 -134
- union/_internal/runtime/task_serde.py +0 -202
- union/_internal/runtime/taskrunner.py +0 -179
- union/_internal/runtime/types_serde.py +0 -53
- union/_logging.py +0 -124
- union/_protos/__init__.py +0 -0
- union/_protos/common/authorization_pb2.py +0 -66
- union/_protos/common/authorization_pb2.pyi +0 -106
- union/_protos/common/authorization_pb2_grpc.py +0 -4
- union/_protos/common/identifier_pb2.py +0 -71
- union/_protos/common/identifier_pb2.pyi +0 -82
- union/_protos/common/identifier_pb2_grpc.py +0 -4
- union/_protos/common/identity_pb2.py +0 -48
- union/_protos/common/identity_pb2.pyi +0 -72
- union/_protos/common/identity_pb2_grpc.py +0 -4
- union/_protos/common/list_pb2.py +0 -36
- union/_protos/common/list_pb2.pyi +0 -69
- union/_protos/common/list_pb2_grpc.py +0 -4
- union/_protos/common/policy_pb2.py +0 -37
- union/_protos/common/policy_pb2.pyi +0 -27
- union/_protos/common/policy_pb2_grpc.py +0 -4
- union/_protos/common/role_pb2.py +0 -37
- union/_protos/common/role_pb2.pyi +0 -51
- union/_protos/common/role_pb2_grpc.py +0 -4
- union/_protos/common/runtime_version_pb2.py +0 -28
- union/_protos/common/runtime_version_pb2.pyi +0 -24
- union/_protos/common/runtime_version_pb2_grpc.py +0 -4
- union/_protos/logs/dataplane/payload_pb2.py +0 -96
- union/_protos/logs/dataplane/payload_pb2.pyi +0 -168
- union/_protos/logs/dataplane/payload_pb2_grpc.py +0 -4
- union/_protos/secret/definition_pb2.py +0 -49
- union/_protos/secret/definition_pb2.pyi +0 -93
- union/_protos/secret/definition_pb2_grpc.py +0 -4
- union/_protos/secret/payload_pb2.py +0 -62
- union/_protos/secret/payload_pb2.pyi +0 -94
- union/_protos/secret/payload_pb2_grpc.py +0 -4
- union/_protos/secret/secret_pb2.py +0 -38
- union/_protos/secret/secret_pb2.pyi +0 -6
- union/_protos/secret/secret_pb2_grpc.py +0 -198
- union/_protos/validate/validate/validate_pb2.py +0 -76
- union/_protos/workflow/node_execution_service_pb2.py +0 -26
- union/_protos/workflow/node_execution_service_pb2.pyi +0 -4
- union/_protos/workflow/node_execution_service_pb2_grpc.py +0 -32
- union/_protos/workflow/queue_service_pb2.py +0 -75
- union/_protos/workflow/queue_service_pb2.pyi +0 -103
- union/_protos/workflow/queue_service_pb2_grpc.py +0 -172
- union/_protos/workflow/run_definition_pb2.py +0 -100
- union/_protos/workflow/run_definition_pb2.pyi +0 -256
- union/_protos/workflow/run_definition_pb2_grpc.py +0 -4
- union/_protos/workflow/run_logs_service_pb2.py +0 -41
- union/_protos/workflow/run_logs_service_pb2.pyi +0 -28
- union/_protos/workflow/run_logs_service_pb2_grpc.py +0 -69
- union/_protos/workflow/run_service_pb2.py +0 -133
- union/_protos/workflow/run_service_pb2.pyi +0 -173
- union/_protos/workflow/run_service_pb2_grpc.py +0 -412
- union/_protos/workflow/state_service_pb2.py +0 -58
- union/_protos/workflow/state_service_pb2.pyi +0 -69
- union/_protos/workflow/state_service_pb2_grpc.py +0 -138
- union/_protos/workflow/task_definition_pb2.py +0 -72
- union/_protos/workflow/task_definition_pb2.pyi +0 -65
- union/_protos/workflow/task_definition_pb2_grpc.py +0 -4
- union/_protos/workflow/task_service_pb2.py +0 -44
- union/_protos/workflow/task_service_pb2.pyi +0 -31
- union/_protos/workflow/task_service_pb2_grpc.py +0 -104
- union/_resources.py +0 -226
- union/_retry.py +0 -32
- union/_reusable_environment.py +0 -25
- union/_run.py +0 -374
- union/_secret.py +0 -61
- union/_task.py +0 -354
- union/_task_environment.py +0 -186
- union/_timeout.py +0 -47
- union/_tools.py +0 -27
- union/_utils/__init__.py +0 -11
- union/_utils/asyn.py +0 -119
- union/_utils/file_handling.py +0 -71
- union/_utils/helpers.py +0 -46
- union/_utils/lazy_module.py +0 -54
- union/_utils/uv_script_parser.py +0 -49
- union/_version.py +0 -21
- union/connectors/__init__.py +0 -0
- union/errors.py +0 -128
- union/extras/__init__.py +0 -5
- union/extras/_container.py +0 -263
- union/io/__init__.py +0 -11
- union/io/_dataframe.py +0 -0
- union/io/_dir.py +0 -425
- union/io/_file.py +0 -418
- union/io/pickle/__init__.py +0 -0
- union/io/pickle/transformer.py +0 -117
- union/io/structured_dataset/__init__.py +0 -122
- union/io/structured_dataset/basic_dfs.py +0 -219
- union/io/structured_dataset/structured_dataset.py +0 -1057
- union/py.typed +0 -0
- union/remote/__init__.py +0 -23
- union/remote/_client/__init__.py +0 -0
- union/remote/_client/_protocols.py +0 -129
- union/remote/_client/auth/__init__.py +0 -12
- union/remote/_client/auth/_authenticators/__init__.py +0 -0
- union/remote/_client/auth/_authenticators/base.py +0 -391
- union/remote/_client/auth/_authenticators/client_credentials.py +0 -73
- union/remote/_client/auth/_authenticators/device_code.py +0 -120
- union/remote/_client/auth/_authenticators/external_command.py +0 -77
- union/remote/_client/auth/_authenticators/factory.py +0 -200
- union/remote/_client/auth/_authenticators/pkce.py +0 -515
- union/remote/_client/auth/_channel.py +0 -184
- union/remote/_client/auth/_client_config.py +0 -83
- union/remote/_client/auth/_default_html.py +0 -32
- union/remote/_client/auth/_grpc_utils/__init__.py +0 -0
- union/remote/_client/auth/_grpc_utils/auth_interceptor.py +0 -204
- union/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +0 -144
- union/remote/_client/auth/_keyring.py +0 -154
- union/remote/_client/auth/_token_client.py +0 -258
- union/remote/_client/auth/errors.py +0 -16
- union/remote/_client/controlplane.py +0 -86
- union/remote/_data.py +0 -149
- union/remote/_logs.py +0 -74
- union/remote/_project.py +0 -86
- union/remote/_run.py +0 -820
- union/remote/_secret.py +0 -132
- union/remote/_task.py +0 -193
- union/report/__init__.py +0 -3
- union/report/_report.py +0 -178
- union/report/_template.html +0 -124
- union/storage/__init__.py +0 -24
- union/storage/_remote_fs.py +0 -34
- union/storage/_storage.py +0 -247
- union/storage/_utils.py +0 -5
- union/types/__init__.py +0 -11
- union/types/_renderer.py +0 -162
- union/types/_string_literals.py +0 -120
- union/types/_type_engine.py +0 -2131
- union/types/_utils.py +0 -80
- /flyte/{_cli → _debug}/__init__.py +0 -0
- /flyte/{_protos → _keyring}/__init__.py +0 -0
- {flyte-0.0.1b0.dist-info → flyte-2.0.0b46.dist-info}/WHEEL +0 -0
- {flyte-0.0.1b0.dist-info → flyte-2.0.0b46.dist-info}/top_level.txt +0 -0
flyte/_internal/runtime/io.py
CHANGED
|
@@ -5,14 +5,13 @@ It uses the storage module to handle the actual uploading and downloading of fil
|
|
|
5
5
|
TODO: Convert to use streaming apis
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
from flyteidl.core import errors_pb2, execution_pb2
|
|
8
|
+
from flyteidl2.core import errors_pb2, execution_pb2
|
|
9
|
+
from flyteidl2.task import common_pb2
|
|
11
10
|
|
|
12
11
|
import flyte.storage as storage
|
|
13
|
-
from flyte.
|
|
12
|
+
from flyte._logging import logger
|
|
13
|
+
from flyte.models import PathRewrite
|
|
14
14
|
|
|
15
|
-
from ..._logging import log
|
|
16
15
|
from .convert import Inputs, Outputs, _clean_error_code
|
|
17
16
|
|
|
18
17
|
# ------------------------------- CONSTANTS ------------------------------- #
|
|
@@ -21,11 +20,11 @@ _OUTPUTS_FILE_NAME = "outputs.pb"
|
|
|
21
20
|
_CHECKPOINT_FILE_NAME = "_flytecheckpoints"
|
|
22
21
|
_ERROR_FILE_NAME = "error.pb"
|
|
23
22
|
_REPORT_FILE_NAME = "report.html"
|
|
24
|
-
|
|
23
|
+
_PKL_EXT = ".pkl.gz"
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
def pkl_path(base_path: str) -> str:
|
|
28
|
-
return storage.join(base_path,
|
|
26
|
+
def pkl_path(base_path: str, pkl_name: str) -> str:
|
|
27
|
+
return storage.join(base_path, f"{pkl_name}{_PKL_EXT}")
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
def inputs_path(base_path: str) -> str:
|
|
@@ -55,16 +54,25 @@ async def upload_inputs(inputs: Inputs, input_path: str):
|
|
|
55
54
|
await storage.put_stream(data_iterable=inputs.proto_inputs.SerializeToString(), to_path=input_path)
|
|
56
55
|
|
|
57
56
|
|
|
58
|
-
async def upload_outputs(outputs: Outputs, output_path: str):
|
|
57
|
+
async def upload_outputs(outputs: Outputs, output_path: str, max_bytes: int = -1):
|
|
59
58
|
"""
|
|
60
59
|
:param outputs: Outputs
|
|
61
60
|
:param output_path: The path to upload the output file.
|
|
61
|
+
:param max_bytes: Maximum number of bytes to write to the output file. Default is -1, which means no limit.
|
|
62
62
|
"""
|
|
63
|
+
if max_bytes != -1 and outputs.proto_outputs.ByteSize() > max_bytes:
|
|
64
|
+
import flyte.errors
|
|
65
|
+
|
|
66
|
+
raise flyte.errors.InlineIOMaxBytesBreached(
|
|
67
|
+
f"Output file at {output_path} exceeds max_bytes limit of {max_bytes},"
|
|
68
|
+
f" size: {outputs.proto_outputs.ByteSize()}"
|
|
69
|
+
)
|
|
63
70
|
output_uri = outputs_path(output_path)
|
|
64
71
|
await storage.put_stream(data_iterable=outputs.proto_outputs.SerializeToString(), to_path=output_uri)
|
|
72
|
+
logger.debug(f"Uploaded {output_uri} to {output_path}")
|
|
65
73
|
|
|
66
74
|
|
|
67
|
-
async def upload_error(err: execution_pb2.ExecutionError, output_prefix: str):
|
|
75
|
+
async def upload_error(err: execution_pb2.ExecutionError, output_prefix: str) -> str:
|
|
68
76
|
"""
|
|
69
77
|
:param err: execution_pb2.ExecutionError
|
|
70
78
|
:param output_prefix: The output prefix of the remote uri.
|
|
@@ -76,34 +84,76 @@ async def upload_error(err: execution_pb2.ExecutionError, output_prefix: str):
|
|
|
76
84
|
message=err.message,
|
|
77
85
|
kind=errors_pb2.ContainerError.RECOVERABLE,
|
|
78
86
|
origin=err.kind,
|
|
79
|
-
timestamp=err.timestamp,
|
|
80
|
-
worker=err.worker,
|
|
81
87
|
)
|
|
82
88
|
)
|
|
83
89
|
error_uri = error_path(output_prefix)
|
|
84
|
-
await storage.put_stream(data_iterable=error_document.SerializeToString(), to_path=error_uri)
|
|
90
|
+
return await storage.put_stream(data_iterable=error_document.SerializeToString(), to_path=error_uri)
|
|
85
91
|
|
|
86
92
|
|
|
87
93
|
# ------------------------------- DOWNLOAD Methods ------------------------------- #
|
|
88
|
-
|
|
89
|
-
async def load_inputs(path: str) -> Inputs:
|
|
94
|
+
async def load_inputs(path: str, max_bytes: int = -1, path_rewrite_config: PathRewrite | None = None) -> Inputs:
|
|
90
95
|
"""
|
|
91
96
|
:param path: Input file to be downloaded
|
|
97
|
+
:param max_bytes: Maximum number of bytes to read from the input file. Default is -1, which means no limit.
|
|
98
|
+
:param path_rewrite_config: If provided, rewrites paths in the input blobs according to the configuration.
|
|
92
99
|
:return: Inputs object
|
|
93
100
|
"""
|
|
94
|
-
lm =
|
|
95
|
-
|
|
101
|
+
lm = common_pb2.Inputs()
|
|
102
|
+
if max_bytes == -1:
|
|
103
|
+
proto_str = b"".join([c async for c in storage.get_stream(path=path)])
|
|
104
|
+
else:
|
|
105
|
+
proto_bytes = []
|
|
106
|
+
total_bytes = 0
|
|
107
|
+
async for chunk in storage.get_stream(path=path):
|
|
108
|
+
if total_bytes + len(chunk) > max_bytes:
|
|
109
|
+
import flyte.errors
|
|
110
|
+
|
|
111
|
+
raise flyte.errors.InlineIOMaxBytesBreached(
|
|
112
|
+
f"Input file at {path} exceeds max_bytes limit of {max_bytes}"
|
|
113
|
+
)
|
|
114
|
+
proto_bytes.append(chunk)
|
|
115
|
+
total_bytes += len(chunk)
|
|
116
|
+
proto_str = b"".join(proto_bytes)
|
|
117
|
+
|
|
96
118
|
lm.ParseFromString(proto_str)
|
|
119
|
+
|
|
120
|
+
if path_rewrite_config is not None:
|
|
121
|
+
for inp in lm.literals:
|
|
122
|
+
if inp.value.HasField("scalar") and inp.value.scalar.HasField("blob"):
|
|
123
|
+
scalar_blob = inp.value.scalar.blob
|
|
124
|
+
if scalar_blob.uri.startswith(path_rewrite_config.old_prefix):
|
|
125
|
+
scalar_blob.uri = scalar_blob.uri.replace(
|
|
126
|
+
path_rewrite_config.old_prefix, path_rewrite_config.new_prefix, 1
|
|
127
|
+
)
|
|
128
|
+
|
|
97
129
|
return Inputs(proto_inputs=lm)
|
|
98
130
|
|
|
99
131
|
|
|
100
|
-
async def load_outputs(path: str) -> Outputs:
|
|
132
|
+
async def load_outputs(path: str, max_bytes: int = -1) -> Outputs:
|
|
101
133
|
"""
|
|
102
134
|
:param path: output file to be loaded
|
|
135
|
+
:param max_bytes: Maximum number of bytes to read from the output file.
|
|
136
|
+
If -1, reads the entire file.
|
|
103
137
|
:return: Outputs object
|
|
104
138
|
"""
|
|
105
|
-
lm =
|
|
106
|
-
|
|
139
|
+
lm = common_pb2.Outputs()
|
|
140
|
+
|
|
141
|
+
if max_bytes == -1:
|
|
142
|
+
proto_str = b"".join([c async for c in storage.get_stream(path=path)])
|
|
143
|
+
else:
|
|
144
|
+
proto_bytes = []
|
|
145
|
+
total_bytes = 0
|
|
146
|
+
async for chunk in storage.get_stream(path=path):
|
|
147
|
+
if total_bytes + len(chunk) > max_bytes:
|
|
148
|
+
import flyte.errors
|
|
149
|
+
|
|
150
|
+
raise flyte.errors.InlineIOMaxBytesBreached(
|
|
151
|
+
f"Output file at {path} exceeds max_bytes limit of {max_bytes}"
|
|
152
|
+
)
|
|
153
|
+
proto_bytes.append(chunk)
|
|
154
|
+
total_bytes += len(chunk)
|
|
155
|
+
proto_str = b"".join(proto_bytes)
|
|
156
|
+
|
|
107
157
|
lm.ParseFromString(proto_str)
|
|
108
158
|
return Outputs(proto_outputs=lm)
|
|
109
159
|
|
|
@@ -118,14 +168,12 @@ async def load_error(path: str) -> execution_pb2.ExecutionError:
|
|
|
118
168
|
err.ParseFromString(proto_str)
|
|
119
169
|
|
|
120
170
|
if err.error is not None:
|
|
121
|
-
user_code,
|
|
171
|
+
user_code, _server_code = _clean_error_code(err.error.code)
|
|
122
172
|
return execution_pb2.ExecutionError(
|
|
123
173
|
code=user_code,
|
|
124
174
|
message=err.error.message,
|
|
125
175
|
kind=err.error.origin,
|
|
126
176
|
error_uri=path,
|
|
127
|
-
timestamp=err.error.timestamp,
|
|
128
|
-
worker=err.error.worker,
|
|
129
177
|
)
|
|
130
178
|
|
|
131
179
|
return execution_pb2.ExecutionError(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from typing import List, Optional, Tuple
|
|
1
|
+
from typing import Dict, List, Optional, Tuple
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from flyteidl2.core import tasks_pb2
|
|
4
4
|
|
|
5
|
-
from flyte._resources import CPUBaseType, Resources
|
|
5
|
+
from flyte._resources import CPUBaseType, DeviceClass, Resources
|
|
6
6
|
|
|
7
7
|
ACCELERATOR_DEVICE_MAP = {
|
|
8
8
|
"A100": "nvidia-tesla-a100",
|
|
@@ -11,7 +11,7 @@ ACCELERATOR_DEVICE_MAP = {
|
|
|
11
11
|
"A10G": "nvidia-a10g",
|
|
12
12
|
"A100G": "nvidia-a100g",
|
|
13
13
|
"L4": "nvidia-l4",
|
|
14
|
-
"L40s": "nvidia-
|
|
14
|
+
"L40s": "nvidia-l40s",
|
|
15
15
|
"L4_VWS": "nvidia-l4-vws",
|
|
16
16
|
"K80": "nvidia-tesla-k80",
|
|
17
17
|
"M60": "nvidia-tesla-m60",
|
|
@@ -24,6 +24,14 @@ ACCELERATOR_DEVICE_MAP = {
|
|
|
24
24
|
"V6E": "tpu-v6e-slice",
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
_DeviceClassToProto: Dict[DeviceClass, "tasks_pb2.GPUAccelerator.DeviceClass"] = {
|
|
28
|
+
"GPU": tasks_pb2.GPUAccelerator.NVIDIA_GPU,
|
|
29
|
+
"TPU": tasks_pb2.GPUAccelerator.GOOGLE_TPU,
|
|
30
|
+
"NEURON": tasks_pb2.GPUAccelerator.AMAZON_NEURON,
|
|
31
|
+
"AMD_GPU": tasks_pb2.GPUAccelerator.AMD_GPU,
|
|
32
|
+
"HABANA_GAUDI": tasks_pb2.GPUAccelerator.HABANA_GAUDI,
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
|
|
28
36
|
def _get_cpu_resource_entry(cpu: CPUBaseType) -> tasks_pb2.Resources.ResourceEntry:
|
|
29
37
|
return tasks_pb2.Resources.ResourceEntry(
|
|
@@ -54,11 +62,17 @@ def _get_gpu_extended_resource_entry(resources: Resources) -> Optional[tasks_pb2
|
|
|
54
62
|
device = resources.get_device()
|
|
55
63
|
if device is None:
|
|
56
64
|
return None
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
|
|
66
|
+
device_class = _DeviceClassToProto.get(device.device_class, tasks_pb2.GPUAccelerator.NVIDIA_GPU)
|
|
67
|
+
if device.device is None:
|
|
68
|
+
raise RuntimeError("Device type must be specified for GPU string.")
|
|
69
|
+
else:
|
|
70
|
+
device_type = device.device
|
|
71
|
+
device_type = ACCELERATOR_DEVICE_MAP.get(device_type, device_type)
|
|
59
72
|
return tasks_pb2.GPUAccelerator(
|
|
60
|
-
device=
|
|
73
|
+
device=device_type,
|
|
61
74
|
partition_size=device.partition if device.partition else None,
|
|
75
|
+
device_class=device_class,
|
|
62
76
|
)
|
|
63
77
|
|
|
64
78
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import typing
|
|
3
|
+
from venv import logger
|
|
4
|
+
|
|
5
|
+
from flyteidl2.core import tasks_pb2
|
|
6
|
+
|
|
7
|
+
import flyte.errors
|
|
8
|
+
from flyte import ReusePolicy
|
|
9
|
+
from flyte._pod import _PRIMARY_CONTAINER_DEFAULT_NAME, _PRIMARY_CONTAINER_NAME_FIELD
|
|
10
|
+
from flyte.models import CodeBundle
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def extract_unique_id_and_image(
|
|
14
|
+
env_name: str,
|
|
15
|
+
code_bundle: CodeBundle | None,
|
|
16
|
+
task: tasks_pb2.TaskTemplate,
|
|
17
|
+
reuse_policy: ReusePolicy,
|
|
18
|
+
) -> typing.Tuple[str, str]:
|
|
19
|
+
"""
|
|
20
|
+
Compute a unique ID for the task based on its name, version, image URI, and code bundle.
|
|
21
|
+
:param env_name: Name of the reusable environment.
|
|
22
|
+
:param reuse_policy: The reuse policy for the task.
|
|
23
|
+
:param task: The task template.
|
|
24
|
+
:param code_bundle: The code bundle associated with the task.
|
|
25
|
+
:return: A unique ID string and the image URI.
|
|
26
|
+
"""
|
|
27
|
+
image = ""
|
|
28
|
+
container_ser = ""
|
|
29
|
+
if task.HasField("container"):
|
|
30
|
+
copied_container = tasks_pb2.Container()
|
|
31
|
+
copied_container.CopyFrom(task.container)
|
|
32
|
+
copied_container.args.clear() # Clear args to ensure deterministic serialization
|
|
33
|
+
container_ser = copied_container.SerializeToString(deterministic=True)
|
|
34
|
+
image = copied_container.image
|
|
35
|
+
|
|
36
|
+
if task.HasField("k8s_pod"):
|
|
37
|
+
# Clear args to ensure deterministic serialization
|
|
38
|
+
copied_k8s_pod = tasks_pb2.K8sPod()
|
|
39
|
+
copied_k8s_pod.CopyFrom(task.k8s_pod)
|
|
40
|
+
if task.config is not None:
|
|
41
|
+
primary_container_name = task.config[_PRIMARY_CONTAINER_NAME_FIELD]
|
|
42
|
+
else:
|
|
43
|
+
primary_container_name = _PRIMARY_CONTAINER_DEFAULT_NAME
|
|
44
|
+
for container in copied_k8s_pod.pod_spec["containers"]:
|
|
45
|
+
if "name" in container and container["name"] == primary_container_name:
|
|
46
|
+
image = container["image"]
|
|
47
|
+
del container["args"]
|
|
48
|
+
container_ser = copied_k8s_pod.SerializeToString(deterministic=True)
|
|
49
|
+
|
|
50
|
+
components = f"{env_name}:{container_ser}"
|
|
51
|
+
if isinstance(reuse_policy.replicas, tuple):
|
|
52
|
+
components += f":{reuse_policy.replicas[0]}:{reuse_policy.replicas[1]}"
|
|
53
|
+
else:
|
|
54
|
+
components += f":{reuse_policy.replicas}"
|
|
55
|
+
if reuse_policy.idle_ttl:
|
|
56
|
+
components += f":{reuse_policy.idle_ttl.total_seconds()}" # type: ignore [union-attr]
|
|
57
|
+
if reuse_policy.get_scaledown_ttl() is not None:
|
|
58
|
+
components += f":{reuse_policy.get_scaledown_ttl()}"
|
|
59
|
+
if code_bundle is not None:
|
|
60
|
+
components += f":{code_bundle.computed_version}"
|
|
61
|
+
if task.security_context is not None:
|
|
62
|
+
security_ctx_str = task.security_context.SerializeToString(deterministic=True)
|
|
63
|
+
components += f":{security_ctx_str}"
|
|
64
|
+
if task.metadata.interruptible is not None:
|
|
65
|
+
components += f":{task.metadata.interruptible}"
|
|
66
|
+
if task.metadata.pod_template_name is not None:
|
|
67
|
+
components += f":{task.metadata.pod_template_name}"
|
|
68
|
+
sha256 = hashlib.sha256()
|
|
69
|
+
sha256.update(components.encode("utf-8"))
|
|
70
|
+
return sha256.hexdigest(), image
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def add_reusable(
|
|
74
|
+
task: tasks_pb2.TaskTemplate,
|
|
75
|
+
reuse_policy: ReusePolicy,
|
|
76
|
+
code_bundle: CodeBundle | None,
|
|
77
|
+
parent_env_name: str | None = None,
|
|
78
|
+
) -> tasks_pb2.TaskTemplate:
|
|
79
|
+
"""
|
|
80
|
+
Convert a ReusePolicy to a custom configuration dictionary.
|
|
81
|
+
|
|
82
|
+
:param task: The task to which the reusable policy will be added.
|
|
83
|
+
:param reuse_policy: The reuse policy to apply.
|
|
84
|
+
:param code_bundle: The code bundle associated with the task.
|
|
85
|
+
:param parent_env_name: The name of the parent environment, if any.
|
|
86
|
+
:return: The modified task with the reusable policy added.
|
|
87
|
+
"""
|
|
88
|
+
if reuse_policy is None:
|
|
89
|
+
return task
|
|
90
|
+
|
|
91
|
+
if task.HasField("custom"):
|
|
92
|
+
raise flyte.errors.RuntimeUserError(
|
|
93
|
+
"BadConfiguration", "Plugins do not support reusable policy. Only container tasks and pods."
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
logger.debug(f"Adding reusable policy for task: {task.id.name}")
|
|
97
|
+
name = parent_env_name if parent_env_name else ""
|
|
98
|
+
if parent_env_name is None:
|
|
99
|
+
name = task.id.name.split(".")[0]
|
|
100
|
+
|
|
101
|
+
version, image_uri = extract_unique_id_and_image(
|
|
102
|
+
env_name=name, code_bundle=code_bundle, task=task, reuse_policy=reuse_policy
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
scaledown_ttl = reuse_policy.get_scaledown_ttl()
|
|
106
|
+
|
|
107
|
+
task.custom = {
|
|
108
|
+
"name": name,
|
|
109
|
+
"version": version[:15], # Use only the first 15 characters for the version
|
|
110
|
+
"type": "actor",
|
|
111
|
+
"spec": {
|
|
112
|
+
"container_image": image_uri,
|
|
113
|
+
"backlog_length": None,
|
|
114
|
+
"parallelism": reuse_policy.concurrency,
|
|
115
|
+
"min_replica_count": reuse_policy.min_replicas,
|
|
116
|
+
"replica_count": reuse_policy.max_replicas,
|
|
117
|
+
"ttl_seconds": reuse_policy.idle_ttl.total_seconds() if reuse_policy.idle_ttl else None, # type: ignore [union-attr]
|
|
118
|
+
"scaledown_ttl_seconds": scaledown_ttl.total_seconds() if scaledown_ttl else None,
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
task.type = "actor"
|
|
123
|
+
logger.info(f"Reusable task {task.id.name} with config {task.custom}")
|
|
124
|
+
|
|
125
|
+
return task
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Tuple
|
|
4
|
+
|
|
5
|
+
from flyte._context import contextual_run
|
|
6
|
+
from flyte._internal.controllers import Controller
|
|
7
|
+
from flyte._internal.controllers import create_controller as _create_controller
|
|
8
|
+
from flyte._internal.imagebuild.image_builder import ImageCache
|
|
9
|
+
from flyte._internal.runtime.entrypoints import download_code_bundle, load_pkl_task, load_task
|
|
10
|
+
from flyte._internal.runtime.taskrunner import extract_download_run_upload
|
|
11
|
+
from flyte._logging import logger
|
|
12
|
+
from flyte._task import TaskTemplate
|
|
13
|
+
from flyte._utils import adjust_sys_path
|
|
14
|
+
from flyte.models import ActionID, Checkpoints, CodeBundle, PathRewrite, RawDataPath
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async def download_tgz(destination: str, version: str, tgz: str) -> CodeBundle:
|
|
18
|
+
"""
|
|
19
|
+
Downloads and loads the task from the code bundle or resolver.
|
|
20
|
+
:param tgz: The path to the task template in a tar.gz format.
|
|
21
|
+
:param destination: The path to save the downloaded task template.
|
|
22
|
+
:param version: The version of the task to load.
|
|
23
|
+
:return: The CodeBundle object.
|
|
24
|
+
"""
|
|
25
|
+
logger.info(f"[rusty] Downloading tgz code bundle from {tgz} to {destination} with version {version}")
|
|
26
|
+
adjust_sys_path()
|
|
27
|
+
|
|
28
|
+
code_bundle = CodeBundle(
|
|
29
|
+
tgz=tgz,
|
|
30
|
+
destination=destination,
|
|
31
|
+
computed_version=version,
|
|
32
|
+
)
|
|
33
|
+
return await download_code_bundle(code_bundle)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
async def download_load_pkl(destination: str, version: str, pkl: str) -> Tuple[CodeBundle, TaskTemplate]:
|
|
37
|
+
"""
|
|
38
|
+
Downloads and loads the task from the code bundle or resolver.
|
|
39
|
+
:param pkl: The path to the task template in a pickle format.
|
|
40
|
+
:param destination: The path to save the downloaded task template.
|
|
41
|
+
:param version: The version of the task to load.
|
|
42
|
+
:return: The CodeBundle object.
|
|
43
|
+
"""
|
|
44
|
+
logger.info(f"[rusty] Downloading pkl code bundle from {pkl} to {destination} with version {version}")
|
|
45
|
+
adjust_sys_path()
|
|
46
|
+
|
|
47
|
+
code_bundle = CodeBundle(
|
|
48
|
+
pkl=pkl,
|
|
49
|
+
destination=destination,
|
|
50
|
+
computed_version=version,
|
|
51
|
+
)
|
|
52
|
+
code_bundle = await download_code_bundle(code_bundle)
|
|
53
|
+
return code_bundle, load_pkl_task(code_bundle)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def load_task_from_code_bundle(resolver: str, resolver_args: List[str]) -> TaskTemplate:
|
|
57
|
+
"""
|
|
58
|
+
Loads the task from the code bundle or resolver.
|
|
59
|
+
:param resolver: The resolver to use to load the task.
|
|
60
|
+
:param resolver_args: The arguments to pass to the resolver.
|
|
61
|
+
:return: The loaded task template.
|
|
62
|
+
"""
|
|
63
|
+
logger.debug(f"[rusty] Loading task from code bundle {resolver} with args: {resolver_args}")
|
|
64
|
+
return load_task(resolver, *resolver_args)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
async def create_controller(
|
|
68
|
+
endpoint: str = "host.docker.internal:8090",
|
|
69
|
+
insecure: bool = False,
|
|
70
|
+
api_key: str | None = None,
|
|
71
|
+
) -> Controller:
|
|
72
|
+
"""
|
|
73
|
+
Creates a controller instance for remote operations.
|
|
74
|
+
:param endpoint:
|
|
75
|
+
:param insecure:
|
|
76
|
+
:param api_key:
|
|
77
|
+
:return:
|
|
78
|
+
"""
|
|
79
|
+
logger.info(f"[rusty] Creating controller with endpoint {endpoint}")
|
|
80
|
+
import flyte.errors
|
|
81
|
+
from flyte._initialize import init_in_cluster
|
|
82
|
+
|
|
83
|
+
loop = asyncio.get_event_loop()
|
|
84
|
+
loop.set_exception_handler(flyte.errors.silence_grpc_polling_error)
|
|
85
|
+
|
|
86
|
+
# TODO Currently remote tasks are not supported in Rusty.
|
|
87
|
+
controller_kwargs = await init_in_cluster.aio(api_key=api_key, endpoint=endpoint, insecure=insecure)
|
|
88
|
+
return _create_controller(ct="remote", **controller_kwargs)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
async def run_task(
|
|
92
|
+
task: TaskTemplate,
|
|
93
|
+
controller: Controller,
|
|
94
|
+
org: str,
|
|
95
|
+
project: str,
|
|
96
|
+
domain: str,
|
|
97
|
+
run_name: str,
|
|
98
|
+
name: str,
|
|
99
|
+
raw_data_path: str,
|
|
100
|
+
output_path: str,
|
|
101
|
+
run_base_dir: str,
|
|
102
|
+
version: str,
|
|
103
|
+
image_cache: str | None = None,
|
|
104
|
+
checkpoint_path: str | None = None,
|
|
105
|
+
prev_checkpoint: str | None = None,
|
|
106
|
+
code_bundle: CodeBundle | None = None,
|
|
107
|
+
input_path: str | None = None,
|
|
108
|
+
path_rewrite_cfg: str | None = None,
|
|
109
|
+
):
|
|
110
|
+
"""
|
|
111
|
+
Runs the task with the provided parameters.
|
|
112
|
+
:param prev_checkpoint: Previous checkpoint path to resume from.
|
|
113
|
+
:param checkpoint_path: Checkpoint path to save the current state.
|
|
114
|
+
:param image_cache: Image cache to use for the task.
|
|
115
|
+
:param name: Action name to run.
|
|
116
|
+
:param run_name: Parent run name to use for the task.
|
|
117
|
+
:param domain: domain to run the task in.
|
|
118
|
+
:param project: project to run the task in.
|
|
119
|
+
:param org: organization to run the task in.
|
|
120
|
+
:param task: The task template to run.
|
|
121
|
+
:param raw_data_path: The path to the raw data.
|
|
122
|
+
:param output_path: The path to save the output.
|
|
123
|
+
:param run_base_dir: The base directory for the run.
|
|
124
|
+
:param version: The version of the task to run.
|
|
125
|
+
:param controller: The controller to use for the task.
|
|
126
|
+
:param code_bundle: Optional code bundle for the task.
|
|
127
|
+
:param input_path: Optional input path for the task.
|
|
128
|
+
:param path_rewrite_cfg: Optional path rewrite configuration.
|
|
129
|
+
:return: The loaded task template.
|
|
130
|
+
"""
|
|
131
|
+
start_time = time.time()
|
|
132
|
+
action_id = f"{org}/{project}/{domain}/{run_name}/{name}"
|
|
133
|
+
|
|
134
|
+
logger.info(
|
|
135
|
+
f"[rusty] Running task '{task.name}' (action: {action_id})"
|
|
136
|
+
f" at {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
path_rewrite = PathRewrite.from_str(path_rewrite_cfg) if path_rewrite_cfg else None
|
|
140
|
+
if path_rewrite:
|
|
141
|
+
import flyte.storage as storage
|
|
142
|
+
|
|
143
|
+
if not await storage.exists(path_rewrite.new_prefix):
|
|
144
|
+
logger.error(
|
|
145
|
+
f"[rusty] Path rewrite failed for path {path_rewrite.new_prefix}, "
|
|
146
|
+
f"not found, reverting to original path {path_rewrite.old_prefix}"
|
|
147
|
+
)
|
|
148
|
+
path_rewrite = None
|
|
149
|
+
else:
|
|
150
|
+
logger.info(f"[rusty] Using path rewrite: {path_rewrite}")
|
|
151
|
+
|
|
152
|
+
try:
|
|
153
|
+
await contextual_run(
|
|
154
|
+
extract_download_run_upload,
|
|
155
|
+
task,
|
|
156
|
+
action=ActionID(name=name, org=org, project=project, domain=domain, run_name=run_name),
|
|
157
|
+
version=version,
|
|
158
|
+
controller=controller,
|
|
159
|
+
raw_data_path=RawDataPath(path=raw_data_path, path_rewrite=path_rewrite),
|
|
160
|
+
output_path=output_path,
|
|
161
|
+
run_base_dir=run_base_dir,
|
|
162
|
+
checkpoints=Checkpoints(prev_checkpoint_path=prev_checkpoint, checkpoint_path=checkpoint_path),
|
|
163
|
+
code_bundle=code_bundle,
|
|
164
|
+
input_path=input_path,
|
|
165
|
+
image_cache=ImageCache.from_transport(image_cache) if image_cache else None,
|
|
166
|
+
)
|
|
167
|
+
except asyncio.CancelledError as e:
|
|
168
|
+
logger.error(f"[rusty] Task cancellation received: {e!s}")
|
|
169
|
+
raise
|
|
170
|
+
except Exception as e:
|
|
171
|
+
logger.error(f"[rusty] Task failed: {e!s}")
|
|
172
|
+
raise
|
|
173
|
+
finally:
|
|
174
|
+
end_time = time.time()
|
|
175
|
+
duration = end_time - start_time
|
|
176
|
+
logger.info(
|
|
177
|
+
f"[rusty] TASK_EXECUTION_END: Task '{task.name}' (action: {action_id})"
|
|
178
|
+
f" done after {duration:.2f}s at {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}"
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
async def ping(name: str) -> str:
|
|
183
|
+
"""
|
|
184
|
+
A simple hello world function to test the Rusty entrypoint.
|
|
185
|
+
"""
|
|
186
|
+
print(f"Received ping request from {name} in Rusty!")
|
|
187
|
+
return f"pong from Rusty to {name}!"
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
async def hello(name: str):
|
|
191
|
+
"""
|
|
192
|
+
A simple hello world function to test the Rusty entrypoint.
|
|
193
|
+
:param name: The name to greet.
|
|
194
|
+
:return: A greeting message.
|
|
195
|
+
"""
|
|
196
|
+
print(f"Received hello request in Rusty with name: {name}!")
|