modal 1.6.4.dev14__tar.gz → 1.6.4.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.
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/PKG-INFO +1 -1
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_functions.py +3 -4
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_image.py +2 -2
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/app.py +41 -2
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/app.pyi +101 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/_help.py +97 -2
- modal-1.6.4.dev16/modal/cli/_suggest.py +139 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/app.py +220 -2
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/function.py +1 -13
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/run.py +21 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/utils.py +62 -1
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/client.pyi +2 -2
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/__init__.py +1 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/stream.py +225 -32
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/stream.pyi +283 -17
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/functions.pyi +7 -7
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/image.pyi +2 -2
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/types.py +154 -1
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal.egg-info/PKG-INFO +1 -1
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal.egg-info/SOURCES.txt +1 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/api_pb2.py +1573 -1542
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/api_pb2.pyi +95 -9
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_version/__init__.py +1 -1
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/LICENSE +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/README.md +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/__main__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_audit_logs/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_audit_logs/_rpcs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_audit_logs/count.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_audit_logs/list.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_billing.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_cluster.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_cluster.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_container_entrypoint.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_environments.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_function_variants.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_grpc_client.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_ipython.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_load_context.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_location.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_logs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_logs_manager.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_logs_manager.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_metrics.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_metrics.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_object.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_outbound_policy.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_outbound_policy.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_output/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_output/manager.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_output/pty.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_output/rich.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_output/status.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_partial_function.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_resolver.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_resources.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/asgi.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/container_io_manager.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/container_io_manager.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/execution_context.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/execution_context.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/gpu_memory_snapshot.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/task_lifecycle_manager.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/task_lifecycle_manager.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/telemetry.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/user_code_event_loop.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_runtime/user_code_imports.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_serialization.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_server.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_server.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_supports_logs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_traceback.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_tunnel.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_tunnel.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_type_manager.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/app_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/async_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/auth_token_manager.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/blob_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/browser_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/bytes_io_segment_payload.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/curl_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/deprecation.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/display_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/docker_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/function_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/git_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/grpc_testing.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/grpc_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/hash_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/http_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/idle_countdown.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/jwt_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/logger.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/mount_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/name_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/oauth.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/package_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/pattern_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/proxy_support.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/rand_pb_testing.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/sandbox_fs_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/shell_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_utils/time_utils.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_vendor/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_vendor/a2wsgi_wsgi.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_vendor/cloudpickle.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_vendor/tblib.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_vendor/version.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_watcher.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/_workspace.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/billing.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/billing.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/2023.12.312.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/2023.12.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/2024.04.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/2024.10.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/2025.06.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/2026.10.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/PREVIEW.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/README.md +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/builder/base-images.json +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/call_graph.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/_download.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/_logs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/_stats.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/_traceback.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/billing.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/changelog.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/config.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/container.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/curl.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/dashboard.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/dict.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/endpoint.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/entry_point.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/environment.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/image.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/import_refs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/logo.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/network_file_system.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/profile.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/queues.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/secret.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/selector.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/server.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/shell.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/skills.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/token.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/volume.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cli/workspace.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/client.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cloud_bucket_mount.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cloud_bucket_mount.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cls.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cls.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cluster.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/cluster.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/config.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/container_process.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/container_process.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/dict.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/dict.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/environments.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/environments.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/exception.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/_flash_container_entry.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/flash.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/flash.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/flash_server.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/flash_server.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/experimental/ipython.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/file_pattern_matcher.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/functions.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/image.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/io_streams.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/io_streams.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/mount.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/mount.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/network_file_system.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/network_file_system.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/object.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/object.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/output.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/parallel_map.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/parallel_map.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/partial_function.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/partial_function.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/proxy.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/proxy.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/py.typed +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/queue.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/queue.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/retries.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/runner.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/runner.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/running_app.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_common.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_filesystem.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_impl_persistent.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_impl_v1.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_impl_v2.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_sandbox.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_sidecar.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_snapshot.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/_task_command_router_client.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/sandbox.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/sandbox/sandbox.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/schedule.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/scheduler_placement.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/secret.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/secret.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/server.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/server.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/serving.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/serving.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/skills/modal/SKILL.md +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/stream_type.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/token_flow.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/token_flow.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/volume.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/volume.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/workspace.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal/workspace.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal.egg-info/dependency_links.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal.egg-info/entry_points.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal.egg-info/requires.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal.egg-info/top_level.txt +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/gen_cli_docs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/gen_cli_docs_main.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/gen_reference_docs.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/gen_reference_docs_main.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/mdmd/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/mdmd/mdmd.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/mdmd/signatures.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/mdmd/types.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_docs/reference_intro.md +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/__init__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/api_grpc.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/api_pb2_grpc.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/api_pb2_grpc.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/modal_api_grpc.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/py.typed +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/task_command_router_grpc.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/task_command_router_pb2.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/task_command_router_pb2.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/task_command_router_pb2_grpc.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_proto/task_command_router_pb2_grpc.pyi +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/modal_version/__main__.py +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/pyproject.toml +0 -0
- {modal-1.6.4.dev14 → modal-1.6.4.dev16}/setup.cfg +0 -0
|
@@ -126,7 +126,8 @@ _OBSERVABILITY_ONLY_APIS = (
|
|
|
126
126
|
".stats()",
|
|
127
127
|
".get_current_stats()",
|
|
128
128
|
".get_web_url()",
|
|
129
|
-
".autoscaler
|
|
129
|
+
".autoscaler",
|
|
130
|
+
".update_autoscaler()",
|
|
130
131
|
)
|
|
131
132
|
TERMINAL_STATUSES = (
|
|
132
133
|
api_pb2.GenericResult.GENERIC_STATUS_SUCCESS,
|
|
@@ -1409,7 +1410,6 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], _Object, type
|
|
|
1409
1410
|
|
|
1410
1411
|
"""
|
|
1411
1412
|
|
|
1412
|
-
self._check_not_observability_only()
|
|
1413
1413
|
deprecation_warning(
|
|
1414
1414
|
(2026, 10, 16),
|
|
1415
1415
|
"`Function.update_autoscaler()` is deprecated and will be removed in a future version "
|
|
@@ -1527,7 +1527,7 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], _Object, type
|
|
|
1527
1527
|
|
|
1528
1528
|
If the ID belongs to a Cls, the Function only supports the following APIs:
|
|
1529
1529
|
`.logs`, `.metrics`, `.info()`, `.stats()`, `.get_current_stats()`,
|
|
1530
|
-
`.get_web_url()` and `.
|
|
1530
|
+
`.get_web_url()`, `.autoscaler` and `.update_autoscaler()`. Use `modal.Cls.from_name(...)`
|
|
1531
1531
|
to invoke all other methods.
|
|
1532
1532
|
|
|
1533
1533
|
Args:
|
|
@@ -2704,7 +2704,6 @@ class _FunctionAutoscalerManager:
|
|
|
2704
2704
|
if not self._function._is_hydrated:
|
|
2705
2705
|
await self._function.hydrate()
|
|
2706
2706
|
|
|
2707
|
-
self._function._check_not_observability_only()
|
|
2708
2707
|
settings: api_pb2.AutoscalerSettings = api_pb2.AutoscalerSettings()
|
|
2709
2708
|
|
|
2710
2709
|
if min_containers != UNSET_PARAMETER:
|
|
@@ -2929,8 +2929,8 @@ class _Image(_Object, type_prefix="im"):
|
|
|
2929
2929
|
volumes: Volume and bucket mounts attached for the build.
|
|
2930
2930
|
network_file_systems: Network file systems attached for the build.
|
|
2931
2931
|
gpu: GPU type or list of types for the builder container.
|
|
2932
|
-
cpu: CPU cores to request
|
|
2933
|
-
memory: Memory to request in MiB
|
|
2932
|
+
cpu: CPU cores to request.
|
|
2933
|
+
memory: Memory to request in MiB.
|
|
2934
2934
|
timeout: Maximum build-step runtime in seconds.
|
|
2935
2935
|
cloud: Cloud provider for the builder function.
|
|
2936
2936
|
region: Region or regions for the builder function.
|
|
@@ -3,7 +3,7 @@ import inspect
|
|
|
3
3
|
import typing
|
|
4
4
|
from collections.abc import AsyncGenerator, Callable, Collection, Coroutine, Mapping, Sequence
|
|
5
5
|
from dataclasses import dataclass
|
|
6
|
-
from datetime import datetime, timezone
|
|
6
|
+
from datetime import datetime, timedelta, timezone
|
|
7
7
|
from pathlib import PurePosixPath
|
|
8
8
|
from textwrap import dedent
|
|
9
9
|
from typing import (
|
|
@@ -57,7 +57,7 @@ from .retries import Retries
|
|
|
57
57
|
from .running_app import RunningApp
|
|
58
58
|
from .schedule import Schedule
|
|
59
59
|
from .secret import _Secret
|
|
60
|
-
from .types import AppInfo, SandboxGroupStats
|
|
60
|
+
from .types import AppInfo, AppStats, SandboxGroupStats
|
|
61
61
|
from .volume import _Volume
|
|
62
62
|
|
|
63
63
|
_default_image: _Image = _Image.debian_slim()
|
|
@@ -1764,6 +1764,45 @@ class _App:
|
|
|
1764
1764
|
"""Namespace for the Sandboxes belonging to this App."""
|
|
1765
1765
|
return _AppSandboxesManager(self)
|
|
1766
1766
|
|
|
1767
|
+
async def stats(self, *, since: datetime | None = None, until: datetime | None = None) -> AppStats:
|
|
1768
|
+
"""Return aggregate Function, Server, and Sandbox statistics for this App.
|
|
1769
|
+
|
|
1770
|
+
The default window is the most recent hour. Windows can span at most seven days,
|
|
1771
|
+
with a start in the past 30 days.
|
|
1772
|
+
|
|
1773
|
+
App stats show total call counts, request counts, and the count of active and errored containers in
|
|
1774
|
+
the time window. The count of sandboxes that finished in the interval as well as the count
|
|
1775
|
+
that were still running as of the end of the window is also returned.
|
|
1776
|
+
|
|
1777
|
+
The available stats and their definitions are subject to change and are provided
|
|
1778
|
+
on a best-effort basis. They may be delayed or incomplete.
|
|
1779
|
+
|
|
1780
|
+
Args:
|
|
1781
|
+
since: The beginning of the time range, inclusive. If omitted, this defaults to an hour before `until`.
|
|
1782
|
+
Values without a timezone are interpeted as local time.
|
|
1783
|
+
until: The end of the time range, exclusive. If omitted, this defaults to current time.
|
|
1784
|
+
Values without a timezone are interpeted as local time.
|
|
1785
|
+
|
|
1786
|
+
Examples:
|
|
1787
|
+
```python notest
|
|
1788
|
+
stats = modal.App.lookup("my-app").stats()
|
|
1789
|
+
print(stats.functions.total.calls.failed)
|
|
1790
|
+
print(stats.functions["embed"].counts.containers.errors)
|
|
1791
|
+
```
|
|
1792
|
+
"""
|
|
1793
|
+
if not self._app_id:
|
|
1794
|
+
raise InvalidError("`app.stats` requires a running or stopped app.")
|
|
1795
|
+
until = (until or datetime.now(timezone.utc)).astimezone(timezone.utc)
|
|
1796
|
+
since = (since or until - timedelta(hours=1)).astimezone(timezone.utc)
|
|
1797
|
+
if since >= until:
|
|
1798
|
+
raise InvalidError("`since` must be before `until`.")
|
|
1799
|
+
request = api_pb2.AppGetTimeRangeStatsRequest(app_id=self._app_id)
|
|
1800
|
+
request.since.FromDatetime(since)
|
|
1801
|
+
request.until.FromDatetime(until)
|
|
1802
|
+
client = self._client or await _Client.from_env()
|
|
1803
|
+
response = await client._stub.AppGetTimeRangeStats(request)
|
|
1804
|
+
return AppStats._from_proto(response)
|
|
1805
|
+
|
|
1767
1806
|
async def info(self, refresh: bool = False) -> AppInfo:
|
|
1768
1807
|
"""Return information for a modal `App`.
|
|
1769
1808
|
|
|
@@ -1007,6 +1007,36 @@ class _App:
|
|
|
1007
1007
|
"""Namespace for the Sandboxes belonging to this App."""
|
|
1008
1008
|
...
|
|
1009
1009
|
|
|
1010
|
+
async def stats(
|
|
1011
|
+
self, *, since: typing.Optional[datetime.datetime] = None, until: typing.Optional[datetime.datetime] = None
|
|
1012
|
+
) -> modal.types.AppStats:
|
|
1013
|
+
"""Return aggregate Function, Server, and Sandbox statistics for this App.
|
|
1014
|
+
|
|
1015
|
+
The default window is the most recent hour. Windows can span at most seven days,
|
|
1016
|
+
with a start in the past 30 days.
|
|
1017
|
+
|
|
1018
|
+
App stats show total call counts, request counts, and the count of active and errored containers in
|
|
1019
|
+
the time window. The count of sandboxes that finished in the interval as well as the count
|
|
1020
|
+
that were still running as of the end of the window is also returned.
|
|
1021
|
+
|
|
1022
|
+
The available stats and their definitions are subject to change and are provided
|
|
1023
|
+
on a best-effort basis. They may be delayed or incomplete.
|
|
1024
|
+
|
|
1025
|
+
Args:
|
|
1026
|
+
since: The beginning of the time range, inclusive. If omitted, this defaults to an hour before `until`.
|
|
1027
|
+
Values without a timezone are interpeted as local time.
|
|
1028
|
+
until: The end of the time range, exclusive. If omitted, this defaults to current time.
|
|
1029
|
+
Values without a timezone are interpeted as local time.
|
|
1030
|
+
|
|
1031
|
+
Examples:
|
|
1032
|
+
```python notest
|
|
1033
|
+
stats = modal.App.lookup("my-app").stats()
|
|
1034
|
+
print(stats.functions.total.calls.failed)
|
|
1035
|
+
print(stats.functions["embed"].counts.containers.errors)
|
|
1036
|
+
```
|
|
1037
|
+
"""
|
|
1038
|
+
...
|
|
1039
|
+
|
|
1010
1040
|
async def info(self, refresh: bool = False) -> modal.types.AppInfo:
|
|
1011
1041
|
"""Return information for a modal `App`.
|
|
1012
1042
|
|
|
@@ -2227,6 +2257,77 @@ class App:
|
|
|
2227
2257
|
"""Namespace for the Sandboxes belonging to this App."""
|
|
2228
2258
|
...
|
|
2229
2259
|
|
|
2260
|
+
class __stats_spec(typing_extensions.Protocol):
|
|
2261
|
+
def __call__(
|
|
2262
|
+
self,
|
|
2263
|
+
/,
|
|
2264
|
+
*,
|
|
2265
|
+
since: typing.Optional[datetime.datetime] = None,
|
|
2266
|
+
until: typing.Optional[datetime.datetime] = None,
|
|
2267
|
+
) -> modal.types.AppStats:
|
|
2268
|
+
"""Return aggregate Function, Server, and Sandbox statistics for this App.
|
|
2269
|
+
|
|
2270
|
+
The default window is the most recent hour. Windows can span at most seven days,
|
|
2271
|
+
with a start in the past 30 days.
|
|
2272
|
+
|
|
2273
|
+
App stats show total call counts, request counts, and the count of active and errored containers in
|
|
2274
|
+
the time window. The count of sandboxes that finished in the interval as well as the count
|
|
2275
|
+
that were still running as of the end of the window is also returned.
|
|
2276
|
+
|
|
2277
|
+
The available stats and their definitions are subject to change and are provided
|
|
2278
|
+
on a best-effort basis. They may be delayed or incomplete.
|
|
2279
|
+
|
|
2280
|
+
Args:
|
|
2281
|
+
since: The beginning of the time range, inclusive. If omitted, this defaults to an hour before `until`.
|
|
2282
|
+
Values without a timezone are interpeted as local time.
|
|
2283
|
+
until: The end of the time range, exclusive. If omitted, this defaults to current time.
|
|
2284
|
+
Values without a timezone are interpeted as local time.
|
|
2285
|
+
|
|
2286
|
+
Examples:
|
|
2287
|
+
```python notest
|
|
2288
|
+
stats = modal.App.lookup("my-app").stats()
|
|
2289
|
+
print(stats.functions.total.calls.failed)
|
|
2290
|
+
print(stats.functions["embed"].counts.containers.errors)
|
|
2291
|
+
```
|
|
2292
|
+
"""
|
|
2293
|
+
...
|
|
2294
|
+
|
|
2295
|
+
async def aio(
|
|
2296
|
+
self,
|
|
2297
|
+
/,
|
|
2298
|
+
*,
|
|
2299
|
+
since: typing.Optional[datetime.datetime] = None,
|
|
2300
|
+
until: typing.Optional[datetime.datetime] = None,
|
|
2301
|
+
) -> modal.types.AppStats:
|
|
2302
|
+
"""Return aggregate Function, Server, and Sandbox statistics for this App.
|
|
2303
|
+
|
|
2304
|
+
The default window is the most recent hour. Windows can span at most seven days,
|
|
2305
|
+
with a start in the past 30 days.
|
|
2306
|
+
|
|
2307
|
+
App stats show total call counts, request counts, and the count of active and errored containers in
|
|
2308
|
+
the time window. The count of sandboxes that finished in the interval as well as the count
|
|
2309
|
+
that were still running as of the end of the window is also returned.
|
|
2310
|
+
|
|
2311
|
+
The available stats and their definitions are subject to change and are provided
|
|
2312
|
+
on a best-effort basis. They may be delayed or incomplete.
|
|
2313
|
+
|
|
2314
|
+
Args:
|
|
2315
|
+
since: The beginning of the time range, inclusive. If omitted, this defaults to an hour before `until`.
|
|
2316
|
+
Values without a timezone are interpeted as local time.
|
|
2317
|
+
until: The end of the time range, exclusive. If omitted, this defaults to current time.
|
|
2318
|
+
Values without a timezone are interpeted as local time.
|
|
2319
|
+
|
|
2320
|
+
Examples:
|
|
2321
|
+
```python notest
|
|
2322
|
+
stats = modal.App.lookup("my-app").stats()
|
|
2323
|
+
print(stats.functions.total.calls.failed)
|
|
2324
|
+
print(stats.functions["embed"].counts.containers.errors)
|
|
2325
|
+
```
|
|
2326
|
+
"""
|
|
2327
|
+
...
|
|
2328
|
+
|
|
2329
|
+
stats: __stats_spec
|
|
2330
|
+
|
|
2230
2331
|
class __info_spec(typing_extensions.Protocol):
|
|
2231
2332
|
def __call__(self, /, refresh: bool = False) -> modal.types.AppInfo:
|
|
2232
2333
|
"""Return information for a modal `App`.
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
|
+
import asyncio
|
|
6
7
|
import inspect
|
|
7
8
|
import os
|
|
9
|
+
import re
|
|
10
|
+
import shlex
|
|
8
11
|
import shutil
|
|
9
12
|
import sys
|
|
10
|
-
from collections.abc import Sequence
|
|
11
|
-
from typing import Any
|
|
13
|
+
from collections.abc import Callable, Sequence
|
|
14
|
+
from typing import Any, cast
|
|
12
15
|
|
|
13
16
|
import click
|
|
14
17
|
from rich.console import Console, Group, RenderableType
|
|
@@ -18,6 +21,12 @@ from rich.panel import Panel
|
|
|
18
21
|
from rich.table import Table
|
|
19
22
|
from rich.text import Text
|
|
20
23
|
|
|
24
|
+
from modal._utils.async_utils import synchronizer
|
|
25
|
+
from modal_proto import api_pb2
|
|
26
|
+
from modal_version import __version__
|
|
27
|
+
|
|
28
|
+
from ._suggest import _invocation_args, unknown_command_hint
|
|
29
|
+
|
|
21
30
|
_HEADING_STYLE = "bold bright_green"
|
|
22
31
|
_COMMAND_NAME_STYLE = ""
|
|
23
32
|
_COMMAND_DESC_STYLE = "dim"
|
|
@@ -27,6 +36,56 @@ _ERROR_STYLE = "red"
|
|
|
27
36
|
|
|
28
37
|
_MAX_HELP_WIDTH = 80
|
|
29
38
|
_HELP_PADDING = 1
|
|
39
|
+
COMMAND_SUGGESTION_TIMEOUT = 1.0
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def _fetch_command_suggestion_async(
|
|
43
|
+
parent_path: list[str], unknown_command: str
|
|
44
|
+
) -> api_pb2.CliCommandSuggestResponse:
|
|
45
|
+
from modal._utils.grpc_utils import create_channel
|
|
46
|
+
from modal.client import _get_metadata
|
|
47
|
+
from modal.config import config
|
|
48
|
+
from modal_proto import api_grpc
|
|
49
|
+
|
|
50
|
+
async def fetch() -> api_pb2.CliCommandSuggestResponse:
|
|
51
|
+
# Command guidance is public and must also work before authentication.
|
|
52
|
+
metadata = _get_metadata(api_pb2.CLIENT_TYPE_CLIENT, credentials=None, version=__version__)
|
|
53
|
+
async with create_channel(config["server_url"], metadata) as channel:
|
|
54
|
+
return await api_grpc.ModalClientStub(channel).CliCommandSuggest(
|
|
55
|
+
api_pb2.CliCommandSuggestRequest(parent_path=parent_path, unknown_command=unknown_command),
|
|
56
|
+
timeout=COMMAND_SUGGESTION_TIMEOUT,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# The deadline includes opening the connection, not just receiving a response.
|
|
60
|
+
return await asyncio.wait_for(fetch(), timeout=COMMAND_SUGGESTION_TIMEOUT)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
_fetch_command_suggestion = cast(
|
|
64
|
+
Callable[[list[str], str], api_pb2.CliCommandSuggestResponse],
|
|
65
|
+
synchronizer.create_blocking(_fetch_command_suggestion_async, "_fetch_command_suggestion"),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _command_suggestion_hint(ctx: click.Context, name: str, rest: Sequence[str]) -> str:
|
|
70
|
+
parent_path: list[str] = []
|
|
71
|
+
parent = ctx
|
|
72
|
+
while parent.parent is not None:
|
|
73
|
+
parent_path.append(parent.info_name or "")
|
|
74
|
+
parent = parent.parent
|
|
75
|
+
parent_path.reverse()
|
|
76
|
+
path = [*parent_path, name]
|
|
77
|
+
if len(path) > 8 or any(not re.fullmatch(r"[a-zA-Z][a-zA-Z0-9_-]{0,63}", word) for word in path):
|
|
78
|
+
return ""
|
|
79
|
+
try:
|
|
80
|
+
response = _fetch_command_suggestion(parent_path, name)
|
|
81
|
+
hint = response.message
|
|
82
|
+
if hint and response.append_original_command:
|
|
83
|
+
original_args = ctx.meta.get("modal_original_args", [*path, *rest])
|
|
84
|
+
hint += f"\n {shlex.join(['modal', *original_args])}"
|
|
85
|
+
return hint
|
|
86
|
+
except Exception:
|
|
87
|
+
pass
|
|
88
|
+
return ""
|
|
30
89
|
|
|
31
90
|
|
|
32
91
|
class ModalGlobalOption(click.Option):
|
|
@@ -320,12 +379,21 @@ class ModalCommand(click.Command):
|
|
|
320
379
|
)
|
|
321
380
|
|
|
322
381
|
|
|
382
|
+
def _is_no_such_command(exc: click.UsageError) -> bool:
|
|
383
|
+
no_such_command = getattr(click.exceptions, "NoSuchCommand", None) # click >= 8.4
|
|
384
|
+
if no_such_command is not None:
|
|
385
|
+
return isinstance(exc, no_such_command)
|
|
386
|
+
return exc.message.startswith("No such command")
|
|
387
|
+
|
|
388
|
+
|
|
323
389
|
class ModalGroup(click.Group):
|
|
324
390
|
"""click.Group whose subcommands and subgroups inherit `ModalCommand`."""
|
|
325
391
|
|
|
326
392
|
command_class = ModalCommand
|
|
327
393
|
group_class = type # nested @group.group() reuses the enclosing class
|
|
328
394
|
defer_global_option_parsing = False
|
|
395
|
+
# Groups that resolve subcommands from user input (e.g. `modal run`) opt out of "Did you mean".
|
|
396
|
+
dynamic_subcommands = False
|
|
329
397
|
|
|
330
398
|
def __init__(self, *args: Any, panel: str | None = None, **kwargs: Any) -> None:
|
|
331
399
|
# Default to showing help when a group is invoked with no subcommand.
|
|
@@ -348,7 +416,34 @@ class ModalGroup(click.Group):
|
|
|
348
416
|
if hidden is not None:
|
|
349
417
|
cmd.hidden = hidden
|
|
350
418
|
|
|
419
|
+
def invoke(self, ctx: click.Context) -> Any:
|
|
420
|
+
token = _invocation_args.set(ctx.meta.get("modal_original_args"))
|
|
421
|
+
try:
|
|
422
|
+
return super().invoke(ctx)
|
|
423
|
+
finally:
|
|
424
|
+
_invocation_args.reset(token)
|
|
425
|
+
|
|
426
|
+
def resolve_command(
|
|
427
|
+
self, ctx: click.Context, args: list[str]
|
|
428
|
+
) -> tuple[str | None, click.Command | None, list[str]]:
|
|
429
|
+
try:
|
|
430
|
+
return super().resolve_command(ctx, args)
|
|
431
|
+
except click.UsageError as exc:
|
|
432
|
+
if self.dynamic_subcommands or not args or not _is_no_such_command(exc):
|
|
433
|
+
raise
|
|
434
|
+
name = click.utils.make_str(args[0])
|
|
435
|
+
message = f"No such command '{name}'."
|
|
436
|
+
# Replaces click's own suggestion (8.4+ only, and it can include hidden commands)
|
|
437
|
+
# so the hint is the same on every supported click version.
|
|
438
|
+
rest = [click.utils.make_str(a) for a in args[1:]]
|
|
439
|
+
hint = _command_suggestion_hint(ctx, name, rest) or unknown_command_hint(self, ctx, name)
|
|
440
|
+
if hint:
|
|
441
|
+
message += f"\n\n{hint}"
|
|
442
|
+
raise click.UsageError(message, ctx) from None
|
|
443
|
+
|
|
351
444
|
def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:
|
|
445
|
+
if ctx.parent is None:
|
|
446
|
+
ctx.meta["modal_original_args"] = tuple(args)
|
|
352
447
|
index = 0
|
|
353
448
|
while index < len(args):
|
|
354
449
|
arg = args[index]
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Copyright Modal Labs 2026
|
|
2
|
+
"""Helpers for "Did you mean ...?" hints in CLI error messages."""
|
|
3
|
+
|
|
4
|
+
import difflib
|
|
5
|
+
import shlex
|
|
6
|
+
from collections.abc import Iterable, Sequence
|
|
7
|
+
from contextvars import ContextVar
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
|
|
11
|
+
MAX_SUGGESTIONS = 3
|
|
12
|
+
MAX_NESTED_SUGGESTIONS = 5
|
|
13
|
+
CUTOFF = 0.6
|
|
14
|
+
MIN_PREFIX_LEN = 3
|
|
15
|
+
|
|
16
|
+
# Async handlers run on the synchronizer's thread, where Click's thread-local context isn't
|
|
17
|
+
# visible; this ContextVar reaches them via the context copied by run_coroutine_threadsafe.
|
|
18
|
+
_invocation_args: ContextVar[tuple[str, ...] | None] = ContextVar("modal_cli_invocation_args", default=None)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _normalize(s: str) -> str:
|
|
22
|
+
return s.lower().replace("_", "-")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def close_matches(
|
|
26
|
+
word: str, candidates: Iterable[str], *, n: int = MAX_SUGGESTIONS, cutoff: float = CUTOFF
|
|
27
|
+
) -> list[str]:
|
|
28
|
+
"""Return up to `n` candidates that `word` was most likely meant to be, best first.
|
|
29
|
+
|
|
30
|
+
Order of preference:
|
|
31
|
+
1. A normalized exact match (case-insensitive, `_` == `-`).
|
|
32
|
+
2. difflib similarity above `cutoff`.
|
|
33
|
+
3. Candidates that `word` is a prefix of (only for words of 3+ characters).
|
|
34
|
+
"""
|
|
35
|
+
unique = list(dict.fromkeys(c for c in candidates if c and c != word))
|
|
36
|
+
if not word or not unique:
|
|
37
|
+
return []
|
|
38
|
+
|
|
39
|
+
by_norm: dict[str, str] = {}
|
|
40
|
+
for c in unique:
|
|
41
|
+
by_norm.setdefault(_normalize(c), c)
|
|
42
|
+
|
|
43
|
+
norm_word = _normalize(word)
|
|
44
|
+
if norm_word in by_norm:
|
|
45
|
+
return [by_norm[norm_word]]
|
|
46
|
+
|
|
47
|
+
matches = difflib.get_close_matches(norm_word, list(by_norm), n=n, cutoff=cutoff)
|
|
48
|
+
if matches:
|
|
49
|
+
return [by_norm[m] for m in matches]
|
|
50
|
+
|
|
51
|
+
if len(word) >= MIN_PREFIX_LEN:
|
|
52
|
+
prefixed = [c for norm, c in by_norm.items() if norm.startswith(norm_word)]
|
|
53
|
+
return prefixed if len(prefixed) == 1 else []
|
|
54
|
+
return []
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def slash_ref_candidates(identifier: str) -> list[str]:
|
|
58
|
+
"""Possible `APP_NAME/OBJECT_NAME` rewrites of a dot-separated ref.
|
|
59
|
+
|
|
60
|
+
Handles `app.func` and `app.Cls.method`. Returns an empty list for colon-separated refs
|
|
61
|
+
or when the ref already contains `/`, since `/` is the only separator and
|
|
62
|
+
`app.name/func.name` is already valid.
|
|
63
|
+
"""
|
|
64
|
+
if not identifier or "/" in identifier or ":" in identifier:
|
|
65
|
+
return []
|
|
66
|
+
|
|
67
|
+
candidates: list[str] = []
|
|
68
|
+
# App and object names may both contain dots, so every split is a candidate. Callers must
|
|
69
|
+
# disambiguate (e.g. against deployed App names) rather than assume any one split.
|
|
70
|
+
parts = identifier.split(".")
|
|
71
|
+
for i in range(1, len(parts)):
|
|
72
|
+
app, rest = ".".join(parts[:i]), ".".join(parts[i:])
|
|
73
|
+
if app and rest:
|
|
74
|
+
candidates.append(f"{app}/{rest}")
|
|
75
|
+
|
|
76
|
+
return list(dict.fromkeys(candidates))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def corrected_commands(reference: str, suggestions: Sequence[str], *, allow_trailing_args: bool = True) -> list[str]:
|
|
80
|
+
"""The current invocation with `reference` replaced by each suggestion, as retry commands.
|
|
81
|
+
|
|
82
|
+
Returns an empty list unless `reference` is exactly one argument of the invocation, since
|
|
83
|
+
otherwise the argument that Click parsed as the reference is ambiguous. With
|
|
84
|
+
`allow_trailing_args=False`, also returns an empty list when arguments follow `reference`.
|
|
85
|
+
"""
|
|
86
|
+
args = _invocation_args.get()
|
|
87
|
+
if args is None or args.count(reference) != 1:
|
|
88
|
+
return []
|
|
89
|
+
if not allow_trailing_args and args[-1] != reference:
|
|
90
|
+
return []
|
|
91
|
+
return [shlex.join(["modal", *(new if arg == reference else arg for arg in args)]) for new in suggestions]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def format_hint(suggestions: Sequence[str], commands: Sequence[str] = ()) -> str:
|
|
95
|
+
"""Render a hint block. `suggestions` are values; `commands` are full command lines.
|
|
96
|
+
|
|
97
|
+
Returns an empty string when there is nothing to suggest.
|
|
98
|
+
"""
|
|
99
|
+
items = commands or suggestions
|
|
100
|
+
if not items:
|
|
101
|
+
return ""
|
|
102
|
+
return "\n".join(["Did you mean:", *(f" {item}" for item in items)])
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _visible_commands(group: click.Group, ctx: click.Context) -> dict[str, click.Command]:
|
|
106
|
+
out: dict[str, click.Command] = {}
|
|
107
|
+
for name in group.list_commands(ctx):
|
|
108
|
+
cmd = group.get_command(ctx, name)
|
|
109
|
+
if cmd is not None and not cmd.hidden:
|
|
110
|
+
out[name] = cmd
|
|
111
|
+
return out
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def unknown_command_hint(group: click.Group, ctx: click.Context, name: str) -> str:
|
|
115
|
+
"""Hint for `modal <name>` when `<name>` isn't a subcommand of `group`.
|
|
116
|
+
|
|
117
|
+
Combines fuzzy matches at this level with exact matches one level down, so
|
|
118
|
+
`modal logs` suggests `modal app logs`, `modal function logs`, ...
|
|
119
|
+
"""
|
|
120
|
+
visible = _visible_commands(group, ctx)
|
|
121
|
+
prefix = ctx.command_path
|
|
122
|
+
commands = close_matches(name, visible)
|
|
123
|
+
|
|
124
|
+
nested: list[str] = []
|
|
125
|
+
for child_name, child in visible.items():
|
|
126
|
+
if isinstance(child, click.Group) and not getattr(child, "dynamic_subcommands", False):
|
|
127
|
+
sub_ctx = click.Context(child, info_name=child_name, parent=ctx, resilient_parsing=True)
|
|
128
|
+
sub_visible = _visible_commands(child, sub_ctx)
|
|
129
|
+
norm = _normalize(name)
|
|
130
|
+
for sub_name in sub_visible:
|
|
131
|
+
if _normalize(sub_name) == norm:
|
|
132
|
+
nested.append(f"{prefix} {child_name} {sub_name}")
|
|
133
|
+
if len(nested) > MAX_NESTED_SUGGESTIONS:
|
|
134
|
+
nested = nested[:MAX_NESTED_SUGGESTIONS] + [f"... (see '{prefix} --help')"]
|
|
135
|
+
|
|
136
|
+
suggestions = list(dict.fromkeys(commands + nested))
|
|
137
|
+
if len(suggestions) == 1 and not nested:
|
|
138
|
+
return f"Did you mean '{suggestions[0]}'?"
|
|
139
|
+
return format_hint(suggestions)
|