modal 1.0.6.dev14__tar.gz → 1.0.6.dev16__tar.gz
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 modal might be problematic. Click here for more details.
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/PKG-INFO +1 -1
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_container_entrypoint.py +16 -26
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/container_io_manager.py +40 -27
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/container_io_manager.pyi +13 -11
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/blob_utils.py +15 -3
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/client.pyi +2 -2
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/functions.pyi +6 -6
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal.egg-info/PKG-INFO +1 -1
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_version/__init__.py +1 -1
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/LICENSE +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/README.md +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/__main__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_clustered_functions.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_clustered_functions.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_functions.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_ipython.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_location.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_object.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_output.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_partial_function.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_pty.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_resolver.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_resources.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/asgi.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/execution_context.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/execution_context.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/gpu_memory_snapshot.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/telemetry.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_runtime/user_code_imports.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_serialization.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_traceback.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_tunnel.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_tunnel.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_type_manager.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/app_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/async_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/bytes_io_segment_payload.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/deprecation.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/docker_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/function_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/git_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/grpc_testing.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/grpc_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/hash_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/http_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/jwt_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/logger.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/mount_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/name_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/package_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/pattern_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/rand_pb_testing.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/shell_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_utils/time_utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_vendor/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_vendor/a2wsgi_wsgi.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_vendor/cloudpickle.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_vendor/tblib.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/_watcher.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/app.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/app.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/call_graph.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/_download.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/_traceback.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/app.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/cluster.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/config.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/container.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/dict.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/entry_point.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/environment.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/import_refs.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/launch.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/network_file_system.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/profile.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/programs/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/programs/run_jupyter.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/programs/vscode.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/queues.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/run.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/secret.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/token.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/utils.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cli/volume.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/client.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cloud_bucket_mount.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cloud_bucket_mount.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cls.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/cls.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/config.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/container_process.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/container_process.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/dict.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/dict.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/environments.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/environments.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/exception.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/experimental/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/experimental/ipython.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/file_io.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/file_io.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/file_pattern_matcher.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/functions.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/gpu.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/image.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/image.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/io_streams.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/io_streams.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/mount.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/mount.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/network_file_system.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/network_file_system.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/object.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/object.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/output.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/parallel_map.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/parallel_map.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/partial_function.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/partial_function.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/proxy.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/proxy.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/py.typed +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/queue.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/queue.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/2023.12.312.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/2023.12.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/2024.04.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/2024.10.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/PREVIEW.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/README.md +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/requirements/base-images.json +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/retries.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/runner.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/runner.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/running_app.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/sandbox.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/sandbox.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/schedule.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/scheduler_placement.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/secret.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/secret.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/serving.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/serving.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/snapshot.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/snapshot.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/stream_type.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/token_flow.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/token_flow.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/volume.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal/volume.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal.egg-info/SOURCES.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal.egg-info/dependency_links.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal.egg-info/entry_points.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal.egg-info/requires.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal.egg-info/top_level.txt +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_docs/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_docs/gen_cli_docs.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_docs/gen_reference_docs.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_docs/mdmd/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_docs/mdmd/mdmd.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_docs/mdmd/signatures.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/__init__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/api.proto +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/api_grpc.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/api_pb2.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/api_pb2.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/api_pb2_grpc.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/api_pb2_grpc.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/modal_api_grpc.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/modal_options_grpc.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/options.proto +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/options_grpc.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/options_pb2.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/options_pb2.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/options_pb2_grpc.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/options_pb2_grpc.pyi +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_proto/py.typed +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/modal_version/__main__.py +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/pyproject.toml +0 -0
- {modal-1.0.6.dev14 → modal-1.0.6.dev16}/setup.cfg +0 -0
|
@@ -15,7 +15,6 @@ if telemetry_socket:
|
|
|
15
15
|
instrument_imports(telemetry_socket)
|
|
16
16
|
|
|
17
17
|
import asyncio
|
|
18
|
-
import concurrent.futures
|
|
19
18
|
import inspect
|
|
20
19
|
import queue
|
|
21
20
|
import signal
|
|
@@ -49,7 +48,6 @@ from ._runtime.container_io_manager import (
|
|
|
49
48
|
ContainerIOManager,
|
|
50
49
|
IOContext,
|
|
51
50
|
UserException,
|
|
52
|
-
_ContainerIOManager,
|
|
53
51
|
)
|
|
54
52
|
|
|
55
53
|
if TYPE_CHECKING:
|
|
@@ -198,21 +196,16 @@ def call_function(
|
|
|
198
196
|
|
|
199
197
|
# Send up to this many outputs at a time.
|
|
200
198
|
generator_queue: asyncio.Queue[Any] = await container_io_manager._queue_create.aio(1024)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
async for value in res:
|
|
211
|
-
await container_io_manager._queue_put.aio(generator_queue, value)
|
|
212
|
-
item_count += 1
|
|
199
|
+
async with container_io_manager.generator_output_sender(
|
|
200
|
+
function_call_ids[0],
|
|
201
|
+
io_context.finalized_function.data_format,
|
|
202
|
+
generator_queue,
|
|
203
|
+
):
|
|
204
|
+
item_count = 0
|
|
205
|
+
async for value in res:
|
|
206
|
+
await container_io_manager._queue_put.aio(generator_queue, value)
|
|
207
|
+
item_count += 1
|
|
213
208
|
|
|
214
|
-
await container_io_manager._queue_put.aio(generator_queue, _ContainerIOManager._GENERATOR_STOP_SENTINEL)
|
|
215
|
-
await generator_output_task # Wait to finish sending generator outputs.
|
|
216
209
|
message = api_pb2.GeneratorDone(items_total=item_count)
|
|
217
210
|
await container_io_manager.push_outputs.aio(
|
|
218
211
|
io_context,
|
|
@@ -249,20 +242,17 @@ def call_function(
|
|
|
249
242
|
|
|
250
243
|
# Send up to this many outputs at a time.
|
|
251
244
|
generator_queue: asyncio.Queue[Any] = container_io_manager._queue_create(1024)
|
|
252
|
-
|
|
245
|
+
|
|
246
|
+
with container_io_manager.generator_output_sender(
|
|
253
247
|
function_call_ids[0],
|
|
254
248
|
io_context.finalized_function.data_format,
|
|
255
249
|
generator_queue,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
container_io_manager._queue_put(generator_queue, value)
|
|
262
|
-
item_count += 1
|
|
250
|
+
):
|
|
251
|
+
item_count = 0
|
|
252
|
+
for value in res:
|
|
253
|
+
container_io_manager._queue_put(generator_queue, value)
|
|
254
|
+
item_count += 1
|
|
263
255
|
|
|
264
|
-
container_io_manager._queue_put(generator_queue, _ContainerIOManager._GENERATOR_STOP_SENTINEL)
|
|
265
|
-
generator_output_task.result() # Wait to finish sending generator outputs.
|
|
266
256
|
message = api_pb2.GeneratorDone(items_total=item_count)
|
|
267
257
|
container_io_manager.push_outputs(io_context, started_at, message, api_pb2.DATA_FORMAT_GENERATOR_DONE)
|
|
268
258
|
else:
|
|
@@ -290,7 +290,6 @@ class _ContainerIOManager:
|
|
|
290
290
|
|
|
291
291
|
_client: _Client
|
|
292
292
|
|
|
293
|
-
_GENERATOR_STOP_SENTINEL: ClassVar[Sentinel] = Sentinel()
|
|
294
293
|
_singleton: ClassVar[Optional["_ContainerIOManager"]] = None
|
|
295
294
|
|
|
296
295
|
def _init(self, container_args: api_pb2.ContainerArguments, client: _Client):
|
|
@@ -508,33 +507,47 @@ class _ContainerIOManager:
|
|
|
508
507
|
req = api_pb2.FunctionCallPutDataRequest(function_call_id=function_call_id, data_chunks=data_chunks)
|
|
509
508
|
await retry_transient_errors(self._client.stub.FunctionCallPutDataOut, req)
|
|
510
509
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
await
|
|
523
|
-
|
|
524
|
-
total_size = len(serialized_messages[0]) + 512
|
|
525
|
-
while total_size < 16 * 1024 * 1024: # 16 MiB, maximum size in a single message
|
|
526
|
-
try:
|
|
527
|
-
message = message_rx.get_nowait()
|
|
528
|
-
except asyncio.QueueEmpty:
|
|
529
|
-
break
|
|
530
|
-
if message is self._GENERATOR_STOP_SENTINEL:
|
|
531
|
-
received_sentinel = True
|
|
510
|
+
@asynccontextmanager
|
|
511
|
+
async def generator_output_sender(
|
|
512
|
+
self, function_call_id: str, data_format: int, message_rx: asyncio.Queue
|
|
513
|
+
) -> AsyncGenerator[None, None]:
|
|
514
|
+
"""Runs background task that feeds generator outputs into a function call's `data_out` stream."""
|
|
515
|
+
GENERATOR_STOP_SENTINEL = Sentinel()
|
|
516
|
+
|
|
517
|
+
async def generator_output_task():
|
|
518
|
+
index = 1
|
|
519
|
+
received_sentinel = False
|
|
520
|
+
while not received_sentinel:
|
|
521
|
+
message = await message_rx.get()
|
|
522
|
+
if message is GENERATOR_STOP_SENTINEL:
|
|
532
523
|
break
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
524
|
+
# ASGI 'http.response.start' and 'http.response.body' msgs are observed to be separated by 1ms.
|
|
525
|
+
# If we don't sleep here for 1ms we end up with an extra call to .put_data_out().
|
|
526
|
+
if index == 1:
|
|
527
|
+
await asyncio.sleep(0.001)
|
|
528
|
+
serialized_messages = [serialize_data_format(message, data_format)]
|
|
529
|
+
total_size = len(serialized_messages[0]) + 512
|
|
530
|
+
while total_size < 16 * 1024 * 1024: # 16 MiB, maximum size in a single message
|
|
531
|
+
try:
|
|
532
|
+
message = message_rx.get_nowait()
|
|
533
|
+
except asyncio.QueueEmpty:
|
|
534
|
+
break
|
|
535
|
+
if message is GENERATOR_STOP_SENTINEL:
|
|
536
|
+
received_sentinel = True
|
|
537
|
+
break
|
|
538
|
+
else:
|
|
539
|
+
serialized_messages.append(serialize_data_format(message, data_format))
|
|
540
|
+
total_size += len(serialized_messages[-1]) + 512 # 512 bytes for estimated framing overhead
|
|
541
|
+
await self.put_data_out(function_call_id, index, data_format, serialized_messages)
|
|
542
|
+
index += len(serialized_messages)
|
|
543
|
+
|
|
544
|
+
task = asyncio.create_task(generator_output_task())
|
|
545
|
+
try:
|
|
546
|
+
yield
|
|
547
|
+
finally:
|
|
548
|
+
# gracefully stop the task after all current inputs have been sent
|
|
549
|
+
await message_rx.put(GENERATOR_STOP_SENTINEL)
|
|
550
|
+
await task
|
|
538
551
|
|
|
539
552
|
async def _queue_create(self, size: int) -> asyncio.Queue:
|
|
540
553
|
"""Create a queue, on the synchronicity event loop (needed on Python 3.8 and 3.9)."""
|
|
@@ -106,7 +106,6 @@ class _ContainerIOManager:
|
|
|
106
106
|
_is_interactivity_enabled: bool
|
|
107
107
|
_fetching_inputs: bool
|
|
108
108
|
_client: modal.client._Client
|
|
109
|
-
_GENERATOR_STOP_SENTINEL: typing.ClassVar[Sentinel]
|
|
110
109
|
_singleton: typing.ClassVar[typing.Optional[_ContainerIOManager]]
|
|
111
110
|
|
|
112
111
|
def _init(self, container_args: modal_proto.api_pb2.ContainerArguments, client: modal.client._Client): ...
|
|
@@ -148,10 +147,10 @@ class _ContainerIOManager:
|
|
|
148
147
|
"""
|
|
149
148
|
...
|
|
150
149
|
|
|
151
|
-
|
|
150
|
+
def generator_output_sender(
|
|
152
151
|
self, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue
|
|
153
|
-
) -> None:
|
|
154
|
-
"""
|
|
152
|
+
) -> typing.AsyncContextManager[None]:
|
|
153
|
+
"""Runs background task that feeds generator outputs into a function call's `data_out` stream."""
|
|
155
154
|
...
|
|
156
155
|
|
|
157
156
|
async def _queue_create(self, size: int) -> asyncio.queues.Queue:
|
|
@@ -268,7 +267,6 @@ class ContainerIOManager:
|
|
|
268
267
|
_is_interactivity_enabled: bool
|
|
269
268
|
_fetching_inputs: bool
|
|
270
269
|
_client: modal.client.Client
|
|
271
|
-
_GENERATOR_STOP_SENTINEL: typing.ClassVar[Sentinel]
|
|
272
270
|
_singleton: typing.ClassVar[typing.Optional[ContainerIOManager]]
|
|
273
271
|
|
|
274
272
|
def __init__(self, /, *args, **kwargs):
|
|
@@ -367,16 +365,20 @@ class ContainerIOManager:
|
|
|
367
365
|
|
|
368
366
|
put_data_out: __put_data_out_spec[typing_extensions.Self]
|
|
369
367
|
|
|
370
|
-
class
|
|
371
|
-
def __call__(
|
|
372
|
-
|
|
368
|
+
class __generator_output_sender_spec(typing_extensions.Protocol[SUPERSELF]):
|
|
369
|
+
def __call__(
|
|
370
|
+
self, /, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue
|
|
371
|
+
) -> synchronicity.combined_types.AsyncAndBlockingContextManager[None]:
|
|
372
|
+
"""Runs background task that feeds generator outputs into a function call's `data_out` stream."""
|
|
373
373
|
...
|
|
374
374
|
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
def aio(
|
|
376
|
+
self, /, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue
|
|
377
|
+
) -> typing.AsyncContextManager[None]:
|
|
378
|
+
"""Runs background task that feeds generator outputs into a function call's `data_out` stream."""
|
|
377
379
|
...
|
|
378
380
|
|
|
379
|
-
|
|
381
|
+
generator_output_sender: __generator_output_sender_spec[typing_extensions.Self]
|
|
380
382
|
|
|
381
383
|
class ___queue_create_spec(typing_extensions.Protocol[SUPERSELF]):
|
|
382
384
|
def __call__(self, /, size: int) -> asyncio.queues.Queue:
|
|
@@ -188,6 +188,14 @@ def get_content_length(data: BinaryIO) -> int:
|
|
|
188
188
|
return content_length - pos
|
|
189
189
|
|
|
190
190
|
|
|
191
|
+
async def _measure_endpoint_latency(item: str) -> int:
|
|
192
|
+
latency_ms = 0
|
|
193
|
+
t0 = time.monotonic_ns()
|
|
194
|
+
async with ClientSessionRegistry.get_session().head(item) as _:
|
|
195
|
+
latency_ms = (time.monotonic_ns() - t0) // 1_000_000
|
|
196
|
+
return latency_ms
|
|
197
|
+
|
|
198
|
+
|
|
191
199
|
async def _blob_upload_with_fallback(items, blob_ids: list[str], callback) -> tuple[str, bool, int]:
|
|
192
200
|
r2_latency_ms = 0
|
|
193
201
|
r2_failed = False
|
|
@@ -197,10 +205,14 @@ async def _blob_upload_with_fallback(items, blob_ids: list[str], callback) -> tu
|
|
|
197
205
|
if idx == 0 and len(items) > 1 and random.random() > HEALTHY_R2_UPLOAD_PERCENTAGE:
|
|
198
206
|
continue
|
|
199
207
|
try:
|
|
200
|
-
init_time = time.monotonic_ns()
|
|
201
|
-
await callback(item)
|
|
202
208
|
if blob_id.endswith(":r2"):
|
|
203
|
-
|
|
209
|
+
# measure the time it takes to contact the bucket endpoint
|
|
210
|
+
r2_latency_ms, _ = await asyncio.gather(
|
|
211
|
+
_measure_endpoint_latency(item),
|
|
212
|
+
callback(item),
|
|
213
|
+
)
|
|
214
|
+
else:
|
|
215
|
+
await callback(item)
|
|
204
216
|
return blob_id, r2_failed, r2_latency_ms
|
|
205
217
|
except Exception as _:
|
|
206
218
|
if blob_id.endswith(":r2"):
|
|
@@ -31,7 +31,7 @@ class _Client:
|
|
|
31
31
|
server_url: str,
|
|
32
32
|
client_type: int,
|
|
33
33
|
credentials: typing.Optional[tuple[str, str]],
|
|
34
|
-
version: str = "1.0.6.
|
|
34
|
+
version: str = "1.0.6.dev16",
|
|
35
35
|
):
|
|
36
36
|
"""mdmd:hidden
|
|
37
37
|
The Modal client object is not intended to be instantiated directly by users.
|
|
@@ -160,7 +160,7 @@ class Client:
|
|
|
160
160
|
server_url: str,
|
|
161
161
|
client_type: int,
|
|
162
162
|
credentials: typing.Optional[tuple[str, str]],
|
|
163
|
-
version: str = "1.0.6.
|
|
163
|
+
version: str = "1.0.6.dev16",
|
|
164
164
|
):
|
|
165
165
|
"""mdmd:hidden
|
|
166
166
|
The Modal client object is not intended to be instantiated directly by users.
|
|
@@ -428,7 +428,7 @@ class Function(
|
|
|
428
428
|
|
|
429
429
|
_call_generator: ___call_generator_spec[typing_extensions.Self]
|
|
430
430
|
|
|
431
|
-
class __remote_spec(typing_extensions.Protocol[
|
|
431
|
+
class __remote_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER, SUPERSELF]):
|
|
432
432
|
def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER:
|
|
433
433
|
"""Calls the function remotely, executing it with the given arguments and returning the execution's result."""
|
|
434
434
|
...
|
|
@@ -437,7 +437,7 @@ class Function(
|
|
|
437
437
|
"""Calls the function remotely, executing it with the given arguments and returning the execution's result."""
|
|
438
438
|
...
|
|
439
439
|
|
|
440
|
-
remote: __remote_spec[modal._functions.
|
|
440
|
+
remote: __remote_spec[modal._functions.P, modal._functions.ReturnType, typing_extensions.Self]
|
|
441
441
|
|
|
442
442
|
class __remote_gen_spec(typing_extensions.Protocol[SUPERSELF]):
|
|
443
443
|
def __call__(self, /, *args, **kwargs) -> typing.Generator[typing.Any, None, None]:
|
|
@@ -464,7 +464,7 @@ class Function(
|
|
|
464
464
|
"""
|
|
465
465
|
...
|
|
466
466
|
|
|
467
|
-
class ___experimental_spawn_spec(typing_extensions.Protocol[
|
|
467
|
+
class ___experimental_spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER, SUPERSELF]):
|
|
468
468
|
def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]:
|
|
469
469
|
"""[Experimental] Calls the function with the given arguments, without waiting for the results.
|
|
470
470
|
|
|
@@ -488,7 +488,7 @@ class Function(
|
|
|
488
488
|
...
|
|
489
489
|
|
|
490
490
|
_experimental_spawn: ___experimental_spawn_spec[
|
|
491
|
-
modal._functions.
|
|
491
|
+
modal._functions.P, modal._functions.ReturnType, typing_extensions.Self
|
|
492
492
|
]
|
|
493
493
|
|
|
494
494
|
class ___spawn_map_inner_spec(typing_extensions.Protocol[P_INNER, SUPERSELF]):
|
|
@@ -497,7 +497,7 @@ class Function(
|
|
|
497
497
|
|
|
498
498
|
_spawn_map_inner: ___spawn_map_inner_spec[modal._functions.P, typing_extensions.Self]
|
|
499
499
|
|
|
500
|
-
class __spawn_spec(typing_extensions.Protocol[
|
|
500
|
+
class __spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER, SUPERSELF]):
|
|
501
501
|
def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]:
|
|
502
502
|
"""Calls the function with the given arguments, without waiting for the results.
|
|
503
503
|
|
|
@@ -518,7 +518,7 @@ class Function(
|
|
|
518
518
|
"""
|
|
519
519
|
...
|
|
520
520
|
|
|
521
|
-
spawn: __spawn_spec[modal._functions.
|
|
521
|
+
spawn: __spawn_spec[modal._functions.P, modal._functions.ReturnType, typing_extensions.Self]
|
|
522
522
|
|
|
523
523
|
def get_raw_f(self) -> collections.abc.Callable[..., typing.Any]:
|
|
524
524
|
"""Return the inner Python object wrapped by this Modal Function."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|