Showing preview only (3,414K chars total). Download the full file or copy to clipboard to get everything.
Repository: replicate/cog
Branch: main
Commit: cb3ac3c727f6
Files: 575
Total size: 3.2 MB
Directory structure:
gitextract_1_nczbz8/
├── .all-contributorsrc
├── .git_archival.txt
├── .gitattributes
├── .github/
│ ├── CODEOWNERS
│ ├── dependabot.yml
│ └── workflows/
│ ├── README.md
│ ├── ci.yaml
│ ├── codeql.yml
│ ├── docs.yaml
│ ├── release-build.yaml
│ └── release-publish.yaml
├── .gitignore
├── .golangci.yaml
├── .goreleaser.yaml
├── .mockery.yml
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── AGENTS.md
├── CONTRIBUTING.md
├── DESIGN.md
├── LICENSE
├── Makefile
├── README.md
├── architecture/
│ ├── 00-overview.md
│ ├── 01-model-source.md
│ ├── 02-schema.md
│ ├── 05-build-system.md
│ ├── 06-cli.md
│ ├── ffi/
│ │ ├── 03-prediction-api.md
│ │ ├── 04-container-runtime.md
│ │ └── README.md
│ └── legacy/
│ ├── 03-prediction-api.md
│ ├── 04-container-runtime.md
│ └── README.md
├── cmd/
│ └── cog/
│ └── cog.go
├── crates/
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── README.md
│ ├── coglet/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── bridge/
│ │ │ ├── codec.rs
│ │ │ ├── mod.rs
│ │ │ ├── protocol.rs
│ │ │ ├── snapshots/
│ │ │ │ ├── coglet__bridge__protocol__tests__control_cancel_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_cancelled_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_failed_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_healthcheck_result_healthy_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_healthcheck_result_unhealthy_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_healthcheck_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_idle_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_init_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_ready_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_ready_with_schema_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_shutdown_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_cancelled_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_done_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_failed_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_log_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_append_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_complex_value_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_delete_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_increment_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_replace_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_output_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_predict_file_input_serializes.snap
│ │ │ │ └── coglet__bridge__protocol__tests__slot_predict_serializes.snap
│ │ │ └── transport.rs
│ │ ├── fd_redirect.rs
│ │ ├── health.rs
│ │ ├── input_validation.rs
│ │ ├── lib.rs
│ │ ├── orchestrator.rs
│ │ ├── permit/
│ │ │ ├── mod.rs
│ │ │ ├── pool.rs
│ │ │ └── slot.rs
│ │ ├── prediction.rs
│ │ ├── predictor.rs
│ │ ├── service.rs
│ │ ├── setup_log_accumulator.rs
│ │ ├── snapshots/
│ │ │ ├── coglet__health__tests__health_all_variants.snap
│ │ │ ├── coglet__health__tests__health_response_all_variants.snap
│ │ │ ├── coglet__health__tests__setup_status_all_variants.snap
│ │ │ ├── coglet__predictor__tests__output_single.snap
│ │ │ ├── coglet__predictor__tests__output_stream.snap
│ │ │ ├── coglet__version__tests__version_full.snap
│ │ │ └── coglet__version__tests__version_minimal.snap
│ │ ├── transport/
│ │ │ ├── http/
│ │ │ │ ├── mod.rs
│ │ │ │ ├── routes.rs
│ │ │ │ └── server.rs
│ │ │ └── mod.rs
│ │ ├── version.rs
│ │ ├── webhook.rs
│ │ ├── worker.rs
│ │ └── worker_tracing_layer.rs
│ ├── coglet-python/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ ├── build.rs
│ │ ├── coglet/
│ │ │ ├── __init__.py
│ │ │ ├── __init__.pyi
│ │ │ ├── _impl.pyi
│ │ │ ├── _sdk/
│ │ │ │ └── __init__.pyi
│ │ │ └── py.typed
│ │ ├── pyproject.toml
│ │ ├── src/
│ │ │ ├── audit.rs
│ │ │ ├── bin/
│ │ │ │ └── stub_gen.rs
│ │ │ ├── cancel.rs
│ │ │ ├── input.rs
│ │ │ ├── lib.rs
│ │ │ ├── log_writer.rs
│ │ │ ├── metric_scope.rs
│ │ │ ├── output.rs
│ │ │ ├── predictor.rs
│ │ │ └── worker_bridge.rs
│ │ └── tests/
│ │ └── test_coglet.py
│ └── deny.toml
├── docs/
│ ├── CNAME
│ ├── cli.md
│ ├── deploy.md
│ ├── environment.md
│ ├── getting-started-own-model.md
│ ├── getting-started.md
│ ├── http.md
│ ├── llms.txt
│ ├── notebooks.md
│ ├── private-package-registry.md
│ ├── python.md
│ ├── stylesheets/
│ │ └── extra.css
│ ├── training.md
│ ├── wsl2/
│ │ └── wsl2.md
│ └── yaml.md
├── go.mod
├── go.sum
├── integration-tests/
│ ├── .gitignore
│ ├── README.md
│ ├── concurrent/
│ │ └── concurrent_test.go
│ ├── harness/
│ │ ├── cmd_pty.go
│ │ ├── command.go
│ │ └── harness.go
│ ├── login/
│ │ └── login_test.go
│ ├── suite_test.go
│ └── tests/
│ ├── apt_packages.txtar
│ ├── async_generator_precollect.txtar
│ ├── async_predictor.txtar
│ ├── async_sleep.txtar
│ ├── bad_dockerignore.txtar
│ ├── bool_input_output.txtar
│ ├── build_base_image_sha.txtar
│ ├── build_cog_init.txtar
│ ├── build_cog_version_match.txtar
│ ├── build_gpu_labels.txtar
│ ├── build_image_option.txtar
│ ├── build_openapi_schema.txtar
│ ├── build_openapi_schema_complex.txtar
│ ├── build_pip_freeze.txtar
│ ├── build_python313_base_image.txtar
│ ├── build_torch_version_required.txtar
│ ├── ca_cert.txtar
│ ├── cancel_async_prediction.txtar
│ ├── cancel_repeated.txtar
│ ├── cancel_sync_prediction.txtar
│ ├── coglet_iterator_path_output.txtar
│ ├── coglet_iterator_upload_url.txtar
│ ├── coglet_large_file_upload_serial.txtar
│ ├── coglet_large_input.txtar
│ ├── coglet_large_output.txtar
│ ├── coglet_list_path_single_element.txtar
│ ├── coglet_list_path_upload_url.txtar
│ ├── coglet_metrics.txtar
│ ├── coglet_metrics_webhook.txtar
│ ├── coglet_single_path_output.txtar
│ ├── complex_output.txtar
│ ├── concatenate_iterator_output.txtar
│ ├── config_subdirectory.txtar
│ ├── debug_secrets.txtar
│ ├── dict_output.txtar
│ ├── emit_metric_deprecated.txtar
│ ├── env_vars.txtar
│ ├── experimental_feature_warning.txtar
│ ├── ffmpeg_package.txtar
│ ├── file_input.txtar
│ ├── file_list_input.txtar
│ ├── float_input_output.txtar
│ ├── function_predictor.txtar
│ ├── future_annotations.txtar
│ ├── glb_project.txtar
│ ├── granite_project.txtar
│ ├── healthcheck.txtar
│ ├── healthcheck_async.txtar
│ ├── healthcheck_async_exception.txtar
│ ├── healthcheck_async_timeout.txtar
│ ├── healthcheck_async_unhealthy.txtar
│ ├── healthcheck_during_prediction.txtar
│ ├── healthcheck_exception.txtar
│ ├── healthcheck_immediately_after_prediction.txtar
│ ├── healthcheck_repeated_calls.txtar
│ ├── healthcheck_timeout.txtar
│ ├── healthcheck_unhealthy.txtar
│ ├── int_input_output.txtar
│ ├── int_none_output.txtar
│ ├── int_predictor.txtar
│ ├── invalid_int_validation.txtar
│ ├── iterator_error_midstream.txtar
│ ├── iterator_string_output.txtar
│ ├── legacy_sdk_schema.txtar
│ ├── list_int_input_output.txtar
│ ├── list_string_output.txtar
│ ├── many_inputs.txtar
│ ├── multi_file_schema.txtar
│ ├── nested_output_types.txtar
│ ├── no_predictor.txtar
│ ├── non_base_predictor_class.txtar
│ ├── non_base_predictor_function.txtar
│ ├── oci_bundle_build.txtar
│ ├── oci_bundle_inspect.txtar
│ ├── oci_bundle_push.txtar
│ ├── optional_path_input.txtar
│ ├── path_input.txtar
│ ├── path_input_output.txtar
│ ├── path_list_input.txtar
│ ├── path_list_output.txtar
│ ├── path_output.txtar
│ ├── predict_existing_image.txtar
│ ├── predict_json_file.txtar
│ ├── predict_json_input.txtar
│ ├── predict_json_output_file.txtar
│ ├── predict_json_stdin.txtar
│ ├── predict_json_stdin_dash.txtar
│ ├── predict_many_inputs_image.txtar
│ ├── predict_output_file.txtar
│ ├── predict_output_string.txtar
│ ├── predict_sys_exit.txtar
│ ├── prediction_error_response.txtar
│ ├── pty_echo.txtar
│ ├── pty_interactive.txtar
│ ├── pydantic2.txtar
│ ├── pydantic2_output.txtar
│ ├── python313.txtar
│ ├── python37_deprecated.txtar
│ ├── python38_deprecated.txtar
│ ├── python39_deprecated.txtar
│ ├── run_basic.txtar
│ ├── run_stdin_cat.txtar
│ ├── run_stdin_unconsumed.txtar
│ ├── scope_context.txtar
│ ├── secrets.txtar
│ ├── sequential_state_leak.txtar
│ ├── setup_slow_serial.txtar
│ ├── setup_subprocess_double_fork.txtar
│ ├── setup_subprocess_double_fork_http.txtar
│ ├── setup_subprocess_multiprocessing.txtar
│ ├── setup_subprocess_simple.txtar
│ ├── setup_timeout_serial.txtar
│ ├── setup_worker_tracing_logs.txtar
│ ├── static_schema_fallback.txtar
│ ├── static_schema_gen.txtar
│ ├── string_list_input.txtar
│ ├── string_none_output.txtar
│ ├── string_predictor.txtar
│ ├── subdirectory_predictor.txtar
│ ├── tensorflow.txtar
│ ├── torch_270_cuda_126.txtar
│ ├── torch_271_cuda_128.txtar
│ ├── torch_baseimage_fallback.txtar
│ ├── torch_baseimage_no_cog_base.txtar
│ ├── torch_baseimage_precompile.txtar
│ ├── torch_cuda_baseimage.txtar
│ ├── train_basic.txtar
│ ├── train_deprecated.txtar
│ ├── training_setup.txtar
│ ├── union_type.txtar
│ ├── webhook_delivery_failure.txtar
│ ├── webhook_prediction_error.txtar
│ ├── weights_build.txtar
│ ├── weights_push_inspect.txtar
│ ├── wheel_coglet_missing.txtar
│ ├── wheel_resolution.txtar
│ └── zsh_package.txtar
├── mise.toml
├── mkdocs.yml
├── noxfile.py
├── pkg/
│ ├── cli/
│ │ ├── baseimage.go
│ │ ├── build.go
│ │ ├── debug.go
│ │ ├── init-templates/
│ │ │ └── base/
│ │ │ ├── .dockerignore
│ │ │ ├── .github/
│ │ │ │ └── workflows/
│ │ │ │ └── push.yaml
│ │ │ ├── cog.yaml
│ │ │ ├── predict.py
│ │ │ └── requirements.txt
│ │ ├── init.go
│ │ ├── init_test.go
│ │ ├── inspect.go
│ │ ├── login.go
│ │ ├── predict.go
│ │ ├── predict_test.go
│ │ ├── push.go
│ │ ├── root.go
│ │ ├── run.go
│ │ ├── serve.go
│ │ ├── train.go
│ │ ├── train_test.go
│ │ ├── weights.go
│ │ └── weights_inspect.go
│ ├── config/
│ │ ├── build_options.go
│ │ ├── compatibility.go
│ │ ├── compatibility_test.go
│ │ ├── config.go
│ │ ├── config_file.go
│ │ ├── config_test.go
│ │ ├── cuda_compatibility.json
│ │ ├── data/
│ │ │ └── config_schema_v1.0.json
│ │ ├── env.go
│ │ ├── env_variables_test.go
│ │ ├── errors.go
│ │ ├── image_name.go
│ │ ├── image_name_test.go
│ │ ├── load.go
│ │ ├── load_test.go
│ │ ├── parse.go
│ │ ├── tf_compatibility.json
│ │ ├── torch_compatibility.json
│ │ ├── validate.go
│ │ ├── validate_test.go
│ │ └── version.go
│ ├── docker/
│ │ ├── build_secrets.go
│ │ ├── buildkit.go
│ │ ├── command/
│ │ │ ├── command.go
│ │ │ ├── errors.go
│ │ │ ├── manifest.go
│ │ │ └── user_info.go
│ │ ├── credential_helper_input.go
│ │ ├── credentials.go
│ │ ├── credentials_test.go
│ │ ├── docker.go
│ │ ├── docker_client_test.go
│ │ ├── dockertest/
│ │ │ ├── command_mocks.go
│ │ │ ├── helper_client.go
│ │ │ ├── image.go
│ │ │ ├── mock_command.go
│ │ │ ├── ref.go
│ │ │ ├── ref_test.go
│ │ │ └── testdata/
│ │ │ └── create-image-fixtures.sh
│ │ ├── env.go
│ │ ├── errors.go
│ │ ├── host.go
│ │ ├── host_unix.go
│ │ ├── host_windows.go
│ │ ├── login.go
│ │ ├── options.go
│ │ ├── progress.go
│ │ ├── push.go
│ │ ├── run.go
│ │ ├── run_test.go
│ │ ├── standard_push.go
│ │ └── standard_push_test.go
│ ├── dockercontext/
│ │ ├── build_tempdir.go
│ │ ├── build_tempdir_test.go
│ │ └── directories.go
│ ├── dockerfile/
│ │ ├── base.go
│ │ ├── base_test.go
│ │ ├── cacert.go
│ │ ├── cacert_test.go
│ │ ├── env.go
│ │ ├── generator.go
│ │ ├── generator_factory.go
│ │ ├── generator_factory_test.go
│ │ ├── standard_generator.go
│ │ ├── standard_generator_test.go
│ │ └── version_check.go
│ ├── dockerignore/
│ │ ├── dockerignore.go
│ │ └── dockerignore_test.go
│ ├── env/
│ │ ├── env.go
│ │ └── env_test.go
│ ├── errors/
│ │ ├── common.go
│ │ └── errors.go
│ ├── global/
│ │ └── global.go
│ ├── http/
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── transport.go
│ │ ├── transport_test.go
│ │ ├── user_agent.go
│ │ └── user_agent_test.go
│ ├── image/
│ │ ├── build.go
│ │ ├── build_test.go
│ │ ├── config.go
│ │ ├── openapi_schema.go
│ │ └── pip_freeze.go
│ ├── model/
│ │ ├── artifact.go
│ │ ├── artifact_image.go
│ │ ├── artifact_image_test.go
│ │ ├── artifact_test.go
│ │ ├── artifact_weight.go
│ │ ├── artifact_weight_test.go
│ │ ├── builder.go
│ │ ├── builder_test.go
│ │ ├── errors.go
│ │ ├── errors_test.go
│ │ ├── factory.go
│ │ ├── factory_test.go
│ │ ├── format.go
│ │ ├── format_test.go
│ │ ├── hash.go
│ │ ├── image_builder.go
│ │ ├── image_builder_test.go
│ │ ├── image_pusher.go
│ │ ├── image_pusher_test.go
│ │ ├── image_test.go
│ │ ├── index.go
│ │ ├── index_factory.go
│ │ ├── index_factory_test.go
│ │ ├── index_test.go
│ │ ├── model.go
│ │ ├── model_test.go
│ │ ├── options.go
│ │ ├── options_test.go
│ │ ├── push_helpers.go
│ │ ├── pusher.go
│ │ ├── pusher_test.go
│ │ ├── ref.go
│ │ ├── ref_test.go
│ │ ├── ref_types.go
│ │ ├── ref_types_test.go
│ │ ├── resolver.go
│ │ ├── resolver_test.go
│ │ ├── source.go
│ │ ├── source_test.go
│ │ ├── weight_builder.go
│ │ ├── weight_builder_test.go
│ │ ├── weight_pusher.go
│ │ ├── weight_pusher_test.go
│ │ ├── weights.go
│ │ ├── weights_lock.go
│ │ ├── weights_lock_test.go
│ │ └── weights_test.go
│ ├── path/
│ │ ├── path.go
│ │ └── path_test.go
│ ├── predict/
│ │ ├── api.go
│ │ ├── input.go
│ │ └── predictor.go
│ ├── provider/
│ │ ├── generic/
│ │ │ ├── generic.go
│ │ │ └── generic_test.go
│ │ ├── provider.go
│ │ ├── registry.go
│ │ ├── registry_test.go
│ │ ├── replicate/
│ │ │ ├── replicate.go
│ │ │ └── replicate_test.go
│ │ └── setup/
│ │ ├── setup.go
│ │ └── setup_test.go
│ ├── registry/
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── config.go
│ │ ├── config_test.go
│ │ ├── manifest_result.go
│ │ ├── push_test.go
│ │ ├── registry_client.go
│ │ └── registrytest/
│ │ └── mock_client.go
│ ├── registry_testhelpers/
│ │ ├── registry_container.go
│ │ └── testdata/
│ │ └── docker/
│ │ └── registry/
│ │ └── v2/
│ │ ├── blobs/
│ │ │ └── sha256/
│ │ │ ├── 1c/
│ │ │ │ └── 1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474/
│ │ │ │ └── data
│ │ │ ├── 6e/
│ │ │ │ └── 6e771e15690e2fabf2332d3a3b744495411d6e0b00b2aea64419b58b0066cf81/
│ │ │ │ └── data
│ │ │ ├── 75/
│ │ │ │ └── 757d680068d77be46fd1ea20fb21db16f150468c5e7079a08a2e4705aec096ac/
│ │ │ │ └── data
│ │ │ ├── 8d/
│ │ │ │ └── 8d591b0b7dea080ea3be9e12ae563eebf9869168ffced1cb25b2470a3d9fe15e/
│ │ │ │ └── data
│ │ │ ├── 9a/
│ │ │ │ └── 9a0ff41dccad7a96f324a4655a715c623ed3511c7336361ffa9dadcecbdb99e5/
│ │ │ │ └── data
│ │ │ ├── ad/
│ │ │ │ └── aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b/
│ │ │ │ └── data
│ │ │ └── f1/
│ │ │ └── f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870/
│ │ │ └── data
│ │ └── repositories/
│ │ └── alpine/
│ │ ├── _layers/
│ │ │ └── sha256/
│ │ │ ├── 6e771e15690e2fabf2332d3a3b744495411d6e0b00b2aea64419b58b0066cf81/
│ │ │ │ └── link
│ │ │ ├── 8d591b0b7dea080ea3be9e12ae563eebf9869168ffced1cb25b2470a3d9fe15e/
│ │ │ │ └── link
│ │ │ ├── aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b/
│ │ │ │ └── link
│ │ │ └── f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870/
│ │ │ └── link
│ │ └── _manifests/
│ │ ├── revisions/
│ │ │ └── sha256/
│ │ │ ├── 1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474/
│ │ │ │ └── link
│ │ │ ├── 757d680068d77be46fd1ea20fb21db16f150468c5e7079a08a2e4705aec096ac/
│ │ │ │ └── link
│ │ │ └── 9a0ff41dccad7a96f324a4655a715c623ed3511c7336361ffa9dadcecbdb99e5/
│ │ │ └── link
│ │ └── tags/
│ │ └── latest/
│ │ ├── current/
│ │ │ └── link
│ │ └── index/
│ │ └── sha256/
│ │ └── 9a0ff41dccad7a96f324a4655a715c623ed3511c7336361ffa9dadcecbdb99e5/
│ │ └── link
│ ├── requirements/
│ │ ├── requirements.go
│ │ └── requirements_test.go
│ ├── schema/
│ │ ├── errors.go
│ │ ├── generator.go
│ │ ├── generator_test.go
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── python/
│ │ │ ├── parser.go
│ │ │ ├── parser_fuzz_test.go
│ │ │ └── parser_test.go
│ │ ├── schema_type.go
│ │ ├── schema_type_fuzz_test.go
│ │ └── types.go
│ ├── update/
│ │ ├── state.go
│ │ └── update.go
│ ├── util/
│ │ ├── console/
│ │ │ ├── console.go
│ │ │ ├── formatting.go
│ │ │ ├── global.go
│ │ │ ├── interactive.go
│ │ │ ├── levels.go
│ │ │ └── term.go
│ │ ├── env.go
│ │ ├── errors.go
│ │ ├── files/
│ │ │ ├── files.go
│ │ │ └── files_test.go
│ │ ├── hash.go
│ │ ├── hash_test.go
│ │ ├── mime/
│ │ │ ├── mime.go
│ │ │ └── mime_test.go
│ │ ├── net.go
│ │ ├── overwrite_yaml.go
│ │ ├── overwrite_yaml_test.go
│ │ ├── platform.go
│ │ ├── ringbuffer.go
│ │ ├── shell/
│ │ │ ├── net.go
│ │ │ └── pipes.go
│ │ └── version/
│ │ ├── version.go
│ │ └── version_test.go
│ ├── web/
│ │ ├── client.go
│ │ └── client_test.go
│ ├── weights/
│ │ ├── manifest.go
│ │ ├── weights.go
│ │ └── weights_test.go
│ └── wheels/
│ ├── wheels.go
│ └── wheels_test.go
├── pyproject.toml
├── python/
│ ├── cog/
│ │ ├── .gitignore
│ │ ├── __init__.py
│ │ ├── _adt.py
│ │ ├── _inspector.py
│ │ ├── _schemas.py
│ │ ├── coder.py
│ │ ├── command/
│ │ │ ├── __init__.py
│ │ │ └── openapi_schema.py
│ │ ├── config.py
│ │ ├── errors.py
│ │ ├── input.py
│ │ ├── mode.py
│ │ ├── model.py
│ │ ├── predictor.py
│ │ ├── server/
│ │ │ ├── __init__.py
│ │ │ └── http.py
│ │ ├── suppress_output.py
│ │ └── types.py
│ └── tests/
│ ├── __init__.py
│ ├── test_emit_metric.py
│ ├── test_experimental_feature_warning.py
│ ├── test_input.py
│ ├── test_model.py
│ ├── test_predictor.py
│ └── test_types.py
├── script/
│ └── generate-compat
├── test-helpers/
│ └── https-server/
│ ├── go.mod
│ └── main.go
├── test-integration/
│ └── test_integration/
│ └── fixtures/
│ └── hello-image/
│ ├── cog.yaml
│ └── predict.py
└── tools/
├── compatgen/
│ ├── internal/
│ │ ├── cuda.go
│ │ ├── tensorflow.go
│ │ ├── torch.go
│ │ ├── torch_package.go
│ │ ├── torch_test.go
│ │ ├── torch_test.html
│ │ └── util.go
│ └── main.go
├── gendocs/
│ └── main.go
├── install.sh
├── test-harness/
│ ├── .gitignore
│ ├── README.md
│ ├── harness/
│ │ ├── __init__.py
│ │ ├── __main__.py
│ │ ├── cli.py
│ │ ├── cog_resolver.py
│ │ ├── patcher.py
│ │ ├── report.py
│ │ ├── runner.py
│ │ └── validators.py
│ ├── manifest.yaml
│ ├── pyproject.toml
│ └── results/
│ └── .gitkeep
├── test-registry-util/
│ ├── README.md
│ └── main.go
└── weights-gen/
├── README.md
└── main.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .all-contributorsrc
================================================
{
"projectName": "cog",
"projectOwner": "replicate",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"commitConvention": "none",
"contributors": [
{
"login": "bfirsh",
"name": "Ben Firshman",
"avatar_url": "https://avatars.githubusercontent.com/u/40906?v=4",
"profile": "https://fir.sh/",
"contributions": [
"code",
"doc"
]
},
{
"login": "andreasjansson",
"name": "Andreas Jansson",
"avatar_url": "https://avatars.githubusercontent.com/u/713993?v=4",
"profile": "https://replicate.ai/",
"contributions": [
"code",
"doc",
"maintenance"
]
},
{
"login": "zeke",
"name": "Zeke Sikelianos",
"avatar_url": "https://avatars.githubusercontent.com/u/2289?v=4",
"profile": "http://zeke.sikelianos.com/",
"contributions": [
"code",
"doc",
"tool"
]
},
{
"login": "synek",
"name": "Rory Byrne",
"avatar_url": "https://avatars.githubusercontent.com/u/9436784?v=4",
"profile": "https://rory.bio/",
"contributions": [
"code",
"doc",
"test"
]
},
{
"login": "hangtwenty",
"name": "Michael Floering",
"avatar_url": "https://avatars.githubusercontent.com/u/2420688?v=4",
"profile": "https://github.com/hangtwenty",
"contributions": [
"code",
"doc",
"ideas"
]
},
{
"login": "bencevans",
"name": "Ben Evans",
"avatar_url": "https://avatars.githubusercontent.com/u/638535?v=4",
"profile": "https://bencevans.io/",
"contributions": [
"doc"
]
},
{
"login": "imshashank",
"name": "shashank agarwal",
"avatar_url": "https://avatars.githubusercontent.com/u/778870?v=4",
"profile": "https://shashank.pw/",
"contributions": [
"code",
"doc"
]
},
{
"login": "VictorXLR",
"name": "VictorXLR",
"avatar_url": "https://avatars.githubusercontent.com/u/22397950?v=4",
"profile": "https://victorxlr.me/",
"contributions": [
"code",
"doc",
"test"
]
},
{
"login": "annahung31",
"name": "hung anna",
"avatar_url": "https://avatars.githubusercontent.com/u/39179888?v=4",
"profile": "https://annahung31.github.io/",
"contributions": [
"bug"
]
},
{
"login": "bwhitman",
"name": "Brian Whitman",
"avatar_url": "https://avatars.githubusercontent.com/u/76612?v=4",
"profile": "http://notes.variogr.am/",
"contributions": [
"bug"
]
},
{
"login": "JimothyJohn",
"name": "JimothyJohn",
"avatar_url": "https://avatars.githubusercontent.com/u/24216724?v=4",
"profile": "https://github.com/JimothyJohn",
"contributions": [
"bug"
]
},
{
"login": "ericguizzo",
"name": "ericguizzo",
"avatar_url": "https://avatars.githubusercontent.com/u/26746670?v=4",
"profile": "https://github.com/ericguizzo",
"contributions": [
"bug"
]
},
{
"login": "evilstreak",
"name": "Dominic Baggott",
"avatar_url": "https://avatars.githubusercontent.com/u/74812?v=4",
"profile": "http://www.dominicbaggott.com",
"contributions": [
"code",
"test"
]
},
{
"login": "dashstander",
"name": "Dashiell Stander",
"avatar_url": "https://avatars.githubusercontent.com/u/7449128?v=4",
"profile": "https://github.com/dashstander",
"contributions": [
"bug",
"code",
"test"
]
},
{
"login": "Hurricane-eye",
"name": "Shuwei Liang",
"avatar_url": "https://avatars.githubusercontent.com/u/31437546?v=4",
"profile": "https://github.com/Hurricane-eye",
"contributions": [
"bug",
"question"
]
},
{
"login": "ericallam",
"name": "Eric Allam",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"profile": "https://github.com/ericallam",
"contributions": [
"ideas"
]
},
{
"login": "iperdomo",
"name": "Iván Perdomo",
"avatar_url": "https://avatars.githubusercontent.com/u/178474?v=4",
"profile": "https://perdomo.me",
"contributions": [
"bug"
]
},
{
"login": "charlesfrye",
"name": "Charles Frye",
"avatar_url": "https://avatars.githubusercontent.com/u/10442975?v=4",
"profile": "http://charlesfrye.github.io",
"contributions": [
"doc"
]
},
{
"login": "phamquiluan",
"name": "Luan Pham",
"avatar_url": "https://avatars.githubusercontent.com/u/24642166?v=4",
"profile": "https://github.com/phamquiluan",
"contributions": [
"bug",
"doc"
]
},
{
"login": "TommyDew42",
"name": "TommyDew",
"avatar_url": "https://avatars.githubusercontent.com/u/46992350?v=4",
"profile": "https://github.com/TommyDew42",
"contributions": [
"code"
]
},
{
"login": "anotherjesse",
"name": "Jesse Andrews",
"avatar_url": "https://avatars.githubusercontent.com/u/27?v=4",
"profile": "https://m4ke.org",
"contributions": [
"code",
"doc",
"test"
]
},
{
"login": "nickstenning",
"name": "Nick Stenning",
"avatar_url": "https://avatars.githubusercontent.com/u/3602?v=4",
"profile": "https://whiteink.com",
"contributions": [
"code",
"doc",
"design",
"infra",
"test"
]
},
{
"login": "justinmerrell",
"name": "Justin Merrell",
"avatar_url": "https://avatars.githubusercontent.com/u/14996837?v=4",
"profile": "https://merrell.io/",
"contributions": [
"doc"
]
},
{
"login": "ruriky",
"name": "Rurik Ylä-Onnenvuori",
"avatar_url": "https://avatars.githubusercontent.com/u/19946546?v=4",
"profile": "https://github.com/ruriky",
"contributions": [
"bug"
]
},
{
"login": "youkaclub",
"name": "Youka",
"avatar_url": "https://avatars.githubusercontent.com/u/59315275?v=4",
"profile": "https://www.youka.club/",
"contributions": [
"bug"
]
},
{
"login": "afiaka87",
"name": "Clay Mullis",
"avatar_url": "https://avatars.githubusercontent.com/u/3994972?v=4",
"profile": "https://github.com/afiaka87",
"contributions": [
"doc"
]
},
{
"login": "mattt",
"name": "Mattt",
"avatar_url": "https://avatars.githubusercontent.com/u/7659?v=4",
"profile": "https://github.com/mattt",
"contributions": [
"code",
"doc",
"infra"
]
},
{
"login": "Juneezee",
"name": "Eng Zer Jun",
"avatar_url": "https://avatars.githubusercontent.com/u/20135478?v=4",
"profile": "https://github.com/Juneezee",
"contributions": [
"test"
]
},
{
"login": "bbedward",
"name": "BB",
"avatar_url": "https://avatars.githubusercontent.com/u/550752?v=4",
"profile": "https://github.com/bbedward",
"contributions": [
"code"
]
},
{
"login": "williamluer",
"name": "williamluer",
"avatar_url": "https://avatars.githubusercontent.com/u/85975676?v=4",
"profile": "https://github.com/williamluer",
"contributions": [
"doc"
]
},
{
"login": "sirupsen",
"name": "Simon Eskildsen",
"avatar_url": "https://avatars.githubusercontent.com/u/97400?v=4",
"profile": "http://sirupsen.com",
"contributions": [
"code"
]
},
{
"login": "erbridge",
"name": "F",
"avatar_url": "https://avatars.githubusercontent.com/u/1027364?v=4",
"profile": "https://erbridge.co.uk",
"contributions": [
"bug",
"code"
]
},
{
"login": "philandstuff",
"name": "Philip Potter",
"avatar_url": "https://avatars.githubusercontent.com/u/581269?v=4",
"profile": "https://github.com/philandstuff",
"contributions": [
"bug",
"code"
]
},
{
"login": "joannejchen",
"name": "Joanne Chen",
"avatar_url": "https://avatars.githubusercontent.com/u/33409024?v=4",
"profile": "https://github.com/joannejchen",
"contributions": [
"doc"
]
},
{
"login": "technillogue",
"name": "technillogue",
"avatar_url": "https://avatars.githubusercontent.com/u/945691?v=4",
"profile": "http://technillogue.github.io",
"contributions": [
"code"
]
},
{
"login": "aron",
"name": "Aron Carroll",
"avatar_url": "https://avatars.githubusercontent.com/u/47144?v=4",
"profile": "http://aroncarroll.com",
"contributions": [
"doc",
"code",
"ideas"
]
},
{
"login": "Theodotus1243",
"name": "Bohdan Mykhailenko",
"avatar_url": "https://avatars.githubusercontent.com/u/32220358?v=4",
"profile": "https://github.com/Theodotus1243",
"contributions": [
"doc",
"bug"
]
},
{
"login": "one1zero1one",
"name": "Daniel Radu",
"avatar_url": "https://avatars.githubusercontent.com/u/724604?v=4",
"profile": "https://github.com/one1zero1one",
"contributions": [
"doc",
"bug"
]
},
{
"login": "Etelis",
"name": "Itay Etelis",
"avatar_url": "https://avatars.githubusercontent.com/u/92247226?v=4",
"profile": "https://github.com/Etelis",
"contributions": [
"code"
]
},
{
"login": "gschian0",
"name": "Gennaro Schiano",
"avatar_url": "https://avatars.githubusercontent.com/u/54407820?v=4",
"profile": "http://www.wavefunction.dev",
"contributions": [
"doc"
]
},
{
"login": "aknoerig",
"name": "André Knörig",
"avatar_url": "https://avatars.githubusercontent.com/u/481350?v=4",
"profile": "http://andreknoerig.de",
"contributions": [
"doc"
]
},
{
"login": "danfairs",
"name": "Dan Fairs",
"avatar_url": "https://avatars.githubusercontent.com/u/24726?v=4",
"profile": "https://condense.live",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
"skipCi": true,
"commitType": "docs"
}
================================================
FILE: .git_archival.txt
================================================
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
================================================
FILE: .gitattributes
================================================
.git_archival.txt export-subst
Makefile -linguist-detectable
docs/llms.txt linguist-generated=true
================================================
FILE: .github/CODEOWNERS
================================================
# Default code owners for the entire repository
* @replicate/cog
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
allow:
- dependency-type: "direct"
- package-ecosystem: "cargo"
directory: "/crates"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
================================================
FILE: .github/workflows/README.md
================================================
# CI Architecture
This document describes the CI/CD architecture for the Cog repository.
## Design Principles
1. **Single gate job** - Branch protection uses one required check (`ci-complete`) that depends on all other jobs
2. **Path-based filtering** - Jobs skip when irrelevant files change (Go changes don't trigger Rust tests)
3. **Build once, test many** - Artifacts built once and reused across test jobs
4. **Parallel execution** - Independent jobs run concurrently
5. **Skipped = passing** - Jobs that skip due to path filtering count as passing for the gate
## Workflows
### `ci.yaml` - Main CI Pipeline
The primary CI workflow that runs on all PRs and pushes to main.
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ CHANGES DETECTION │
│ Determines which components changed: go, rust, python, integration-tests │
└─────────────────────────────────────────────────────────────────────────────┘
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│build-rust│ │ build-sdk│ │ (none) │
│ (wheel) │ │ (wheel) │ │ │
└────┬─────┘ └────┬─────┘ └──────────┘
│ │
┌─────────────┼────────────────┼─────────────────────┐
│ │ │ │
▼ ▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌───────────┐ ┌───────────┐
│fmt-rust │ │test-rust │ │ fmt-go │ │fmt-python │
│lint-rust│ │coglet-py │ │ lint-go │ │lint-python│
│ deny │ │ (matrix) │ │ test-go │ │test-python│
└─────────┘ └────┬─────┘ └───────────┘ └───────────┘
│ │ │
└────────────────┼─────────────────────┘
▼
┌────────────────┐
│test-integration│
│ (matrix) │
└───────┬────────┘
▼
┌───────────────┐
│ ci-complete │ ← Branch protection requires this
└───────────────┘
```
#### Jobs
| Job | Runs when | Depends on | Purpose |
|-----|-----------|------------|---------|
| `changes` | Always | - | Detect which components changed |
| `build-sdk` | python changed | changes | Build cog SDK wheel |
| `build-rust` | rust changed | changes | Build coglet ABI3 wheel |
| `fmt-go` | go changed | changes | Check Go formatting |
| `fmt-rust` | rust changed | changes | Check Rust formatting |
| `fmt-python` | python changed | changes | Check Python formatting |
| `lint-go` | go changed | changes | Lint Go code |
| `lint-rust` | rust changed | changes | Run clippy |
| `lint-rust-deny` | rust changed | changes | Check licenses/advisories |
| `lint-python` | python changed | build-sdk | Lint Python code |
| `test-go` | go changed | build-sdk | Run Go tests (matrix: ubuntu, macos) |
| `test-rust` | rust changed | changes | Run Rust tests |
| `test-python` | python changed | build-sdk | Run Python tests (matrix: 3.10-3.13) |
| `test-coglet-python` | rust or python changed | build-rust | Test coglet bindings (matrix: 3.10-3.13) |
| `test-integration` | any changed | build-sdk, build-rust | Integration tests (matrix: cog, cog-rust) |
| `ci-complete` | Always | all jobs | Gate job for branch protection |
#### Python Version Matrix
Python versions are defined once at the workflow level:
```yaml
env:
SUPPORTED_PYTHONS: '["3.10", "3.11", "3.12", "3.13"]'
```
Jobs that need the matrix reference it via `fromJson(env.SUPPORTED_PYTHONS)`.
### `codeql.yml` - Security Analysis
Runs CodeQL security scanning for Go, Python, and Rust.
- **Triggers**: Push to main, PRs to main, weekly schedule
- **Languages**: go, python, rust
### Deleted Workflows
- `rust.yaml` - Consolidated into `ci.yaml`. The separate workflow was redundant.
- `pypi-package.yaml` - Replaced by `release-build.yaml` + `release-publish.yaml`.
- `version-bump.yaml` - Removed. Just edit `crates/Cargo.toml` directly.
## Caching Strategy
### Rust Cache
- **Save**: Only on `main` branch pushes (to avoid PR cache pollution)
- **Restore**: On all runs (PRs restore from main's cache)
- Uses `Swatinem/rust-cache@v2` with workspace path `crates -> target`
### Go Cache
- Built into `actions/setup-go` via `cache-dependency-path`
### Python/uv Cache
- Built into `jdx/mise-action` and `astral-sh/setup-uv`
## Artifacts
| Artifact | Contents | Retention |
|----------|----------|-----------|
| `CogPackage` | cog-*.whl, cog-*.tar.gz | Default (90 days) |
| `CogletRustWheel` | coglet-*-cp310-abi3-*.whl | Default (90 days) |
The ABI3 wheel is built with Python 3.10 minimum but works on all 3.10+ versions.
## Local Development
Use mise tasks to run the same checks locally:
```bash
# Format (check)
mise run fmt
# Format (fix)
mise run fmt:fix
# Lint
mise run lint
# Test
mise run test:go
mise run test:rust
mise run test:python
# Build
mise run build:cog
mise run build:coglet
mise run build:sdk
```
## Adding New Checks
1. Add a mise task in `mise.toml`
2. Add a job in `ci.yaml` with appropriate `needs` and path filtering
3. Add the job to `ci-complete`'s needs list
4. Update this README
## Branch Protection
Configure branch protection to require only `ci-complete`:
```
Settings > Branches > main > Require status checks:
✓ ci-complete
```
Skipped jobs (from path filtering) are treated as passing by the gate job.
## Release Workflow
Releases use a two-workflow system. There are three release types:
| Type | Example tag | Branch rule | Draft? | PyPI/crates.io? |
|------|-------------|-------------|--------|-----------------|
| **Stable** | `v0.17.0` | Must be on main | Yes (manual publish) | Yes |
| **Pre-release** | `v0.17.0-alpha3` | Must be on main | Yes (manual publish) | Yes |
| **Dev** | `v0.17.0-dev1` | Any branch | No (immediate) | No |
### Stable / Pre-release Flow
```
Developer pushes tag on main (e.g. v0.17.0, v0.17.0-rc1)
│
▼
release-build.yaml (automatic)
┌──────────────────────────────────────────────┐
│ verify-tag ──▶ build-sdk ──┐ │
│ (must be build-coglet ┼──▶ create- │
│ main) build-CLI ──┘ release │
│ (DRAFT) │
└──────────────────────────────────────────────┘
│
Maintainer publishes draft in GitHub UI
│
▼
release-publish.yaml (automatic)
┌──────────────────────────────────────────────┐
│ coglet → PyPI ──▶ SDK → PyPI │
│ coglet → crates.io │
└──────────────────────────────────────────────┘
```
### Dev Release Flow
```
Developer pushes tag from any branch (e.g. v0.17.0-dev1)
│
▼
release-build.yaml (automatic)
┌──────────────────────────────────────────────┐
│ verify-tag ──▶ build-sdk ──┐ │
│ (no branch build-coglet ┼──▶ create- │
│ restriction) build-CLI ──┘ release │
│ (PRE- │
│ RELEASE) │
└──────────────────────────────────────────────┘
│
Done. No PyPI/crates.io.
Wheels + CLI binaries on GH release.
```
### Workflows
#### `release-build.yaml`
Triggered by version tags (`v*.*.*`). Builds all artifacts and creates a GitHub release.
| Job | Purpose |
|-----|---------|
| `verify-tag` | Cargo.toml version match + branch rules (main for stable/pre-release, any for dev) |
| `build-sdk` | Build cog SDK wheel and sdist |
| `build-coglet-wheels` | Build coglet wheels (3 platforms via zig cross-compile) |
| `create-release` | Goreleaser builds CLI + creates release, then appends wheels. Dev releases are immediately published as pre-release; stable/pre-release remain as draft. |
**Security**: No secrets needed for dev. Stable/pre-release require maintainer to publish draft.
#### `release-publish.yaml`
Triggered when a release is published. Publishes to PyPI and crates.io.
**Skips entirely for dev releases** (all jobs gated on `is_dev != true`).
| Job | Depends on | Purpose |
|-----|------------|---------|
| `verify-release` | - | Validate tag format, classify release type |
| `publish-pypi-coglet` | verify-release | Publish coglet to PyPI (trusted publishing) |
| `publish-pypi-sdk` | publish-pypi-coglet | Publish SDK to PyPI (waits for coglet) |
| `publish-crates-io` | verify-release | Publish coglet crate (OIDC) |
| `update-homebrew-tap` | publish-pypi-sdk, publish-crates-io | Update `replicate/homebrew-tap` cask (stable only, macOS, via GH App) |
### Package Versioning
All packages use **lockstep versioning** from `crates/Cargo.toml`.
| Package | Registry | Version format | Example |
|---------|----------|----------------|---------|
| cog SDK | PyPI | PEP 440 | `cog==0.17.0`, `cog==0.17.0a3`, `cog==0.17.0.dev1` |
| coglet | PyPI | PEP 440 | `coglet==0.17.0`, `coglet==0.17.0a3` |
| coglet | crates.io | semver | `coglet@0.17.0`, `coglet@0.17.0-alpha3` |
| CLI | GitHub Release | semver | `cog v0.17.0`, `cog v0.17.0-dev1` |
**Version conversion** (semver -> PEP 440):
- `0.17.0-alpha3` -> `0.17.0a3`
- `0.17.0-beta1` -> `0.17.0b1`
- `0.17.0-rc1` -> `0.17.0rc1`
- `0.17.0-dev1` -> `0.17.0.dev1`
- `0.17.0` -> `0.17.0`
### SDK Wheel Sourcing
The CLI installs the cog SDK from PyPI at container build time:
| Scenario | COG_SDK_WHEEL env var | Behavior |
|----------|-----------------------|----------|
| Released CLI | (unset) | Install latest `cog` from PyPI |
| Dev CLI (in repo) | (unset) | Auto-detect `dist/cog-*.whl` if present, else PyPI |
| Force PyPI | `pypi` | Install latest from PyPI |
| Specific version | `pypi:0.12.0` | Install `cog==0.12.0` from PyPI |
| Local wheel | `/path/to/cog.whl` | Install from local file |
| Force dist | `dist` | Install from `dist/` (error if missing) |
Same pattern for `COGLET_WHEEL` (but coglet is optional by default).
### GitHub Environment Setup
1. Create environments in **Settings -> Environments**:
- `pypi` - For PyPI publishing (trusted publishing, no secrets)
- `crates-io` - For crates.io publishing (trusted publishing, no secrets)
2. Configure protection rules for each environment:
- **Deployment branches**: "Selected branches and tags"
- **Add pattern**: `v*` (restricts to version tags)
- **Required reviewers**: Add maintainers
3. Configure trusted publishers:
- **PyPI** (both `cog` and `coglet`): workflow `release-publish.yaml`, environment `pypi`
- **crates.io** (`coglet`): workflow `release-publish.yaml`, environment `crates-io`
4. Configure the Homebrew tap GitHub App:
- App: `cog-homebrew-tapbot` (ID: 1232932405)
- Create environment `homebrew` with secret `COG_HOMEBREW_TAP_PRIVATE_KEY` (app private key)
- App must have write access to `replicate/homebrew-tap`
### Performing a Stable / Pre-release
```bash
# 1. Update crates/Cargo.toml version (e.g. "0.17.0" or "0.17.0-alpha3")
# 2. Merge to main
# 3. Tag and push
git tag v0.17.0
git push origin v0.17.0
# 4. Wait for release-build.yaml to complete (creates draft release)
# 5. Review the draft release in GitHub UI
# 6. Click "Publish release" -> triggers release-publish.yaml -> PyPI + crates.io
```
### Performing a Dev Release
```bash
# From any branch:
# 1. Update crates/Cargo.toml version (e.g. "0.17.0-dev1")
# 2. Commit and push
# 3. Tag and push
git tag v0.17.0-dev1
git push origin v0.17.0-dev1
# 4. Done. release-build.yaml creates a pre-release with all artifacts.
# No PyPI/crates.io publishing. No manual approval needed.
```
================================================
FILE: .github/workflows/ci.yaml
================================================
name: CI
on:
merge_group:
push:
branches: [main]
pull_request:
workflow_dispatch:
# Cancel in-progress runs for PRs, queue for merge group and main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-v2
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# Single source of truth for supported Python versions
SUPPORTED_PYTHONS: '["3.10", "3.11", "3.12", "3.13"]'
# Default Python version for non-matrix jobs
PYTHON_VERSION: "3.13"
# Minimum supported Python — used for ABI3 wheel builds and glob patterns.
# Must match the lowest entry in SUPPORTED_PYTHONS.
MINIMUM_PYTHON: "3.10"
# Number of runners to shard integration tests across (per runtime)
# Slow tests ([short] skip) are distributed round-robin first, then fast tests fill in
NUM_IT_RUNNER_SHARDS: "4"
# Standard environment
HYPOTHESIS_PROFILE: ci
FORCE_COLOR: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
CARGO_TERM_COLOR: always
# CGo required for go-tree-sitter (static Python schema parser)
CGO_ENABLED: "1"
# Disable tools in mise that CI installs via dedicated GitHub Actions for
# better reliability (avoids transient GitHub Releases 502s from aqua downloads),
# better caching, and guaranteed tool ordering.
# - Rust toolchain: dtolnay/rust-toolchain
# - cargo-binstall: taiki-e/install-action
# - Python: astral-sh/setup-uv
# - golangci-lint: golangci/golangci-lint-action
# - gotestsum: go install (uses Go module proxy, not GitHub Releases)
# - cargo-deny, cargo-nextest: taiki-e/install-action
# - zig, cargo-zigbuild, maturin, cargo-insta: not needed in CI (maturin-action bundles zig)
MISE_DISABLE_TOOLS: rust,rustup,rustup-init,cargo-binstall,python,golangci-lint,gotestsum,cargo-deny,cargo-insta,cargo-nextest,cargo:cargo-nextest,zig,cargo-zigbuild,maturin,cargo:maturin
permissions: {}
# =============================================================================
# Change Detection
# =============================================================================
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
go: ${{ steps.filter.outputs.go }}
rust: ${{ steps.filter.outputs.rust }}
python: ${{ steps.filter.outputs.python }}
integration: ${{ steps.filter.outputs.integration }}
docs: ${{ steps.filter.outputs.docs }}
version_only: ${{ steps.filter.outputs.version_only }}
version_changed: ${{ steps.filter.outputs.version_changed }}
# Pass through for matrix jobs (env context unavailable in strategy)
supported_pythons: ${{ env.SUPPORTED_PYTHONS }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect changed paths
id: filter
run: |
# For PRs, compare against base; for pushes, compare against previous commit;
# for merge_group, compare against the merge group base.
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="${{ github.event.pull_request.base.sha }}"
elif [ "${{ github.event_name }}" = "merge_group" ]; then
BASE="${{ github.event.merge_group.base_sha }}"
else
BASE="${{ github.event.before }}"
# Handle initial push (no before)
if [ "$BASE" = "0000000000000000000000000000000000000000" ]; then
BASE="HEAD~1"
fi
fi
echo "Comparing $BASE..HEAD"
# Get changed files
CHANGED=$(git diff --name-only "$BASE" HEAD 2>/dev/null || echo "")
# Check if coglet version changed
VERSION_CHANGED="false"
if echo "$CHANGED" | grep -qE '^crates/Cargo\.toml$'; then
# Check if only the version line changed
if git diff "$BASE" HEAD -- crates/Cargo.toml | grep -qE '^\+version = '; then
VERSION_CHANGED="true"
echo "Coglet version changed"
fi
fi
echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT
# Check if ONLY the version changed (version bump PR)
# This is true if crates/Cargo.toml is the only file and only version line changed
VERSION_ONLY="false"
if [ "$VERSION_CHANGED" = "true" ]; then
FILE_COUNT=$(echo "$CHANGED" | grep -c . || echo "0")
if [ "$FILE_COUNT" = "1" ]; then
# Only crates/Cargo.toml changed, check if only version line changed
# Get actual diff lines (excluding +++ and --- headers)
DIFF_CONTENT=$(git diff "$BASE" HEAD -- crates/Cargo.toml | grep -E '^[+-]' | grep -v '^[+-]{3}')
# Should be exactly: -version = "old" and +version = "new"
MINUS_LINES=$(echo "$DIFF_CONTENT" | grep -c '^-' || echo "0")
PLUS_LINES=$(echo "$DIFF_CONTENT" | grep -c '^\+' || echo "0")
VERSION_MINUS=$(echo "$DIFF_CONTENT" | grep -c '^-version = ' || echo "0")
VERSION_PLUS=$(echo "$DIFF_CONTENT" | grep -c '^\+version = ' || echo "0")
if [ "$MINUS_LINES" = "1" ] && [ "$PLUS_LINES" = "1" ] && \
[ "$VERSION_MINUS" = "1" ] && [ "$VERSION_PLUS" = "1" ]; then
VERSION_ONLY="true"
echo "Version-only change detected - skipping heavy CI"
fi
fi
fi
echo "version_only=$VERSION_ONLY" >> $GITHUB_OUTPUT
# CI/tooling changes should run everything (unless version-only)
if [ "$VERSION_ONLY" = "true" ]; then
echo "go=false" >> $GITHUB_OUTPUT
echo "rust=false" >> $GITHUB_OUTPUT
echo "python=false" >> $GITHUB_OUTPUT
echo "integration=false" >> $GITHUB_OUTPUT
echo "docs=false" >> $GITHUB_OUTPUT
elif echo "$CHANGED" | grep -qE '^(\.github/workflows/|mise\.toml)'; then
echo "CI/tooling changed - running all jobs"
echo "go=true" >> $GITHUB_OUTPUT
echo "rust=true" >> $GITHUB_OUTPUT
echo "python=true" >> $GITHUB_OUTPUT
echo "integration=true" >> $GITHUB_OUTPUT
echo "docs=true" >> $GITHUB_OUTPUT
else
# Detect Go changes
if echo "$CHANGED" | grep -qE '^(cmd/|pkg/|go\.(mod|sum)|\.golangci\.yml|Makefile)'; then
echo "go=true" >> $GITHUB_OUTPUT
else
echo "go=false" >> $GITHUB_OUTPUT
fi
# Detect Rust changes
if echo "$CHANGED" | grep -qE '^(crates/|Cargo\.(toml|lock))'; then
echo "rust=true" >> $GITHUB_OUTPUT
else
echo "rust=false" >> $GITHUB_OUTPUT
fi
# Detect Python changes
if echo "$CHANGED" | grep -qE '^(python/|pyproject\.toml|uv\.lock|noxfile\.py|\.ruff\.toml)'; then
echo "python=true" >> $GITHUB_OUTPUT
else
echo "python=false" >> $GITHUB_OUTPUT
fi
# Detect integration test changes (or if any code changed)
if echo "$CHANGED" | grep -qE '^(integration-tests/|cmd/|pkg/|python/|crates/|go\.(mod|sum)|uv\.lock|pyproject\.toml)'; then
echo "integration=true" >> $GITHUB_OUTPUT
else
echo "integration=false" >> $GITHUB_OUTPUT
fi
# Detect docs changes (includes CLI source which generates docs/cli.md)
if echo "$CHANGED" | grep -qE '^(docs/|README\.md|cmd/|pkg/cli/)'; then
echo "docs=true" >> $GITHUB_OUTPUT
else
echo "docs=false" >> $GITHUB_OUTPUT
fi
fi
# Debug output
echo "Changed files:"
echo "$CHANGED" | head -50
# =============================================================================
# Version Check - Validates coglet version changes
# =============================================================================
version-check:
name: Validate coglet version
needs: changes
if: needs.changes.outputs.version_changed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate version
run: |
# Get version from Cargo.toml
VERSION=$(grep '^version = ' crates/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "Coglet version: $VERSION"
# Validate semver format
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Invalid version format: $VERSION"
echo "::error::Expected semver format: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-prerelease"
exit 1
fi
echo "✓ Valid semver format"
# Check version doesn't already exist as a tag
if git tag -l "v$VERSION" | grep -q .; then
echo "::error::Tag v$VERSION already exists!"
echo "::error::Cannot set version to an already-released version."
exit 1
fi
echo "✓ Version not yet released"
# Get the highest existing stable version tag
HIGHEST_TAG=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | grep -v '-' | sed 's/^v//' | sort -V | tail -1)
if [ -n "$HIGHEST_TAG" ]; then
echo "Highest released version: $HIGHEST_TAG"
# Check it's not a downgrade (using sort -V for proper semver comparison)
BASE_VERSION="${VERSION%%-*}"
SORTED_HIGHEST=$(printf '%s\n%s' "$HIGHEST_TAG" "$BASE_VERSION" | sort -V | tail -1)
if [ "$SORTED_HIGHEST" = "$HIGHEST_TAG" ] && [ "$HIGHEST_TAG" != "$BASE_VERSION" ]; then
echo "::error::Cannot downgrade version from $HIGHEST_TAG to $VERSION"
echo "::error::New version must be greater than the highest released version."
exit 1
fi
echo "✓ Version is not a downgrade"
else
echo "No existing version tags found"
fi
echo ""
echo "✓ Version $VERSION is valid for release"
# =============================================================================
# Build Stage - Produces artifacts for downstream jobs
# =============================================================================
build-sdk:
name: Build SDK
needs: changes
if: needs.changes.outputs.python == 'true' || needs.changes.outputs.go == 'true' || needs.changes.outputs.integration == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable
- uses: taiki-e/install-action@cargo-binstall
- uses: jdx/mise-action@v4
with:
cache: false
- name: Build SDK
run: mise run ci:build:sdk
- name: Upload SDK package
uses: actions/upload-artifact@v6
with:
name: CogPackage
path: dist/cog-*
build-rust:
name: Build coglet wheel
needs: changes
if: needs.changes.outputs.rust == 'true' || needs.changes.outputs.integration == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
save-if: ${{ github.ref == 'refs/heads/main' }}
# No mise needed - maturin-action bundles maturin and zig
# Explicitly request MINIMUM_PYTHON inside the manylinux container so
# maturin produces an ABI3 wheel (cp310-abi3). Without this, maturin
# picks up the container's default Python (3.8), which doesn't support
# ABI3, producing a cp38-cp38 wheel that the upload glob won't match.
- name: Build coglet wheel (ABI3)
uses: PyO3/maturin-action@v1
with:
target: x86_64-unknown-linux-gnu
args: --release --out dist -m crates/coglet-python/Cargo.toml --interpreter python${{ env.MINIMUM_PYTHON }}
manylinux: auto
- name: Verify ABI3 wheel exists
run: |
CPVER="cp${MINIMUM_PYTHON//.}"
ls -la dist/coglet-*-${CPVER}-abi3-*.whl
- name: Upload coglet wheel
uses: actions/upload-artifact@v6
with:
name: CogletRustWheel
# ABI3 wheels use cpXYZ-abi3 naming; just match any abi3 wheel
path: dist/coglet-*-abi3-*.whl
build-cog:
name: Build cog CLI
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.integration == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Get version from Cargo.toml
id: version
run: echo "version=$(grep '^version' crates/Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')" >> "$GITHUB_OUTPUT"
- name: Build cog binary
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: build --clean --snapshot --single-target --id cog --output cog
env:
GOFLAGS: -buildvcs=false
# Use Cargo.toml as version source so snapshot builds match the wheel version
COG_VERSION: ${{ steps.version.outputs.version }}
- name: Upload cog binary
uses: actions/upload-artifact@v6
with:
name: CogBinary
path: cog
# =============================================================================
# Format Checks - Fast, parallel
# =============================================================================
fmt-go:
name: Format Go
needs: changes
if: needs.changes.outputs.go == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable
- uses: taiki-e/install-action@cargo-binstall
- uses: jdx/mise-action@v4
with:
cache: false
- name: Check Go formatting
run: mise run fmt:go
fmt-rust:
name: Format Rust
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
# No mise needed - rustfmt comes with toolchain
- name: Check Rust formatting
run: cargo fmt --manifest-path crates/Cargo.toml --all -- --check
fmt-python:
name: Format Python
needs: changes
if: needs.changes.outputs.python == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable
- uses: taiki-e/install-action@cargo-binstall
- uses: jdx/mise-action@v4
with:
cache: false
- name: Check Python formatting
run: mise run fmt:python
check-llm-docs:
name: Check LLM docs
needs: changes
if: needs.changes.outputs.docs == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable
- uses: taiki-e/install-action@cargo-binstall
- uses: jdx/mise-action@v4
with:
cache: false
- name: Check llms.txt is up to date
run: mise run docs:llm:check
- name: Check CLI docs are up to date
run: mise run docs:cli:check
# =============================================================================
# Lint Checks - Parallel
# =============================================================================
lint-go:
name: Lint Go
needs: changes
if: needs.changes.outputs.go == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v9
with:
version: v2.10.1
lint-rust:
name: Lint Rust
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
save-if: ${{ github.ref == 'refs/heads/main' }}
# No mise needed - clippy comes with toolchain
- name: Lint Rust (clippy)
run: cargo clippy --manifest-path crates/Cargo.toml --workspace -- -D warnings
lint-rust-deny:
name: Lint Rust (deny)
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: cargo-deny@0.19.0
# No mise needed - cargo-deny installed via taiki-e
- name: Check licenses and advisories
run: cargo deny --manifest-path crates/Cargo.toml check
lint-python:
name: Lint Python
needs: [changes, build-sdk, build-rust]
if: |
needs.changes.outputs.python == 'true' &&
(needs.build-rust.result == 'success' || needs.build-rust.result == 'skipped')
runs-on: ubuntu-latest-8-cores
timeout-minutes: 15
steps:
- name: Download SDK
uses: actions/download-artifact@v8
with:
name: CogPackage
path: dist
- name: Download coglet wheel
uses: actions/download-artifact@v8
with:
name: CogletRustWheel
path: dist
if: needs.build-rust.result == 'success'
- name: Extract source distribution
run: tar xf dist/*.tar.gz --strip-components=1
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable
- uses: taiki-e/install-action@cargo-binstall
- uses: jdx/mise-action@v4
with:
cache: false
- name: Lint Python
run: mise run lint:python
# =============================================================================
# Test Jobs
# =============================================================================
test-go:
name: "Test Go (${{ matrix.platform }})"
needs: changes
if: needs.changes.outputs.go == 'true'
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
# gotestsum via Go module proxy (not GitHub Releases) for reliability
- name: Install gotestsum
run: go install gotest.tools/gotestsum@v1.13.0
- name: Test Go
shell: bash
run: |
set -euo pipefail
set -m # job control, ensures script is in its own process group
cleanup() {
echo "::warning::Cancelling..."
kill -TERM -- -$$ 2>/dev/null || true
sleep 5
kill -KILL -- -$$ 2>/dev/null || true
}
trap cleanup INT TERM
gotestsum -- -short -timeout 1200s -parallel 5 ./... &
wait $!
fuzz-go:
name: Fuzz Go
needs: changes
if: needs.changes.outputs.go == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
env:
CGO_ENABLED: "1"
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Fuzz schema type resolution
run: go test ./pkg/schema/ -run='^$' -fuzz=FuzzResolveSchemaType -fuzztime=30s
- name: Fuzz JSON schema generation
run: go test ./pkg/schema/ -run='^$' -fuzz=FuzzJSONSchema -fuzztime=30s
- name: Fuzz Python parser
run: go test ./pkg/schema/python/ -run='^$' -fuzz=FuzzParsePredictor -fuzztime=30s
- name: Fuzz type annotation parsing
run: go test ./pkg/schema/python/ -run='^$' -fuzz=FuzzParseTypeAnnotation -fuzztime=30s
test-rust:
name: Test Rust
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest@0.9.120
- uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
save-if: ${{ github.ref == 'refs/heads/main' }}
# No mise needed - cargo-nextest installed via taiki-e
- name: Test Rust
run: cargo nextest run --manifest-path crates/Cargo.toml --workspace --exclude coglet-python --no-tests=pass
test-python:
name: "Test Python ${{ matrix.python-version }}"
needs: [changes, build-sdk, build-rust]
if: |
needs.changes.outputs.python == 'true' &&
needs.build-sdk.result == 'success' &&
(needs.build-rust.result == 'success' || needs.build-rust.result == 'skipped')
runs-on: ubuntu-latest-8-cores
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.changes.outputs.supported_pythons) }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Extract source distribution
run: tar xf dist/*.tar.gz --strip-components=1
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable
- uses: taiki-e/install-action@cargo-binstall
- uses: jdx/mise-action@v4
- name: Remove src to ensure tests run against wheel
run: rm -rf python/cog
- name: Test Python
run: uvx nox -s tests -p ${{ matrix.python-version }}
test-coglet-python:
name: "Test coglet-python (${{ matrix.python-version }})"
needs: [changes, build-rust]
if: |
always() &&
(needs.changes.outputs.rust == 'true' || needs.changes.outputs.python == 'true') &&
(needs.build-rust.result == 'success' || needs.build-rust.result == 'skipped')
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.changes.outputs.supported_pythons) }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download coglet wheel
uses: actions/download-artifact@v8
with:
name: CogletRustWheel
path: dist
if: needs.build-rust.result == 'success'
- uses: dtolnay/rust-toolchain@stable
- run: rustup default stable # Required for cargo-binstall to find cargo
- uses: taiki-e/install-action@cargo-binstall
- uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
- name: Test coglet-python bindings
run: uvx nox -s coglet -p ${{ matrix.python-version }}
# Compute integration test shards dynamically.
# Slow tests (tagged with [short] skip) are distributed round-robin first,
# then remaining tests fill in. This ensures slow tests don't pile up on one runner.
integration-shards:
name: Compute test shards
needs: changes
if: needs.changes.outputs.integration == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
shards: ${{ steps.shard.outputs.shards }}
steps:
- uses: actions/checkout@v6
- name: Compute shards
id: shard
run: |
NUM_SHARDS=${{ env.NUM_IT_RUNNER_SHARDS }}
# Find unconditionally skipped tests (bare "skip" without condition brackets)
# These are disabled tests that shouldn't affect shard distribution
SKIPPED_TESTS=$(grep -rl '^skip ' integration-tests/tests/*.txtar | \
xargs -I{} basename {} .txtar | sort || echo "")
# Identify slow tests (have [short] skip marker), excluding unconditionally skipped
SLOW_TESTS=$(grep -rl '\[short\] skip' integration-tests/tests/*.txtar | \
xargs -I{} basename {} .txtar | sort)
if [ -n "$SKIPPED_TESTS" ]; then
SLOW_TESTS=$(comm -23 <(echo "$SLOW_TESTS") <(echo "$SKIPPED_TESTS"))
fi
# All tests
ALL_TESTS=$(ls integration-tests/tests/*.txtar | \
xargs -I{} basename {} .txtar | sort)
# Fast tests = all - slow (skipped tests end up here but run instantly)
FAST_TESTS=$(comm -23 <(echo "$ALL_TESTS") <(echo "$SLOW_TESTS"))
# Distribute slow tests round-robin across shards
declare -a SHARDS
for i in $(seq 0 $((NUM_SHARDS - 1))); do
SHARDS[$i]=""
done
idx=0
while IFS= read -r test; do
[ -z "$test" ] && continue
if [ -n "${SHARDS[$idx]}" ]; then
SHARDS[$idx]="${SHARDS[$idx]}|${test}"
else
SHARDS[$idx]="$test"
fi
idx=$(( (idx + 1) % NUM_SHARDS ))
done <<< "$SLOW_TESTS"
# Distribute fast tests round-robin across shards
while IFS= read -r test; do
[ -z "$test" ] && continue
if [ -n "${SHARDS[$idx]}" ]; then
SHARDS[$idx]="${SHARDS[$idx]}|${test}"
else
SHARDS[$idx]="$test"
fi
idx=$(( (idx + 1) % NUM_SHARDS ))
done <<< "$FAST_TESTS"
# Build JSON array of shard objects
JSON="["
for i in $(seq 0 $((NUM_SHARDS - 1))); do
PATTERN="${SHARDS[$i]}"
COUNT=$(echo "$PATTERN" | tr '|' '\n' | wc -l | tr -d ' ')
[ $i -gt 0 ] && JSON="${JSON},"
JSON="${JSON}{\"index\":$i,\"pattern\":\"${PATTERN}\",\"count\":$COUNT}"
done
JSON="${JSON}]"
echo "shards=$JSON" >> "$GITHUB_OUTPUT"
# Debug output
echo "Shard distribution:"
for i in $(seq 0 $((NUM_SHARDS - 1))); do
COUNT=$(echo "${SHARDS[$i]}" | tr '|' '\n' | wc -l | tr -d ' ')
SLOW_COUNT=$(echo "${SHARDS[$i]}" | tr '|' '\n' | while read t; do
echo "$SLOW_TESTS" | grep -q "^${t}$" && echo "$t"
done | wc -l | tr -d ' ')
echo " Shard $i: $COUNT tests ($SLOW_COUNT slow)"
done
test-integration:
name: "Test integration (shard ${{ matrix.shard.index }})"
needs: [changes, build-cog, build-sdk, build-rust, integration-shards]
if: |
!cancelled() &&
needs.changes.outputs.integration == 'true' &&
needs.integration-shards.result == 'success' &&
(needs.build-cog.result == 'success' || needs.build-cog.result == 'skipped') &&
(needs.build-sdk.result == 'success' || needs.build-sdk.result == 'skipped') &&
(needs.build-rust.result == 'success' || needs.build-rust.result == 'skipped')
runs-on: ubuntu-latest-16-cores
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: ${{ fromJSON(needs.integration-shards.outputs.shards) }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v4
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
with:
registry: index.docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Install cog binary
run: |
cp dist/cog ./cog
chmod +x ./cog
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum
# gotestsum via Go module proxy (not GitHub Releases) for reliability
- name: Install gotestsum
run: go install gotest.tools/gotestsum@v1.13.0
- name: Set wheel environment
run: |
# Use locally-built wheels, not PyPI (version may not be published yet)
# Must use absolute paths — cog subprocess runs from txtar workdir, not checkout root
echo "COG_SDK_WHEEL=${{ github.workspace }}/dist" >> $GITHUB_ENV
echo "COGLET_WHEEL=${{ github.workspace }}/dist" >> $GITHUB_ENV
- name: Run integration tests (shard ${{ matrix.shard.index }}, ${{ matrix.shard.count }} tests)
env:
COG_BINARY: ./cog
TEST_PARALLEL: 4
BUILDKIT_PROGRESS: 'quiet'
shell: bash
run: |
set -euo pipefail
set -m # job control, ensures script is in its own process group
cleanup() {
echo "::warning::Cancelling..."
kill -TERM -- -$$ 2>/dev/null || true
sleep 5
kill -KILL -- -$$ 2>/dev/null || true
}
trap cleanup INT TERM
# Build -run regex from shard pattern
# Pattern is "test1|test2|test3" - wrap each in TestIntegration/<name>/
RUN_PATTERN="${{ matrix.shard.pattern }}"
echo "Running tests matching: $RUN_PATTERN"
gotestsum --format github-actions -- \
-tags integration \
-parallel $TEST_PARALLEL \
-timeout 30m \
-run "TestIntegration/($RUN_PATTERN)/" \
./integration-tests/... &
wait $!
# =============================================================================
# Gate Job - Single required check for branch protection
# =============================================================================
ci-complete:
name: CI Complete
needs:
- changes
- version-check
- build-cog
- build-sdk
- build-rust
- fmt-go
- fmt-rust
- fmt-python
- check-llm-docs
- lint-go
- lint-rust
- lint-rust-deny
- lint-python
- test-go
- test-rust
- test-python
- test-coglet-python
- integration-shards
- test-integration
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check job results
run: |
echo "Job results:"
echo " changes: ${{ needs.changes.result }}"
echo " build-sdk: ${{ needs.build-sdk.result }}"
echo " build-rust: ${{ needs.build-rust.result }}"
echo " fmt-go: ${{ needs.fmt-go.result }}"
echo " fmt-rust: ${{ needs.fmt-rust.result }}"
echo " fmt-python: ${{ needs.fmt-python.result }}"
echo " check-llm-docs: ${{ needs.check-llm-docs.result }}"
echo " lint-go: ${{ needs.lint-go.result }}"
echo " lint-rust: ${{ needs.lint-rust.result }}"
echo " lint-rust-deny: ${{ needs.lint-rust-deny.result }}"
echo " lint-python: ${{ needs.lint-python.result }}"
echo " test-go: ${{ needs.test-go.result }}"
echo " test-rust: ${{ needs.test-rust.result }}"
echo " test-python: ${{ needs.test-python.result }}"
echo " test-coglet-python: ${{ needs.test-coglet-python.result }}"
echo " integration-shards: ${{ needs.integration-shards.result }}"
echo " test-integration: ${{ needs.test-integration.result }}"
# Fail if any job failed (skipped is OK)
FAILED=false
for result in \
"${{ needs.changes.result }}" \
"${{ needs.build-sdk.result }}" \
"${{ needs.build-rust.result }}" \
"${{ needs.fmt-go.result }}" \
"${{ needs.fmt-rust.result }}" \
"${{ needs.fmt-python.result }}" \
"${{ needs.check-llm-docs.result }}" \
"${{ needs.lint-go.result }}" \
"${{ needs.lint-rust.result }}" \
"${{ needs.lint-rust-deny.result }}" \
"${{ needs.lint-python.result }}" \
"${{ needs.test-go.result }}" \
"${{ needs.test-rust.result }}" \
"${{ needs.test-python.result }}" \
"${{ needs.test-coglet-python.result }}" \
"${{ needs.integration-shards.result }}" \
"${{ needs.test-integration.result }}"
do
if [ "$result" = "failure" ] || [ "$result" = "cancelled" ]; then
FAILED=true
fi
done
if [ "$FAILED" = "true" ]; then
echo "::error::Some jobs failed or were cancelled"
exit 1
fi
echo "All CI checks passed!"
# =============================================================================
# Release Validation - Dry-run checks (PRs and main)
# =============================================================================
release-dry-run:
name: Release Dry Run
needs: ci-complete
if: "!startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check coglet crates.io publish
run: cargo publish --dry-run -p coglet --manifest-path crates/Cargo.toml
- uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: check
================================================
FILE: .github/workflows/codeql.yml
================================================
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '37 18 * * 5'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
# CodeQL supports: cpp, csharp, go, java, javascript, python, ruby, rust
# https://aka.ms/codeql-docs/language-support
language: ['go', 'python', 'rust']
steps:
- name: Checkout repository
uses: actions/checkout@v6
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v4
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
================================================
FILE: .github/workflows/docs.yaml
================================================
name: Deploy docs
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Generate CLI docs
run: go run ./tools/gendocs/main.go -o docs/cli.md
- name: Copy top-level docs like README and CONTRIBUTING
run: |
sed 's/docs\///g' README.md > ./docs/README.md
cp CONTRIBUTING.md ./docs/
- name: Deploy
run: |
pip install mkdocs-material
mkdocs gh-deploy --force
================================================
FILE: .github/workflows/release-build.yaml
================================================
---
name: Release Build
# Triggered on version tags to build release artifacts and create a GitHub release.
#
# THREE RELEASE TYPES:
#
# 1. Stable (v0.17.0) - must be on main
# - Creates DRAFT release → maintainer publishes → release-publish.yaml → PyPI/crates.io
#
# 2. Pre-release (v0.17.0-alpha3, v0.17.0-rc1) - must be on main
# - Same flow as stable, but marked as pre-release
#
# 3. Dev (v0.17.0-dev1) - can be tagged from ANY branch
# - Creates a published pre-release immediately (no draft, no human approval)
# - Does NOT publish to PyPI or crates.io
# - Artifacts (CLI binaries, wheels) attached to the GH release
#
# SECURITY:
# - Stable/pre-release tags verified on main branch
# - Dev releases have no branch restriction but no registry publishing
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
verify-tag:
name: Verify tag and version
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
is_dev: ${{ steps.check.outputs.is_dev }}
version: ${{ steps.check.outputs.version }}
pep440: ${{ steps.check.outputs.pep440 }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Verify tag and version
id: check
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
TAG_COMMIT="${{ github.sha }}"
# Get version from Cargo.toml
CARGO_VERSION=$(grep '^version = ' crates/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "Tag: $TAG"
echo "Tag version: $VERSION"
echo "Cargo.toml version: $CARGO_VERSION"
echo "Commit: $TAG_COMMIT"
echo ""
# Check Cargo.toml matches tag
if [[ "$CARGO_VERSION" != "$VERSION" ]]; then
echo "::error::Version mismatch! crates/Cargo.toml has version $CARGO_VERSION but tag is $TAG"
echo "::error::"
echo "::error::To fix: Update crates/Cargo.toml to match, merge to main, then delete this tag and re-tag."
exit 1
fi
echo "✓ Cargo.toml version matches tag"
# Determine release type
IS_DEV="false"
if [[ "$VERSION" == *-dev* ]]; then
IS_DEV="true"
fi
echo "is_dev=$IS_DEV" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Compute PEP 440 version: v0.17.0-alpha1 -> 0.17.0a1, v0.17.0-dev1 -> 0.17.0.dev1
PEP440=$(echo "$VERSION" | sed -E 's/-alpha\.?/a/; s/-beta\.?/b/; s/-rc\.?/rc/; s/-dev\.?/.dev/')
echo "pep440=$PEP440" >> "$GITHUB_OUTPUT"
echo "PEP 440 version: $PEP440"
# Branch rules
if [[ "$IS_DEV" == "true" ]]; then
echo "Dev release - no branch restriction"
echo "✓ Dev release, skipping branch check"
else
# Stable and pre-release tags must be on main
echo "Stable/pre-release detected, verifying main branch..."
git fetch origin main
if ! git merge-base --is-ancestor "$TAG_COMMIT" origin/main; then
echo "::error::Release tags must be on the main branch"
echo "::error::Tag commit $TAG_COMMIT is not reachable from origin/main"
echo "::error::"
echo "::error::To fix: Merge to main first, then tag"
exit 1
fi
echo "✓ Tag is on main branch"
fi
build-sdk:
name: Build SDK wheel
needs: verify-tag
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
- name: Update coglet version constraint
run: |
VERSION="${{ needs.verify-tag.outputs.pep440 }}"
echo "Setting coglet constraint to >=$VERSION,<1.0"
# Update pyproject.toml with lockstep version constraint
sed -i "s/coglet>=0\.1\.0,<1\.0/coglet>=$VERSION,<1.0/" pyproject.toml
# Verify the change took effect
grep "coglet>=$VERSION" pyproject.toml
- name: Build SDK wheel
run: |
echo "Building SDK with version: $SETUPTOOLS_SCM_PRETEND_VERSION"
uv build --out-dir dist .
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.verify-tag.outputs.pep440 }}
- name: Upload SDK artifacts
uses: actions/upload-artifact@v6
with:
name: sdk-dist
path: dist/*
build-coglet-wheels:
name: Build coglet wheel (${{ matrix.target }})
needs: verify-tag
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact-suffix: linux-x64
manylinux: auto
zig: true
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact-suffix: linux-arm64
manylinux: auto
zig: true
- os: macos-14
target: aarch64-apple-darwin
artifact-suffix: macos-arm64
manylinux: "off"
zig: false
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: crates -> target
key: release-${{ matrix.target }}
- uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
enable-cache: false
- name: Build coglet wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
args: --release --out dist -m crates/coglet-python/Cargo.toml ${{ matrix.zig && '--zig' || '' }}
- name: Upload coglet wheel
uses: actions/upload-artifact@v6
with:
name: coglet-wheel-${{ matrix.artifact-suffix }}
path: dist/*.whl
create-release:
name: Create release
needs: [verify-tag, build-sdk, build-coglet-wheels]
# macOS arm64 runner: native clang for darwin targets, zig for linux targets.
# CGo required for go-tree-sitter (static Python schema parser).
runs-on: macos-14
timeout-minutes: 30
env:
CGO_ENABLED: "1"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Check for existing release
run: |
TAG="${{ github.ref_name }}"
EXISTING=$(gh release view "$TAG" --json isDraft,isPrerelease --jq '.' 2>/dev/null || echo "")
if [ -n "$EXISTING" ]; then
echo "::error::Release for $TAG already exists. Delete it before re-running."
echo "::error::Run: gh release delete $TAG --yes"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Goreleaser builds CLI binaries and creates draft release
- name: Build CLI and create draft release
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Append Python wheels to the release
- name: Download all wheel artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Upload wheels to release
run: |
TAG="${{ github.ref_name }}"
# Collect all wheels
mkdir -p release-wheels
cp artifacts/sdk-dist/* release-wheels/
cp artifacts/coglet-wheel-*/*.whl release-wheels/
# Download goreleaser's checksums.txt and append wheel checksums
gh release download "$TAG" -p checksums.txt -D release-wheels
cd release-wheels
shasum -a 256 *.whl *.tar.gz >> checksums.txt
echo "Checksums:"
cat checksums.txt
cd ..
echo "Uploading wheels and updated checksums..."
gh release upload "$TAG" release-wheels/* --clobber
echo "Release assets:"
gh release view "$TAG" --json assets --jq '.assets[].name'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# For dev releases: immediately publish as pre-release (no draft review)
# For stable/pre-release: leave as draft for maintainer review
- name: Publish dev release
if: needs.verify-tag.outputs.is_dev == 'true'
run: |
TAG="${{ github.ref_name }}"
echo "Publishing dev release $TAG as pre-release (no draft phase)..."
gh release edit "$TAG" --draft=false --prerelease
echo "✓ Dev release $TAG published as pre-release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/release-publish.yaml
================================================
---
name: Release Publish
# Publishes packages to PyPI and crates.io when a release is published.
#
# For stable releases: publishes to PyPI, crates.io, and updates Homebrew tap.
# For pre-releases: publishes to PyPI and crates.io only (no Homebrew tap).
# For dev releases: ALL jobs are skipped. (Dev releases do trigger this workflow
# when release-build.yaml publishes them, but every job gates on is_dev.)
#
# PUBLISH ORDER:
# 1. coglet -> PyPI (must be first, SDK depends on it)
# 2. coglet -> crates.io (parallel with coglet PyPI)
# 3. SDK -> PyPI (after coglet is on PyPI)
# 4. Homebrew cask (stable only, after all publishing completes)
#
# REQUIRED GITHUB CONFIGURATION:
# 1. Create environments in Settings -> Environments:
# - "pypi": For PyPI publishing (Trusted Publisher)
# - "crates-io": For crates.io publishing
# - "homebrew": For Homebrew tap updates
#
# 2. Configure environment protection rules:
# - Deployment branches: "Selected branches and tags"
# - Add pattern: v* (to restrict to version tags only)
#
# 3. crates-io uses Trusted Publishing (OIDC via rust-lang/crates-io-auth-action)
#
# 4. Homebrew tap uses the cog-homebrew-tapbot GitHub App (ID: 1232932405)
# - Secret: COG_HOMEBREW_TAP_PRIVATE_KEY (app's private key)
on:
release:
types: [published]
permissions:
contents: read
id-token: write
env:
CARGO_TERM_COLOR: always
jobs:
verify-release:
name: Verify release tag
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
is_dev: ${{ steps.check.outputs.is_dev }}
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
version: ${{ steps.check.outputs.version }}
steps:
- name: Verify valid release tag
id: check
run: |
TAG="${{ github.event.release.tag_name }}"
# Release must be from a valid version tag
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid tag format: $TAG"
echo "::error::Tags must match pattern v*.*.* (e.g., v1.0.0)"
exit 1
fi
echo "✓ Valid release tag: $TAG"
VERSION="${TAG#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Classify release type
IS_DEV="false"
IS_PRERELEASE="false"
if [[ "$VERSION" == *-dev* ]]; then
IS_DEV="true"
echo "Dev release detected - skipping all publishing"
elif [[ "$VERSION" == *-* ]]; then
IS_PRERELEASE="true"
echo "Pre-release detected - publishing to PyPI/crates.io (no Homebrew tap)"
else
echo "Stable release detected - full publishing including Homebrew tap"
fi
echo "is_dev=$IS_DEV" >> "$GITHUB_OUTPUT"
echo "is_prerelease=$IS_PRERELEASE" >> "$GITHUB_OUTPUT"
publish-pypi-coglet:
name: Publish coglet to PyPI
needs: verify-release
if: needs.verify-release.outputs.is_dev != 'true'
runs-on: ubuntu-latest
environment: pypi
timeout-minutes: 10
steps:
- name: Download coglet wheels from release
run: |
mkdir -p dist
gh release download "$TAG" -p "coglet-*.whl" -D dist -R "${{ github.repository }}"
env:
TAG: ${{ github.event.release.tag_name }}
GH_TOKEN: ${{ github.token }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-crates-io:
name: Publish coglet to crates.io
needs: verify-release
if: needs.verify-release.outputs.is_dev != 'true'
runs-on: ubuntu-latest
environment: crates-io
timeout-minutes: 15
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.release.tag_name }}
- uses: dtolnay/rust-toolchain@stable
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish to crates.io
run: cargo publish -p coglet --manifest-path crates/Cargo.toml
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
publish-pypi-sdk:
name: Publish SDK to PyPI
needs: [verify-release, publish-pypi-coglet]
if: needs.verify-release.outputs.is_dev != 'true'
runs-on: ubuntu-latest
environment: pypi
timeout-minutes: 10
steps:
- name: Download SDK artifacts from release
run: |
mkdir -p dist
gh release download "$TAG" -p "cog-*.whl" -D dist -R "${{ github.repository }}"
gh release download "$TAG" -p "cog-*.tar.gz" -D dist -R "${{ github.repository }}"
env:
TAG: ${{ github.event.release.tag_name }}
GH_TOKEN: ${{ github.token }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
update-homebrew-tap:
name: Update Homebrew cask
needs: [verify-release, publish-pypi-sdk, publish-crates-io]
# Stable releases only — no dev, no pre-release
if: >-
needs.verify-release.outputs.is_dev != 'true' &&
needs.verify-release.outputs.is_prerelease != 'true'
runs-on: ubuntu-latest
environment: homebrew
timeout-minutes: 10
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: 1232932405
private-key: ${{ secrets.COG_HOMEBREW_TAP_PRIVATE_KEY }}
owner: replicate
repositories: homebrew-tap
- name: Download checksums from release
run: gh release download "$TAG" -p checksums.txt -R "${{ github.repository }}"
env:
TAG: ${{ github.event.release.tag_name }}
GH_TOKEN: ${{ github.token }}
- name: Generate and push cask
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
TAG: ${{ github.event.release.tag_name }}
VERSION: ${{ needs.verify-release.outputs.version }}
run: |
# Extract SHA256s for Darwin binaries from checksums.txt
SHA_X86=$(grep 'cog_Darwin_x86_64' checksums.txt | awk '{print $1}')
SHA_ARM=$(grep 'cog_Darwin_arm64' checksums.txt | awk '{print $1}')
if [ -z "$SHA_X86" ] || [ -z "$SHA_ARM" ]; then
echo "::error::Missing Darwin binary checksums in checksums.txt"
echo "Darwin x86_64: ${SHA_X86:-MISSING}"
echo "Darwin arm64: ${SHA_ARM:-MISSING}"
cat checksums.txt
exit 1
fi
echo "Checksums:"
echo " Darwin x86_64: $SHA_X86"
echo " Darwin arm64: $SHA_ARM"
BASE_URL="https://github.com/replicate/cog/releases/download/${TAG}"
# Generate cask file (no indentation to avoid stripping issues)
cat > cog.rb <<CASK
cask "cog" do
version "${VERSION}"
on_intel do
url "${BASE_URL}/cog_Darwin_x86_64"
sha256 "${SHA_X86}"
end
on_arm do
url "${BASE_URL}/cog_Darwin_arm64"
sha256 "${SHA_ARM}"
end
name "Cog"
desc "Containers for machine learning"
homepage "https://cog.run"
binary "cog_Darwin_#{Hardware::CPU.intel? ? "x86_64" : "arm64"}", target: "cog"
postflight do
system_command "/usr/bin/xattr",
args: ["-dr", "com.apple.quarantine", "#{staged_path}/cog"]
end
end
CASK
# Strip heredoc indentation
sed -i 's/^ //' cog.rb
echo "Generated cask:"
cat cog.rb
# Clone tap repo and push update
git clone "https://x-access-token:${GH_TOKEN}@github.com/replicate/homebrew-tap.git" tap
mkdir -p tap/Casks
cp cog.rb tap/Casks/cog.rb
cd tap
git config user.name "cog-homebrew-tapbot[bot]"
git config user.email "1232932405+cog-homebrew-tapbot[bot]@users.noreply.github.com"
git add Casks/cog.rb
git diff --cached --quiet && echo "No changes to cask" && exit 0
git commit -m "Update cog to ${VERSION}"
git push origin main
echo "✓ Homebrew cask updated to ${VERSION}"
================================================
FILE: .gitignore
================================================
/cog
.ipynb_checkpoints/
Untitled*.ipynb
__pycache__
.cog
.hypothesis/
build
dist
*.egg-info
pkg/wheels/*.whl
# Used by a vim plugin (projectionist)
.projections.json
.tox/
.venv/
.idea/
.DS_Store
docs/README.md
docs/CONTRIBUTING.md
venv
base-image
flag_file
bin/*
.beads/
# Compiled test tools
/weights-gen
# Test directory for weights testing
/test-weights/
weights.lock
# Auto-:d version files from setuptools-scm
python/cog/_version.py
coglet/python/coglet/_version.py
cog-dataclass/python/cog/_version.py
# Built coglet-server binaries
coglet/python/cog/bin/
# Local planning files
docs/plans/**
# Local agent files
AGENTS.local.md
CLAUDE.local.md
# Local mise files
mise.local.toml
mise.local.lock
# Built extension modules
*.so
*.pyd
# Ignore rust specific build artifacts
target
/.cargo-home
/.cargo-home/**
/.rustup
/.rustup/**
.coverage
# Generated docs
/site
================================================
FILE: .golangci.yaml
================================================
version: "2"
run:
timeout: 20m
output:
# Show all issues, not just first few per linter
show-stats: true
linters:
enable:
- copyloopvar
- errcheck
- gocritic
- gosec
- govet
- ineffassign
- misspell
- modernize
- revive
- staticcheck
- unconvert
- unused
settings:
errcheck:
disable-default-exclusions: false
gosec:
excludes:
- G301 # Expect directory permissions to be 0750 or less
- G302 # Expect file permissions to be 0600 or less
- G304 # Potential file inclusion via variable
- G306 # Expect WriteFile permissions to be 0600 or less
misspell:
locale: US
revive:
rules:
- name: unused-parameter
disabled: true
- name: exported
disabled: true
- name: var-naming
disabled: true
gocritic:
enabled-checks:
- appendCombine
- boolExprSimplify
- builtinShadow
- commentedOutCode
- commentedOutImport
- docStub
- emptyFallthrough
- equalFold
- hexLiteral
- indexAlloc
- initClause
- methodExprCall
- nilValReturn
- octalLiteral
- rangeExprCopy
- stringXbytes
- typeAssertChain
- typeUnparen
- unnecessaryBlock
- weakCond
exclusions:
generated: strict
rules:
# Exclude some linters from running on test files
- path: '(.+)_test\.go'
linters:
- errcheck
- gosec
# Exclude errcheck on defer cleanup patterns (can't handle error in defer)
- source: 'defer .+\.Close\(\)'
linters:
- errcheck
- source: 'defer os\.RemoveAll\('
linters:
- errcheck
# Exclude gosec G204 (command injection) - we intentionally run dynamic commands
- linters:
- gosec
text: 'G204:'
# ST1005: error strings should not be capitalized - too many to fix now
# TODO: Enable and fix these incrementally
- linters:
- staticcheck
text: 'ST1005:'
# modernize newexpr false positives: ptr(true) cannot be simplified to new(bool)
# because new(T) only produces zero-value pointers
- linters:
- modernize
text: 'newexpr:'
================================================
FILE: .goreleaser.yaml
================================================
version: 2
before:
hooks:
- go mod tidy
dist: ./dist/go
env:
# CGo required for go-tree-sitter (static Python schema parser).
# Linux cross-compilation uses zig cc — see per-build overrides.
# Darwin builds use the native compiler (zig lacks macOS SDK stubs).
- CGO_ENABLED=1
builds:
- binary: cog
id: cog
goos:
- darwin
- linux
goarch:
- amd64
- arm64
main: ./cmd/cog
ldflags:
# COG_VERSION (from Cargo.toml via mise build:cog) overrides git-derived version for snapshots.
# For tagged releases, COG_VERSION is unset and envOrDefault falls back to .Version (from tag).
- "-s -w -X github.com/replicate/cog/pkg/global.Version={{ envOrDefault \"COG_VERSION\" .Version }} -X github.com/replicate/cog/pkg/global.Commit={{.Commit}} -X github.com/replicate/cog/pkg/global.BuildTime={{.Date}}"
overrides:
- goos: linux
goarch: amd64
env:
- CC=zig cc -target x86_64-linux-gnu
- goos: linux
goarch: arm64
env:
- CC=zig cc -target aarch64-linux-gnu
- binary: base-image
id: base-image
goos:
- darwin
- linux
goarch:
- amd64
- arm64
main: ./cmd/base-image
ldflags:
- "-s -w -X github.com/replicate/cog/pkg/global.Version={{ envOrDefault \"COG_VERSION\" .Version }} -X github.com/replicate/cog/pkg/global.Commit={{.Commit}} -X github.com/replicate/cog/pkg/global.BuildTime={{.Date}}"
overrides:
- goos: linux
goarch: amd64
env:
- CC=zig cc -target x86_64-linux-gnu
- goos: linux
goarch: arm64
env:
- CC=zig cc -target aarch64-linux-gnu
archives:
- formats: [binary]
ids:
- cog # for now we only release cog
name_template: >-
{{ .Binary }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end -}}
checksum:
name_template: "checksums.txt"
snapshot:
version_template: '{{ envOrDefault "COG_VERSION" (printf "%s-dev+g%s" (incpatch .Version) .ShortCommit) }}'
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
draft: true
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-alpha
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: auto
================================================
FILE: .mockery.yml
================================================
all: false
dir: '{{.InterfaceDir}}'
filename: mocks_test.go
force-file-write: true
formatter: goimports
log-level: info
structname: '{{.Mock}}{{.InterfaceName}}'
pkgname: '{{.SrcPackageName}}'
recursive: false
require-template-schema-exists: true
template: testify
template-schema: '{{.Template}}.schema.json'
packages:
github.com/replicate/cog/pkg/docker/command:
config:
all: true
dir: "pkg/docker/dockertest"
filename: "command_mocks.go"
pkgname: "dockertest"
structname: "{{.Mock}}{{.InterfaceName}}2"
================================================
FILE: .vscode/extensions.json
================================================
{
"recommendations": [
"charliermarsh.ruff",
"golang.go",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
================================================
FILE: .vscode/settings.json
================================================
{
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.formatOnPaste": true,
"editor.renderControlCharacters": true,
"editor.suggest.localityBonus": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"go.coverOnTestPackage": false,
"go.lintTool": "golangci-lint",
"go.formatTool": "goimports",
"go.testOnSave": true,
"gopls": {
"formatting.local": "github.com/replicate/cog"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.languageServer": "Pylance",
"python.testing.pytestArgs": [
"-vvv",
"python"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
================================================
FILE: AGENTS.md
================================================
# AGENTS.md
This file provides guidance to coding agents when working with code in this repository.
## Project Overview
Cog is a tool that packages machine learning models in production-ready containers.
It consists of:
- **Cog CLI** (`cmd/cog/`) - Command-line interface for building, running, and deploying models, written in Go
- **Python SDK** (`python/cog/`) - Python library for defining model predictors and training in Python
- **Coglet** (`crates/`) - Rust-based prediction server that runs inside containers, with Python bindings via PyO3
Documentation for the CLI and SDK is available by reading ./docs/llms.txt.
## Development Commands
Development tasks are managed with [mise](https://mise.jdx.dev/). Run `mise tasks` to see all available tasks.
### Quick Reference
| Task | Description |
|------|-------------|
| `mise run fmt` | Check formatting (all languages) |
| `mise run fmt:fix` | Fix formatting (all languages) |
| `mise run lint` | Run linters (all languages) |
| `mise run lint:fix` | Fix lint issues (all languages) |
| `mise run test:go` | Run Go tests |
| `mise run test:rust` | Run Rust tests |
| `mise run test:python` | Run Python tests |
| `mise run test:integration` | Run integration tests |
| `mise run build:cog` | Build cog CLI binary |
| `mise run build:coglet` | Build coglet wheel (dev) |
| `mise run build:sdk` | Build SDK wheel |
| `mise run install` | Build and symlink cog to /usr/local/bin |
| `mise run docs:llm` | **IMPORTANT:** Regenerate `docs/llms.txt` after editing docs |
| `mise run docs:cli` | Generate CLI reference docs from Go source code |
### Task Naming Convention
Tasks follow a consistent naming pattern:
- **Language-based tasks** for fmt/lint/test/typecheck: `task:go`, `task:rust`, `task:python`
- **Component-based tasks** for build: `build:cog`, `build:coglet`, `build:sdk`
- **Check vs Fix**: `fmt` and `lint` default to check mode (non-destructive); use `:fix` suffix to auto-fix
### All Tasks by Category
**Format:**
- `mise run fmt` / `mise run fmt:check` - Check all (alias)
- `mise run fmt:fix` - Fix all
- `mise run fmt:go` / `mise run fmt:rust` / `mise run fmt:python` - Per-language
**Lint:**
- `mise run lint` / `mise run lint:check` - Check all (alias)
- `mise run lint:fix` - Fix all
- `mise run lint:go` / `mise run lint:rust` / `mise run lint:python` - Per-language
- `mise run lint:rust:deny` - Check Rust licenses/advisories
**Test:**
- `mise run test:go` - Go unit tests
- `mise run test:rust` - Rust unit tests
- `mise run test:python` - Python unit tests (via tox)
- `mise run test:coglet:python` - Coglet Python binding tests
- `mise run test:integration` - Integration tests
**Build:**
- `mise run build:cog` - Build cog CLI (development)
- `mise run build:cog:release` - Build cog CLI (release)
- `mise run build:coglet` - Build coglet wheel (dev install)
- `mise run build:coglet:wheel` - Build coglet wheel (native platform)
- `mise run build:coglet:wheel:linux-x64` - Build for Linux x86_64
- `mise run build:coglet:wheel:linux-arm64` - Build for Linux ARM64
- `mise run build:sdk` - Build SDK wheel
**Install:**
- `mise run install` - Symlink cog CLI to `/usr/local/bin` (requires `build:cog` first)
- `PREFIX=/custom/path mise run install` - Symlink to custom location
**Other:**
- `mise run typecheck` - Type check all languages
- `mise run generate` - Run code generation
- `mise run clean` - Clean all build artifacts
- `mise run docs` - Build documentation
- `mise run docs:serve` - Serve docs locally
## Code Style Guidelines
### Go
- **Imports**: Organize in three groups separated by blank lines: (1) Standard library, (2) Third-party packages, (3) Internal packages (`github.com/replicate/cog/pkg/...`)
- **Formatting**: Use `mise run fmt:go:fix`
- **Linting**: Must pass golangci-lint with: errcheck, gocritic, gosec, govet, ineffassign, misspell, revive, staticcheck, unused
- **Error Handling**: Return errors as values; use `pkg/errors.CodedError` for user-facing errors with error codes
- **Naming**: CamelCase for exported, camelCase for unexported
- **Testing**: Use `testify/require` for assertions; prefer table-driven tests
Example import block:
```go
import (
"fmt"
"github.com/spf13/cobra"
"github.com/replicate/cog/pkg/config"
)
```
### Python
- **Imports**: Automatically organized by ruff/isort (stdlib → third-party → local)
- **Formatting**: Use `mise run fmt:python:fix`
- **Linting**: Must pass ruff checks: E (pycodestyle), F (Pyflakes), I (isort), W (warnings), S (bandit), B (bugbear), ANN (annotations)
- **Type Annotations**: Required on all function signatures; use `typing_extensions` for compatibility; avoid `Any` where possible
- **Error Handling**: Raise exceptions with descriptive messages; avoid generic exception catching
- **Naming**: snake_case for functions/variables/modules, PascalCase for classes
- **Testing**: Use pytest with fixtures; async tests with pytest-asyncio
- **Compatibility**: Must support Python 3.10-3.13
### Rust
- **Formatting**: Use `mise run fmt:rust:fix`
- **Linting**: Must pass `mise run lint:rust` (clippy)
- **Dependencies**: Audited with `cargo-deny` (see `crates/deny.toml`); run `mise run lint:rust:deny`
- **Error Handling**: Use `thiserror` for typed errors, `anyhow` for application errors
- **Naming**: snake_case for functions/variables, PascalCase for types
- **Testing**: Use `cargo test`; snapshot tests use `insta`
- **Async**: tokio runtime; async/await patterns
## Working on the CLI and support tooling
The CLI code is in the `cmd/cog/` and `pkg/` directories. Support tooling is in the `tools/` directory.
The main commands for working on the CLI are:
- `go run ./cmd/cog` - Runs the Cog CLI directly from source (requires wheel to be built first)
- `mise run build:cog` - Builds the Cog CLI binary
- `mise run install` - Symlinks the built binary to `/usr/local/bin` (run `build:cog` first), or to a custom path with `PREFIX=/custom/path mise run install`
- `mise run test:go` - Runs all Go unit tests
- `go test ./pkg/...` - Runs tests directly with `go test`
## Working on the Python SDK
The Python SDK is developed in the `python/cog/` directory. It uses `uv` for virtual environments and `tox` for testing across multiple Python versions.
The main commands for working on the SDK are:
- `mise run build:sdk` - Builds the Python wheel
- `mise run test:python` - Runs Python tests across all supported versions
## Working on Coglet (Rust)
Coglet is the Rust-based prediction server that runs inside Cog containers, handling HTTP requests, worker process management, and prediction execution.
The code is in the `crates/` directory:
- `crates/coglet/` - Core Rust library (HTTP server, worker orchestration, IPC)
- `crates/coglet-python/` - PyO3 bindings for Python predictor integration (requires Python 3.10+)
For detailed architecture documentation, see `crates/README.md` and `crates/coglet/README.md`.
The main commands for working on Coglet are:
- `mise run build:coglet` - Build and install coglet wheel for development (macOS, for local Rust/Python tests)
- `mise run build:coglet:wheel:linux-x64` - Build Linux x86_64 wheel (required to test Rust changes in Docker containers via `cog predict`/`cog train`)
- `mise run test:rust` - Run Rust unit tests
- `mise run lint:rust` - Run clippy linter
- `mise run fmt:rust:fix` - Format code
### Testing
Go code is tested using the built-in `go test` framework:
- `go test ./pkg/... -run <name>` - Runs specific Go tests by name
- `mise run test:go` - Runs all Go unit tests
Python code is tested using `tox`, which allows testing across multiple Python versions and configurations:
- `mise run test:python` - Runs all Python unit tests
- `uv run tox -e py312-tests -- python/tests/server/test_http.py::test_openapi_specification_with_yield` - Runs a specific Python test
The integration test suite in `integration-tests/` tests the end-to-end functionality of the Cog CLI and Python SDK using Go's testscript framework:
- `mise run test:integration` - Runs the integration tests
- `mise run test:integration string_predictor` - Runs a specific integration test
The integration tests require a built Cog binary, which defaults to the first `cog` in `PATH`. Run tests against a specific binary with the `COG_BINARY` environment variable:
```bash
mise run build:cog
COG_BINARY=dist/go/*/cog mise run test:integration
```
### Development Workflow
1. Run `mise install` to set up the development environment
2. Run `mise run build:sdk` after making changes to the `./python` directory
3. Run `mise run build:coglet:wheel:linux-x64` after making changes to the `./crates` directory (needed for Docker testing)
4. Run `mise run build:cog` to build the CLI (wheels are picked up from `dist/` at Docker build time, not embedded in the binary)
5. Run `mise run fmt:fix` to format code
6. Run `mise run lint` to check code quality
7. Run `mise run docs:llm` to regenerate `docs/llms.txt` after changing `README.md` or any `docs/*.md` file
8. Read the `./docs` directory and make sure the documentation is up to date
**IMPORTANT:** Always run `mise run lint` (or the language-specific variant, e.g. `mise run lint:go`) before committing to catch linter errors early. CI will reject PRs that fail lint checks.
## Architecture
### CLI Architecture (Go)
The CLI follows a command pattern with subcommands. The main components are:
- `pkg/cli/` - Command definitions (build, run, predict, serve, etc.)
- `pkg/docker/` - Docker client and container management
- `pkg/dockerfile/` - Dockerfile generation and templating
- `pkg/config/` - cog.yaml parsing and validation
- `pkg/image/` - Image building and pushing logic
### Python SDK Architecture
- `python/cog/` - Core SDK
- `base_predictor.py` - Base class for model predictors
- `types.py` - Input/output type definitions
- `server/` - HTTP/queue server implementation
- `command/` - Runner implementations for predict/train
### Coglet Architecture (Rust)
The prediction server that runs inside Cog containers. Uses a two-process architecture: a parent process (HTTP server + orchestrator) and a worker subprocess (Python predictor execution).
See `crates/README.md` for detailed architecture documentation.
- `crates/coglet/` - Core Rust library (HTTP server, worker orchestration, IPC bridge)
- `crates/coglet-python/` - PyO3 bindings for Python predictor integration
### Key Design Patterns
1. **Local Wheel Resolution**: The CLI discovers SDK and coglet wheels from `dist/` at Docker build time (not embedded in the binary)
2. **Docker SDK Integration**: Uses Docker Go SDK for container operations
3. **Type Safety**: Dataclasses for Python type validation, strongly typed Go interfaces
4. **Compatibility Matrix**: Automated CUDA/PyTorch/TensorFlow compatibility management
For comprehensive architecture documentation, see [`architecture/`](./architecture/00-overview.md).
## Common Tasks
### Adding a new CLI command
1. Create command file in `pkg/cli/`
2. Add command to `pkg/cli/root.go`
3. Implement business logic in appropriate `pkg/` subdirectory
4. Add tests
### Modifying Python SDK behavior
1. Edit files in `python/cog/`
2. Run `mise run build:sdk` to rebuild wheel
3. Test with `mise run test:python`
4. Integration test with `mise run test:integration`
### Updating ML framework compatibility
1. See `tools/compatgen/` for compatibility matrix generation
2. Update framework versions in relevant Dockerfile templates
3. Test with various framework combinations
### Updating the docs
- Documentation is in the `docs/` directory, written in Markdown and generated into HTML using `mkdocs`.
- **IMPORTANT:** After editing any file in `docs/` or `README.md`, you MUST run `mise run docs:llm` to regenerate `docs/llms.txt`. This file is used by coding agents and should be kept in sync with the documentation.
- **IMPORTANT:** CLI reference docs (`docs/cli.md`) are auto-generated from Go source code. After modifying CLI commands in `cmd/` or `pkg/cli/`, run `mise run docs:cli` to regenerate, and ensure `mise run docs:cli:check` passes before committing.
## CI Tool Dependencies
Development tools are managed in **two places** that must be kept in sync:
1. **`mise.toml`** — Tool versions for local development (uses aqua backend for prebuilt binaries)
2. **`.github/workflows/ci.yaml`** — Tool installation for CI (uses dedicated GitHub Actions)
CI deliberately avoids aqua downloads from GitHub Releases to prevent transient 502 failures. Instead, it uses:
| Tool | CI installation method | Why |
|------|----------------------|-----|
| gotestsum | `go install` | Uses Go module proxy, not GitHub Releases |
| cargo-deny | `taiki-e/install-action` | Prebuilt with checksum verification |
| cargo-nextest | `taiki-e/install-action` | Prebuilt with checksum verification |
| coglet wheel (maturin+zig) | `PyO3/maturin-action` | Bundles maturin and zig |
| golangci-lint | `golangci/golangci-lint-action` | Built-in caching |
| Rust toolchain | `dtolnay/rust-toolchain` | Guaranteed ordering |
Tools disabled in CI are listed in `MISE_DISABLE_TOOLS` in `ci.yaml`.
**When updating a tool version**, update both:
- The version in `mise.toml` (for local dev)
- The corresponding version pin in `.github/workflows/ci.yaml` (for CI)
## Important Files
- `cog.yaml` - User-facing model configuration
- `pkg/config/config.go` - Go code for parsing and validating `cog.yaml`
- `pkg/config/data/config_schema_v1.0.json` - JSON schema for `cog.yaml`
- `python/cog/base_predictor.py` - Predictor interface
- `crates/Cargo.toml` - Rust workspace configuration
- `crates/README.md` - Coglet architecture overview
- `mise.toml` - Task definitions for development workflow
## Testing Philosophy
- Unit tests for individual components (Go and Python)
- Integration tests for end-to-end workflows
- Tests use real Docker operations (no mocking Docker API)
- Always run `mise run build:sdk` after making Python changes before testing Go code
- Python 3.10-3.13 compatibility is required
### Go Test Conventions
All Go tests must use [testify](https://github.com/stretchr/testify) for assertions. Do **not** use raw `if` checks with `t.Fatal`/`t.Errorf` — use `require` and `assert` instead.
- **`require`** — for fatal assertions that should stop the test (setup failures, preconditions):
```go
require.NoError(t, err, "failed to create client")
require.Equal(t, expected, actual)
require.True(t, condition, "server should be ready")
```
- **`assert`** — for non-fatal checks where the test should continue (e.g. validating multiple fields in a loop):
```go
assert.Equal(t, http.StatusOK, resp.StatusCode)
assert.Contains(t, output, "expected substring")
assert.NoError(t, err, "prediction %d failed", i)
```
- Use `require` for errors in setup/teardown and `assert` for the actual test expectations
- Prefer specific assertions (`Equal`, `Contains`, `NoError`, `Len`, `Less`) over generic `True`/`False` — they produce better failure messages
- Prefer table-driven tests for testing multiple similar cases
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing guide
## Development environment
Development tasks are managed with [mise](https://mise.jdx.dev/). Run `mise tasks` to see all available tasks.
### Prerequisites
- [mise](https://mise.jdx.dev/getting-started.html): Manages Go, Rust, Python, and other tools
- [Docker](https://docs.docker.com/desktop) or [OrbStack](https://orbstack.dev)
### Setup
```sh
# Trust the mise configuration and install tools
mise trust
mise install
# Create Python virtualenv and install dependencies
uv venv
uv sync --all-groups
```
### Build & install
```sh
mise run build
# symlink the binary to /usr/local/bin
sudo mise run install
```
After making changes, run `mise run build` to rebuild and it will get picked up by the symlink.
### Common tasks
```sh
# Run all tests
mise run test:go
mise run test:python
mise run test:rust
# Run specific tests
mise run test:go -- ./pkg/config
uv run tox -e py312-tests -- python/tests/server/test_http.py -k test_name
# Format code (all languages)
mise run fmt:fix
# Lint code (all languages)
mise run lint
```
Run `mise tasks` for the complete list of available tasks.
If you encounter any errors, see the troubleshooting section below.
## Project structure
As much as possible, this is attempting to follow the [Standard Go Project Layout](https://github.com/golang-standards/project-layout).
- `cmd/` - The root `cog` command.
- `pkg/cli/` - CLI commands.
- `pkg/config` - Everything `cog.yaml` related.
- `pkg/docker/` - Low-level interface for Docker commands.
- `pkg/dockerfile/` - Creates Dockerfiles.
- `pkg/image/` - Creates and manipulates Cog Docker images.
- `pkg/predict/` - Runs predictions on models.
- `pkg/util/` - Various packages that aren't part of Cog. They could reasonably be separate re-usable projects.
- `python/` - The Cog Python library.
- `integration-tests/` - Go-based integration tests using testscript.
- `tools/compatgen/` - Tool for generating CUDA/PyTorch/TensorFlow compatibility matrices.
For deeper architectural understanding, see the [architecture documentation](./architecture/00-overview.md).
## Updating compatibility matrices
The CUDA base images and framework compatibility matrices in `pkg/config/` are checked into source control and only need to be regenerated when adding support for new versions of CUDA, PyTorch, or TensorFlow.
To regenerate the compatibility matrices, run:
```sh
# Regenerate all matrices
mise run generate:compat
# Or regenerate specific matrices
mise run generate:compat cuda
mise run generate:compat torch
mise run generate:compat tensorflow
```
The generated files are:
- `pkg/config/cuda_base_images.json` - Available NVIDIA CUDA base images
- `pkg/config/torch_compatibility_matrix.json` - PyTorch/CUDA/Python compatibility
- `pkg/config/tf_compatibility_matrix.json` - TensorFlow/CUDA/Python compatibility
## CI tool dependencies
Development tools are managed in **two places** that must be kept in sync:
1. **`mise.toml`** — Tool versions for local development (uses aqua backend for prebuilt binaries)
2. **`.github/workflows/ci.yaml`** — Tool installation for CI (uses dedicated GitHub Actions)
CI deliberately avoids aqua downloads from GitHub Releases to prevent transient 502 failures. Instead, it uses dedicated actions (`taiki-e/install-action`, `go install`, `PyO3/maturin-action`, etc.) that are more reliable.
Tools disabled in CI are listed in `MISE_DISABLE_TOOLS` in `ci.yaml`.
**When updating a tool version**, update both:
- The version in `mise.toml` (for local dev)
- The corresponding version pin in `.github/workflows/ci.yaml` (for CI)
See the [CI Tool Dependencies section in AGENTS.md](./AGENTS.md#ci-tool-dependencies) for the full mapping of tools to their CI installation methods.
## Concepts
There are a few concepts used throughout Cog that might be helpful to understand.
- **Config**: The `cog.yaml` file.
- **Image**: Represents a built Docker image that serves the Cog API, containing a **model**.
- **Input**: Input from a **prediction**, as key/value JSON object.
- **Model**: A user's machine learning model, consisting of code and weights.
- **Output**: Output from a **prediction**, as arbitrarily complex JSON object.
- **Prediction**: A single run of the model, that takes **input** and produces **output**.
- **Predictor**: Defines how Cog runs **predictions** on a **model**.
## Running tests
**To run the entire test suite:**
```sh
mise run test:go
mise run test:python
mise run test:rust
```
**To run just the Go unit tests:**
```sh
mise run test:go
```
**To run just the Python tests:**
```sh
mise run test:python
```
> [!INFO]
> This runs the Python test suite across all supported Python versions (3.10-3.13) using tox.
### Integration Tests
Integration tests are in `integration-tests/` using [testscript](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript). Each test is a self-contained `.txtar` file in `integration-tests/tests/`, with some specialized tests as Go test functions in subpackages.
```sh
# Run all integration tests
mise run test:integration
# Run a specific test
mise run test:integration string_predictor
# Run fast tests only (skip slow GPU/framework tests)
cd integration-tests && go test -short -v
# Run with a custom cog binary
COG_BINARY=/path/to/cog mise run test:integration
```
### Writing Integration Tests
When adding new functionality, add integration tests in `integration-tests/tests/`. They are:
- Self-contained (embedded fixtures in `.txtar` files)
- Faster to run (parallel execution with automatic cleanup)
- Easier to read and write (simple command script format)
Example test structure:
```txtar
# Test string predictor
cog build -t $TEST_IMAGE
cog predict $TEST_IMAGE -i s=world
stdout 'hello world'
-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"
-- predict.py --
from cog import BasePredictor
class Predictor(BasePredictor):
def predict(self, s: str) -> str:
return "hello " + s
```
For testing `cog serve`, use `cog serve` and the `curl` command:
```txtar
cog build -t $TEST_IMAGE
cog serve
curl POST /predictions '{"input":{"s":"test"}}'
stdout '"output":"hello test"'
```
#### Advanced Test Commands
For tests that require subprocess initialization or async operations, use `retry-curl`:
**`retry-curl` - HTTP request with automatic retries:**
```txtar
# Make HTTP request with retry logic (useful for subprocess initialization delays)
# retry-curl [method] [path] [body] [max-attempts] [retry-delay]
retry-curl POST /predictions '{"input":{"s":"test"}}' 30 1s
stdout '"output":"hello test"'
```
**Example: Testing predictor with subprocess in setup**
```txtar
cog build -t $TEST_IMAGE
cog serve
# Use generous retries since setup spawns a background process
retry-curl POST /predictions '{"input":{"s":"test"}}' 30 1s
stdout '"output":"hello test"'
-- predict.py --
class Predictor(BasePredictor):
def setup(self):
self.process = subprocess.Popen(["./background.sh"])
def predict(self, s: str) -> str:
return "hello " + s
```
#### Test Conditions
Use conditions to control when tests run based on environment:
**`[short]` - Skip slow tests in short mode:**
```txtar
[short] skip 'requires GPU or long build time'
cog build -t $TEST_IMAGE
# ... rest of test
```
Run with `go test -short` to skip these tests.
**`[linux]` / `[!linux]` - Platform-specific tests:**
```txtar
[!linux] skip 'requires Linux'
# Linux-specific test
cog build -t $TEST_IMAGE
```
**`[amd64]` / `[!amd64]` - Architecture-specific tests:**
```txtar
[!amd64] skip 'requires amd64 architecture'
# amd64-specific test
cog build -t $TEST_IMAGE
```
**`[linux_amd64]` - Combined platform and architecture:**
```txtar
[!linux_amd64] skip 'requires Linux on amd64'
# Test that requires both Linux and amd64
cog build -t $TEST_IMAGE
```
**Combining conditions:**
Conditions can be negated with `!`. Examples:
- `[short]` - True when `go test -short` is used (skip this test in short mode)
- `[!short]` - True when NOT running with `-short` flag (only run this in full test mode)
- `[!linux]` - True when NOT on Linux
- `[linux_amd64]` - True when on Linux AND amd64
See existing tests in `integration-tests/tests/`, especially `setup_subprocess_*.txtar`, for more examples.
## Running the docs server
To run the docs website server locally:
```sh
mise run docs:serve
```
## Publishing a release
Releases are managed by GitHub Actions workflows. See [`.github/workflows/README.md`](.github/workflows/README.md) for full details.
All packages use **lockstep versioning** from `crates/Cargo.toml`. There are three release types:
| Type | Example tag | Branch rule | PyPI/crates.io? |
|------|-------------|-------------|-----------------|
| **Stable** | `v0.17.0` | Must be on main | Yes |
| **Pre-release** | `v0.17.0-alpha3` | Must be on main | Yes |
| **Dev** | `v0.17.0-dev1` | Any branch | No |
### Stable / Pre-release
```bash
# 1. Update crates/Cargo.toml version (e.g. "0.17.0" or "0.17.0-alpha3")
# 2. Merge to main
# 3. Tag and push
git tag v0.17.0
git push origin v0.17.0
# 4. Wait for release-build.yaml to create a draft release
# 5. Review the draft in GitHub UI, then click "Publish release"
# This triggers release-publish.yaml -> PyPI + crates.io
```
### Dev release
```bash
# From any branch:
# 1. Update crates/Cargo.toml version (e.g. "0.17.0-dev1")
# 2. Commit and push
# 3. Tag and push
git tag v0.17.0-dev1
git push origin v0.17.0-dev1
# 4. Done. Artifacts are built and published as a GH pre-release.
# No PyPI/crates.io. No manual approval.
```
## Troubleshooting
### `cog command not found`
The compiled `cog` binary will be installed in `$GOPATH/bin/cog`, e.g. `~/go/bin/cog`. Make sure that Golang's bin directory is present on your system PATH by adding it to your shell config (`.bashrc`, `.zshrc`, etc):
export PATH=~/go/bin:$PATH
---
Still having trouble? Please [open an issue](https://github.com/replicate/cog/issues) on GitHub.
================================================
FILE: DESIGN.md
================================================
# Design
## Background
Cog came from Andreas's experience at Spotify and Ben's experience at Docker.
At Spotify, Andreas noticed a cluster of related problems:
- **It was hard to run open-source machine learning models.** All the advances in machine learning were locked up inside prose in PDFs, scraps of code on GitHub, weights on Google Drive (if you were lucky!). If you wanted to build upon this research, or apply it to real-world problems, you had to implement it all from scratch.
- **It was hard to deploy machine learning models to production.** Andreas was the only person on the research team who was also an infrastructure engineer. Typically a researcher would have to sit down with Andreas to decide on an API, get a server written, package up dependencies, battle CUDA, get it running efficiently, get it deployed on the cluster, and so on and so forth. It would take weeks to get something running in production.
Ben connected this back to his experience at Docker. What Docker did was define a standard box that software could go in. You could put any kind of server software in there – Python, Java, Ruby on Rails, whatever – and you could then know that you could run it on your local machine or on any cloud, as long as it supported Docker. We wanted to do the same thing for machine learning.
## Vision
We want Cog to be a standard artifact for what a model is and how that model is run.
(More detail...)
## Design principles
There are a few things driving Cog's design:
- **Reproducible artifact**: When you've put your model in Cog, it'll run anywhere, and _keep_ on running. This is why it's a Docker image, with all of the model's dependencies. Docker images have a content-addressable SHA256 ID, which is the identifier for that model's behavior, byte-for-byte.
- **Weights inside the image**: We encourage users to put model weights in images. If the weights are on cloud storage somewhere, then they might change or disappear, and the image will produce different results. There's nothing magical about Docker images – they're just a bundle of files. Docker moves around that bundle of files quite slowly, though, but we can optimize that process so it's as fast as reading weights directly from blob storage, or wherever.
- **Models are just functions**: Models can be lots of things. We are of the opinion that [machine learning is just software](https://replicate.com/blog/machine-learning-needs-better-tools), and a model is just a function. It often needs to be attached to a GPU, but apart from that it's just a normal function that has some input and some output. This is the core difference between Docker's abstraction and Cog's abstraction: Docker packages up an executable, whereas Cog packages up a _function_.
- **Standard interface**: When you run the Docker container, it serves an HTTP server, that is a standard API for running that function. You can think of it like a remote procedure call.
- **Self-describing artifact**: A Cog model has it's schema (or type signature, if you're thinking of it as a function) attached to the image as a label. This means systems that work with Cog models can know what the model is and what requests to send to it. This is what powers the forms on Replicate, for example.
- **Not just the model**: Before Cog, the typical standard packaging formats for machine learning models were at the network level. A way of taking a Tensorflow or PyTorch network and packaging up in a way that would run on lots of different types of accelerators. Things like [ONNX](https://onnx.ai/) or [TVM's IR](https://tvm.apache.org/). We realized that "models" are not just the network, but they are also pre- and post-processing, and are so diverse and the field is so fast-moving that you can't possible squeeze it into some high-level abstraction. It just needs to be code running on a computer.
- **It's just Docker**: Cog models need to run anywhere, and they'll only run anywhere if it's vanilla Docker. We might optimize how Docker images get shipped around to make it faster, but we're not going to invent our own image format.
- **The API is for software developers**: In the olden days, you have to pass tensors to TFServing and know how to generate a tensor from a JPEG. Cog's API intentionally just speaks JSON, strings, files, etc. It's intended to be the interface between the software developer and the ML engineer. Sort of like Docker was intended to be the interface between the software developer and the infrastructure engineer.
- **Cog is the APIs and interfaces, not just the software**: The most important thing about Cog is that it defines a standard for what a model is and how to run it. It doesn't necessarily need to involve Cog the piece of software itself. For example, Replicate could serve a model from OpenAI with a Cog API and schema, but it's not packaged or running with Cog under the hood at all – it's just calling the OpenAI API directly.
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2022, Replicate, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: Makefile
================================================
# Makefile - Shim that delegates to mise tasks
#
# This Makefile provides backward compatibility for common targets.
# All task definitions live in mise.toml. Run `mise tasks` to see available tasks.
#
# For new development, prefer using mise directly:
# mise run build:cog instead of make cog
# mise run test:go instead of make test-go
# mise run fmt:fix instead of make fmt
SHELL := bash
# Show deprecation warning (set MAKE_NO_WARN=1 to suppress)
ifndef MAKE_NO_WARN
$(info )
$(info ┌────────────────────────────────────────────────────────────────────┐)
$(info │ NOTE: This Makefile is a compatibility shim. Prefer using mise: │)
$(info │ │)
$(info │ mise run build:cog mise run test:go mise run fmt:fix │)
$(info │ │)
$(info │ Run 'mise tasks' to see all available tasks. │)
$(info │ Set MAKE_NO_WARN=1 to suppress this message. │)
$(info └────────────────────────────────────────────────────────────────────┘)
$(info )
endif
PREFIX ?= /usr/local
GO ?= go
COG_BINARIES := cog base-image
default: cog
# =============================================================================
# Build targets
# =============================================================================
.PHONY: cog base-image
$(COG_BINARIES):
mise run build:cog
.PHONY: wheel
wheel:
mise run build:sdk
.PHONY: install
install: cog
PREFIX=$(PREFIX) mise run install
# =============================================================================
# Test targets
# =============================================================================
.PHONY: test
test:
mise run test:go
mise run test:python
.PHONY: test-go
test-go:
mise run test:go
.PHONY: test-python
test-python:
mise run test:python
.PHONY: test-integration
test-integration:
mise run test:integration
.PHONY: test-coglet
test-coglet: test-coglet-rust
.PHONY: test-coglet-rust
test-coglet-rust:
mise run test:rust
.PHONY: test-coglet-python
test-coglet-python:
mise run test:coglet:python
# =============================================================================
# Format and lint targets
# =============================================================================
.PHONY: fmt
fmt:
mise run fmt:fix
.PHONY: check-fmt
check-fmt:
mise run fmt
.PHONY: lint
lint:
mise run lint
.PHONY: vet
vet:
$(GO) vet ./...
# =============================================================================
# Code generation
# =============================================================================
.PHONY: generate
generate:
mise run generate
.PHONY: gen-mocks
gen-mocks:
mockery
# =============================================================================
# Coglet (Rust) targets
# =============================================================================
.PHONY: fmt-coglet
fmt-coglet:
mise run fmt:rust:fix
.PHONY: check-fmt-coglet
check-fmt-coglet:
mise run fmt:rust
.PHONY: lint-coglet
lint-coglet:
mise run lint:rust
# =============================================================================
# Documentation
# =============================================================================
.PHONY: run-docs-server
run-docs-server:
mise run docs:serve
# =============================================================================
# Clean
# =============================================================================
.PHONY: clean
clean:
mise run clean
.PHONY: clean-coglet
clean-coglet:
mise run clean:rust
================================================
FILE: README.md
================================================
# Cog: Containers for machine learning
Cog is an open-source tool that lets you package machine learning models in a standard, production-ready container.
You can deploy your packaged model to your own infrastructure, or to [Replicate](https://replicate.com/).
## Highlights
- 📦 **Docker containers without the pain.** Writing your own `Dockerfile` can be a bewildering process. With Cog, you define your environment with a [simple configuration file](#how-it-works) and it generates a Docker image with all the best practices: Nvidia base images, efficient caching of dependencies, installing specific Python versions, sensible environment variable defaults, and so on.
- 🤬️ **No more CUDA hell.** Cog knows which CUDA/cuDNN/PyTorch/Tensorflow/Python combos are compatible and will set it all up correctly for you.
- ✅ **Define the inputs and outputs for your model with standard Python.** Then, Cog generates an OpenAPI schema and validates the inputs and outputs.
- 🎁 **Automatic HTTP prediction server**: Your model's types are used to dynamically generate a RESTful HTTP API using a high-performance Rust/Axum server.
- 🚀 **Ready for production.** Deploy your model anywhere that Docker images run. Your own infrastructure, or [Replicate](https://replicate.com).
## How it works
Define the Docker environment your model runs in with `cog.yaml`:
```yaml
build:
gpu: true
system_packages:
- "libgl1-mesa-glx"
- "libglib2.0-0"
python_version: "3.13"
python_requirements: requirements.txt
predict: "predict.py:Predictor"
```
Define how predictions are run on your model with `predict.py`:
```python
from cog import BasePredictor, Input, Path
import torch
class Predictor(BasePredictor):
def setup(self):
"""Load the model into memory to make running multiple predictions efficient"""
self.model = torch.load("./weights.pth")
# The arguments and types the model takes as input
def predict(self,
image: Path = Input(description="Grayscale input image")
) -> Path:
"""Run a single prediction on the model"""
processed_image = preprocess(image)
output = self.model(processed_image)
return postprocess(output)
```
In the above we accept a path to the image as an input, and return a path to our transformed image after running it through our model.
Now, you can run predictions on this model:
```console
$ cog predict -i image=@input.jpg
--> Building Docker image...
--> Running Prediction...
--> Output written to output.jpg
```
Or, build a Docker image for deployment:
```console
$ cog build -t my-classification-model
--> Building Docker image...
--> Built my-classification-model:latest
$ docker run -d -p 5000:5000 --gpus all my-classification-model
$ curl http://localhost:5000/predictions -X POST \
-H 'Content-Type: application/json' \
-d '{"input": {"image": "https://.../input.jpg"}}'
```
Or, combine build and run via the `serve` command:
```console
$ cog serve -p 8080
$ curl http://localhost:8080/predictions -X POST \
-H 'Content-Type: application/json' \
-d '{"input": {"image": "https://.../input.jpg"}}'
```
<!-- NOTE (bfirsh): Development environment instructions intentionally left out of readme for now, so as not to confuse the "ship a model to production" message.
In development, you can also run arbitrary commands inside the Docker environment:
```console
$ cog run python train.py
...
```
Or, [spin up a Jupyter notebook](docs/notebooks.md):
```console
$ cog run -p 8888 jupyter notebook --allow-root --ip=0.0.0.0
```
-->
## Why are we building this?
It's really hard for researchers to ship machine learning models to production.
Part of the solution is Docker, but it is so complex to get it to work: Dockerfiles, pre-/post-processing, Flask servers, CUDA versions. More often than not the researcher has to sit down with an engineer to get the damn thing deployed.
[Andreas](https://github.com/andreasjansson) and [Ben](https://github.com/bfirsh) created Cog. Andreas used to work at Spotify, where he built tools for building and deploying ML models with Docker. Ben worked at Docker, where he created [Docker Compose](https://github.com/docker/compose).
We realized that, in addition to Spotify, other companies were also using Docker to build and deploy machine learning models. [Uber](https://eng.uber.com/michelangelo-pyml/) and others have built similar systems. So, we're making an open source version so other people can do this too.
Hit us up if you're interested in using it or want to collaborate with us. [We're on Discord](https://discord.gg/replicate) or email us at [team@replicate.com](mailto:team@replicate.com).
## Prerequisites
- **macOS, Linux or Windows 11**. Cog works on macOS, Linux and Windows 11 with [WSL 2](docs/wsl2/wsl2.md)
- **Docker**. Cog uses Docker to create a container for your model. You'll need to [install Docker](https://docs.docker.com/get-docker/) before you can run Cog. If you install Docker Engine instead of Docker Desktop, you will need to [install Buildx](https://docs.docker.com/build/architecture/#buildx) as well.
## Install
If you're using macOS, you can install Cog using Homebrew:
```console
brew install replicate/tap/cog
```
You can also download and install the latest release using our
[install script](https://cog.run/install):
```sh
# bash, zsh, and other shells
sh <(curl -fsSL https://cog.run/install.sh)
# fish shell
sh (curl -fsSL https://cog.run/install.sh | psub)
# download with wget and run in a separate command
wget -qO- https://cog.run/install.sh
sh ./install.sh
```
You can manually install the latest release of Cog directly from GitHub
by running the following commands in a terminal:
```console
sudo curl -o /usr/local/bin/cog -L "https://github.com/replicate/cog/releases/latest/download/cog_$(uname -s)_$(uname -m)"
sudo chmod +x /usr/local/bin/cog
```
Or if you are on docker:
```
RUN sh -c "INSTALL_DIR=\"/usr/local/bin\" SUDO=\"\" $(curl -fsSL https://cog.run/install.sh)"
```
## Upgrade
If you're using macOS and you previously installed Cog with Homebrew, run the following:
```console
brew upgrade replicate/tap/cog
```
Otherwise, you can upgrade to the latest version by running the same commands you used to install it.
## Development
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to set up a development environment and build from source.
## Next steps
- [Get started with an example model](docs/getting-started.md)
- [Get started with your own model](docs/getting-started-own-model.md)
- [Using Cog with notebooks](docs/notebooks.md)
- [Using Cog with Windows 11](docs/wsl2/wsl2.md)
- [Take a look at some examples of using Cog](https://github.com/replicate/cog-examples)
- [Deploy models with Cog](docs/deploy.md)
- [`cog.yaml` reference](docs/yaml.md) to learn how to define your model's environment
- [Prediction interface reference](docs/python.md) to learn how the `Predictor` interface works
- [Training interface reference](docs/training.md) to learn how to add a fine-tuning API to your model
- [HTTP API reference](docs/http.md) to learn how to use the HTTP API that models serve
## Need help?
[Join us in #cog on Discord.](https://discord.gg/replicate)
[](https://deepwiki.com/replicate/cog)
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://fir.sh/"><img src="https://avatars.githubusercontent.com/u/40906?v=4?s=100" width="100px;" alt="Ben Firshman"/><br /><sub><b>Ben Firshman</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=bfirsh" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=bfirsh" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://replicate.ai/"><img src="https://avatars.githubusercontent.com/u/713993?v=4?s=100" width="100px;" alt="Andreas Jansson"/><br /><sub><b>Andreas Jansson</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=andreasjansson" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=andreasjansson" title="Documentation">📖</a> <a href="#maintenance-andreasjansson" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://zeke.sikelianos.com/"><img src="https://avatars.githubusercontent.com/u/2289?v=4?s=100" width="100px;" alt="Zeke Sikelianos"/><br /><sub><b>Zeke Sikelianos</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=zeke" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=zeke" title="Documentation">📖</a> <a href="#tool-zeke" title="Tools">🔧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://rory.bio/"><img src="https://avatars.githubusercontent.com/u/9436784?v=4?s=100" width="100px;" alt="Rory Byrne"/><br /><sub><b>Rory Byrne</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=synek" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=synek" title="Documentation">📖</a> <a href="https://github.com/replicate/cog/commits?author=synek" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hangtwenty"><img src="https://avatars.githubusercontent.com/u/2420688?v=4?s=100" width="100px;" alt="Michael Floering"/><br /><sub><b>Michael Floering</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=hangtwenty" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=hangtwenty" title="Documentation">📖</a> <a href="#ideas-hangtwenty" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://bencevans.io/"><img src="https://avatars.githubusercontent.com/u/638535?v=4?s=100" width="100px;" alt="Ben Evans"/><br /><sub><b>Ben Evans</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=bencevans" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://shashank.pw/"><img src="https://avatars.githubusercontent.com/u/778870?v=4?s=100" width="100px;" alt="shashank agarwal"/><br /><sub><b>shashank agarwal</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=imshashank" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=imshashank" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://victorxlr.me/"><img src="https://avatars.githubusercontent.com/u/22397950?v=4?s=100" width="100px;" alt="VictorXLR"/><br /><sub><b>VictorXLR</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=VictorXLR" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=VictorXLR" title="Documentation">📖</a> <a href="https://github.com/replicate/cog/commits?author=VictorXLR" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://annahung31.github.io/"><img src="https://avatars.githubusercontent.com/u/39179888?v=4?s=100" width="100px;" alt="hung anna"/><br /><sub><b>hung anna</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aannahung31" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://notes.variogr.am/"><img src="https://avatars.githubusercontent.com/u/76612?v=4?s=100" width="100px;" alt="Brian Whitman"/><br /><sub><b>Brian Whitman</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Abwhitman" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/JimothyJohn"><img src="https://avatars.githubusercontent.com/u/24216724?v=4?s=100" width="100px;" alt="JimothyJohn"/><br /><sub><b>JimothyJohn</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3AJimothyJohn" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ericguizzo"><img src="https://avatars.githubusercontent.com/u/26746670?v=4?s=100" width="100px;" alt="ericguizzo"/><br /><sub><b>ericguizzo</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aericguizzo" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.dominicbaggott.com"><img src="https://avatars.githubusercontent.com/u/74812?v=4?s=100" width="100px;" alt="Dominic Baggott"/><br /><sub><b>Dominic Baggott</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=evilstreak" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=evilstreak" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dashstander"><img src="https://avatars.githubusercontent.com/u/7449128?v=4?s=100" width="100px;" alt="Dashiell Stander"/><br /><sub><b>Dashiell Stander</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Adashstander" title="Bug reports">🐛</a> <a href="https://github.com/replicate/cog/commits?author=dashstander" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=dashstander" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Hurricane-eye"><img src="https://avatars.githubusercontent.com/u/31437546?v=4?s=100" width="100px;" alt="Shuwei Liang"/><br /><sub><b>Shuwei Liang</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3AHurricane-eye" title="Bug reports">🐛</a> <a href="#question-Hurricane-eye" title="Answering Questions">💬</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ericallam"><img src="https://avatars.githubusercontent.com/u/534?v=4?s=100" width="100px;" alt="Eric Allam"/><br /><sub><b>Eric Allam</b></sub></a><br /><a href="#ideas-ericallam" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://perdomo.me"><img src="https://avatars.githubusercontent.com/u/178474?v=4?s=100" width="100px;" alt="Iván Perdomo"/><br /><sub><b>Iván Perdomo</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aiperdomo" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://charlesfrye.github.io"><img src="https://avatars.githubusercontent.com/u/10442975?v=4?s=100" width="100px;" alt="Charles Frye"/><br /><sub><b>Charles Frye</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=charlesfrye" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/phamquiluan"><img src="https://avatars.githubusercontent.com/u/24642166?v=4?s=100" width="100px;" alt="Luan Pham"/><br /><sub><b>Luan Pham</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aphamquiluan" title="Bug reports">🐛</a> <a href="https://github.com/replicate/cog/commits?author=phamquiluan" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/TommyDew42"><img src="https://avatars.githubusercontent.com/u/46992350?v=4?s=100" width="100px;" alt="TommyDew"/><br /><sub><b>TommyDew</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=TommyDew42" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://m4ke.org"><img src="https://avatars.githubusercontent.com/u/27?v=4?s=100" width="100px;" alt="Jesse Andrews"/><br /><sub><b>Jesse Andrews</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=anotherjesse" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=anotherjesse" title="Documentation">📖</a> <a href="https://github.com/replicate/cog/commits?author=anotherjesse" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://whiteink.com"><img src="https://avatars.githubusercontent.com/u/3602?v=4?s=100" width="100px;" alt="Nick Stenning"/><br /><sub><b>Nick Stenning</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=nickstenning" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=nickstenning" title="Documentation">📖</a> <a href="#design-nickstenning" title="Design">🎨</a> <a href="#infra-nickstenning" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/replicate/cog/commits?author=nickstenning" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://merrell.io/"><img src="https://avatars.githubusercontent.com/u/14996837?v=4?s=100" width="100px;" alt="Justin Merrell"/><br /><sub><b>Justin Merrell</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=justinmerrell" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ruriky"><img src="https://avatars.githubusercontent.com/u/19946546?v=4?s=100" width="100px;" alt="Rurik Ylä-Onnenvuori"/><br /><sub><b>Rurik Ylä-Onnenvuori</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aruriky" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.youka.club/"><img src="https://avatars.githubusercontent.com/u/59315275?v=4?s=100" width="100px;" alt="Youka"/><br /><sub><b>Youka</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Ayoukaclub" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/afiaka87"><img src="https://avatars.githubusercontent.com/u/3994972?v=4?s=100" width="100px;" alt="Clay Mullis"/><br /><sub><b>Clay Mullis</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=afiaka87" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mattt"><img src="https://avatars.githubusercontent.com/u/7659?v=4?s=100" width="100px;" alt="Mattt"/><br /><sub><b>Mattt</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=mattt" title="Code">💻</a> <a href="https://github.com/replicate/cog/commits?author=mattt" title="Documentation">📖</a> <a href="#infra-mattt" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Juneezee"><img src="https://avatars.githubusercontent.com/u/20135478?v=4?s=100" width="100px;" alt="Eng Zer Jun"/><br /><sub><b>Eng Zer Jun</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=Juneezee" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bbedward"><img src="https://avatars.githubusercontent.com/u/550752?v=4?s=100" width="100px;" alt="BB"/><br /><sub><b>BB</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=bbedward" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/williamluer"><img src="https://avatars.githubusercontent.com/u/85975676?v=4?s=100" width="100px;" alt="williamluer"/><br /><sub><b>williamluer</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=williamluer" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://sirupsen.com"><img src="https://avatars.githubusercontent.com/u/97400?v=4?s=100" width="100px;" alt="Simon Eskildsen"/><br /><sub><b>Simon Eskildsen</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=sirupsen" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://erbridge.co.uk"><img src="https://avatars.githubusercontent.com/u/1027364?v=4?s=100" width="100px;" alt="F"/><br /><sub><b>F</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aerbridge" title="Bug reports">🐛</a> <a href="https://github.com/replicate/cog/commits?author=erbridge" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/philandstuff"><img src="https://avatars.githubusercontent.com/u/581269?v=4?s=100" width="100px;" alt="Philip Potter"/><br /><sub><b>Philip Potter</b></sub></a><br /><a href="https://github.com/replicate/cog/issues?q=author%3Aphilandstuff" title="Bug reports">🐛</a> <a href="https://github.com/replicate/cog/commits?author=philandstuff" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/joannejchen"><img src="https://avatars.githubusercontent.com/u/33409024?v=4?s=100" width="100px;" alt="Joanne Chen"/><br /><sub><b>Joanne Chen</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=joannejchen" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://technillogue.github.io"><img src="https://avatars.githubusercontent.com/u/945691?v=4?s=100" width="100px;" alt="technillogue"/><br /><sub><b>technillogue</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=technillogue" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://aroncarroll.com"><img src="https://avatars.githubusercontent.com/u/47144?v=4?s=100" width="100px;" alt="Aron Carroll"/><br /><sub><b>Aron Carroll</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=aron" title="Documentation">📖</a> <a href="https://github.com/replicate/cog/commits?author=aron" title="Code">💻</a> <a href="#ideas-aron" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Theodotus1243"><img src="https://avatars.githubusercontent.com/u/32220358?v=4?s=100" width="100px;" alt="Bohdan Mykhailenko"/><br /><sub><b>Bohdan Mykhailenko</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=Theodotus1243" title="Documentation">📖</a> <a href="https://github.com/replicate/cog/issues?q=author%3ATheodotus1243" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/one1zero1one"><img src="https://avatars.githubusercontent.com/u/724604?v=4?s=100" width="100px;" alt="Daniel Radu"/><br /><sub><b>Daniel Radu</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=one1zero1one" title="Documentation">📖</a> <a href="https://github.com/replicate/cog/issues?q=author%3Aone1zero1one" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Etelis"><img src="https://avatars.githubusercontent.com/u/92247226?v=4?s=100" width="100px;" alt="Itay Etelis"/><br /><sub><b>Itay Etelis</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=Etelis" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.wavefunction.dev"><img src="https://avatars.githubusercontent.com/u/54407820?v=4?s=100" width="100px;" alt="Gennaro Schiano"/><br /><sub><b>Gennaro Schiano</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=gschian0" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://andreknoerig.de"><img src="https://avatars.githubusercontent.com/u/481350?v=4?s=100" width="100px;" alt="André Knörig"/><br /><sub><b>André Knörig</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=aknoerig" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://condense.live"><img src="https://avatars.githubusercontent.com/u/24726?v=4?s=100" width="100px;" alt="Dan Fairs"/><br /><sub><b>Dan Fairs</b></sub></a><br /><a href="https://github.com/replicate/cog/commits?author=danfairs" title="Code">💻</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
================================================
FILE: architecture/00-overview.md
================================================
# Cog Architecture Overview
Cog packages machine learning models into production-ready OCI images.
## The Big Picture
```mermaid
flowchart LR
subgraph input["What you write"]
model["Model Code<br/>+ cog.yaml"]
end
subgraph cog["Cog"]
cli["CLI"]
sdk["Python SDK"]
end
subgraph output["What you get"]
image["Container Image"]
api["HTTP API"]
end
model --> cli
cli -->|"builds"| image
image -->|"runs"| sdk
sdk -->|"serves"| api
```
## Components
### Model Source
What the model author provides: `cog.yaml` for environment config, a Predictor class with `setup()` and `predict()` methods, and optionally model weights.
**Deep dive**: [Model Source](./01-model-source.md)
---
### Schema
An OpenAPI specification generated from the predictor's type hints. Describes what inputs the model accepts and what outputs it produces.
**Deep dive**: [Schema](./02-schema.md)
---
### Prediction API
The HTTP interface for running predictions. A fixed envelope format (`PredictionRequest`/`PredictionResponse`) wraps model-specific inputs and outputs.
**Deep dives**:
- [Legacy API](./legacy/03-prediction-api.md) - FastAPI implementation details
- [FFI API](./ffi/03-prediction-api.md) - Rust/Axum implementation details
---
### Container Runtime
The runtime that runs inside the container: an HTTP server, worker process isolation, and prediction execution. Cog has two runtime implementations:
- **Legacy (Python/FastAPI)**: Current default implementation - [Documentation](./legacy/)
- **FFI (Rust/PyO3)**: Next-generation experimental implementation - [Documentation](./ffi/)
**Deep dives**:
- [Legacy Runtime](./legacy/04-container-runtime.md) - FastAPI/Uvicorn two-process architecture
- [FFI Runtime](./ffi/04-container-runtime.md) - Rust/Axum with PyO3 FFI bridge
---
### Build System
Transforms `cog.yaml` and user code into a Docker image with the right Python version, CUDA libraries, and dependencies.
**Deep dive**: [Build System](./05-build-system.md)
---
### CLI
The command-line tool for building, testing, and deploying models.
**Deep dive**: [CLI](./06-cli.md)
---
## How It Fits Together
```mermaid
flowchart TB
subgraph source["Model Source"]
yaml["cog.yaml"]
code["predict.py"]
weights["weights"]
end
subgraph build["Build Time"]
config["Config Parser"]
generator["Dockerfile Generator"]
schema_gen["Schema Generator"]
end
subgraph image["Container Image"]
layers["Base + Deps + Code"]
schema["OpenAPI Schema<br/>(label)"]
end
subgraph runtime["Runtime"]
server["HTTP Server"]
worker["Worker Process"]
predictor["Predictor"]
end
yaml --> config
config --> generator
generator --> layers
code --> layers
weights --> layers
layers --> schema_gen
schema_gen --> schema
image --> server
server --> worker
worker --> predictor
```
## Terminology
| Term | Meaning |
|------|---------|
| **Predictor** | User's model class with `setup()` and `predict()` methods |
| **Schema** | OpenAPI spec describing the model's input/output interface |
| **Envelope** | Fixed request/response structure wrapping model-specific data |
| **Worker** | Isolated subprocess running user code |
| **Setup** | One-time model initialization at container start |
## Runtime Implementations
Cog supports two runtime implementations:
### Legacy Runtime (Python/FastAPI)
- **Status**: Current default
- **Use when**: Running standard Cog containers
- **Implementation**: `python/cog/server/`
- **Documentation**: [legacy/](./legacy/)
### FFI Runtime (Rust/PyO3)
- **Status**: Experimental (in development)
- **Use when**: Set `USE_COGLET` environment variable
- **Implementation**: `crates/coglet/`
- **Documentation**: [ffi/](./ffi/)
- **Benefits**: Better performance, stability, and resource management
Both runtimes expose the same HTTP API and support the same model code. The FFI runtime is a drop-in replacement with improved internals.
## Reading Order
For understanding Cog's architecture, we recommend reading in this order:
1. [Model Source](./01-model-source.md) - What users write
2. [Schema](./02-schema.md) - How the interface is described
3. **Choose a runtime path**:
- **Legacy**: [Prediction API](./legacy/03-prediction-api.md) → [Container Runtime](./legacy/04-container-runtime.md)
- **FFI**: [Prediction API](./ffi/03-prediction-api.md) → [Container Runtime](./ffi/04-container-runtime.md)
4. [Build System](./05-build-system.md) - How images are built
5. [CLI](./06-cli.md) - How users interact with it all
================================================
FILE: architecture/01-model-source.md
================================================
# Model Source
This document covers what a model author provides to Cog and the primitives they work with.
## What Users Write
A Cog model consists of:
```
my-model/
├── cog.yaml # Environment configuration
├── predict.py # Predictor class
└── weights/ # Model weights (optional, can be downloaded)
```
## cog.yaml
Declares the runtime environment:
```yaml
build:
python_version: "3.11"
gpu: true
python_packages:
- torch==2.1.0
- transformers==4.35.0
system_packages:
- ffmpeg
run:
- curl -o /src/model.bin https://example.com/model.bin
predict: "predict.py:Predictor"
concurrency:
max: 1
```
| Field | Purpose |
|-------|---------|
| `build.python_version` | Python interpreter version (3.10-3.13) |
| `build.gpu` | Enable CUDA support |
| `build.python_packages` | pip packages to install |
| `build.system_packages` | apt packages to install |
| `build.run` | Arbitrary shell commands during build |
| `predict` | Path to predictor class (`module:ClassName`) |
| `train` | Path to training class (optional) |
| `concurrency.max` | Max concurrent predictions (requires async) |
The [Build System](./05-build-system.md) uses this configuration to produce an image containing all necessary dependencies, libraries, and the correct Python/CUDA versions.
## The Predictor Class
A predictor is a Python class with two methods:
```python
from cog import BasePredictor, Input, Path
class Predictor(BasePredictor):
def setup(self):
"""Load model into memory. Called once at container start."""
self.model = load_model("./weights")
def predict(self, prompt: str, steps: int = 50) -> Path:
"""Run inference. Called for each prediction request."""
output = self.model.generate(prompt, steps=steps)
output.save("/tmp/output.png")
return Path("/tmp/output.png")
```
### setup()
- Called **once** when the container starts
- Used to load model weights, initialize GPU contexts, warm up caches
- Runs before the HTTP server accepts requests
- Optional: if omitted, Cog proceeds directly to serving
### predict()
- Called **for each prediction request**
- Signature defines the model's input schema (via type hints)
- Return type defines the output schema
- Can be sync (`def`) or async (`async def`)
### train() (optional)
- Same contract as `predict()` but for fine-tuning workflows
- Configured separately in `cog.yaml` with `train:` key
## Input Types
The types used in `predict()` parameters become the model's input schema.
### Basic Types
```python
def predict(
self,
text: str, # String input
count: int, # Integer
temperature: float, # Float
verbose: bool, # Boolean
) -> str:
```
### File Inputs (cog.Path)
URLs are automatically downloaded to local files:
```python
from cog import Path
def predict(self, image: Path) -> Path:
# Client sends: {"input": {"image": "https://example.com/photo.jpg"}}
# Cog downloads the URL, `image` is a local path like /tmp/inputabc123.jpg
img = PIL.Image.open(image)
...
```
`cog.Path` extends `pathlib.Path`. At runtime:
- HTTP/HTTPS URLs are downloaded to temp files
- Data URLs are decoded
- The predictor receives a local filesystem path
### Secrets (cog.Secret)
For sensitive values that shouldn't appear in logs:
```python
from cog import Secret
def predict(self, api_key: Secret) -> str:
# Value is masked in logs and webhooks
client = SomeAPI(api_key.get_secret_value())
...
```
### Input Constraints
Use `Input()` to add metadata and validation:
```python
from cog import Input
def predict(
self,
prompt: str = Input(description="The text prompt"),
steps: int = Input(default=50, ge=1, le=100, description="Inference steps"),
style: str = Input(choices=["photo", "art", "sketch"]),
) -> str:
```
| Parameter | Effect |
|-----------|--------|
| `description` | Shown in UI and schema |
| `default` | Default value if not provided |
| `ge`, `le` | Numeric bounds (greater/less than or equal) |
| `min_length`, `max_length` | String length bounds |
| `choices` | Enum values (deprecated: prefer `Literal`) |
### Enums with Literal
```python
from typing import Literal
def predict(
self,
size: Literal["small", "medium", "large"] = "medium",
) -> str:
```
### Lists
```python
from typing import List
from cog import Path
def predict(
self,
images: List[Path], # Multiple file inputs
tags: List[str], # Multiple strings
) -> str:
```
### Optional Inputs
```python
from typing import Optional
def predict(
self,
seed: Optional[int] = None, # Can be omitted or null
) -> str:
```
## Output Types
The return type annotation defines what the model produces.
### Basic Types
```python
def predict(self, prompt: str) -> str:
return "Generated text..."
```
### File Outputs
Return `cog.Path` pointing to a generated file:
```python
from cog import Path
def predict(self, prompt: str) -> Path:
# Generate file
output_path = "/tmp/output.png"
self.model.generate(prompt).save(output_path)
return Path(output_path)
```
At runtime, Cog uploads the file and returns a URL to the client.
### Multiple Outputs
Return a list:
```python
from typing import List
from cog import Path
def predict(self, prompt: str) -> List[Path]:
paths = []
for i in range(4):
path = f"/tmp/output_{i}.png"
self.model.generate(prompt, seed=i).save(path)
paths.append(Path(path))
return paths
```
### Streaming with Iterator
Yield values progressively:
```python
from typing import Iterator
def predict(self, prompt: str) -> Iterator[str]:
for token in self.model.generate_stream(prompt):
yield token
```
The schema marks this as `x-cog-array-type: iterator`. Clients receive outputs as they're produced via webhooks or streaming responses.
### Streaming Text with ConcatenateIterator
For LLM-style token streaming where outputs should be concatenated:
```python
from cog import ConcatenateIterator
def predict(self, prompt: str) -> ConcatenateIterator[str]:
for token in self.model.generate(prompt):
yield token # "Hello", " ", "world", "!"
# Client sees progressive: "Hello" -> "Hello " -> "Hello world" -> "Hello world!"
```
The schema includes `x-cog-array-display: concatenate` to signal that outputs should be joined rather than displayed as a list.
## Weights
Model weights can be loaded in several ways:
### Bundled in the Image
Include weights in your source directory - they're copied into the image during build:
```
my-model/
├── cog.yaml
├── predict.py
└── weights/
└── model.safetensors
```
```python
def setup(self):
self.model = load("./weights/model.safetensors")
```
### Downloaded at Runtime
Weights can be fetched during `setup()` rather than bundled. Common approaches:
**Using the `weights` parameter** (Cog's built-in mechanism):
```python
class Predictor(BasePredictor):
def setup(self, weights: Path):
self.model = load(weights)
```
The `weights` value comes from `COG_WEIGHTS` env var or falls back to `./weights`:
```bash
COG_WEIGHTS=https://example.com/model.tar cog predict ...
```
**Using pget** (parallel download tool, included in Cog images):
```python
import subprocess
def setup(self):
subprocess.run(["pget", "https://example.com/model.tar", "./weights"])
self.model = load("./weights/model.safetensors")
```
**Direct download in setup**:
```python
def setup(self):
# Using requests, huggingface_hub, or any other method
snapshot_download(repo_id="meta-llama/Llama-2-7b", local_dir="./weights")
self.model = load("./weights")
```
The choice depends on your deployment needs - bundled weights make images larger but start faster; downloaded weights keep images small but require network access at startup.
## Async Predictors
For concurrent predictions, use async:
```python
class Predictor(BasePredictor):
async def setup(self):
self.model = await load_model_async()
async def predict(self, prompt: str) -> str:
return await self.model.generate(prompt)
```
Requires:
- Python 3.11+
- `concurrency.max > 1` in cog.yaml
See [Container Runtime](./04-container-runtime.md) for concurrency details.
## Code References
| File | Purpose |
|------|---------|
| `python/cog/__init__.py` | Public API exports |
| `python/cog/base_predictor.py` | BasePredictor class |
| `python/cog/types.py` | Input, Path, Secret, ConcatenateIterator |
| `python/cog/predictor.py` | Type introspection, weights handling |
| `pkg/config/config.go` | cog.yaml parsing |
================================================
FILE: architecture/02-schema.md
================================================
# Schema
The schema is an **OpenAPI 3.0.2 specification** that describes a model's interface. It's the contract between the model and everything that interacts with it.
## Why the Schema Exists
Every Cog model uses the same [Prediction API](./ffi/03-prediction-api.md) envelope format, but the `input` and `output` fields are model-specific. The schema captures what each model expects and produces.
```
┌─────────────────────────────────────────────────┐
│ PredictionRequest (fixed envelope) │
│ ┌─────────────────────────────────────────┐ │
│ │ "input": { ... } <- model-specific │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
↑
Schema defines this part
```
Without the schema, consumers would have no way to know:
- What inputs the model accepts
- What types those inputs should be
- What constraints apply (required fields, min/max values, allowed choices)
- What the output looks like
### How It's Used Today
| Consumer | What They Use the Schema For |
|----------|------------------------------|
| **Replicate platform** | Generate input forms in the web UI, validate requests before routing to models |
| **HTTP server (coglet)** | Validate incoming JSON, reject malformed requests before they reach user code |
| **CLI (`cog predict`)** | Parse `-i key=value` flags into correctly-typed Python objects |
| **Docker label** | Extract model interface without running the container |
| **API clients** | Know what to send and what to expect back without reading source code |
## How It's Generated
Cog supports two schema generation paths:
### Legacy Runtime Path (default)
The **legacy path** boots the built Docker container and runs `python -m cog.command.openapi_schema` to introspect the model at runtime using pydantic. This is the default for all builds. It works with any Python type that pydantic can serialize, including third-party types, complex inheritance, and dynamically constructed classes.
### Static Path (opt-in)
The **static path** parses Python source code at `cog build` time using [tree-sitter](https://tree-sitter.github.io/tree-sitter/) in Go. No Python runtime is invoked. This makes schema generation deterministic, fast, and independent of the model's dependencies.
Enable it by setting the `COG_STATIC_SCHEMA` environment variable:
```bash
COG_STATIC_SCHEMA=1 cog build -t my-model
```
The static path requires SDK >= 0.17.0. When opted in, if the static parser encounters a type it cannot resolve, it **falls back to the legacy runtime path** automatically with a warning — so builds never fail due to static parser limitations.
For local commands (`cog train`, `cog serve`, `cog predict`), the static path is always used regardless of the `COG_STATIC_SCHEMA` flag, because these commands return before the post-build legacy generation step — the CLI needs the schema to parse `-i` input flags.
```mermaid
flowchart LR
subgraph source["Model Source"]
predict["predict.py"]
types["output_types.py"]
end
subgraph parser["Go Static Parser"]
ts["tree-sitter Python"]
resolve["Type Resolver"]
cross["Cross-File Resolver"]
end
subgraph output["Schema"]
spec["OpenAPI 3.0.2 JSON"]
end
predict --> ts
types --> cross
ts --> resolve
cross --> resolve
resolve --> spec
```
### Static Path Pipeline Steps
1. **Parse** the predictor file with tree-sitter (concrete syntax tree, not AST)
2. **Collect imports** — track where each name came from (`from cog import Path`, `from pydantic import BaseModel`)
3. **Collect module scope** — resolve module-level variable assignments (for default values, choices lists)
4. **Collect BaseModel subclasses** — find all classes that inherit from `BaseModel` (cog or pydantic) in the current file
5. **Resolve cross-file models** — for imported names not found locally, find the `.py` file on disk, parse it, and extract its BaseModel definitions
6. **Extract inputs** — walk the `predict()` / `train()` method parameters, resolve types, defaults, and `Input()` metadata
7. **Resolve output type** — recursively resolve the return type annotation into a `SchemaType`
8. **Generate OpenAPI** — convert the extracted `PredictorInfo` into a full OpenAPI 3.0.2 JSON document
If any step fails with an unresolvable type, the build falls back to the legacy runtime path.
### Cross-File Resolution
When a predictor imports types from other project files, the schema generator resolves them automatically:
```python
# output_types.py
from pydantic import BaseModel
class Prediction(BaseModel):
text: str
score: float
tags: list[str]
```
```python
# predict.py
from cog import BasePredictor
from output_types import Prediction
class Predictor(BasePredictor):
def predict(self, prompt: str) -> Prediction:
...
```
The resolver handles every permutation of local imports:
| Import Style | File Resolved |
|-------------|---------------|
| `from output_types import X` | `<project>/output_types.py` |
| `from .output_types import X` | `<project>/output_types.py` |
| `from models.output import X` | `<project>/models/output.py` |
| `from .models.output import X` | `<project>/models/output.py` |
| `from output_types import X as Y` | `<project>/output_types.py` (alias tracked) |
**How it distinguishes local from external**: the resolver converts the module path to a filesystem path and checks if the file exists. If `output_types.py` exists in the project directory, it's local. If not (e.g., `from transformers import ...`), it's external. Known external packages (stdlib, torch, numpy, etc.) are skipped without a filesystem check.
**Error messages**: when a type can't be resolved, the error includes the import source:
```
cannot resolve output type 'WeirdType' (imported from 'some_package') —
external types cannot be statically analyzed. Define it as a BaseModel
subclass in your predict file, or provide a .pyi stub
```
## SchemaType: The Type System
Output types are represented as a recursive algebraic data type (`SchemaType`) that composes arbitrarily:
```
SchemaType
├── SchemaPrimitive — str, int, float, bool, Path
├── SchemaAny — untyped (bare dict, Any)
├── SchemaArray — list[T], with Items → SchemaType
├── SchemaDict -- dict[str, V], with ValueType -> SchemaType
├── SchemaObject — BaseModel subclass, with Fields → OrderedMap[name, SchemaField]
├── SchemaIterator — Iterator[T], with Elem → SchemaType
└── SchemaConcatIterator — ConcatenateIterator[str]
```
This recursive structure means nested types like `dict[str, list[dict[str, int]]]` are fully representable and produce correct JSON Schema:
```json
{
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"type": "integer"
}
}
}
}
```
### JSON Schema Generation
Each `SchemaType` produces its JSON Schema fragment via `JSONSchema()`:
| SchemaType Kind | JSON Schema |
|-----------------|-------------|
| `SchemaPrimitive(str)` | `{"type": "string"}` |
| `SchemaPrimitive(Path)` | `{"type": "string", "format": "uri"}` |
| `SchemaAny` | `{"type": "object"}` |
| `SchemaArray(items)` | `{"type": "array", "items": items.JSONSchema()}` |
| `SchemaDict(valueType)` | `{"type": "object", "additionalProperties": valueType.JSONSchema()}` |
| `SchemaObject(fields)` | `{"type": "object", "properties": {...}, "required": [...]}` |
| `SchemaIterator(elem)` | `{"type": "array", "items": elem.JSONSchema(), "x-cog-array-type": "iterator"}` |
| `SchemaConcatIterator` | `{"type": "array", "items": {"type": "string"}, "x-cog-array-type": "iterator", "x-cog-array-display": "concatenate"}` |
## Type Mappings
### Input Types
| Python | JSON Schema | Notes |
|--------|-------------|-------|
| `str` | `{"type": "string"}` | |
| `int` | `{"type": "integer"}` | |
| `float` | `{"type": "number"}` | |
| `bool` | `{"type": "boolean"}` | |
| `cog.Path` | `{"type": "string", "format": "uri"}` | URLs downloaded at runtime |
| `cog.File` | `{"type": "string", "format": "uri"}` | File uploads |
| `cog.Secret` | `{"type": "string", "format": "password", "x-cog-secret": true}` | Masked in logs |
| `list[T]` | `{"type": "array", "items": {...}}` | |
| `Optional[T]` | Type T + not in `required` | Input fields only |
| `Literal["a", "b"]` / `choices=[...]` | `{"enum": ["a", "b"]}` | |
### Output Types
| Python | SchemaType | JSON Schema |
|--------|------------|-------------|
| `str` | `SchemaPrimitive` | `{"type": "string"}` |
| `int` | `SchemaPrimitive` | `{"type": "integer"}` |
| `float` | `SchemaPrimitive` | `{"type": "number"}` |
| `bool` | `SchemaPrimitive` | `{"type": "boolean"}` |
| `Path` | `SchemaPrimitive` | `{"type": "string", "format": "uri"}` |
| `dict` (bare) | `SchemaAny` | `{"type": "object"}` |
| `dict[str, V]` | `SchemaDict` | `{"type": "object", "additionalProperties": V}` |
| `list` (bare) | `SchemaArray(SchemaAny)` | `{"type": "array", "items": {"type": "object"}}` |
| `list[T]` | `SchemaArray` | `{"type": "array", "items": T}` |
| `BaseModel` subclass | `SchemaObject` | `{"type": "object", "properties": {...}}` |
| `Iterator[T]` | `SchemaIterator` | `{"type": "array", "items": T, "x-cog-array-type": "iterator"}` |
| `ConcatenateIterator[str]` | `SchemaConcatIterator` | Streaming token output |
| Nested types | Recursive | `dict[str, list[dict[str, int]]]` fully supported |
### Unsupported Output Types
| Python | Error |
|--------|-------|
| `Optional[T]` / `T \| None` | Predictions must succeed with a value or fail with an error |
| `Union[A, B]` | Ambiguous for downstream consumers |
| External package types | Cannot be statically analyzed — define as BaseModel or use .pyi stub |
## Cog-Specific Extensions
| Extension | Purpose |
|-----------|---------|
| `x-order` | Preserves parameter order from function signature |
| `x-cog-array-type` | Marks iterators vs regular arrays |
| `x-cog-array-display` | Hints for how to display streaming output |
| `x-cog-secret` | Marks sensitive inputs |
## Where the Schema Lives
### In the Image
Embedded as a Docker label during build:
```bash
docker inspect my-model | jq -r '.[0].Config.Labels["run.cog.openapi_schema"]'
```
Also written to `.cog/openapi_schema.json` inside the image for the runtime to serve.
### At Runtime
| Endpoint | Format |
|----------|--------|
| `GET /openapi.json` | Raw OpenAPI spec |
### Override and Configuration
| Environment Variable | Purpose |
|---------------------|---------|
| `COG_STATIC_SCHEMA=1` | Opt in to the static Go tree-sitter schema generator (falls back to legacy on failure) |
| `COG_OPENAPI_SCHEMA=path` | Skip generation entirely and use a pre-built schema file |
```bash
# Use static schema generation
COG_STATIC_SCHEMA=1 cog build -t my-model
# Use a pre-built schema file
COG_OPENAPI_SCHEMA=my_schema.json cog build
```
## Schema Structure
A simplified example showing a multi-file predictor with structured output:
```json
{
"openapi": "3.0.2",
"info": { "title": "Cog", "version": "0.1.0" },
"paths": {
"/predictions": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/PredictionRequest" }
}
}
}
}
}
},
"components": {
"schemas": {
"Input": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "Text prompt",
"x-order": 0
},
"steps": {
"type": "integer",
"default": 50,
"minimum": 1,
"maximum": 100,
"x-order": 1
}
},
"required": ["prompt"]
},
"Output": {
"type": "object",
"properties": {
"text": { "type": "string", "title": "Text" },
"score": { "type": "number", "title": "Score" }
},
"required": ["text", "score"]
},
"PredictionRequest": { "..." : "..." },
"PredictionResponse": { "..." : "..." }
}
}
}
```
## Code References
| File | Purpose |
|------|---------|
| `pkg/schema/schema_type.go` | `SchemaType` ADT, `ResolveSchemaType()`, `JSONSchema()` generation |
| `pkg/schema/types.go` | `PredictorInfo`, `PrimitiveType`, `FieldType`, `InputField`, `ImportContext` |
| `pkg/schema/python/parser.go` | Tree-sitter Python parser, `ParsePredictor()`, cross-file resolution |
| `pkg/schema/openapi.go` | OpenAPI document assembly from `PredictorInfo` |
| `pkg/schema/generator.go` | Top-level `Generate()`, `GenerateCombined()`, `Parser` type |
| `pkg/schema/errors.go` | Typed error kinds (`ErrUnresolvableType`, `ErrOptionalOutput`, etc.) |
| `pkg/image/build.go` | `canUseStaticSchemaGen()` — opt-in gate, `generateStaticSchema()` — entry point, fallback to legacy on `ErrUnresolvableType` |
| `pkg/image/openapi_schema.go` | `GenerateOpenAPISchema()` — legacy runtime path (boots container, runs `python -m cog.command.openapi_schema`) |
| `python/cog/_adt.py` | Internal ADT types for Python-side predictor introspection |
| `python/cog/_inspector.py` | Python-side predictor inspector (runtime introspection for legacy path) |
| `python/cog/_schemas.py` | Python-side OpenAPI schema generation from inspected predictor info |
| `python/cog/command/openapi_schema.py` | CLI entry point for `python -m cog.command.openapi_schema` (invoked by legacy runtime path) |
================================================
FILE: architecture/05-build-system.md
================================================
# Build System
The build system transforms [Model Source](./01-model-source.md) (cog.yaml + predict.py + weights) into a production-ready OCI image containing the [Container Runtime](./04-container-runtime.md).
## Build Flow
```mermaid
flowchart TB
subgraph input["Inputs"]
yaml["cog.yaml"]
code["predict.py"]
weights["weights"]
end
subgraph cli["CLI (pkg/cli/build.go)"]
parse["Parse Config"]
validate["Validate"]
end
subgraph generate["Dockerfile Generation (pkg/dockerfile/)"]
generator["Generator"]
baseimage["Base Image Selection"]
compat["Compatibility Matrix"]
wheel["Embedded Python Wheel"]
end
subgraph docker["Docker Build"]
buildkit["Buildkit"]
image["Container Image"]
end
subgraph post["Post-Build"]
schema["Generate OpenAPI Schema"]
freeze["pip freeze"]
labels["Apply Labels"]
end
yaml --> parse --> validate
validate --> generator
compat --> generator
baseimage --> generator
wheel --> generator
generator -->|"Dockerfile"| buildkit
code --> buildkit
weights --> buildkit
buildkit --> image
image --> schema
image --> freeze
schema --> labels
freeze --> labels
labels -->|"Final Image"| output["Tagged Image"]
```
## Key Components
### 1. Config Parsing & Validation
Reads `cog.yaml` and validates/completes the configuration:
- Validates Python version (3.10-3.13)
- Auto-detects CUDA version from PyTorch/TensorFlow requirements
- Resolves package versions against compatibility matrix
```
cog.yaml (user provides) → Config (completed)
───────────────────────── ─────────────────
gpu: true gpu: true
python_packages: cuda: "12.1" ← auto-detected
- torch==2.1.0 cudnn: "8" ← auto-detected
```
---
### 2. Dockerfile Generator
The generator produces a Dockerfile from the validated config.
#### Generated Dockerfile Sections
```dockerfile
# 1. Base image (cog-base, CUDA, or python-slim)
FROM r8.im/cog-base:cuda12.1-python3.11-torch2.1.0
# 2. System packages
RUN apt-get update && apt-get install -y ffmpeg
# 3. Python packages
RUN pip install -r requirements.txt
# 4. Cog wheel (embedded in CLI binary)
COPY cog-0.12.0-py3-none-any.whl /tmp/
RUN pip install /tmp/cog-0.12.0-py3-none-any.whl
# 5. User run commands
RUN echo "custom setup"
# 6. Copy source
WORKDIR /src
COPY . /src
# 7. Entrypoint
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["python", "-m", "cog.server.http"]
```
---
### 3. Compatibility Matrix
PyTorch and TensorFlow releases are built against specific CUDA/cuDNN versions. The compatibility matrix captures these relationships from upstream release notes.
```mermaid
flowchart LR
subgraph input["User specifies"]
torch["torch==2.1.0"]
end
subgraph matrix["Compatibility Matrix"]
lookup["torch_compatibility_matrix.json"]
end
subgraph output["Cog determines"]
cuda["CUDA 12.1"]
cudnn["cuDNN 8"]
python["Python 3.10-3.13"]
end
torch --> lookup
lookup --> cuda
lookup --> cudnn
lookup --> python
```
**Data files** (embedded JSON, generated by `tools/compatgen/`):
- `pkg/config/torch_compatibility_matrix.json` - PyTorch ↔ CUDA mappings
- `pkg/config/tf_compatibility_matrix.json` - TensorFlow ↔ CUDA mappings
- `pkg/config/cuda_base_images.json` - Available NVIDIA base image tags
These are regenerated when new framework versions are released and embedded into the CLI binary at build time.
**What it stores** (for each framework release):
- Framework version (e.g., `torch==2.1.0`)
- Compatible CUDA versions
- Compatible cuDNN versions
- Compatible Python versions
- Package index URLs (for CUDA-specific wheels)
---
### 4. Base Image Selection
Base image selection uses the compatibility matrix to find a pre-built image that matches the required Python/CUDA/PyTorch combination.
```mermaid
flowchart TD
start["Config has Python + CUDA + Torch versions"] --> lookup{"Matching cog-base<br/>image exists?"}
lookup -->|"Yes"| cogbase["Use cog-base image<br/>r8.im/cog-base:cuda12.1-python3.11-torch2.1.0"]
lookup -->|"No"| gpu{"GPU enabled?"}
gpu -->|"Yes"| cuda["Use NVIDIA CUDA image<br/>nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04<br/>(install Python + Torch in Dockerfile)"]
gpu -->|"No"| slim["Use Python slim image<br/>python:3.11-slim"]
```
#### Cog Base Images
Pre-built images hosted at `r8.im/cog-base` with Python, CUDA, cuDNN, and PyTorch already installed.
- Format: `r8.im/cog-base:cuda<version>-python<version>-torch<version>`
- Generated from the compatibility matrix (`BaseImageConfigurations()`)
- Includes common system packages (ffmpeg, git, curl, etc.)
- Faster builds since heavy dependencies are pre-installed
#### Fallback: NVIDIA CUDA Images
When no matching cog-base exists (e.g., unusual version combination):
- Uses official `nvidia/cuda` images
- Dockerfile installs Python via pyenv
- Dockerfile installs PyTorch and other packages via pip
- Slower builds but supports any valid combination
---
### 5. Embedded Python Wheel
The Cog Python SDK is embedded in the Go binary at compile time and injected into images during build.
During build, the wheel is:
1. Selected based on configuration (see below)
2. Copied into the Docker build context
3. Installed via pip
#### Wheel Selection
The `COG_SDK_WHEEL` environment variable controls which cog SDK wheel is installed:
| Value | Source |
|-------|--------|
| (unset) | Latest `cog` from PyPI (auto-detects local wheel in dev builds) |
| `pypi` | Latest `cog` from PyPI |
| `pypi:0.18.0` | Specific version from PyPI |
| `https://...` | Download wheel from URL |
| `/path/to/file.whl` | Use local wheel file |
This allows testing development versions of the SDK or pinning to specific releases. The `build.sdk_version` field in `cog.yaml` provides the same version-pinning capability without requiring environment variables.
---
### 6. Post-Build: Labels & Schema
After the main build, Cog:
1. **Runs the container** to generate OpenAPI schema
2. **Runs pip freeze** to capture installed packages
3. **Applies labels** with metadata
#### Image Labels
| Label | Content |
|-------|---------|
| `run.cog.version` | Cog CLI version |
| `run.cog.config` | Serialized cog.yaml |
| `run.cog.openapi_schema` | OpenAPI spec from type hints |
| `run.cog.pip_freeze` | Installed package versions |
These labels can be fetched from a remote registry or local image store (like containerd) without pulling the full image. This allows tooling - both the Cog CLI during development and production infrastructure - to inspect model metadata and make decisions about how to run a model before booting it.
---
## Image Layer Structure
A built Cog image has layers in this order (bottom to top):
```
┌─────────────────────────────────────────────────┐
│ COPY . /src │ ← User code + weights
├─────────────────────────────────────────────────┤
│ RUN commands (from cog.yaml) │ ← Custom build steps
├─────────────────────────────────────────────────┤
│ pip install (python_packages) │ ← Python dependencies
├─────────────────────────────────────────────────┤
│ Cog wheel install │ ← Cog runtime
├─────────────────────────────────────────────────┤
│ apt-get install (system_packages) │ ← System dependencies
├─────────────────────────────────────────────────┤
│ tini init │ ← Process manager
├─────────────────────────────────────────────────┤
│ │
│ Base image │ ← Largest layer
│ (OS, Python, CUDA, cuDNN, PyTorch) │ ~5-15 GB for GPU images
│ │
└─────────────────────────────────────────────────┘
```
The base image is by far the largest layer. Using a matching `cog-base` image means this layer is shared across builds and doesn't need to be re-downloaded or rebuilt.
---
## Code Reference
| Component | Location |
|-----------|----------|
| CLI command | `pkg/cli/build.go` |
| Build orchestration | `pkg/image/build.go` |
| Dockerfile generator | `pkg/dockerfile/standard_generator.go` |
| Base image selection | `pkg/dockerfile/base.go` |
| Compatibility matrix | `pkg/config/compatibility.go` |
| Embedded wheels | `pkg/wheels/wheels.go` |
| Label definitions | `pkg/docker/command/manifest.go` |
================================================
FILE: architecture/06-cli.md
================================================
# CLI
The Cog CLI is a Go binary that provides commands for the full model lifecycle: development, building, testing, and deployment. This document covers what each command does and how it connects to the systems described in previous docs.
**Important**: Model code always runs inside a container, never on the host machine. Commands like `cog predict`, `cog train`, and `cog serve` build an image, start a container, and interact with it via the [Prediction API](./03-prediction-api.md). The CLI orchestrates this, but the model execution happens in the containerized [Container Runtime](./04-container-runtime.md).
## Commands Overview
| Command | Job To Be Done |
|---------|----------------|
| `cog init` | Bootstrap a new model project |
| `cog build` | Create a container image |
| `cog predict` | Run a prediction in a container |
| `cog train` | Run training in a container |
| `cog run` | Run arbitrary commands in a container |
| `cog serve` | Start HTTP server in a container |
| `cog push` | Deploy to Replicate |
| `cog login` | Authenticate with Replicate |
## Development Commands
### cog init
**Job**: Create a starter `cog.yaml` and `predict.py` for a new model.
```bash
cog init
```
Creates:
- `cog.yaml` with sensible defaults
- `predict.py` with a skeleton Predictor class
**Code**: `pkg/cli/init.go`
---
### cog predict
**Job**: Run a prediction in a container.
```bash
cog predict -i prompt="A photo of a cat" -i steps=50
```
What happens:
1. Builds the image (if needed)
2. Starts a container running the [Container Runtime](./04-container-runtime.md)
3. Parses `-i` flags against the [Schema](./02-schema.md)
4. Sends a [PredictionRequest](./03-prediction-api.md) to the container's HTTP API
5. Streams output back to terminal
Input types are inferred from the schema:
- Strings: `-i prompt="hello"`
- Numbers: `-i steps=50`
- Files: `-i image=@photo.jpg` (uploaded to container)
- URLs: `-i image=https://example.com/photo.jpg`
**Code**: `pkg/cli/predict.go`
---
### cog train
**Job**: Run training in a container.
```bash
cog train -i data=@dataset.zip -i epochs=10
```
Same as `cog predict` but calls the `train()` method instead of `predict()`.
**Code**: `pkg/cli/train.go`
---
### cog run
**Job**: Run arbitrary commands in a container.
```bash
cog run python -c "import torch; print(torch.cuda.is_available())"
cog run bash
```
Builds the image (if needed), starts a container, and runs the specified command inside it. Useful for:
- Debugging the container environment
- Running one-off scripts
- Interactive exploration
**Code**: `pkg/cli/run.go`
---
### cog serve
**Job**: Start the HTTP server in a container for testing.
```bash
cog serve
# Server running at http://localhost:5000
```
Builds the image (if needed) and starts a container running the [Container Runtime](./04-container-runtime.md). The container's port 5000 is exposed to the host. You can then:
- Send requests to `POST /predictions`
- View Swagger UI at `/docs`
- Test webhooks
**Code**: `pkg/cli/serve.go`
## Build Commands
### cog build
**Job**: Build a container image from [Model Source](./01-model-source.md).
```bash
cog build -t my-model
```
What happens (see [Build System](./05-build-system.md) for details):
1. **Parse** `cog.yaml`
2. **Resolve** CUDA/cuDNN versions from compatibility matrix
3. **Generate** Dockerfile
4. **Build** image via Docker/Buildkit
5. **Run** container to extract [Schema](./02-schema.md)
6. **Apply** labels (schema, config, pip freeze)
Key flags:
- `-t, --tag`: Image tag
- `--no-cache`: Disable Docker cache
- `--separate-weights`: Exclude weights from image (for separate upload)
**Code**: `pkg/cli/build.go`, `pkg/image/build.go`
## Deployment Commands
### cog push
**Job**: Build and push to Replicate.
```bash
cog push
gitextract_1_nczbz8/
├── .all-contributorsrc
├── .git_archival.txt
├── .gitattributes
├── .github/
│ ├── CODEOWNERS
│ ├── dependabot.yml
│ └── workflows/
│ ├── README.md
│ ├── ci.yaml
│ ├── codeql.yml
│ ├── docs.yaml
│ ├── release-build.yaml
│ └── release-publish.yaml
├── .gitignore
├── .golangci.yaml
├── .goreleaser.yaml
├── .mockery.yml
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── AGENTS.md
├── CONTRIBUTING.md
├── DESIGN.md
├── LICENSE
├── Makefile
├── README.md
├── architecture/
│ ├── 00-overview.md
│ ├── 01-model-source.md
│ ├── 02-schema.md
│ ├── 05-build-system.md
│ ├── 06-cli.md
│ ├── ffi/
│ │ ├── 03-prediction-api.md
│ │ ├── 04-container-runtime.md
│ │ └── README.md
│ └── legacy/
│ ├── 03-prediction-api.md
│ ├── 04-container-runtime.md
│ └── README.md
├── cmd/
│ └── cog/
│ └── cog.go
├── crates/
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── README.md
│ ├── coglet/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── bridge/
│ │ │ ├── codec.rs
│ │ │ ├── mod.rs
│ │ │ ├── protocol.rs
│ │ │ ├── snapshots/
│ │ │ │ ├── coglet__bridge__protocol__tests__control_cancel_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_cancelled_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_failed_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_healthcheck_result_healthy_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_healthcheck_result_unhealthy_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_healthcheck_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_idle_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_init_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_ready_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_ready_with_schema_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__control_shutdown_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_cancelled_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_done_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_failed_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_log_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_append_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_complex_value_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_delete_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_increment_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_metric_replace_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_output_serializes.snap
│ │ │ │ ├── coglet__bridge__protocol__tests__slot_predict_file_input_serializes.snap
│ │ │ │ └── coglet__bridge__protocol__tests__slot_predict_serializes.snap
│ │ │ └── transport.rs
│ │ ├── fd_redirect.rs
│ │ ├── health.rs
│ │ ├── input_validation.rs
│ │ ├── lib.rs
│ │ ├── orchestrator.rs
│ │ ├── permit/
│ │ │ ├── mod.rs
│ │ │ ├── pool.rs
│ │ │ └── slot.rs
│ │ ├── prediction.rs
│ │ ├── predictor.rs
│ │ ├── service.rs
│ │ ├── setup_log_accumulator.rs
│ │ ├── snapshots/
│ │ │ ├── coglet__health__tests__health_all_variants.snap
│ │ │ ├── coglet__health__tests__health_response_all_variants.snap
│ │ │ ├── coglet__health__tests__setup_status_all_variants.snap
│ │ │ ├── coglet__predictor__tests__output_single.snap
│ │ │ ├── coglet__predictor__tests__output_stream.snap
│ │ │ ├── coglet__version__tests__version_full.snap
│ │ │ └── coglet__version__tests__version_minimal.snap
│ │ ├── transport/
│ │ │ ├── http/
│ │ │ │ ├── mod.rs
│ │ │ │ ├── routes.rs
│ │ │ │ └── server.rs
│ │ │ └── mod.rs
│ │ ├── version.rs
│ │ ├── webhook.rs
│ │ ├── worker.rs
│ │ └── worker_tracing_layer.rs
│ ├── coglet-python/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ ├── build.rs
│ │ ├── coglet/
│ │ │ ├── __init__.py
│ │ │ ├── __init__.pyi
│ │ │ ├── _impl.pyi
│ │ │ ├── _sdk/
│ │ │ │ └── __init__.pyi
│ │ │ └── py.typed
│ │ ├── pyproject.toml
│ │ ├── src/
│ │ │ ├── audit.rs
│ │ │ ├── bin/
│ │ │ │ └── stub_gen.rs
│ │ │ ├── cancel.rs
│ │ │ ├── input.rs
│ │ │ ├── lib.rs
│ │ │ ├── log_writer.rs
│ │ │ ├── metric_scope.rs
│ │ │ ├── output.rs
│ │ │ ├── predictor.rs
│ │ │ └── worker_bridge.rs
│ │ └── tests/
│ │ └── test_coglet.py
│ └── deny.toml
├── docs/
│ ├── CNAME
│ ├── cli.md
│ ├── deploy.md
│ ├── environment.md
│ ├── getting-started-own-model.md
│ ├── getting-started.md
│ ├── http.md
│ ├── llms.txt
│ ├── notebooks.md
│ ├── private-package-registry.md
│ ├── python.md
│ ├── stylesheets/
│ │ └── extra.css
│ ├── training.md
│ ├── wsl2/
│ │ └── wsl2.md
│ └── yaml.md
├── go.mod
├── go.sum
├── integration-tests/
│ ├── .gitignore
│ ├── README.md
│ ├── concurrent/
│ │ └── concurrent_test.go
│ ├── harness/
│ │ ├── cmd_pty.go
│ │ ├── command.go
│ │ └── harness.go
│ ├── login/
│ │ └── login_test.go
│ ├── suite_test.go
│ └── tests/
│ ├── apt_packages.txtar
│ ├── async_generator_precollect.txtar
│ ├── async_predictor.txtar
│ ├── async_sleep.txtar
│ ├── bad_dockerignore.txtar
│ ├── bool_input_output.txtar
│ ├── build_base_image_sha.txtar
│ ├── build_cog_init.txtar
│ ├── build_cog_version_match.txtar
│ ├── build_gpu_labels.txtar
│ ├── build_image_option.txtar
│ ├── build_openapi_schema.txtar
│ ├── build_openapi_schema_complex.txtar
│ ├── build_pip_freeze.txtar
│ ├── build_python313_base_image.txtar
│ ├── build_torch_version_required.txtar
│ ├── ca_cert.txtar
│ ├── cancel_async_prediction.txtar
│ ├── cancel_repeated.txtar
│ ├── cancel_sync_prediction.txtar
│ ├── coglet_iterator_path_output.txtar
│ ├── coglet_iterator_upload_url.txtar
│ ├── coglet_large_file_upload_serial.txtar
│ ├── coglet_large_input.txtar
│ ├── coglet_large_output.txtar
│ ├── coglet_list_path_single_element.txtar
│ ├── coglet_list_path_upload_url.txtar
│ ├── coglet_metrics.txtar
│ ├── coglet_metrics_webhook.txtar
│ ├── coglet_single_path_output.txtar
│ ├── complex_output.txtar
│ ├── concatenate_iterator_output.txtar
│ ├── config_subdirectory.txtar
│ ├── debug_secrets.txtar
│ ├── dict_output.txtar
│ ├── emit_metric_deprecated.txtar
│ ├── env_vars.txtar
│ ├── experimental_feature_warning.txtar
│ ├── ffmpeg_package.txtar
│ ├── file_input.txtar
│ ├── file_list_input.txtar
│ ├── float_input_output.txtar
│ ├── function_predictor.txtar
│ ├── future_annotations.txtar
│ ├── glb_project.txtar
│ ├── granite_project.txtar
│ ├── healthcheck.txtar
│ ├── healthcheck_async.txtar
│ ├── healthcheck_async_exception.txtar
│ ├── healthcheck_async_timeout.txtar
│ ├── healthcheck_async_unhealthy.txtar
│ ├── healthcheck_during_prediction.txtar
│ ├── healthcheck_exception.txtar
│ ├── healthcheck_immediately_after_prediction.txtar
│ ├── healthcheck_repeated_calls.txtar
│ ├── healthcheck_timeout.txtar
│ ├── healthcheck_unhealthy.txtar
│ ├── int_input_output.txtar
│ ├── int_none_output.txtar
│ ├── int_predictor.txtar
│ ├── invalid_int_validation.txtar
│ ├── iterator_error_midstream.txtar
│ ├── iterator_string_output.txtar
│ ├── legacy_sdk_schema.txtar
│ ├── list_int_input_output.txtar
│ ├── list_string_output.txtar
│ ├── many_inputs.txtar
│ ├── multi_file_schema.txtar
│ ├── nested_output_types.txtar
│ ├── no_predictor.txtar
│ ├── non_base_predictor_class.txtar
│ ├── non_base_predictor_function.txtar
│ ├── oci_bundle_build.txtar
│ ├── oci_bundle_inspect.txtar
│ ├── oci_bundle_push.txtar
│ ├── optional_path_input.txtar
│ ├── path_input.txtar
│ ├── path_input_output.txtar
│ ├── path_list_input.txtar
│ ├── path_list_output.txtar
│ ├── path_output.txtar
│ ├── predict_existing_image.txtar
│ ├── predict_json_file.txtar
│ ├── predict_json_input.txtar
│ ├── predict_json_output_file.txtar
│ ├── predict_json_stdin.txtar
│ ├── predict_json_stdin_dash.txtar
│ ├── predict_many_inputs_image.txtar
│ ├── predict_output_file.txtar
│ ├── predict_output_string.txtar
│ ├── predict_sys_exit.txtar
│ ├── prediction_error_response.txtar
│ ├── pty_echo.txtar
│ ├── pty_interactive.txtar
│ ├── pydantic2.txtar
│ ├── pydantic2_output.txtar
│ ├── python313.txtar
│ ├── python37_deprecated.txtar
│ ├── python38_deprecated.txtar
│ ├── python39_deprecated.txtar
│ ├── run_basic.txtar
│ ├── run_stdin_cat.txtar
│ ├── run_stdin_unconsumed.txtar
│ ├── scope_context.txtar
│ ├── secrets.txtar
│ ├── sequential_state_leak.txtar
│ ├── setup_slow_serial.txtar
│ ├── setup_subprocess_double_fork.txtar
│ ├── setup_subprocess_double_fork_http.txtar
│ ├── setup_subprocess_multiprocessing.txtar
│ ├── setup_subprocess_simple.txtar
│ ├── setup_timeout_serial.txtar
│ ├── setup_worker_tracing_logs.txtar
│ ├── static_schema_fallback.txtar
│ ├── static_schema_gen.txtar
│ ├── string_list_input.txtar
│ ├── string_none_output.txtar
│ ├── string_predictor.txtar
│ ├── subdirectory_predictor.txtar
│ ├── tensorflow.txtar
│ ├── torch_270_cuda_126.txtar
│ ├── torch_271_cuda_128.txtar
│ ├── torch_baseimage_fallback.txtar
│ ├── torch_baseimage_no_cog_base.txtar
│ ├── torch_baseimage_precompile.txtar
│ ├── torch_cuda_baseimage.txtar
│ ├── train_basic.txtar
│ ├── train_deprecated.txtar
│ ├── training_setup.txtar
│ ├── union_type.txtar
│ ├── webhook_delivery_failure.txtar
│ ├── webhook_prediction_error.txtar
│ ├── weights_build.txtar
│ ├── weights_push_inspect.txtar
│ ├── wheel_coglet_missing.txtar
│ ├── wheel_resolution.txtar
│ └── zsh_package.txtar
├── mise.toml
├── mkdocs.yml
├── noxfile.py
├── pkg/
│ ├── cli/
│ │ ├── baseimage.go
│ │ ├── build.go
│ │ ├── debug.go
│ │ ├── init-templates/
│ │ │ └── base/
│ │ │ ├── .dockerignore
│ │ │ ├── .github/
│ │ │ │ └── workflows/
│ │ │ │ └── push.yaml
│ │ │ ├── cog.yaml
│ │ │ ├── predict.py
│ │ │ └── requirements.txt
│ │ ├── init.go
│ │ ├── init_test.go
│ │ ├── inspect.go
│ │ ├── login.go
│ │ ├── predict.go
│ │ ├── predict_test.go
│ │ ├── push.go
│ │ ├── root.go
│ │ ├── run.go
│ │ ├── serve.go
│ │ ├── train.go
│ │ ├── train_test.go
│ │ ├── weights.go
│ │ └── weights_inspect.go
│ ├── config/
│ │ ├── build_options.go
│ │ ├── compatibility.go
│ │ ├── compatibility_test.go
│ │ ├── config.go
│ │ ├── config_file.go
│ │ ├── config_test.go
│ │ ├── cuda_compatibility.json
│ │ ├── data/
│ │ │ └── config_schema_v1.0.json
│ │ ├── env.go
│ │ ├── env_variables_test.go
│ │ ├── errors.go
│ │ ├── image_name.go
│ │ ├── image_name_test.go
│ │ ├── load.go
│ │ ├── load_test.go
│ │ ├── parse.go
│ │ ├── tf_compatibility.json
│ │ ├── torch_compatibility.json
│ │ ├── validate.go
│ │ ├── validate_test.go
│ │ └── version.go
│ ├── docker/
│ │ ├── build_secrets.go
│ │ ├── buildkit.go
│ │ ├── command/
│ │ │ ├── command.go
│ │ │ ├── errors.go
│ │ │ ├── manifest.go
│ │ │ └── user_info.go
│ │ ├── credential_helper_input.go
│ │ ├── credentials.go
│ │ ├── credentials_test.go
│ │ ├── docker.go
│ │ ├── docker_client_test.go
│ │ ├── dockertest/
│ │ │ ├── command_mocks.go
│ │ │ ├── helper_client.go
│ │ │ ├── image.go
│ │ │ ├── mock_command.go
│ │ │ ├── ref.go
│ │ │ ├── ref_test.go
│ │ │ └── testdata/
│ │ │ └── create-image-fixtures.sh
│ │ ├── env.go
│ │ ├── errors.go
│ │ ├── host.go
│ │ ├── host_unix.go
│ │ ├── host_windows.go
│ │ ├── login.go
│ │ ├── options.go
│ │ ├── progress.go
│ │ ├── push.go
│ │ ├── run.go
│ │ ├── run_test.go
│ │ ├── standard_push.go
│ │ └── standard_push_test.go
│ ├── dockercontext/
│ │ ├── build_tempdir.go
│ │ ├── build_tempdir_test.go
│ │ └── directories.go
│ ├── dockerfile/
│ │ ├── base.go
│ │ ├── base_test.go
│ │ ├── cacert.go
│ │ ├── cacert_test.go
│ │ ├── env.go
│ │ ├── generator.go
│ │ ├── generator_factory.go
│ │ ├── generator_factory_test.go
│ │ ├── standard_generator.go
│ │ ├── standard_generator_test.go
│ │ └── version_check.go
│ ├── dockerignore/
│ │ ├── dockerignore.go
│ │ └── dockerignore_test.go
│ ├── env/
│ │ ├── env.go
│ │ └── env_test.go
│ ├── errors/
│ │ ├── common.go
│ │ └── errors.go
│ ├── global/
│ │ └── global.go
│ ├── http/
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── transport.go
│ │ ├── transport_test.go
│ │ ├── user_agent.go
│ │ └── user_agent_test.go
│ ├── image/
│ │ ├── build.go
│ │ ├── build_test.go
│ │ ├── config.go
│ │ ├── openapi_schema.go
│ │ └── pip_freeze.go
│ ├── model/
│ │ ├── artifact.go
│ │ ├── artifact_image.go
│ │ ├── artifact_image_test.go
│ │ ├── artifact_test.go
│ │ ├── artifact_weight.go
│ │ ├── artifact_weight_test.go
│ │ ├── builder.go
│ │ ├── builder_test.go
│ │ ├── errors.go
│ │ ├── errors_test.go
│ │ ├── factory.go
│ │ ├── factory_test.go
│ │ ├── format.go
│ │ ├── format_test.go
│ │ ├── hash.go
│ │ ├── image_builder.go
│ │ ├── image_builder_test.go
│ │ ├── image_pusher.go
│ │ ├── image_pusher_test.go
│ │ ├── image_test.go
│ │ ├── index.go
│ │ ├── index_factory.go
│ │ ├── index_factory_test.go
│ │ ├── index_test.go
│ │ ├── model.go
│ │ ├── model_test.go
│ │ ├── options.go
│ │ ├── options_test.go
│ │ ├── push_helpers.go
│ │ ├── pusher.go
│ │ ├── pusher_test.go
│ │ ├── ref.go
│ │ ├── ref_test.go
│ │ ├── ref_types.go
│ │ ├── ref_types_test.go
│ │ ├── resolver.go
│ │ ├── resolver_test.go
│ │ ├── source.go
│ │ ├── source_test.go
│ │ ├── weight_builder.go
│ │ ├── weight_builder_test.go
│ │ ├── weight_pusher.go
│ │ ├── weight_pusher_test.go
│ │ ├── weights.go
│ │ ├── weights_lock.go
│ │ ├── weights_lock_test.go
│ │ └── weights_test.go
│ ├── path/
│ │ ├── path.go
│ │ └── path_test.go
│ ├── predict/
│ │ ├── api.go
│ │ ├── input.go
│ │ └── predictor.go
│ ├── provider/
│ │ ├── generic/
│ │ │ ├── generic.go
│ │ │ └── generic_test.go
│ │ ├── provider.go
│ │ ├── registry.go
│ │ ├── registry_test.go
│ │ ├── replicate/
│ │ │ ├── replicate.go
│ │ │ └── replicate_test.go
│ │ └── setup/
│ │ ├── setup.go
│ │ └── setup_test.go
│ ├── registry/
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── config.go
│ │ ├── config_test.go
│ │ ├── manifest_result.go
│ │ ├── push_test.go
│ │ ├── registry_client.go
│ │ └── registrytest/
│ │ └── mock_client.go
│ ├── registry_testhelpers/
│ │ ├── registry_container.go
│ │ └── testdata/
│ │ └── docker/
│ │ └── registry/
│ │ └── v2/
│ │ ├── blobs/
│ │ │ └── sha256/
│ │ │ ├── 1c/
│ │ │ │ └── 1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474/
│ │ │ │ └── data
│ │ │ ├── 6e/
│ │ │ │ └── 6e771e15690e2fabf2332d3a3b744495411d6e0b00b2aea64419b58b0066cf81/
│ │ │ │ └── data
│ │ │ ├── 75/
│ │ │ │ └── 757d680068d77be46fd1ea20fb21db16f150468c5e7079a08a2e4705aec096ac/
│ │ │ │ └── data
│ │ │ ├── 8d/
│ │ │ │ └── 8d591b0b7dea080ea3be9e12ae563eebf9869168ffced1cb25b2470a3d9fe15e/
│ │ │ │ └── data
│ │ │ ├── 9a/
│ │ │ │ └── 9a0ff41dccad7a96f324a4655a715c623ed3511c7336361ffa9dadcecbdb99e5/
│ │ │ │ └── data
│ │ │ ├── ad/
│ │ │ │ └── aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b/
│ │ │ │ └── data
│ │ │ └── f1/
│ │ │ └── f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870/
│ │ │ └── data
│ │ └── repositories/
│ │ └── alpine/
│ │ ├── _layers/
│ │ │ └── sha256/
│ │ │ ├── 6e771e15690e2fabf2332d3a3b744495411d6e0b00b2aea64419b58b0066cf81/
│ │ │ │ └── link
│ │ │ ├── 8d591b0b7dea080ea3be9e12ae563eebf9869168ffced1cb25b2470a3d9fe15e/
│ │ │ │ └── link
│ │ │ ├── aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b/
│ │ │ │ └── link
│ │ │ └── f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870/
│ │ │ └── link
│ │ └── _manifests/
│ │ ├── revisions/
│ │ │ └── sha256/
│ │ │ ├── 1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474/
│ │ │ │ └── link
│ │ │ ├── 757d680068d77be46fd1ea20fb21db16f150468c5e7079a08a2e4705aec096ac/
│ │ │ │ └── link
│ │ │ └── 9a0ff41dccad7a96f324a4655a715c623ed3511c7336361ffa9dadcecbdb99e5/
│ │ │ └── link
│ │ └── tags/
│ │ └── latest/
│ │ ├── current/
│ │ │ └── link
│ │ └── index/
│ │ └── sha256/
│ │ └── 9a0ff41dccad7a96f324a4655a715c623ed3511c7336361ffa9dadcecbdb99e5/
│ │ └── link
│ ├── requirements/
│ │ ├── requirements.go
│ │ └── requirements_test.go
│ ├── schema/
│ │ ├── errors.go
│ │ ├── generator.go
│ │ ├── generator_test.go
│ │ ├── openapi.go
│ │ ├── openapi_test.go
│ │ ├── python/
│ │ │ ├── parser.go
│ │ │ ├── parser_fuzz_test.go
│ │ │ └── parser_test.go
│ │ ├── schema_type.go
│ │ ├── schema_type_fuzz_test.go
│ │ └── types.go
│ ├── update/
│ │ ├── state.go
│ │ └── update.go
│ ├── util/
│ │ ├── console/
│ │ │ ├── console.go
│ │ │ ├── formatting.go
│ │ │ ├── global.go
│ │ │ ├── interactive.go
│ │ │ ├── levels.go
│ │ │ └── term.go
│ │ ├── env.go
│ │ ├── errors.go
│ │ ├── files/
│ │ │ ├── files.go
│ │ │ └── files_test.go
│ │ ├── hash.go
│ │ ├── hash_test.go
│ │ ├── mime/
│ │ │ ├── mime.go
│ │ │ └── mime_test.go
│ │ ├── net.go
│ │ ├── overwrite_yaml.go
│ │ ├── overwrite_yaml_test.go
│ │ ├── platform.go
│ │ ├── ringbuffer.go
│ │ ├── shell/
│ │ │ ├── net.go
│ │ │ └── pipes.go
│ │ └── version/
│ │ ├── version.go
│ │ └── version_test.go
│ ├── web/
│ │ ├── client.go
│ │ └── client_test.go
│ ├── weights/
│ │ ├── manifest.go
│ │ ├── weights.go
│ │ └── weights_test.go
│ └── wheels/
│ ├── wheels.go
│ └── wheels_test.go
├── pyproject.toml
├── python/
│ ├── cog/
│ │ ├── .gitignore
│ │ ├── __init__.py
│ │ ├── _adt.py
│ │ ├── _inspector.py
│ │ ├── _schemas.py
│ │ ├── coder.py
│ │ ├── command/
│ │ │ ├── __init__.py
│ │ │ └── openapi_schema.py
│ │ ├── config.py
│ │ ├── errors.py
│ │ ├── input.py
│ │ ├── mode.py
│ │ ├── model.py
│ │ ├── predictor.py
│ │ ├── server/
│ │ │ ├── __init__.py
│ │ │ └── http.py
│ │ ├── suppress_output.py
│ │ └── types.py
│ └── tests/
│ ├── __init__.py
│ ├── test_emit_metric.py
│ ├── test_experimental_feature_warning.py
│ ├── test_input.py
│ ├── test_model.py
│ ├── test_predictor.py
│ └── test_types.py
├── script/
│ └── generate-compat
├── test-helpers/
│ └── https-server/
│ ├── go.mod
│ └── main.go
├── test-integration/
│ └── test_integration/
│ └── fixtures/
│ └── hello-image/
│ ├── cog.yaml
│ └── predict.py
└── tools/
├── compatgen/
│ ├── internal/
│ │ ├── cuda.go
│ │ ├── tensorflow.go
│ │ ├── torch.go
│ │ ├── torch_package.go
│ │ ├── torch_test.go
│ │ ├── torch_test.html
│ │ └── util.go
│ └── main.go
├── gendocs/
│ └── main.go
├── install.sh
├── test-harness/
│ ├── .gitignore
│ ├── README.md
│ ├── harness/
│ │ ├── __init__.py
│ │ ├── __main__.py
│ │ ├── cli.py
│ │ ├── cog_resolver.py
│ │ ├── patcher.py
│ │ ├── report.py
│ │ ├── runner.py
│ │ └── validators.py
│ ├── manifest.yaml
│ ├── pyproject.toml
│ └── results/
│ └── .gitkeep
├── test-registry-util/
│ ├── README.md
│ └── main.go
└── weights-gen/
├── README.md
└── main.go
Showing preview only (293K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (3199 symbols across 290 files)
FILE: cmd/cog/cog.go
function main (line 8) | func main() {
FILE: crates/coglet-python/build.rs
function main (line 7) | fn main() {
function semver_to_pep440 (line 73) | fn semver_to_pep440(version: &str) -> String {
function test_stable_version (line 121) | fn test_stable_version() {
function test_alpha (line 127) | fn test_alpha() {
function test_beta (line 134) | fn test_beta() {
function test_rc (line 140) | fn test_rc() {
function test_dev (line 146) | fn test_dev() {
FILE: crates/coglet-python/coglet/_impl.pyi
class BuildInfo (line 18) | class BuildInfo:
method version (line 23) | def version(self) -> builtins.str: ...
method git_sha (line 25) | def git_sha(self) -> builtins.str: ...
method build_time (line 27) | def build_time(self) -> builtins.str: ...
method rustc_version (line 29) | def rustc_version(self) -> builtins.str: ...
method __repr__ (line 30) | def __repr__(self) -> builtins.str: ...
class CancelationException (line 32) | class CancelationException(builtins.BaseException):
class Server (line 44) | class Server:
method active (line 54) | def active(self) -> builtins.bool:
method serve (line 58) | def serve(self, predictor_ref: typing.Optional[builtins.str] = None, h...
method _run_worker (line 62) | def _run_worker(self) -> None:
method __repr__ (line 69) | def __repr__(self) -> builtins.str: ...
FILE: crates/coglet-python/coglet/_sdk/__init__.pyi
class MetricRecorder (line 14) | class MetricRecorder:
method record (line 24) | def record(
method delete (line 41) | def delete(self, key: builtins.str) -> None:
method __setitem__ (line 45) | def __setitem__(self, key: builtins.str, value: typing.Any) -> None:
method __delitem__ (line 49) | def __delitem__(self, key: builtins.str) -> None:
method __repr__ (line 53) | def __repr__(self) -> builtins.str: ...
class Scope (line 56) | class Scope:
method metrics (line 64) | def metrics(self) -> MetricRecorder:
method context (line 69) | def context(self) -> dict[builtins.str, builtins.str]:
method record_metric (line 75) | def record_metric(
method __repr__ (line 86) | def __repr__(self) -> builtins.str: ...
class _SlotLogWriter (line 89) | class _SlotLogWriter:
method closed (line 105) | def closed(self) -> builtins.bool:
method encoding (line 110) | def encoding(self) -> typing.Optional[builtins.str]:
method newlines (line 115) | def newlines(self) -> typing.Optional[builtins.str]:
method buffer (line 120) | def buffer(self) -> typing.Any:
method write (line 124) | def write(self, data: builtins.str) -> builtins.int:
method emit_data (line 137) | def emit_data(self, data: builtins.str) -> None:
method flush (line 141) | def flush(self) -> None:
method readable (line 147) | def readable(self) -> builtins.bool:
method writable (line 151) | def writable(self) -> builtins.bool:
method seekable (line 155) | def seekable(self) -> builtins.bool:
method isatty (line 159) | def isatty(self) -> builtins.bool:
method fileno (line 163) | def fileno(self) -> builtins.int:
method close (line 167) | def close(self) -> None:
method __enter__ (line 171) | def __enter__(self) -> _SlotLogWriter:
method __exit__ (line 175) | def __exit__(
class _TeeWriter (line 186) | class _TeeWriter:
method inner (line 194) | def inner(self) -> typing.Any:
method user_stream (line 199) | def user_stream(self) -> typing.Any:
method name (line 204) | def name(self) -> builtins.str:
method closed (line 209) | def closed(self) -> builtins.bool:
method encoding (line 214) | def encoding(self) -> typing.Optional[builtins.str]: ...
method newlines (line 216) | def newlines(self) -> typing.Optional[builtins.str]: ...
method __new__ (line 217) | def __new__(
method write (line 220) | def write(self, data: builtins.str) -> builtins.int:
method flush (line 224) | def flush(self) -> None:
method readable (line 228) | def readable(self) -> builtins.bool: ...
method writable (line 229) | def writable(self) -> builtins.bool: ...
method seekable (line 230) | def seekable(self) -> builtins.bool: ...
method isatty (line 231) | def isatty(self) -> builtins.bool: ...
method fileno (line 232) | def fileno(self) -> builtins.int: ...
method close (line 233) | def close(self) -> None: ...
method __enter__ (line 234) | def __enter__(self) -> _TeeWriter: ...
method __exit__ (line 235) | def __exit__(
function current_scope (line 242) | def current_scope() -> Scope:
FILE: crates/coglet-python/src/audit.rs
function install_audit_hook (line 41) | pub fn install_audit_hook(py: Python<'_>) -> PyResult<()> {
function _coglet_audit_hook (line 70) | fn _coglet_audit_hook(py: Python<'_>, event: &str, args: &Bound<'_, PyAn...
function handle_stream_replacement (line 108) | fn handle_stream_replacement(py: Python<'_>, name: &str, value: &Bound<'...
function is_slot_log_writer (line 162) | pub(crate) fn is_slot_log_writer(py: Python<'_>, value: &Bound<'_, PyAny...
function is_tee_writer (line 178) | pub(crate) fn is_tee_writer(value: &Bound<'_, PyAny>) -> bool {
function get_inner_writer (line 191) | pub(crate) fn get_inner_writer(py: Python<'_>, tee: &Bound<'_, PyAny>) -...
type _TeeWriter (line 215) | pub struct _TeeWriter {
method new (line 234) | fn new(inner: Py<PyAny>, user_stream: Py<PyAny>, name: String) -> Self {
method write (line 244) | fn write(&self, py: Python<'_>, data: &str) -> PyResult<usize> {
method flush (line 261) | fn flush(&self, py: Python<'_>) -> PyResult<()> {
method readable (line 267) | fn readable(&self) -> bool {
method writable (line 271) | fn writable(&self) -> bool {
method seekable (line 275) | fn seekable(&self) -> bool {
method isatty (line 279) | fn isatty(&self, py: Python<'_>) -> PyResult<bool> {
method fileno (line 284) | fn fileno(&self, py: Python<'_>) -> PyResult<i32> {
method close (line 289) | fn close(&mut self) {
method __enter__ (line 293) | fn __enter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> {
method __exit__ (line 297) | fn __exit__(
method encoding (line 307) | fn encoding(&self, py: Python<'_>) -> PyResult<Option<String>> {
method newlines (line 315) | fn newlines(&self) -> Option<String> {
FILE: crates/coglet-python/src/bin/stub_gen.rs
constant PUBLIC_REEXPORTS (line 17) | const PUBLIC_REEXPORTS: &[&str] = &["__build__", "__version__", "server"...
constant PRIVATE_REEXPORTS (line 24) | const PRIVATE_REEXPORTS: &[&str] = &["_sdk"];
function main (line 26) | fn main() -> Result<()> {
FILE: crates/coglet-python/src/cancel.rs
function cancel_sync_thread (line 41) | pub fn cancel_sync_thread(py_thread_id: std::ffi::c_long) {
function current_py_thread_id (line 82) | pub fn current_py_thread_id() -> std::ffi::c_long {
FILE: crates/coglet-python/src/input.rs
type PyObject (line 13) | type PyObject = Py<PyAny>;
type PreparedInput (line 20) | pub struct PreparedInput {
method new (line 29) | pub fn new(dict: Py<PyDict>, cleanup_paths: Vec<PyObject>) -> Self {
method dict (line 37) | pub fn dict<'py>(&self, py: Python<'py>) -> Bound<'py, PyDict> {
method drop (line 43) | fn drop(&mut self) {
function prepare_input (line 76) | pub fn prepare_input(
function detect_file_fields (line 91) | fn detect_file_fields(py: Python<'_>, func: &Bound<'_, PyAny>) -> PyResu...
function coerce_url_strings (line 186) | fn coerce_url_strings(
function download_url_paths_into_dict (line 244) | fn download_url_paths_into_dict(
function file_fields_for (line 377) | fn file_fields_for(py_func_src: &str) -> HashSet<String> {
function detect_direct_file (line 399) | fn detect_direct_file() {
function detect_list_file (line 407) | fn detect_list_file() {
function detect_optional_file (line 414) | fn detect_optional_file() {
function detect_file_union_none (line 426) | fn detect_file_union_none() {
function detect_optional_list_file (line 438) | fn detect_optional_list_file() {
function non_file_types_not_detected (line 450) | fn non_file_types_not_detected() {
FILE: crates/coglet-python/src/lib.rs
type BuildInfo (line 40) | pub struct BuildInfo {
method __repr__ (line 56) | fn __repr__(&self) -> String {
method new (line 69) | fn new() -> Self {
method sha_display (line 80) | fn sha_display(&self) -> String {
function set_active (line 89) | fn set_active() {
function init_tracing (line 95) | fn init_tracing(
function detect_version (line 152) | fn detect_version(py: Python<'_>, build: &BuildInfo) -> VersionInfo {
function read_max_concurrency (line 175) | fn read_max_concurrency() -> usize {
function read_setup_timeout (line 182) | fn read_setup_timeout() -> Option<std::time::Duration> {
type CogletServer (line 215) | pub struct CogletServer {}
method active (line 222) | fn active(&self) -> bool {
method serve (line 229) | fn serve(
method run_worker (line 257) | fn run_worker(&self, py: Python<'_>) -> PyResult<()> {
method __repr__ (line 282) | fn __repr__(&self) -> &'static str {
function serve_impl (line 288) | fn serve_impl(
function serve_subprocess (line 366) | fn serve_subprocess(
function run_worker_with_init (line 479) | async fn run_worker_with_init() -> Result<(), String> {
function coglet (line 542) | fn coglet(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
FILE: crates/coglet-python/src/log_writer.rs
function get_sync_prediction_id_slot (line 47) | fn get_sync_prediction_id_slot() -> &'static Mutex<Option<String>> {
function get_registry (line 56) | fn get_registry() -> &'static Mutex<HashMap<String, Arc<SlotSender>>> {
function get_control_channel_sender_slot (line 60) | fn get_control_channel_sender_slot() -> &'static Mutex<Option<Arc<Contro...
type ControlChannelLogSender (line 70) | pub struct ControlChannelLogSender {
method new (line 76) | pub fn new(tx: Sender<ControlResponse>) -> Self {
method try_send_log (line 84) | pub fn try_send_log(&self, source: LogSource, data: &str) {
function register_control_channel_sender (line 111) | pub fn register_control_channel_sender(sender: Arc<ControlChannelLogSend...
function unregister_control_channel_sender (line 121) | pub fn unregister_control_channel_sender() {
function get_control_channel_sender (line 129) | fn get_control_channel_sender() -> Option<Arc<ControlChannelLogSender>> {
function get_prediction_contextvar (line 140) | pub fn get_prediction_contextvar(py: Python<'_>) -> PyResult<&'static Py...
function register_prediction (line 166) | pub fn register_prediction(prediction_id: String, sender: Arc<SlotSender...
function unregister_prediction (line 176) | pub fn unregister_prediction(prediction_id: &str) {
function get_prediction_sender (line 192) | fn get_prediction_sender(prediction_id: &str) -> Option<Arc<SlotSender>> {
function set_current_prediction (line 201) | pub fn set_current_prediction(py: Python<'_>, prediction_id: &str) -> Py...
function set_sync_prediction_id (line 210) | pub fn set_sync_prediction_id(prediction_id: Option<&str>) {
function get_current_prediction_id (line 219) | fn get_current_prediction_id(py: Python<'_>) -> PyResult<Option<String>> {
type SlotLogWriter (line 267) | pub struct SlotLogWriter {
method write (line 292) | fn write(&self, py: Python<'_>, data: &str) -> PyResult<usize> {
method emit_data (line 326) | fn emit_data(&self, py: Python<'_>, data: &str) -> PyResult<()> {
method flush (line 369) | fn flush(&self, py: Python<'_>) -> PyResult<()> {
method readable (line 385) | fn readable(&self) -> bool {
method writable (line 390) | fn writable(&self) -> bool {
method seekable (line 395) | fn seekable(&self) -> bool {
method isatty (line 400) | fn isatty(&self, py: Python<'_>) -> PyResult<bool> {
method fileno (line 407) | fn fileno(&self, py: Python<'_>) -> PyResult<i32> {
method close (line 414) | fn close(&mut self) {
method __enter__ (line 419) | fn __enter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> {
method __exit__ (line 424) | fn __exit__(
method encoding (line 435) | fn encoding(&self, py: Python<'_>) -> PyResult<Option<String>> {
method newlines (line 444) | fn newlines(&self) -> Option<String> {
method buffer (line 450) | fn buffer(&self, py: Python<'_>) -> PyResult<Py<PyAny>> {
method new_stdout (line 461) | pub fn new_stdout(original: Py<PyAny>) -> Self {
method new_stderr (line 471) | pub fn new_stderr(original: Py<PyAny>) -> Self {
method write_outside_prediction (line 484) | fn write_outside_prediction(&self, _py: Python<'_>, data: &str) -> PyR...
function install_slot_log_writers (line 511) | pub fn install_slot_log_writers(py: Python<'_>) -> PyResult<bool> {
type PredictionLogGuard (line 541) | pub struct PredictionLogGuard {
method enter (line 551) | pub fn enter(py: Python<'_>, prediction_id: String, sender: Arc<SlotSe...
method prediction_id (line 567) | pub fn prediction_id(&self) -> &str {
method drop (line 573) | fn drop(&mut self) {
function registry_operations (line 595) | fn registry_operations() {
function slot_sender_sends_log (line 610) | fn slot_sender_sends_log() {
function slot_sender_ignores_empty (line 627) | fn slot_sender_ignores_empty() {
function slot_sender_detects_closed_channel (line 638) | fn slot_sender_detects_closed_channel() {
FILE: crates/coglet-python/src/metric_scope.rs
type MetricValueType (line 29) | enum MetricValueType {
method from_py (line 40) | fn from_py(obj: &Bound<'_, PyAny>) -> PyResult<Self> {
method as_str (line 63) | fn as_str(&self) -> &'static str {
type MetricRecorder (line 88) | pub struct MetricRecorder {
method new (line 100) | pub fn new(sender: Arc<SlotSender>) -> Self {
method noop (line 109) | pub fn noop() -> Self {
method record (line 129) | fn record(
method delete (line 147) | fn delete(&self, key: &str) -> PyResult<()> {
method __setitem__ (line 157) | fn __setitem__(&self, py: Python<'_>, key: &str, value: &Bound<'_, PyA...
method __delitem__ (line 171) | fn __delitem__(&self, key: &str) -> PyResult<()> {
method __repr__ (line 175) | fn __repr__(&self) -> String {
type RecorderInner (line 92) | struct RecorderInner {
type Scope (line 195) | pub struct Scope {
method new (line 202) | pub fn new(
method noop (line 218) | pub fn noop(py: Python<'_>) -> PyResult<Self> {
method metrics (line 233) | fn metrics(&self, py: Python<'_>) -> Py<MetricRecorder> {
method context (line 241) | fn context(&self, py: Python<'_>) -> Py<PyDict> {
method record_metric (line 249) | fn record_metric(
method __repr__ (line 261) | fn __repr__(&self, py: Python<'_>) -> String {
function parse_mode (line 271) | fn parse_mode(mode: Option<&str>) -> PyResult<MetricMode> {
function record_impl (line 283) | fn record_impl(
function delete_impl (line 324) | fn delete_impl(inner: &mut RecorderInner, key: &str) -> PyResult<()> {
function get_sync_scope_slot (line 348) | fn get_sync_scope_slot() -> &'static Mutex<Option<Py<Scope>>> {
function get_scope_contextvar (line 352) | fn get_scope_contextvar(py: Python<'_>) -> PyResult<&'static Py<PyAny>> {
function set_current_scope (line 371) | pub fn set_current_scope(py: Python<'_>, scope: &Py<Scope>) -> PyResult<...
function set_sync_scope (line 378) | pub fn set_sync_scope(py: Python<'_>, scope: Option<&Py<Scope>>) {
function clear_sync_scope (line 386) | pub fn clear_sync_scope() {
function py_current_scope (line 399) | pub fn py_current_scope(py: Python<'_>) -> PyResult<Py<Scope>> {
type ScopeGuard (line 437) | pub struct ScopeGuard {
method enter (line 445) | pub fn enter(
method drop (line 460) | fn drop(&mut self) {
function py_to_json (line 484) | fn py_to_json(obj: &Bound<'_, PyAny>) -> PyResult<serde_json::Value> {
FILE: crates/coglet-python/src/output.rs
function process_output (line 22) | pub fn process_output<'py>(
function process_output_item (line 31) | pub fn process_output_item<'py>(
function make_encodeable (line 43) | fn make_encodeable<'py>(py: Python<'py>, obj: &Bound<'py, PyAny>) -> PyR...
function encode_files (line 145) | fn encode_files<'py>(py: Python<'py>, obj: &Bound<'py, PyAny>) -> PyResu...
function file_to_base64 (line 196) | fn file_to_base64<'py>(py: Python<'py>, fh: &Bound<'py, PyAny>) -> PyRes...
function is_generator (line 239) | fn is_generator<'py>(py: Python<'py>, obj: &Bound<'py, PyAny>) -> PyResu...
function encodeable (line 252) | fn encodeable(py_expr: &str) -> String {
function processed (line 274) | fn processed(py_expr: &str) -> String {
function encodeable_string (line 296) | fn encodeable_string() {
function encodeable_int (line 301) | fn encodeable_int() {
function encodeable_float (line 306) | fn encodeable_float() {
function encodeable_bool (line 311) | fn encodeable_bool() {
function encodeable_none (line 316) | fn encodeable_none() {
function encodeable_list (line 323) | fn encodeable_list() {
function encodeable_dict (line 328) | fn encodeable_dict() {
function encodeable_tuple_to_list (line 336) | fn encodeable_tuple_to_list() {
function encodeable_set_to_list (line 341) | fn encodeable_set_to_list() {
function encodeable_frozenset_to_list (line 347) | fn encodeable_frozenset_to_list() {
function encodeable_nested_dict (line 352) | fn encodeable_nested_dict() {
function encodeable_enum (line 362) | fn encodeable_enum() {
function encodeable_int_enum (line 370) | fn encodeable_int_enum() {
function encodeable_datetime (line 382) | fn encodeable_datetime() {
function encodeable_dataclass (line 391) | fn encodeable_dataclass() {
function encodeable_nested_dataclass (line 406) | fn encodeable_nested_dataclass() {
function encodeable_generator (line 423) | fn encodeable_generator() {
function encodeable_enum_in_list (line 430) | fn encodeable_enum_in_list() {
function encode_pathlike_to_base64 (line 446) | fn encode_pathlike_to_base64() {
function encode_iobase_to_base64 (line 467) | fn encode_iobase_to_base64() {
function encode_iobase_seeks_to_start (line 484) | fn encode_iobase_seeks_to_start() {
function encode_file_in_dict (line 499) | fn encode_file_in_dict() {
function encode_file_in_list (line 514) | fn encode_file_in_list() {
function encode_string_passthrough (line 527) | fn encode_string_passthrough() {
function encode_mime_type_guessing (line 533) | fn encode_mime_type_guessing() {
function process_output_primitives_passthrough (line 550) | fn process_output_primitives_passthrough() {
function process_output_dataclass_with_file (line 557) | fn process_output_dataclass_with_file() {
FILE: crates/coglet-python/src/predictor.rs
function get_collect_async_gen (line 30) | fn get_collect_async_gen(py: Python<'_>) -> Result<Py<PyAny>, Prediction...
function get_ctx_wrapper (line 56) | fn get_ctx_wrapper(py: Python<'_>) -> Result<Py<PyAny>, PredictionError> {
function is_cancelation_exception (line 79) | fn is_cancelation_exception(py: Python<'_>, err: &PyErr) -> bool {
function format_validation_error (line 99) | fn format_validation_error(py: Python<'_>, err: &PyErr) -> String {
function send_output_item (line 108) | fn send_output_item(
type PyObject (line 194) | type PyObject = Py<PyAny>;
type PredictKind (line 198) | pub enum PredictKind {
type TrainKind (line 209) | pub enum TrainKind {
type PredictorKind (line 220) | pub enum PredictorKind {
type PythonPredictor (line 235) | pub struct PythonPredictor {
method load (line 248) | pub fn load(py: Python<'_>, predictor_ref: &str) -> PyResult<Self> {
method unwrap_field_info_defaults (line 337) | fn unwrap_field_info_defaults(
method detect_async (line 406) | fn detect_async(
method is_async (line 436) | pub fn is_async(&self) -> bool {
method has_train (line 448) | pub fn has_train(&self) -> bool {
method is_train_async (line 456) | pub fn is_train_async(&self) -> bool {
method setup (line 470) | pub fn setup(&self, py: Python<'_>) -> PyResult<()> {
method predict_func (line 498) | pub fn predict_func<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py...
method train_func (line 507) | pub fn train_func<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, ...
method predict_raw (line 518) | pub fn predict_raw(&self, py: Python<'_>, input: &Bound<'_, PyDict>) -...
method train_raw (line 536) | pub fn train_raw(&self, py: Python<'_>, input: &Bound<'_, PyDict>) -> ...
method call_method_raw (line 548) | fn call_method_raw(
method predict_worker (line 577) | pub fn predict_worker(
method train_worker (line 650) | pub fn train_worker(
method process_generator_output (line 722) | fn process_generator_output(
method process_single_output (line 752) | fn process_single_output(
method predict_async_worker (line 858) | pub fn predict_async_worker(
method process_async_result (line 949) | pub fn process_async_result(
method train_async_worker (line 995) | pub fn train_async_worker(
constant HEALTHCHECK_TIMEOUT (line 1070) | const HEALTHCHECK_TIMEOUT: f64 = 5.0;
method has_healthcheck (line 1073) | pub fn has_healthcheck(&self, py: Python<'_>) -> bool {
method is_healthcheck_async (line 1084) | pub fn is_healthcheck_async(&self, py: Python<'_>) -> bool {
method healthcheck_sync (line 1110) | pub fn healthcheck_sync(&self, py: Python<'_>) -> coglet_core::orchest...
method healthcheck_async (line 1172) | pub fn healthcheck_async(
FILE: crates/coglet-python/src/worker_bridge.rs
type HandlerMode (line 16) | pub enum HandlerMode {
type SdkImplementation (line 28) | pub enum SdkImplementation {
method fmt (line 36) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
type SlotState (line 46) | pub enum SlotState {
method is_cancelled (line 65) | pub fn is_cancelled(&self) -> bool {
method mark_cancelled (line 73) | pub fn mark_cancelled(&mut self) {
type PythonPredictHandler (line 92) | pub struct PythonPredictHandler {
method new (line 108) | pub fn new(predictor_ref: String) -> Result<Self, SetupError> {
method new_train (line 125) | pub fn new_train(predictor_ref: String) -> Result<Self, SetupError> {
method init_async_loop (line 138) | fn init_async_loop() -> Result<(Py<PyAny>, JoinHandle<()>), SetupError> {
method is_cancelled (line 183) | fn is_cancelled(&self, slot: SlotId) -> bool {
method take_cancelled (line 189) | fn take_cancelled(&self, slot: SlotId) -> bool {
method start_sync_prediction (line 204) | fn start_sync_prediction(&self, slot: SlotId, py_thread_id: std::ffi::...
method start_async_prediction (line 216) | fn start_async_prediction(&self, slot: SlotId, future: Py<PyAny>) {
method finish_prediction (line 228) | fn finish_prediction(&self, slot: SlotId) {
method cancel_async_future (line 235) | fn cancel_async_future(&self, slot: SlotId) -> bool {
method get_async_loop (line 265) | fn get_async_loop(&self) -> Option<Py<PyAny>> {
method setup (line 278) | async fn setup(&self) -> Result<(), SetupError> {
method predict (line 307) | async fn predict(
method cancel (line 575) | fn cancel(&self, slot: SlotId) {
method healthcheck (line 607) | async fn healthcheck(&self) -> coglet_core::orchestrator::HealthcheckRes...
method drop (line 652) | fn drop(&mut self) {
function output_to_json (line 692) | fn output_to_json(output: coglet_core::PredictionOutput) -> serde_json::...
FILE: crates/coglet-python/tests/test_coglet.py
class TestModuleStructure (line 21) | class TestModuleStructure:
method test_version_is_pep440 (line 24) | def test_version_is_pep440(self) -> None:
method test_version_is_str (line 32) | def test_version_is_str(self) -> None:
method test_build_info_exists (line 35) | def test_build_info_exists(self) -> None:
method test_build_info_fields_are_strings (line 42) | def test_build_info_fields_are_strings(self) -> None:
method test_build_info_version_matches_module_version (line 49) | def test_build_info_version_matches_module_version(self) -> None:
method test_build_info_repr (line 52) | def test_build_info_repr(self) -> None:
method test_build_info_frozen (line 58) | def test_build_info_frozen(self) -> None:
method test_server_exists (line 62) | def test_server_exists(self) -> None:
method test_server_active_is_false (line 65) | def test_server_active_is_false(self) -> None:
method test_server_active_is_property (line 69) | def test_server_active_is_property(self) -> None:
method test_server_frozen (line 73) | def test_server_frozen(self) -> None:
method test_server_active_not_settable (line 77) | def test_server_active_not_settable(self) -> None:
method test_server_repr (line 81) | def test_server_repr(self) -> None:
method test_sdk_submodule_exists (line 84) | def test_sdk_submodule_exists(self) -> None:
method test_sdk_has_slot_log_writer (line 87) | def test_sdk_has_slot_log_writer(self) -> None:
method test_sdk_has_tee_writer (line 90) | def test_sdk_has_tee_writer(self) -> None:
method test_all_excludes_internals (line 93) | def test_all_excludes_internals(self) -> None:
function sync_predictor (line 104) | def sync_predictor(tmp_path: Path) -> Path:
function generator_predictor (line 128) | def generator_predictor(tmp_path: Path) -> Path:
function async_predictor (line 154) | def async_predictor(tmp_path: Path) -> Path:
function async_generator_predictor (line 181) | def async_generator_predictor(tmp_path: Path) -> Path:
class CogletServer (line 208) | class CogletServer:
method __init__ (line 211) | def __init__(self, predictor_path: Path, port: int = 0):
method __enter__ (line 220) | def __enter__(self):
method __exit__ (line 247) | def __exit__(self, exc_type, exc_val, exc_tb):
method _read_stderr (line 252) | def _read_stderr(self):
method _discover_port (line 261) | def _discover_port(self, timeout: float = 5.0):
method _wait_for_ready (line 285) | def _wait_for_ready(self, timeout: float = 10.0):
method base_url (line 309) | def base_url(self) -> str:
method health_check (line 312) | def health_check(self) -> dict:
method predict (line 317) | def predict(self, input_data: dict) -> dict:
class TestHealthCheck (line 325) | class TestHealthCheck:
method test_returns_ready_status (line 328) | def test_returns_ready_status(self, sync_predictor: Path):
method test_returns_version_info (line 333) | def test_returns_version_info(self, sync_predictor: Path):
class TestSyncPredictor (line 342) | class TestSyncPredictor:
method test_basic_prediction (line 345) | def test_basic_prediction(self, sync_predictor: Path):
method test_default_input (line 351) | def test_default_input(self, sync_predictor: Path):
method test_includes_predict_time (line 357) | def test_includes_predict_time(self, sync_predictor: Path):
class TestGeneratorPredictor (line 365) | class TestGeneratorPredictor:
method test_returns_array_output (line 368) | def test_returns_array_output(self, generator_predictor: Path):
method test_custom_count (line 374) | def test_custom_count(self, generator_predictor: Path):
class TestAsyncPredictor (line 380) | class TestAsyncPredictor:
method test_basic_prediction (line 383) | def test_basic_prediction(self, async_predictor: Path):
method test_sequential_requests (line 389) | def test_sequential_requests(self, async_predictor: Path):
class TestAsyncGeneratorPredictor (line 402) | class TestAsyncGeneratorPredictor:
method test_returns_array_output (line 405) | def test_returns_array_output(self, async_generator_predictor: Path):
function slow_sync_predictor (line 417) | def slow_sync_predictor(tmp_path: Path) -> Path:
function blocking_sleep_predictor (line 445) | def blocking_sleep_predictor(tmp_path: Path) -> Path:
function slow_async_predictor (line 471) | def slow_async_predictor(tmp_path: Path) -> Path:
function _wait_for_health_status (line 495) | def _wait_for_health_status(
class TestCancellation (line 515) | class TestCancellation:
method test_cancel_endpoint_returns_404_for_unknown_id (line 518) | def test_cancel_endpoint_returns_404_for_unknown_id(self, sync_predict...
method test_prediction_response_includes_id (line 526) | def test_prediction_response_includes_id(self, sync_predictor: Path):
method test_cancel_running_sync_prediction (line 533) | def test_cancel_running_sync_prediction(self, slow_sync_predictor: Path):
method test_cancel_running_async_prediction (line 557) | def test_cancel_running_async_prediction(self, slow_async_predictor: P...
method test_repeated_cancel_is_idempotent (line 591) | def test_repeated_cancel_is_idempotent(
method test_cancel_sync_prediction_connection_drop (line 631) | def test_cancel_sync_prediction_connection_drop(self, slow_sync_predic...
FILE: crates/coglet/src/bridge/codec.rs
type JsonCodec (line 16) | pub struct JsonCodec<T> {
method default (line 22) | fn default() -> Self {
function new (line 28) | pub fn new() -> Self {
type Item (line 39) | type Item = T;
type Error (line 40) | type Error = io::Error;
method decode (line 42) | fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, S...
type Error (line 55) | type Error = io::Error;
function encode (line 57) | fn encode(&mut self, item: T, dst: &mut BytesMut) -> Result<(), Self::Er...
function codec_roundtrip_control_request (line 88) | fn codec_roundtrip_control_request() {
function codec_roundtrip_control_response (line 101) | fn codec_roundtrip_control_response() {
function codec_roundtrip_slot_request (line 117) | fn codec_roundtrip_slot_request() {
function codec_roundtrip_slot_response (line 158) | fn codec_roundtrip_slot_response() {
FILE: crates/coglet/src/bridge/protocol.rs
type SlotId (line 18) | pub struct SlotId(uuid::Uuid);
method new (line 21) | pub fn new() -> Self {
method as_uuid (line 25) | pub fn as_uuid(&self) -> &uuid::Uuid {
method parse (line 29) | pub fn parse(s: &str) -> Result<Self, uuid::Error> {
method fmt (line 42) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
method default (line 36) | fn default() -> Self {
constant MAX_INLINE_IPC_SIZE (line 51) | pub const MAX_INLINE_IPC_SIZE: usize = 1024 * 1024 * 6;
constant MAX_WORKER_LOG_SIZE (line 53) | const MAX_WORKER_LOG_SIZE: usize = 1024 * 1024 * 4;
constant WORKER_LOG_TRUNCATE_NOTICE (line 54) | const WORKER_LOG_TRUNCATE_NOTICE: &str = "[**** LOG LINE TRUNCATED AT 4 ...
function truncate_worker_log (line 58) | pub fn truncate_worker_log(mut log_message: String) -> String {
type ControlRequest (line 71) | pub enum ControlRequest {
type ControlResponse (line 96) | pub enum ControlResponse {
type HealthcheckStatus (line 160) | pub enum HealthcheckStatus {
type SlotOutcome (line 169) | pub enum SlotOutcome {
method idle (line 175) | pub fn idle(slot: SlotId) -> Self {
method poisoned (line 179) | pub fn poisoned(slot: SlotId, error: impl Into<String>) -> Self {
method slot_id (line 186) | pub fn slot_id(&self) -> SlotId {
method is_poisoned (line 193) | pub fn is_poisoned(&self) -> bool {
method into_control_response (line 197) | pub fn into_control_response(self) -> ControlResponse {
type SlotRequest (line 208) | pub enum SlotRequest {
method prediction_id (line 230) | pub fn prediction_id(&self) -> &str {
method rehydrate_input (line 240) | pub fn rehydrate_input(
type FileOutputKind (line 278) | pub enum FileOutputKind {
type MetricMode (line 288) | pub enum MetricMode {
type SlotResponse (line 300) | pub enum SlotResponse {
type LogSource (line 359) | pub enum LogSource {
function test_slot_id (line 370) | fn test_slot_id() -> SlotId {
function control_init_serializes (line 375) | fn control_init_serializes() {
function control_cancel_serializes (line 390) | fn control_cancel_serializes() {
function control_shutdown_serializes (line 398) | fn control_shutdown_serializes() {
function control_healthcheck_serializes (line 404) | fn control_healthcheck_serializes() {
function control_healthcheck_result_healthy_serializes (line 412) | fn control_healthcheck_result_healthy_serializes() {
function control_healthcheck_result_unhealthy_serializes (line 422) | fn control_healthcheck_result_unhealthy_serializes() {
function control_ready_serializes (line 432) | fn control_ready_serializes() {
function control_ready_with_schema_serializes (line 441) | fn control_ready_with_schema_serializes() {
function control_idle_serializes (line 453) | fn control_idle_serializes() {
function control_cancelled_serializes (line 461) | fn control_cancelled_serializes() {
function control_failed_serializes (line 469) | fn control_failed_serializes() {
function slot_predict_serializes (line 478) | fn slot_predict_serializes() {
function slot_predict_file_input_serializes (line 490) | fn slot_predict_file_input_serializes() {
function slot_log_serializes (line 502) | fn slot_log_serializes() {
function slot_output_serializes (line 511) | fn slot_output_serializes() {
function slot_done_serializes (line 519) | fn slot_done_serializes() {
function slot_failed_serializes (line 530) | fn slot_failed_serializes() {
function slot_cancelled_serializes (line 539) | fn slot_cancelled_serializes() {
function slot_metric_replace_serializes (line 547) | fn slot_metric_replace_serializes() {
function slot_metric_increment_serializes (line 557) | fn slot_metric_increment_serializes() {
function slot_metric_append_serializes (line 567) | fn slot_metric_append_serializes() {
function slot_metric_delete_serializes (line 577) | fn slot_metric_delete_serializes() {
function slot_metric_complex_value_serializes (line 587) | fn slot_metric_complex_value_serializes() {
function rehydrate_input_inline (line 597) | fn rehydrate_input_inline() {
function rehydrate_input_from_file (line 612) | fn rehydrate_input_from_file() {
function rehydrate_input_neither_errors (line 633) | fn rehydrate_input_neither_errors() {
function rehydrate_input_corrupt_file_errors (line 646) | fn rehydrate_input_corrupt_file_errors() {
function truncate_worker_log_truncates_long_messages (line 663) | fn truncate_worker_log_truncates_long_messages() {
function truncate_worker_log_does_not_truncate_short_messages (line 676) | fn truncate_worker_log_does_not_truncate_short_messages() {
FILE: crates/coglet/src/bridge/transport.rs
type ChildTransportInfo (line 15) | pub enum ChildTransportInfo {
type NamedSocketTransport (line 30) | pub struct NamedSocketTransport {
method create (line 39) | pub async fn create(num_slots: usize) -> io::Result<(Self, ChildTransp...
method accept_connections (line 80) | pub async fn accept_connections(&mut self, num_slots: usize) -> io::Re...
method connect (line 94) | pub async fn connect(dir: PathBuf, num_slots: usize) -> io::Result<Sel...
method slot_socket (line 115) | pub fn slot_socket(&mut self, slot: usize) -> Option<&mut UnixStream> {
method drain_sockets (line 120) | pub fn drain_sockets(&mut self) -> Vec<UnixStream> {
method dir (line 124) | pub fn dir(&self) -> &PathBuf {
method num_slots (line 128) | pub fn num_slots(&self) -> usize {
method cleanup (line 132) | pub fn cleanup(&mut self) -> io::Result<()> {
method drop (line 142) | fn drop(&mut self) {
type AbstractSocketTransport (line 153) | pub struct AbstractSocketTransport {
method create (line 163) | pub async fn create(num_slots: usize) -> io::Result<(Self, ChildTransp...
method accept_connections (line 197) | pub async fn accept_connections(&mut self, num_slots: usize) -> io::Re...
method connect (line 211) | pub async fn connect(prefix: String, num_slots: usize) -> io::Result<S...
method slot_socket (line 239) | pub fn slot_socket(&mut self, slot: usize) -> Option<&mut UnixStream> {
method drain_sockets (line 243) | pub fn drain_sockets(&mut self) -> Vec<UnixStream> {
method num_slots (line 247) | pub fn num_slots(&self) -> usize {
type SlotTransport (line 252) | pub enum SlotTransport {
method slot_socket (line 259) | pub fn slot_socket(&mut self, slot: usize) -> Option<&mut UnixStream> {
method drain_sockets (line 267) | pub fn drain_sockets(&mut self) -> Vec<UnixStream> {
method num_slots (line 275) | pub fn num_slots(&self) -> usize {
method accept_connections (line 283) | pub async fn accept_connections(&mut self, num_slots: usize) -> io::Re...
function create_transport (line 293) | pub async fn create_transport(num_slots: usize) -> io::Result<(SlotTrans...
function connect_transport (line 307) | pub async fn connect_transport(info: ChildTransportInfo) -> io::Result<S...
function child_transport_info_roundtrips (line 326) | fn child_transport_info_roundtrips() {
function abstract_socket_info_roundtrips (line 346) | fn abstract_socket_info_roundtrips() {
FILE: crates/coglet/src/fd_redirect.rs
constant CONTROL_STDIN_FD (line 40) | const CONTROL_STDIN_FD: i32 = 99;
constant CONTROL_STDOUT_FD (line 42) | const CONTROL_STDOUT_FD: i32 = 100;
constant WORKER_STDERR_FD (line 44) | const WORKER_STDERR_FD: i32 = 101;
type ControlChannelFds (line 47) | pub struct ControlChannelFds {
function redirect_fds_for_subprocess_isolation (line 57) | pub fn redirect_fds_for_subprocess_isolation(
type ControlChannelFds (line 231) | pub struct ControlChannelFds {
function redirect_fds_for_subprocess_isolation (line 237) | pub fn redirect_fds_for_subprocess_isolation(
FILE: crates/coglet/src/health.rs
type Health (line 8) | pub enum Health {
type HealthResponse (line 28) | pub enum HealthResponse {
method from (line 40) | fn from(health: Health) -> Self {
type SetupStatus (line 55) | pub enum SetupStatus {
type SetupResult (line 63) | pub struct SetupResult {
method starting (line 79) | pub fn starting() -> Self {
method succeeded (line 89) | pub fn succeeded(mut self, logs: String) -> Self {
method failed (line 97) | pub fn failed(mut self, logs: String) -> Self {
function health_default_is_unknown (line 110) | fn health_default_is_unknown() {
function health_serializes_screaming_snake_case (line 115) | fn health_serializes_screaming_snake_case() {
function health_response_serializes_screaming_snake_case (line 130) | fn health_response_serializes_screaming_snake_case() {
function health_deserializes_screaming_snake_case (line 146) | fn health_deserializes_screaming_snake_case() {
function setup_status_serializes_lowercase (line 158) | fn setup_status_serializes_lowercase() {
function setup_status_deserializes_lowercase (line 170) | fn setup_status_deserializes_lowercase() {
FILE: crates/coglet/src/input_validation.rs
type ValidationError (line 13) | pub struct ValidationError {
type InputValidator (line 23) | pub struct InputValidator {
method from_openapi_schema (line 38) | pub fn from_openapi_schema(schema: &Value) -> Option<Self> {
method from_openapi_schema_key (line 46) | pub fn from_openapi_schema_key(schema: &Value, key: &str) -> Option<Se...
method required_count (line 90) | pub fn required_count(&self) -> usize {
method validate (line 98) | pub fn validate(&self, input: &Value) -> Result<(), Vec<ValidationErro...
function inline_refs (line 183) | fn inline_refs(value: &mut Value, all_schemas: Option<&Value>) {
function resolve_ref (line 210) | fn resolve_ref(ref_str: &str, all_schemas: Option<&Value>) -> Option<Val...
function make_schema (line 220) | fn make_schema(input_schema: Value) -> Value {
function validates_required_fields (line 231) | fn validates_required_fields() {
function rejects_additional_properties (line 253) | fn rejects_additional_properties() {
function missing_and_extra_fields (line 274) | fn missing_and_extra_fields() {
function validates_types (line 297) | fn validates_types() {
function no_schema_returns_none (line 317) | fn no_schema_returns_none() {
function resolves_ref_for_choices (line 323) | fn resolves_ref_for_choices() {
function optional_fields_work (line 356) | fn optional_fields_work() {
FILE: crates/coglet/src/orchestrator.rs
function upload_file (line 38) | async fn upload_file(
function ensure_trailing_slash (line 77) | fn ensure_trailing_slash(s: &str) -> String {
function try_lock_prediction (line 88) | fn try_lock_prediction(
function wrap_outputs (line 112) | fn wrap_outputs(
function emit_worker_log (line 133) | fn emit_worker_log(target: &str, level: &str, msg: &str) {
type HealthcheckResult (line 208) | pub struct HealthcheckResult {
method healthy (line 214) | pub fn healthy() -> Self {
method unhealthy (line 221) | pub fn unhealthy(error: impl Into<String>) -> Self {
method is_healthy (line 228) | pub fn is_healthy(&self) -> bool {
type Orchestrator (line 239) | pub trait Orchestrator: Send + Sync {
method register_prediction (line 241) | async fn register_prediction(
method cancel_by_prediction_id (line 252) | async fn cancel_by_prediction_id(&self, prediction_id: &str) -> Result...
method healthcheck (line 255) | async fn healthcheck(&self) -> Result<HealthcheckResult, OrchestratorE...
method shutdown (line 258) | async fn shutdown(&self) -> Result<(), OrchestratorError>;
method register_prediction (line 372) | async fn register_prediction(
method cancel_by_prediction_id (line 384) | async fn cancel_by_prediction_id(&self, prediction_id: &str) -> Result...
method healthcheck (line 391) | async fn healthcheck(&self) -> Result<HealthcheckResult, OrchestratorE...
method shutdown (line 424) | async fn shutdown(&self) -> Result<(), OrchestratorError> {
type WorkerSpawnConfig (line 262) | pub struct WorkerSpawnConfig {
type SpawnError (line 267) | pub enum SpawnError {
type WorkerSpawner (line 275) | pub trait WorkerSpawner: Send + Sync {
method spawn (line 276) | fn spawn(&self, config: &WorkerSpawnConfig) -> Result<Child, SpawnError>;
method spawn (line 283) | fn spawn(&self, _config: &WorkerSpawnConfig) -> Result<Child, SpawnErr...
type SimpleSpawner (line 280) | pub struct SimpleSpawner;
type OrchestratorConfig (line 294) | pub struct OrchestratorConfig {
method new (line 306) | pub fn new(predictor_ref: impl Into<String>) -> Self {
method with_upload_url (line 318) | pub fn with_upload_url(mut self, upload_url: Option<String>) -> Self {
method with_num_slots (line 323) | pub fn with_num_slots(mut self, n: usize) -> Self {
method with_train (line 328) | pub fn with_train(mut self, is_train: bool) -> Self {
method with_async (line 333) | pub fn with_async(mut self, is_async: bool) -> Self {
method with_setup_timeout (line 338) | pub fn with_setup_timeout(mut self, timeout: Option<Duration>) -> Self {
method with_spawner (line 343) | pub fn with_spawner(mut self, spawner: Arc<dyn WorkerSpawner>) -> Self {
type OrchestratorReady (line 349) | pub struct OrchestratorReady {
type OrchestratorHandle (line 356) | pub struct OrchestratorHandle {
method cancel (line 434) | pub async fn cancel(&self, slot_id: SlotId) -> Result<(), Orchestrator...
method slot_ids (line 442) | pub fn slot_ids(&self) -> &[SlotId] {
method wait (line 446) | pub async fn wait(&mut self) -> Result<(), OrchestratorError> {
type OrchestratorError (line 455) | pub enum OrchestratorError {
function spawn_worker (line 468) | pub async fn spawn_worker(
function run_event_loop (line 692) | async fn run_event_loop(
function wrap_outputs_schema_array_empty (line 1241) | fn wrap_outputs_schema_array_empty() {
function wrap_outputs_schema_array_single_item (line 1249) | fn wrap_outputs_schema_array_single_item() {
function wrap_outputs_schema_array_multiple_items (line 1260) | fn wrap_outputs_schema_array_multiple_items() {
function wrap_outputs_schema_array_overrides_is_stream_false (line 1274) | fn wrap_outputs_schema_array_overrides_is_stream_false() {
function wrap_outputs_predictor_stream_empty (line 1284) | fn wrap_outputs_predictor_stream_empty() {
function wrap_outputs_predictor_stream_single_item (line 1292) | fn wrap_outputs_predictor_stream_single_item() {
function wrap_outputs_predictor_stream_multiple_items (line 1300) | fn wrap_outputs_predictor_stream_multiple_items() {
function wrap_outputs_scalar_empty (line 1311) | fn wrap_outputs_scalar_empty() {
function wrap_outputs_scalar_single (line 1319) | fn wrap_outputs_scalar_single() {
function wrap_outputs_scalar_multiple_falls_back_to_stream (line 1330) | fn wrap_outputs_scalar_multiple_falls_back_to_stream() {
function done_is_stream_false_omitted_from_json (line 1342) | fn done_is_stream_false_omitted_from_json() {
function done_is_stream_true_present_in_json (line 1357) | fn done_is_stream_true_present_in_json() {
function done_without_is_stream_deserializes_as_false (line 1369) | fn done_without_is_stream_deserializes_as_false() {
FILE: crates/coglet/src/permit/pool.rs
type PermitInner (line 18) | pub(crate) struct PermitInner {
type PoolConnection (line 25) | struct PoolConnection {
method clone (line 31) | fn clone(&self) -> Self {
type PermitInUse (line 40) | pub struct PermitInUse {
method new (line 49) | pub(crate) fn new(
method slot_id (line 68) | pub fn slot_id(&self) -> SlotId {
method into_idle (line 74) | pub fn into_idle(mut self) -> PermitIdle {
method into_poisoned (line 88) | pub fn into_poisoned(mut self) -> PermitPoisoned {
method send (line 96) | pub async fn send(&mut self, request: SlotRequest) -> Result<(), Permi...
method drop (line 106) | fn drop(&mut self) {
type PermitIdle (line 115) | pub struct PermitIdle {
method slot_id (line 124) | pub fn slot_id(&self) -> SlotId {
method drop (line 130) | fn drop(&mut self) {
type PermitPoisoned (line 153) | pub struct PermitPoisoned {
method slot_id (line 159) | pub fn slot_id(&self) -> SlotId {
method drop (line 165) | fn drop(&mut self) {
type AnyPermit (line 171) | pub enum AnyPermit {
method slot_id (line 178) | pub fn slot_id(&self) -> SlotId {
method is_idle (line 186) | pub fn is_idle(&self) -> bool {
method is_poisoned (line 190) | pub fn is_poisoned(&self) -> bool {
method is_in_use (line 194) | pub fn is_in_use(&self) -> bool {
type InactiveSlotIdleToken (line 201) | pub struct InactiveSlotIdleToken {
method new (line 206) | pub fn new(slot_id: SlotId) -> Self {
method slot_id (line 210) | pub fn slot_id(&self) -> SlotId {
method activate (line 214) | pub fn activate(self) -> SlotIdleToken {
type SlotIdleToken (line 231) | pub struct SlotIdleToken {
constant ALERT_THRESHOLD (line 238) | const ALERT_THRESHOLD: std::time::Duration = std::time::Duration::from...
method slot_id (line 240) | pub fn slot_id(&self) -> SlotId {
method consume (line 244) | pub fn consume(self) {
method drop (line 254) | fn drop(&mut self) {
type PermitError (line 260) | pub enum PermitError {
type PermitPool (line 271) | pub struct PermitPool {
method new (line 281) | pub fn new(num_slots: usize) -> Self {
method add_permit (line 293) | pub fn add_permit(
method poison (line 324) | pub fn poison(&self, slot_id: SlotId) {
method is_poisoned (line 339) | pub fn is_poisoned(&self, slot_id: SlotId) -> bool {
method try_acquire (line 350) | pub fn try_acquire(&self) -> Option<PermitInUse> {
method acquire (line 370) | pub async fn acquire(&self) -> Option<PermitInUse> {
method num_slots (line 390) | pub fn num_slots(&self) -> usize {
method available (line 394) | pub fn available(&self) -> usize {
function make_socket_pair (line 404) | async fn make_socket_pair() -> (OwnedWriteHalf, tokio::net::unix::OwnedR...
function pool_add_and_acquire (line 412) | async fn pool_add_and_acquire() {
function permit_returns_to_pool_when_idle (line 435) | async fn permit_returns_to_pool_when_idle() {
function permit_orphaned_when_poisoned (line 453) | async fn permit_orphaned_when_poisoned() {
function pool_poison_idle_slot (line 471) | async fn pool_poison_idle_slot() {
function pool_poison_in_use_slot_prevents_return (line 498) | async fn pool_poison_in_use_slot_prevents_return() {
function pool_poison_is_idempotent (line 520) | async fn pool_poison_is_idempotent() {
FILE: crates/coglet/src/permit/slot.rs
type SlotError (line 17) | pub enum SlotError {
type UnregisteredPredictionSlot (line 26) | pub struct UnregisteredPredictionSlot {
method new (line 32) | pub fn new(
method into_parts (line 43) | pub fn into_parts(self) -> (tokio::sync::oneshot::Sender<SlotIdleToken...
method prediction (line 47) | pub fn prediction(&self) -> Arc<Mutex<Prediction>> {
type PredictionSlot (line 55) | pub struct PredictionSlot {
method new (line 63) | pub fn new(
method prediction (line 77) | pub fn prediction(&self) -> Arc<Mutex<Prediction>> {
method permit_mut (line 81) | pub fn permit_mut(&mut self) -> Option<&mut PermitInUse> {
method slot_id (line 88) | pub fn slot_id(&self) -> SlotId {
method into_idle (line 97) | pub async fn into_idle(mut self) -> Result<(), SlotError> {
method is_idle (line 138) | pub fn is_idle(&self) -> bool {
method id (line 142) | pub fn id(&self) -> String {
method drop (line 151) | fn drop(&mut self) {
function slot_creation (line 175) | async fn slot_creation() {
function slot_mark_idle_returns_permit (line 193) | async fn slot_mark_idle_returns_permit() {
function slot_not_idle_orphans_permit (line 217) | async fn slot_not_idle_orphans_permit() {
function slot_idle_channel_closed_does_not_return_permit (line 237) | async fn slot_idle_channel_closed_does_not_return_permit() {
FILE: crates/coglet/src/prediction.rs
type PredictionStatus (line 14) | pub enum PredictionStatus {
method is_terminal (line 23) | pub fn is_terminal(&self) -> bool {
method as_str (line 27) | pub fn as_str(&self) -> &'static str {
type PredictionOutput (line 41) | pub enum PredictionOutput {
method is_stream (line 47) | pub fn is_stream(&self) -> bool {
method into_values (line 51) | pub fn into_values(self) -> Vec<serde_json::Value> {
method final_value (line 59) | pub fn final_value(&self) -> &serde_json::Value {
type Prediction (line 68) | pub struct Prediction {
method new (line 84) | pub fn new(id: String, webhook: Option<WebhookSender>) -> Self {
method id (line 100) | pub fn id(&self) -> &str {
method cancel_token (line 104) | pub fn cancel_token(&self) -> CancellationToken {
method is_canceled (line 108) | pub fn is_canceled(&self) -> bool {
method status (line 112) | pub fn status(&self) -> PredictionStatus {
method is_terminal (line 116) | pub fn is_terminal(&self) -> bool {
method set_processing (line 120) | pub fn set_processing(&mut self) {
method set_succeeded (line 125) | pub fn set_succeeded(&mut self, output: PredictionOutput) {
method set_failed (line 141) | pub fn set_failed(&mut self, error: String) {
method set_canceled (line 151) | pub fn set_canceled(&mut self) {
method elapsed (line 160) | pub fn elapsed(&self) -> std::time::Duration {
method append_log (line 164) | pub fn append_log(&mut self, data: &str) {
method logs (line 169) | pub fn logs(&self) -> &str {
method set_metric (line 180) | pub fn set_metric(&mut self, name: String, value: serde_json::Value, m...
method set_metric_dotpath (line 227) | fn set_metric_dotpath(&mut self, parts: &[&str], value: serde_json::Va...
method metrics (line 293) | pub fn metrics(&self) -> &HashMap<String, serde_json::Value> {
method append_output (line 297) | pub fn append_output(&mut self, output: serde_json::Value) {
method outputs (line 302) | pub fn outputs(&self) -> &[serde_json::Value] {
method take_outputs (line 306) | pub fn take_outputs(&mut self) -> Vec<serde_json::Value> {
method output (line 310) | pub fn output(&self) -> Option<&PredictionOutput> {
method error (line 314) | pub fn error(&self) -> Option<&str> {
method wait (line 318) | pub async fn wait(&self) {
method completion (line 325) | pub fn completion(&self) -> Arc<Notify> {
method take_webhook (line 330) | pub fn take_webhook(&mut self) -> Option<WebhookSender> {
method fire_webhook (line 338) | fn fire_webhook(&self, event: WebhookEventType) {
method fire_terminal_webhook (line 349) | fn fire_terminal_webhook(&mut self) {
method build_state_snapshot (line 365) | pub fn build_state_snapshot(&self) -> serde_json::Value {
method build_webhook_payload (line 401) | fn build_webhook_payload(&self) -> serde_json::Value {
method build_terminal_response (line 405) | pub fn build_terminal_response(&self) -> serde_json::Value {
function status_is_terminal (line 415) | fn status_is_terminal() {
function new_starts_in_starting_status (line 424) | fn new_starts_in_starting_status() {
function set_succeeded (line 431) | fn set_succeeded() {
function set_failed (line 438) | fn set_failed() {
function set_canceled (line 445) | fn set_canceled() {
function cancel_token_works (line 452) | fn cancel_token_works() {
function elapsed_time_increases (line 462) | fn elapsed_time_increases() {
function append_log (line 471) | fn append_log() {
function append_output (line 479) | fn append_output() {
function wait_returns_immediately_if_terminal (line 487) | async fn wait_returns_immediately_if_terminal() {
function prediction_output_single (line 496) | fn prediction_output_single() {
function prediction_output_stream (line 503) | fn prediction_output_stream() {
function metric_replace_sets_value (line 513) | fn metric_replace_sets_value() {
function metric_replace_overwrites (line 520) | fn metric_replace_overwrites() {
function metric_replace_null_deletes (line 528) | fn metric_replace_null_deletes() {
function metric_increment_integers (line 536) | fn metric_increment_integers() {
function metric_increment_floats (line 544) | fn metric_increment_floats() {
function metric_increment_creates_from_zero (line 560) | fn metric_increment_creates_from_zero() {
function metric_append_creates_array (line 567) | fn metric_append_creates_array() {
function metric_append_to_non_array_wraps (line 583) | fn metric_append_to_non_array_wraps() {
function metric_dotpath_creates_nested (line 591) | fn metric_dotpath_creates_nested() {
function metric_dotpath_deep (line 605) | fn metric_dotpath_deep() {
function metric_dotpath_multiple_leaves (line 612) | fn metric_dotpath_multiple_leaves() {
function metric_dotpath_delete_leaf (line 631) | fn metric_dotpath_delete_leaf() {
function metric_dotpath_increment (line 648) | fn metric_dotpath_increment() {
function metric_complex_values (line 664) | fn metric_complex_values() {
function terminal_snapshot_merges_metrics_with_predict_time (line 684) | fn terminal_snapshot_merges_metrics_with_predict_time() {
function terminal_snapshot_predict_time_overrides_user (line 698) | fn terminal_snapshot_predict_time_overrides_user() {
function terminal_state_guard_set_failed_after_succeeded (line 715) | fn terminal_state_guard_set_failed_after_succeeded() {
function terminal_state_guard_set_succeeded_after_failed (line 725) | fn terminal_state_guard_set_succeeded_after_failed() {
function terminal_state_guard_set_canceled_after_succeeded (line 734) | fn terminal_state_guard_set_canceled_after_succeeded() {
FILE: crates/coglet/src/predictor.rs
type PredictionResult (line 10) | pub struct PredictionResult {
type PredictionMetrics (line 20) | pub struct PredictionMetrics {
type PredictionGuard (line 25) | pub struct PredictionGuard {
method new (line 32) | pub fn new() -> Self {
method cancel_token (line 40) | pub fn cancel_token(&self) -> CancellationToken {
method is_cancelled (line 44) | pub fn is_cancelled(&self) -> bool {
method cancel (line 48) | pub fn cancel(&self) {
method finish (line 52) | pub fn finish(mut self) -> PredictionMetrics {
method default (line 59) | fn default() -> Self {
type PredictionError (line 65) | pub enum PredictionError {
function prediction_output_single_is_not_stream (line 87) | fn prediction_output_single_is_not_stream() {
function prediction_output_stream_is_stream (line 93) | fn prediction_output_stream_is_stream() {
function prediction_output_serializes_untagged (line 99) | fn prediction_output_serializes_untagged() {
function prediction_guard_tracks_time (line 108) | fn prediction_guard_tracks_time() {
function prediction_error_display (line 120) | fn prediction_error_display() {
FILE: crates/coglet/src/service.rs
function try_lock_prediction (line 29) | fn try_lock_prediction(
type CreatePredictionError (line 46) | pub enum CreatePredictionError {
type HealthSnapshot (line 55) | pub struct HealthSnapshot {
method is_ready (line 64) | pub fn is_ready(&self) -> bool {
method is_busy (line 69) | pub fn is_busy(&self) -> bool {
type PredictionEntry (line 78) | struct PredictionEntry {
type PredictionHandle (line 85) | pub struct PredictionHandle {
method id (line 91) | pub fn id(&self) -> &str {
method cancel_token (line 95) | pub fn cancel_token(&self) -> CancellationToken {
method sync_guard (line 104) | pub fn sync_guard(&self, service: Arc<PredictionService>) -> SyncPredi...
type SyncPredictionGuard (line 115) | pub struct SyncPredictionGuard {
method new (line 121) | pub fn new(prediction_id: String, service: Arc<PredictionService>) -> ...
method disarm (line 128) | pub fn disarm(&mut self) {
method drop (line 134) | fn drop(&mut self) {
type OrchestratorState (line 144) | pub struct OrchestratorState {
method clone (line 150) | fn clone(&self) -> Self {
type PredictionService (line 162) | pub struct PredictionService {
method new_no_pool (line 186) | pub fn new_no_pool() -> Self {
method set_orchestrator (line 203) | pub async fn set_orchestrator(
method has_orchestrator (line 211) | pub async fn has_orchestrator(&self) -> bool {
method shutdown (line 219) | pub async fn shutdown(&self) {
method with_health (line 231) | pub fn with_health(mut self, health: Health) -> Self {
method with_version (line 238) | pub fn with_version(mut self, version: VersionInfo) -> Self {
method version (line 244) | pub fn version(&self) -> &VersionInfo {
method supports_training (line 249) | pub async fn supports_training(&self) -> bool {
method pool (line 254) | pub async fn pool(&self) -> Option<Arc<PermitPool>> {
method health (line 262) | pub async fn health(&self) -> HealthSnapshot {
method set_health (line 291) | pub async fn set_health(&self, health: Health) {
method set_setup_result (line 301) | pub async fn set_setup_result(&self, result: SetupResult) {
method set_schema (line 312) | pub async fn set_schema(&self, schema: serde_json::Value) {
method schema (line 336) | pub async fn schema(&self) -> Option<serde_json::Value> {
method validate_input (line 344) | pub async fn validate_input(
method validate_train_input (line 359) | pub async fn validate_train_input(
method healthcheck (line 375) | pub async fn healthcheck(
method submit_prediction (line 397) | pub async fn submit_prediction(
method prediction_exists (line 438) | pub fn prediction_exists(&self, id: &str) -> bool {
method get_prediction_response (line 446) | pub fn get_prediction_response(&self, id: &str) -> Option<serde_json::...
method predict (line 457) | pub async fn predict(
method cancel (line 590) | pub fn cancel(&self, id: &str) -> bool {
method remove_prediction (line 620) | pub fn remove_prediction(&self, id: &str) {
method trigger_shutdown (line 624) | pub fn trigger_shutdown(&self) {
method shutdown_rx (line 628) | pub fn shutdown_rx(&self) -> watch::Receiver<bool> {
function build_slot_request (line 640) | fn build_slot_request(
type MockOrchestrator (line 684) | struct MockOrchestrator {
method new (line 691) | fn new() -> Self {
method register_count (line 699) | fn register_count(&self) -> usize {
method with_idle_ack (line 703) | fn with_idle_ack(mut self) -> Self {
method register_prediction (line 711) | async fn register_prediction(
method cancel_by_prediction_id (line 729) | async fn cancel_by_prediction_id(
method healthcheck (line 736) | async fn healthcheck(
method shutdown (line 742) | async fn shutdown(&self) -> Result<(), crate::orchestrator::Orchestrator...
function create_test_pool (line 747) | async fn create_test_pool(num_slots: usize) -> Arc<PermitPool> {
function create_test_pool_with_slots (line 771) | async fn create_test_pool_with_slots(num_slots: usize) -> (Arc<PermitPoo...
function create_broken_test_pool (line 797) | async fn create_broken_test_pool() -> (Arc<PermitPool>, SlotId) {
function service_new_no_pool_works (line 814) | async fn service_new_no_pool_works() {
function service_no_pool_initially (line 825) | async fn service_no_pool_initially() {
function shutdown_signal_works (line 833) | async fn shutdown_signal_works() {
function submit_fails_when_not_ready (line 846) | async fn submit_fails_when_not_ready() {
function cannot_set_ready_without_orchestrator (line 856) | async fn cannot_set_ready_without_orchestrator() {
function set_orchestrator_enables_ready_health (line 869) | async fn set_orchestrator_enables_ready_health() {
function submit_prediction_succeeds_when_ready (line 886) | async fn submit_prediction_succeeds_when_ready() {
function submit_returns_at_capacity_when_no_slots (line 904) | async fn submit_returns_at_capacity_when_no_slots() {
function predict_calls_orchestrator_register (line 926) | async fn predict_calls_orchestrator_register() {
function health_shows_busy_when_all_slots_used (line 958) | async fn health_shows_busy_when_all_slots_used() {
function predict_idle_channel_closed_poison_slot_async (line 982) | async fn predict_idle_channel_closed_poison_slot_async() {
function predict_idle_ack_returns_capacity_async (line 1022) | async fn predict_idle_ack_returns_capacity_async() {
function predict_send_failure_poison_slot (line 1061) | async fn predict_send_failure_poison_slot() {
function cancel_prediction_works (line 1091) | async fn cancel_prediction_works() {
function cancel_nonexistent_returns_false (line 1111) | async fn cancel_nonexistent_returns_false() {
function sync_guard_cancels_on_drop (line 1117) | async fn sync_guard_cancels_on_drop() {
function sync_guard_disarm_prevents_cancel (line 1141) | async fn sync_guard_disarm_prevents_cancel() {
function remove_prediction_cleans_up (line 1165) | async fn remove_prediction_cleans_up() {
function build_slot_request_small_input_inline (line 1184) | fn build_slot_request_small_input_inline() {
function build_slot_request_large_input_spills (line 1213) | fn build_slot_request_large_input_spills() {
function build_slot_request_roundtrip (line 1249) | fn build_slot_request_roundtrip() {
FILE: crates/coglet/src/setup_log_accumulator.rs
type SetupLogAccumulator (line 16) | pub struct SetupLogAccumulator {
method new (line 21) | pub fn new(tx: mpsc::UnboundedSender<String>) -> Self {
method on_event (line 30) | fn on_event(&self, event: &tracing::Event<'_>, _ctx: Context<'_, S>) {
type MessageVisitor (line 47) | struct MessageVisitor {
method record_debug (line 52) | fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn ...
method record_str (line 61) | fn record_str(&mut self, field: &tracing::field::Field, value: &str) {
function drain_accumulated_logs (line 68) | pub fn drain_accumulated_logs(rx: &mut mpsc::UnboundedReceiver<String>) ...
FILE: crates/coglet/src/transport/http/routes.rs
type HealthCheckResponse (line 23) | pub struct HealthCheckResponse {
method from_snapshot (line 33) | pub fn from_snapshot(snapshot: HealthSnapshot, user_healthcheck_error:...
type PredictionRequest (line 53) | pub struct PredictionRequest {
function default_empty_input (line 68) | fn default_empty_input() -> serde_json::Value {
function deserialize_input (line 72) | fn deserialize_input<'de, D>(deserializer: D) -> Result<serde_json::Valu...
function default_webhook_events_filter (line 84) | fn default_webhook_events_filter() -> Vec<WebhookEventType> {
function generate_prediction_id (line 93) | fn generate_prediction_id() -> String {
function root (line 109) | async fn root(State(service): State<Arc<PredictionService>>) -> Json<ser...
function health_check (line 139) | async fn health_check(State(service): State<Arc<PredictionService>>) -> ...
function write_readiness_file (line 182) | fn write_readiness_file() {
function should_respond_async (line 204) | fn should_respond_async(headers: &HeaderMap) -> bool {
function extract_trace_context (line 212) | fn extract_trace_context(headers: &HeaderMap) -> TraceContext {
function create_prediction (line 225) | async fn create_prediction(
function create_prediction_idempotent (line 254) | async fn create_prediction_idempotent(
function build_webhook_sender (line 304) | fn build_webhook_sender(
function create_prediction_with_id (line 329) | async fn create_prediction_with_id(
function cancel_prediction (line 528) | async fn cancel_prediction(
function shutdown (line 541) | async fn shutdown(State(service): State<Arc<PredictionService>>) -> impl...
function openapi_schema (line 547) | async fn openapi_schema(State(service): State<Arc<PredictionService>>) -...
function create_training (line 562) | async fn create_training(
function create_training_idempotent (line 591) | async fn create_training_idempotent(
function cancel_training (line 641) | async fn cancel_training(
constant MAX_HTTP_BODY_SIZE (line 653) | const MAX_HTTP_BODY_SIZE: usize = 100 * 1024 * 1024;
function routes (line 655) | pub fn routes(service: Arc<PredictionService>) -> Router {
function response_json (line 679) | async fn response_json(response: axum::response::Response) -> serde_json...
function health_check_returns_status_and_version (line 686) | async fn health_check_returns_status_and_version() {
function health_check_unknown_when_no_predictor (line 703) | async fn health_check_unknown_when_no_predictor() {
function predictions_returns_503_when_not_ready (line 717) | async fn predictions_returns_503_when_not_ready() {
function openapi_returns_503_when_schema_not_available (line 744) | async fn openapi_returns_503_when_schema_not_available() {
function openapi_returns_schema_when_available (line 760) | async fn openapi_returns_schema_when_available() {
type MockOrchestrator (line 792) | struct MockOrchestrator {
method new (line 798) | fn new() -> Self {
method never_complete (line 806) | fn never_complete() -> Self {
method register_prediction (line 816) | async fn register_prediction(
method cancel_by_prediction_id (line 829) | async fn cancel_by_prediction_id(
method healthcheck (line 836) | async fn healthcheck(
method shutdown (line 843) | async fn shutdown(&self) -> Result<(), crate::orchestrator::Orchestrator...
function create_test_pool (line 848) | async fn create_test_pool(num_slots: usize) -> Arc<PermitPool> {
function create_ready_service (line 872) | async fn create_ready_service() -> Arc<PredictionService> {
function health_check_ready_with_orchestrator (line 882) | async fn health_check_ready_with_orchestrator() {
function prediction_sync_success (line 897) | async fn prediction_sync_success() {
function prediction_async_returns_accepted (line 919) | async fn prediction_async_returns_accepted() {
function prediction_with_custom_id (line 940) | async fn prediction_with_custom_id() {
function prediction_idempotent_put (line 961) | async fn prediction_idempotent_put() {
function prediction_idempotent_id_mismatch (line 982) | async fn prediction_idempotent_id_mismatch() {
function prediction_at_capacity (line 1007) | async fn prediction_at_capacity() {
function health_check_busy_when_at_capacity (line 1049) | async fn health_check_busy_when_at_capacity() {
function training_routes_work (line 1084) | async fn training_routes_work() {
function training_idempotent_put (line 1104) | async fn training_idempotent_put() {
function training_idempotent_id_mismatch (line 1125) | async fn training_idempotent_id_mismatch() {
function shutdown_triggers_service_shutdown (line 1150) | async fn shutdown_triggers_service_shutdown() {
function root_returns_discovery_document (line 1168) | async fn root_returns_discovery_document() {
function root_includes_training_urls_when_schema_has_training (line 1206) | async fn root_includes_training_urls_when_schema_has_training() {
function root_cog_version_prefers_python_sdk (line 1247) | async fn root_cog_version_prefers_python_sdk() {
FILE: crates/coglet/src/transport/http/server.rs
type ServerConfig (line 15) | pub struct ServerConfig {
method default (line 24) | fn default() -> Self {
function serve (line 34) | pub async fn serve(config: ServerConfig, service: Arc<PredictionService>...
function shutdown_signal (line 66) | async fn shutdown_signal(await_explicit_shutdown: bool, mut shutdown_rx:...
function server_config_default (line 118) | fn server_config_default() {
FILE: crates/coglet/src/version.rs
constant COGLET_VERSION (line 4) | pub const COGLET_VERSION: &str = env!("CARGO_PKG_VERSION");
type VersionInfo (line 8) | pub struct VersionInfo {
method new (line 39) | pub fn new() -> Self {
method with_git_sha (line 44) | pub fn with_git_sha(mut self, sha: String) -> Self {
method with_build_time (line 50) | pub fn with_build_time(mut self, time: String) -> Self {
method with_python_sdk (line 56) | pub fn with_python_sdk(mut self, version: String) -> Self {
method with_python (line 62) | pub fn with_python(mut self, version: String) -> Self {
method default (line 26) | fn default() -> Self {
function version_info_has_coglet_version (line 73) | fn version_info_has_coglet_version() {
function version_info_builder_pattern (line 81) | fn version_info_builder_pattern() {
function version_info_serializes_minimal (line 95) | fn version_info_serializes_minimal() {
function version_info_serializes_full (line 108) | fn version_info_serializes_full() {
FILE: crates/coglet/src/webhook.rs
type WebhookEventType (line 28) | pub enum WebhookEventType {
method is_terminal (line 37) | pub fn is_terminal(&self) -> bool {
method all (line 41) | pub fn all() -> HashSet<WebhookEventType> {
type WebhookSenderError (line 50) | pub enum WebhookSenderError {
type WebhookConfig (line 56) | pub struct WebhookConfig {
method default (line 65) | fn default() -> Self {
type TraceContext (line 84) | pub struct TraceContext {
type WebhookSender (line 89) | pub struct WebhookSender {
method new (line 98) | pub fn new(url: String, config: WebhookConfig) -> Result<Self, Webhook...
method with_trace_context (line 102) | pub fn with_trace_context(
method url (line 135) | pub fn url(&self) -> &str {
method should_send (line 139) | fn should_send(&self, event: WebhookEventType) -> bool {
method update_last_sent (line 162) | fn update_last_sent(&self) {
method build_request (line 168) | fn build_request(&self, payload: &serde_json::Value) -> reqwest::Reque...
method send (line 182) | pub fn send(&self, event: WebhookEventType, payload: &serde_json::Valu...
method send_terminal (line 198) | pub async fn send_terminal(&self, event: WebhookEventType, payload: &s...
method send_terminal_sync (line 268) | pub fn send_terminal_sync(&self, payload: &serde_json::Value) {
function config_defaults (line 381) | fn config_defaults() {
function event_is_terminal (line 390) | fn event_is_terminal() {
function test_config (line 397) | fn test_config() -> WebhookConfig {
function send_terminal_posts_json (line 407) | async fn send_terminal_posts_json() {
function send_terminal_retries_on_500 (line 429) | async fn send_terminal_retries_on_500() {
function send_terminal_no_retry_on_400 (line 458) | async fn send_terminal_no_retry_on_400() {
function send_terminal_respects_filter (line 480) | async fn send_terminal_respects_filter() {
function send_non_terminal_fires_and_forgets (line 506) | async fn send_non_terminal_fires_and_forgets() {
function send_non_terminal_logs_throttled (line 528) | async fn send_non_terminal_logs_throttled() {
function send_output_not_throttled (line 559) | async fn send_output_not_throttled() {
function send_terminal_sync_posts_json (line 590) | async fn send_terminal_sync_posts_json() {
function send_terminal_sync_retries_on_500 (line 607) | async fn send_terminal_sync_retries_on_500() {
FILE: crates/coglet/src/worker.rs
function increment_dropped_log_count (line 35) | pub fn increment_dropped_log_count() {
function report_dropped_logs (line 41) | fn report_dropped_logs(tx: &mpsc::Sender<ControlResponse>, interval_mill...
type FatalContext (line 55) | struct FatalContext {
function init_fatal_context (line 61) | fn init_fatal_context(tx: mpsc::Sender<ControlResponse>) {
function install_panic_hook (line 71) | fn install_panic_hook() {
function init_worker_tracing (line 103) | fn init_worker_tracing(tx: mpsc::Sender<ControlResponse>) {
type SlotWriter (line 142) | type SlotWriter =
type SlotSender (line 150) | pub struct SlotSender {
method new (line 157) | pub fn new(tx: mpsc::UnboundedSender<SlotResponse>, output_dir: PathBu...
method next_output_path (line 166) | fn next_output_path(&self, extension: &str) -> PathBuf {
method send_log (line 171) | pub fn send_log(&self, source: LogSource, data: &str) -> io::Result<()> {
method write_file_output (line 190) | pub fn write_file_output(
method send_file_output (line 205) | pub fn send_file_output(&self, path: PathBuf, mime_type: Option<String...
method send_metric (line 221) | pub fn send_metric(
method send_output (line 234) | pub fn send_output(&self, output: serde_json::Value) -> io::Result<()> {
function build_output_message (line 243) | fn build_output_message(
type SetupError (line 272) | pub enum SetupError {
method load (line 287) | pub fn load(message: impl Into<String>) -> Self {
method setup (line 293) | pub fn setup(message: impl Into<String>) -> Self {
method internal (line 299) | pub fn internal(message: impl Into<String>) -> Self {
type PredictHandler (line 308) | pub trait PredictHandler: Send + Sync + 'static {
method setup (line 310) | async fn setup(&self) -> Result<(), SetupError>;
method predict (line 313) | async fn predict(
method cancel (line 323) | fn cancel(&self, slot: SlotId);
method healthcheck (line 326) | async fn healthcheck(&self) -> HealthcheckResult {
constant BUNDLED_SCHEMA_PATH (line 333) | const BUNDLED_SCHEMA_PATH: &str = ".cog/openapi_schema.json";
function load_bundled_schema (line 340) | fn load_bundled_schema() -> Option<serde_json::Value> {
type PredictionOutcome (line 370) | pub enum PredictionOutcome {
type PredictResult (line 385) | pub struct PredictResult {
method success (line 390) | pub fn success(output: serde_json::Value, predict_time: f64, is_stream...
method failed (line 400) | pub fn failed(error: String, predict_time: f64) -> Self {
method cancelled (line 409) | pub fn cancelled(predict_time: f64) -> Self {
type SetupLogHook (line 420) | pub type SetupLogHook =
type WorkerConfig (line 423) | pub struct WorkerConfig {
method default (line 430) | fn default() -> Self {
type SlotCompletion (line 438) | struct SlotCompletion {
method idle (line 443) | fn idle(slot: SlotId) -> Self {
method poisoned (line 449) | fn poisoned(slot: SlotId, error: impl Into<String>) -> Self {
function run_worker (line 460) | pub async fn run_worker<H: PredictHandler>(
function slot_reader_task (line 786) | async fn slot_reader_task(
function run_prediction (line 810) | async fn run_prediction<H: PredictHandler>(
function predict_result_success (line 919) | fn predict_result_success() {
function predict_result_success_stream (line 925) | fn predict_result_success_stream() {
function predict_result_failed (line 937) | fn predict_result_failed() {
function predict_result_cancelled (line 946) | fn predict_result_cancelled() {
function worker_config_default (line 952) | fn worker_config_default() {
FILE: crates/coglet/src/worker_tracing_layer.rs
type WorkerTracingLayer (line 15) | pub struct WorkerTracingLayer {
method new (line 21) | pub fn new(tx: mpsc::Sender<ControlResponse>) -> Self {
method level_to_string (line 33) | fn level_to_string(level: &Level) -> &'static str {
method on_event (line 48) | fn on_event(&self, event: &tracing::Event<'_>, _ctx: Context<'_, S>) {
type MessageVisitor (line 93) | struct MessageVisitor {
method record_debug (line 98) | fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn ...
method record_str (line 107) | fn record_str(&mut self, field: &tracing::field::Field, value: &str) {
FILE: integration-tests/concurrent/concurrent_test.go
function TestConcurrentPredictions (line 36) | func TestConcurrentPredictions(t *testing.T) {
type predictionResult (line 142) | type predictionResult struct
function makePrediction (line 148) | func makePrediction(serverURL string, idx int) predictionResult {
function waitForServerReady (line 175) | func waitForServerReady(serverURL string, timeout time.Duration) bool {
function waitForServerStatus (line 212) | func waitForServerStatus(serverURL string, targetStatus string, timeout ...
function allocatePort (line 247) | func allocatePort() (int, error) {
constant cogYAML (line 258) | cogYAML = `build:
constant predictPy (line 265) | predictPy = `import asyncio
function TestConcurrentAboveLimit (line 277) | func TestConcurrentAboveLimit(t *testing.T) {
constant aboveLimitCogYAML (line 373) | aboveLimitCogYAML = `build:
function TestSIGTERMDuringSetup (line 381) | func TestSIGTERMDuringSetup(t *testing.T) {
FILE: integration-tests/harness/cmd_pty.go
type PtyRunCommand (line 17) | type PtyRunCommand struct
method Name (line 21) | func (c *PtyRunCommand) Name() string { return "pty-run" }
method Run (line 37) | func (c *PtyRunCommand) Run(ts *testscript.TestScript, neg bool, args ...
FILE: integration-tests/harness/command.go
type Command (line 6) | type Command interface
type CommandFunc (line 17) | type CommandFunc struct
method Name (line 22) | func (c CommandFunc) Name() string { return c.name }
method Run (line 23) | func (c CommandFunc) Run(ts *testscript.TestScript, neg bool, args []s...
function NewCommand (line 28) | func NewCommand(name string, fn func(ts *testscript.TestScript, neg bool...
FILE: integration-tests/harness/harness.go
type serverInfo (line 43) | type serverInfo struct
type registryInfo (line 49) | type registryInfo struct
type mockUploadRecord (line 56) | type mockUploadRecord struct
type mockUploadServer (line 64) | type mockUploadServer struct
type webhookResult (line 72) | type webhookResult struct
type webhookServer (line 83) | type webhookServer struct
type Harness (line 91) | type Harness struct
method Commands (line 240) | func (h *Harness) Commands() map[string]func(ts *testscript.TestScript...
method cmdCog (line 278) | func (h *Harness) cmdCog(ts *testscript.TestScript, neg bool, args []s...
method Setup (line 307) | func (h *Harness) Setup(env *testscript.Env) error {
method cmdCogServe (line 395) | func (h *Harness) cmdCogServe(ts *testscript.TestScript, neg bool, arg...
method cmdCurl (line 483) | func (h *Harness) cmdCurl(ts *testscript.TestScript, neg bool, args []...
method StopServer (line 616) | func (h *Harness) StopServer(ts *testscript.TestScript) {
method stopServerByWorkDir (line 622) | func (h *Harness) stopServerByWorkDir(workDir string) {
method cmdWaitFor (line 729) | func (h *Harness) cmdWaitFor(ts *testscript.TestScript, neg bool, args...
method cmdDockerRun (line 819) | func (h *Harness) cmdDockerRun(ts *testscript.TestScript, neg bool, ar...
method cmdRegistryStart (line 866) | func (h *Harness) cmdRegistryStart(ts *testscript.TestScript, neg bool...
method stopRegistryByWorkDir (line 905) | func (h *Harness) stopRegistryByWorkDir(workDir string) {
method cmdRegistrySeed (line 930) | func (h *Harness) cmdRegistrySeed(ts *testscript.TestScript, neg bool,...
method cmdRegistryInspect (line 978) | func (h *Harness) cmdRegistryInspect(ts *testscript.TestScript, neg bo...
method cmdDockerPush (line 1013) | func (h *Harness) cmdDockerPush(ts *testscript.TestScript, neg bool, a...
method cmdMockWeights (line 1093) | func (h *Harness) cmdMockWeights(ts *testscript.TestScript, neg bool, ...
method cmdUploadServerStart (line 1244) | func (h *Harness) cmdUploadServerStart(ts *testscript.TestScript, neg ...
method cmdUploadServerCount (line 1307) | func (h *Harness) cmdUploadServerCount(ts *testscript.TestScript, neg ...
method stopUploadServerByWorkDir (line 1343) | func (h *Harness) stopUploadServerByWorkDir(workDir string) {
method cmdWebhookServerStart (line 1367) | func (h *Harness) cmdWebhookServerStart(ts *testscript.TestScript, neg...
method cmdWebhookServerWait (line 1465) | func (h *Harness) cmdWebhookServerWait(ts *testscript.TestScript, neg ...
method stopWebhookServerByWorkDir (line 1502) | func (h *Harness) stopWebhookServerByWorkDir(workDir string) {
function New (line 112) | func New() (*Harness, error) {
function ResolveCogBinary (line 136) | func ResolveCogBinary() (string, error) {
function buildCogBinary (line 156) | func buildCogBinary() (string, error) {
function findRepoRoot (line 203) | func findRepoRoot() (string, error) {
function runCommand (line 231) | func runCommand(dir string, name string, args ...string) error {
function generateUniqueImageName (line 364) | func generateUniqueImageName() string {
function removeDockerImage (line 375) | func removeDockerImage(imageName string) {
function allocatePort (line 658) | func allocatePort() (int, error) {
type healthCheckResponse (line 668) | type healthCheckResponse struct
function waitForServer (line 675) | func waitForServer(serverURL string, timeout time.Duration) bool {
function isAbsoluteImageRef (line 967) | func isAbsoluteImageRef(ref string) bool {
type mockWeightsLock (line 1066) | type mockWeightsLock struct
type mockWeightFile (line 1074) | type mockWeightFile struct
function parseSize (line 1200) | func parseSize(s string) (int64, error) {
FILE: integration-tests/login/login_test.go
function TestLoginGenericRegistryPTY (line 38) | func TestLoginGenericRegistryPTY(t *testing.T) {
function TestLoginProviderRouting (line 232) | func TestLoginProviderRouting(t *testing.T) {
function TestLoginEnvironmentVariable (line 335) | func TestLoginEnvironmentVariable(t *testing.T) {
function TestLoginHelp (line 434) | func TestLoginHelp(t *testing.T) {
function TestLoginSuggestFor (line 467) | func TestLoginSuggestFor(t *testing.T) {
FILE: integration-tests/suite_test.go
function TestMain (line 24) | func TestMain(m *testing.M) {
function TestIntegration (line 37) | func TestIntegration(t *testing.T) {
function condition (line 68) | func condition(cond string) (bool, error) {
FILE: noxfile.py
function _find_compatible_wheel (line 23) | def _find_compatible_wheel(pattern: str) -> str | None:
function _install_coglet (line 57) | def _install_coglet(session: nox.Session) -> None:
function _install_package (line 68) | def _install_package(session: nox.Session) -> None:
function tests (line 82) | def tests(session: nox.Session) -> None:
function typecheck (line 97) | def typecheck(session: nox.Session) -> None:
function coglet_tests (line 105) | def coglet_tests(session: nox.Session) -> None:
FILE: pkg/cli/baseimage.go
function NewBaseImageRootCommand (line 29) | func NewBaseImageRootCommand() (*cobra.Command, error) {
function newBaseImageGenerateMatrix (line 57) | func newBaseImageGenerateMatrix() *cobra.Command {
function newBaseImageDockerfileCommand (line 128) | func newBaseImageDockerfileCommand() *cobra.Command {
function newBaseImageBuildCommand (line 155) | func newBaseImageBuildCommand() *cobra.Command {
function addBaseImageFlags (line 204) | func addBaseImageFlags(cmd *cobra.Command) {
function baseImageGeneratorFromFlags (line 211) | func baseImageGeneratorFromFlags(ctx context.Context) (*dockerfile.BaseI...
FILE: pkg/cli/build.go
constant useCogBaseImageFlagKey (line 31) | useCogBaseImageFlagKey = "use-cog-base-image"
function newBuildCommand (line 33) | func newBuildCommand() *cobra.Command {
function buildCommand (line 73) | func buildCommand(cmd *cobra.Command, args []string) error {
function addBuildProgressOutputFlag (line 109) | func addBuildProgressOutputFlag(cmd *cobra.Command) {
function addSecretsFlag (line 120) | func addSecretsFlag(cmd *cobra.Command) {
function addNoCacheFlag (line 124) | func addNoCacheFlag(cmd *cobra.Command) {
function addSeparateWeightsFlag (line 128) | func addSeparateWeightsFlag(cmd *cobra.Command) {
function addSchemaFlag (line 132) | func addSchemaFlag(cmd *cobra.Command) {
function addUseCudaBaseImageFlag (line 136) | func addUseCudaBaseImageFlag(cmd *cobra.Command) {
function addDockerfileFlag (line 140) | func addDockerfileFlag(cmd *cobra.Command) {
function addUseCogBaseImageFlag (line 149) | func addUseCogBaseImageFlag(cmd *cobra.Command) {
function addBuildTimestampFlag (line 153) | func addBuildTimestampFlag(cmd *cobra.Command) {
function addStripFlag (line 158) | func addStripFlag(cmd *cobra.Command) {
function addPrecompileFlag (line 164) | func addPrecompileFlag(cmd *cobra.Command) {
function addConfigFlag (line 170) | func addConfigFlag(cmd *cobra.Command) {
function checkMutuallyExclusiveFlags (line 174) | func checkMutuallyExclusiveFlags(cmd *cobra.Command, args []string) error {
function DetermineUseCogBaseImage (line 188) | func DetermineUseCogBaseImage(cmd *cobra.Command) *bool {
function buildOptionsFromFlags (line 199) | func buildOptionsFromFlags(cmd *cobra.Command, imageName string, annotat...
FILE: pkg/cli/debug.go
function newDebugCommand (line 19) | func newDebugCommand() *cobra.Command {
function cmdDockerfile (line 38) | func cmdDockerfile(cmd *cobra.Command, args []string) error {
FILE: pkg/cli/init-templates/base/predict.py
class Predictor (line 7) | class Predictor(BasePredictor):
method setup (line 8) | def setup(self) -> None:
method predict (line 12) | def predict(
FILE: pkg/cli/init.go
function newInitCommand (line 21) | func newInitCommand() *cobra.Command {
function initCommand (line 39) | func initCommand(cmd *cobra.Command, args []string) error {
function processTemplateDirectory (line 77) | func processTemplateDirectory(fs embed.FS, templateDir, subDir, cwd stri...
function processTemplateFile (line 103) | func processTemplateFile(fs embed.FS, templateDir, filename, cwd string)...
function downloadAgentsFile (line 154) | func downloadAgentsFile() ([]byte, error) {
FILE: pkg/cli/init_test.go
function TestInit (line 11) | func TestInit(t *testing.T) {
function TestInitSkipExisting (line 25) | func TestInitSkipExisting(t *testing.T) {
FILE: pkg/cli/inspect.go
type InspectOutput (line 18) | type InspectOutput struct
type InspectIndex (line 27) | type InspectIndex struct
type InspectManifest (line 35) | type InspectManifest struct
type InspectLayer (line 48) | type InspectLayer struct
function newInspectCommand (line 54) | func newInspectCommand() *cobra.Command {
function inspectCommand (line 80) | func inspectCommand(cmd *cobra.Command, args []string, localOnly, remote...
function buildInspectOutput (line 129) | func buildInspectOutput(ctx context.Context, reference string, m *model....
function buildManifestEntry (line 186) | func buildManifestEntry(im model.IndexManifest) InspectManifest {
function fetchLayers (line 213) | func fetchLayers(ctx context.Context, reference, digest string, reg regi...
type rawStep (line 243) | type rawStep struct
function streamRaw (line 249) | func streamRaw(ctx context.Context, reference string, m *model.Model, re...
function printInspectText (line 322) | func printInspectText(out *InspectOutput) {
function printManifestText (line 362) | func printManifestText(m InspectManifest, indent string) {
FILE: pkg/cli/login.go
function newLoginCommand (line 12) | func newLoginCommand() *cobra.Command {
function login (line 33) | func login(cmd *cobra.Command, args []string) error {
FILE: pkg/cli/predict.go
constant StdinPath (line 35) | StdinPath = "-"
function newPredictCommand (line 46) | func newPredictCommand() *cobra.Command {
function readStdin (line 96) | func readStdin() (string, error) {
function parseJSONInput (line 105) | func parseJSONInput(jsonInput string) (map[string]any, error) {
function transformPathsToBase64URLs (line 146) | func transformPathsToBase64URLs(inputs map[string]any) (map[string]any, ...
function cmdPredict (line 179) | func cmdPredict(cmd *cobra.Command, args []string) error {
function isURI (line 316) | func isURI(ref *openapi3.Schema) bool {
function predictJSONInputs (line 320) | func predictJSONInputs(predictor predict.Predictor, jsonInput string, ou...
function predictIndividualInputs (line 350) | func predictIndividualInputs(predictor predict.Predictor, inputFlags []s...
function runPrediction (line 364) | func runPrediction(predictor predict.Predictor, inputs predict.Inputs, o...
function ensureOutputWriteable (line 532) | func ensureOutputWriteable(outputPath string, fallbackPath string) (stri...
function prettyJSONMarshal (line 577) | func prettyJSONMarshal(v any) ([]byte, error) {
function processFileOutputs (line 589) | func processFileOutputs(output any, schema *openapi3.Schema, destination...
function parseInputFlags (line 628) | func parseInputFlags(inputs []string, schema *openapi3.T, isTrain ...boo...
function addSetupTimeoutFlag (line 654) | func addSetupTimeoutFlag(cmd *cobra.Command) {
FILE: pkg/cli/predict_test.go
function TestExtractOutputSchemaFromMalformedSchema (line 10) | func TestExtractOutputSchemaFromMalformedSchema(t *testing.T) {
function safeExtractOutputSchema (line 111) | func safeExtractOutputSchema(schema *openapi3.T, url string) *openapi3.S...
function TestExtractOutputSchemaFromValidSchema (line 137) | func TestExtractOutputSchemaFromValidSchema(t *testing.T) {
FILE: pkg/cli/push.go
function newPushCommand (line 18) | func newPushCommand() *cobra.Command {
function push (line 52) | func push(cmd *cobra.Command, args []string) error {
FILE: pkg/cli/root.go
function NewRootCommand (line 14) | func NewRootCommand() (*cobra.Command, error) {
function setPersistentFlags (line 62) | func setPersistentFlags(cmd *cobra.Command) {
FILE: pkg/cli/run.go
function addGpusFlag (line 22) | func addGpusFlag(cmd *cobra.Command) {
function newRunCommand (line 26) | func newRunCommand() *cobra.Command {
function run (line 69) | func run(cmd *cobra.Command, args []string) error {
FILE: pkg/cli/serve.go
function newServeCommand (line 22) | func newServeCommand() *cobra.Command {
function serveBuildOptions (line 62) | func serveBuildOptions(cmd *cobra.Command) model.BuildOptions {
function cmdServe (line 72) | func cmdServe(cmd *cobra.Command, arg []string) error {
FILE: pkg/cli/train.go
function newTrainCommand (line 26) | func newTrainCommand() *cobra.Command {
function cmdTrain (line 56) | func cmdTrain(cmd *cobra.Command, args []string) error {
FILE: pkg/cli/train_test.go
function TestTrainCommandIsDeprecated (line 9) | func TestTrainCommandIsDeprecated(t *testing.T) {
FILE: pkg/cli/weights.go
function newWeightsCommand (line 19) | func newWeightsCommand() *cobra.Command {
function newWeightsBuildCommand (line 33) | func newWeightsBuildCommand() *cobra.Command {
function weightsBuildCommand (line 47) | func weightsBuildCommand(cmd *cobra.Command, args []string) error {
function formatSize (line 95) | func formatSize(bytes int64) string {
function newWeightsPushCommand (line 114) | func newWeightsPushCommand() *cobra.Command {
function weightsPushCommand (line 131) | func weightsPushCommand(cmd *cobra.Command, args []string) error {
FILE: pkg/cli/weights_inspect.go
type localWeight (line 18) | type localWeight struct
type WeightsInspectOutput (line 25) | type WeightsInspectOutput struct
type WeightInspectEntry (line 31) | type WeightInspectEntry struct
type WeightLocalState (line 39) | type WeightLocalState struct
type WeightRemoteLayer (line 47) | type WeightRemoteLayer struct
type WeightRemoteState (line 54) | type WeightRemoteState struct
function newWeightsInspectCommand (line 64) | func newWeightsInspectCommand() *cobra.Command {
function weightsInspectCommand (line 82) | func weightsInspectCommand(cmd *cobra.Command, args []string, jsonOutput...
function resolveWeightsByTag (line 204) | func resolveWeightsByTag(ctx context.Context, repo string, localWeights ...
function printWeightsInspectText (line 260) | func printWeightsInspectText(out *WeightsInspectOutput) {
function fileExists (line 303) | func fileExists(path string) bool {
FILE: pkg/config/build_options.go
type BuildOptions (line 7) | type BuildOptions struct
function DefaultBuildOptions (line 19) | func DefaultBuildOptions() BuildOptions {
FILE: pkg/config/compatibility.go
type TFCompatibility (line 26) | type TFCompatibility struct
method UnmarshalJSON (line 35) | func (compat *TFCompatibility) UnmarshalJSON(data []byte) error {
type TorchCompatibility (line 55) | type TorchCompatibility struct
method TorchVersion (line 65) | func (c *TorchCompatibility) TorchVersion() string {
method TorchvisionVersion (line 69) | func (c *TorchCompatibility) TorchvisionVersion() string {
type CUDABaseImage (line 73) | type CUDABaseImage struct
method ImageTag (line 81) | func (i *CUDABaseImage) ImageTag() string {
function init (line 97) | func init() {
function cudaVersionFromTorchPlusVersion (line 122) | func cudaVersionFromTorchPlusVersion(ver string) (string, string) {
function cudasFromTorch (line 154) | func cudasFromTorch(ver string) ([]string, error) {
function cudaFromTF (line 186) | func cudaFromTF(ver string) (cuda string, cuDNN string, err error) {
function compatibleCuDNNsForCUDA (line 195) | func compatibleCuDNNsForCUDA(cuda string) []string {
function defaultCUDA (line 205) | func defaultCUDA() string {
function latestCUDAFrom (line 210) | func latestCUDAFrom(cudas []string) string {
function latestCuDNNForCUDA (line 229) | func latestCuDNNForCUDA(cuda string) (string, error) {
function versionGreater (line 246) | func versionGreater(a string, b string) (bool, error) {
function cudaBaseImageFor (line 259) | func cudaBaseImageFor(cuda string, cuDNN string) (string, error) {
function tfGPUPackage (line 280) | func tfGPUPackage(ver string, cuda string) (name string, cpuVersion stri...
function torchCPUPackage (line 291) | func torchCPUPackage(ver, goos, goarch string) (name, cpuVersion, findLi...
function torchGPUPackage (line 302) | func torchGPUPackage(ver string, cuda string) (name, cpuVersion, findLin...
function torchvisionCPUPackage (line 339) | func torchvisionCPUPackage(ver, goos, goarch string) (name, cpuVersion, ...
function torchvisionGPUPackage (line 349) | func torchvisionGPUPackage(ver, cuda string) (name, cpuVersion, findLink...
function torchStripCPUSuffixForM1 (line 389) | func torchStripCPUSuffixForM1(version string, goos string, goarch string...
FILE: pkg/config/compatibility_test.go
function TestLatestCuDNNForCUDA (line 9) | func TestLatestCuDNNForCUDA(t *testing.T) {
function TestCudasFromTorchWithCUVersionModifier (line 15) | func TestCudasFromTorchWithCUVersionModifier(t *testing.T) {
FILE: pkg/config/config.go
constant MinimumMajorPythonVersion (line 31) | MinimumMajorPythonVersion int = 3
constant MinimumMinorPythonVersion (line 32) | MinimumMinorPythonVersion int = 10
constant MinimumMinorPythonVersionForConcurrency (line 33) | MinimumMinorPythonVersionForConcurrency int = 11
constant MinimumMajorCudaVersion (line 34) | MinimumMajorCudaVersion int = 11
constant DefaultPythonVersion (line 35) | DefaultPythonVersion string = "3.13"
type RunItem (line 38) | type RunItem struct
method UnmarshalYAML (line 97) | func (r *RunItem) UnmarshalYAML(unmarshal func(any) error) error {
method UnmarshalJSON (line 135) | func (r *RunItem) UnmarshalJSON(data []byte) error {
type Build (line 47) | type Build struct
type Concurrency (line 65) | type Concurrency struct
type WeightSource (line 70) | type WeightSource struct
type Config (line 76) | type Config struct
method CUDABaseImageTag (line 171) | func (c *Config) CUDABaseImageTag() (string, error) {
method TorchVersion (line 175) | func (c *Config) TorchVersion() (string, bool) {
method TorchvisionVersion (line 179) | func (c *Config) TorchvisionVersion() (string, bool) {
method TorchaudioVersion (line 183) | func (c *Config) TorchaudioVersion() (string, bool) {
method TensorFlowVersion (line 187) | func (c *Config) TensorFlowVersion() (string, bool) {
method cudasFromTorch (line 191) | func (c *Config) cudasFromTorch() (torchVersion string, torchCUDAs []s...
method cudaFromTF (line 202) | func (c *Config) cudaFromTF() (tfVersion string, tfCUDA string, tfCuDN...
method pythonPackageVersion (line 213) | func (c *Config) pythonPackageVersion(name string) (version string, ok...
method Complete (line 248) | func (c *Config) Complete(projectDir string) error {
method PythonRequirementsForArch (line 286) | func (c *Config) PythonRequirementsForArch(goos string, goarch string,...
method pythonPackageForArch (line 352) | func (c *Config) pythonPackageForArch(pkg, goos, goarch string) (actua...
method validateAndCompleteCUDA (line 428) | func (c *Config) validateAndCompleteCUDA() error {
method RequirementsFile (line 525) | func (c *Config) RequirementsFile(projectDir string) string {
method ParsedEnvironment (line 529) | func (c *Config) ParsedEnvironment() map[string]string {
method loadEnvironment (line 533) | func (c *Config) loadEnvironment() error {
function defaultConfig (line 88) | func defaultConfig() *Config {
function splitPythonVersion (line 227) | func splitPythonVersion(version string) (major int, minor int, err error) {
function validateCudaVersion (line 411) | func validateCudaVersion(cudaVersion string) error {
FILE: pkg/config/config_file.go
type configFile (line 14) | type configFile struct
type buildFile (line 25) | type buildFile struct
method GetGPU (line 162) | func (b *buildFile) GetGPU() bool {
type runItemFile (line 41) | type runItemFile struct
method UnmarshalYAML (line 67) | func (r *runItemFile) UnmarshalYAML(unmarshal func(any) error) error {
method UnmarshalJSON (line 115) | func (r *runItemFile) UnmarshalJSON(data []byte) error {
type mountFile (line 47) | type mountFile struct
type weightFile (line 54) | type weightFile struct
type concurrencyFile (line 61) | type concurrencyFile struct
FILE: pkg/config/config_test.go
function TestValidateCudaVersion (line 15) | func TestValidateCudaVersion(t *testing.T) {
function assertMinorVersion (line 65) | func assertMinorVersion(t *testing.T, expected, actual string) {
function TestPythonPackagesAndRequirementsCantBeUsedTogether (line 83) | func TestPythonPackagesAndRequirementsCantBeUsedTogether(t *testing.T) {
function TestPythonRequirementsResolvesPythonPackagesAndCudaVersions (line 98) | func TestPythonRequirementsResolvesPythonPackagesAndCudaVersions(t *test...
function TestPythonRequirementsResolvesPythonPackagesAndCudaVersionsWithExtraIndexURL (line 128) | func TestPythonRequirementsResolvesPythonPackagesAndCudaVersionsWithExtr...
function TestPythonRequirementsWorksWithLinesCogCannotParse (line 158) | func TestPythonRequirementsWorksWithLinesCogCannotParse(t *testing.T) {
function TestValidateAndCompleteCUDAForAllTF (line 191) | func TestValidateAndCompleteCUDAForAllTF(t *testing.T) {
function TestValidateAndCompleteCUDAForAllTorch (line 210) | func TestValidateAndCompleteCUDAForAllTorch(t *testing.T) {
function TestValidateAndCompleteCUDAForSelectedTorch (line 234) | func TestValidateAndCompleteCUDAForSelectedTorch(t *testing.T) {
function TestUnsupportedTorch (line 260) | func TestUnsupportedTorch(t *testing.T) {
function TestUnsupportedTensorflow (line 296) | func TestUnsupportedTensorflow(t *testing.T) {
function TestPythonPackagesForArchTorchGPU (line 333) | func TestPythonPackagesForArchTorchGPU(t *testing.T) {
function TestPythonPackagesForArchTorchCPU (line 362) | func TestPythonPackagesForArchTorchCPU(t *testing.T) {
function TestPythonPackagesForArchTensorflowGPU (line 389) | func TestPythonPackagesForArchTensorflowGPU(t *testing.T) {
function TestPythonPackagesBothTorchAndTensorflow (line 419) | func TestPythonPackagesBothTorchAndTensorflow(t *testing.T) {
function TestCUDABaseImageTag (line 444) | func TestCUDABaseImageTag(t *testing.T) {
function TestBuildRunItemStringYAML (line 463) | func TestBuildRunItemStringYAML(t *testing.T) {
function TestBuildRunItemStringJSON (line 483) | func TestBuildRunItemStringJSON(t *testing.T) {
function TestBuildRunItemDictYAML (line 505) | func TestBuildRunItemDictYAML(t *testing.T) {
function TestBuildRunItemDictJSON (line 533) | func TestBuildRunItemDictJSON(t *testing.T) {
function TestTorchWithExistingExtraIndexURL (line 568) | func TestTorchWithExistingExtraIndexURL(t *testing.T) {
function TestBlankBuild (line 590) | func TestBlankBuild(t *testing.T) {
function TestPythonRequirementsForArchWithAddedPackage (line 610) | func TestPythonRequirementsForArchWithAddedPackage(t *testing.T) {
function TestParseTests (line 634) | func TestParseTests(t *testing.T) {
function TestConfigMarshal (line 649) | func TestConfigMarshal(t *testing.T) {
function TestAbsolutePathInPythonRequirements (line 660) | func TestAbsolutePathInPythonRequirements(t *testing.T) {
function TestWeightsWithNameYAML (line 679) | func TestWeightsWithNameYAML(t *testing.T) {
function TestWeightsWithoutNameYAML (line 706) | func TestWeightsWithoutNameYAML(t *testing.T) {
function TestWeightsWithNameJSON (line 725) | func TestWeightsWithNameJSON(t *testing.T) {
function TestSDKVersionConfig (line 759) | func TestSDKVersionConfig(t *testing.T) {
function TestSDKVersionConfigEmpty (line 771) | func TestSDKVersionConfigEmpty(t *testing.T) {
function TestSDKVersionConfigPreRelease (line 782) | func TestSDKVersionConfigPreRelease(t *testing.T) {
function TestSDKVersionConfigBelowMinimumExplodesInGenerator (line 794) | func TestSDKVersionConfigBelowMinimumExplodesInGenerator(t *testing.T) {
FILE: pkg/config/env.go
function validateEnvName (line 40) | func validateEnvName(name string) error {
function parseAndValidateEnvironment (line 60) | func parseAndValidateEnvironment(input []string) (map[string]string, err...
FILE: pkg/config/env_variables_test.go
function TestEnvironmentConfig (line 11) | func TestEnvironmentConfig(t *testing.T) {
FILE: pkg/config/errors.go
type ConfigError (line 10) | type ConfigError interface
type ParseError (line 16) | type ParseError struct
method Error (line 21) | func (e *ParseError) Error() string {
method Unwrap (line 25) | func (e *ParseError) Unwrap() error {
method ConfigError (line 29) | func (e *ParseError) ConfigError() {}
type SchemaError (line 33) | type SchemaError struct
method Error (line 38) | func (e *SchemaError) Error() string {
method ConfigError (line 42) | func (e *SchemaError) ConfigError() {}
type ValidationError (line 46) | type ValidationError struct
method Error (line 52) | func (e *ValidationError) Error() string {
method ConfigError (line 59) | func (e *ValidationError) ConfigError() {}
type DeprecationWarning (line 63) | type DeprecationWarning struct
method Error (line 69) | func (w *DeprecationWarning) Error() string {
method ConfigError (line 76) | func (w *DeprecationWarning) ConfigError() {}
type CompatibilityError (line 79) | type CompatibilityError struct
method Error (line 87) | func (e *CompatibilityError) Error() string {
method ConfigError (line 92) | func (e *CompatibilityError) ConfigError() {}
type ValidationResult (line 95) | type ValidationResult struct
method HasErrors (line 101) | func (r *ValidationResult) HasErrors() bool {
method HasWarnings (line 106) | func (r *ValidationResult) HasWarnings() bool {
method Err (line 111) | func (r *ValidationResult) Err() error {
method AddError (line 119) | func (r *ValidationResult) AddError(err error) {
method AddWarning (line 124) | func (r *ValidationResult) AddWarning(w DeprecationWarning) {
function NewValidationResult (line 129) | func NewValidationResult() *ValidationResult {
FILE: pkg/config/image_name.go
function DockerImageName (line 10) | func DockerImageName(projectDir string) string {
FILE: pkg/config/image_name_test.go
function TestDockerImageName (line 9) | func TestDockerImageName(t *testing.T) {
FILE: pkg/config/load.go
constant maxSearchDepth (line 13) | maxSearchDepth = 100
type LoadResult (line 16) | type LoadResult struct
function Load (line 26) | func Load(r io.Reader, projectDir string) (*LoadResult, error) {
function GetProjectDir (line 64) | func GetProjectDir(configFilename string) (string, error) {
function findConfigPathInDirectory (line 77) | func findConfigPathInDirectory(dir string, configFilename string) (confi...
function findProjectRootDir (line 91) | func findProjectRootDir(startDir string, configFilename string) (string,...
FILE: pkg/config/load_test.go
constant testConfig (line 11) | testConfig = `
function TestFindProjectRootDirShouldFindParentDir (line 21) | func TestFindProjectRootDirShouldFindParentDir(t *testing.T) {
function TestFindProjectRootDirShouldReturnErrIfNoConfig (line 36) | func TestFindProjectRootDirShouldReturnErrIfNoConfig(t *testing.T) {
FILE: pkg/config/parse.go
function parse (line 17) | func parse(r io.Reader) (*configFile, error) {
function parseFile (line 29) | func parseFile(filename string) (*configFile, error) {
function parseBytes (line 62) | func parseBytes(contents []byte) (*configFile, error) {
function FromYAML (line 86) | func FromYAML(contents []byte) (*Config, error) {
function configFileToConfig (line 99) | func configFileToConfig(cfg *configFile) (*Config, error) {
FILE: pkg/config/validate.go
type ValidateOption (line 23) | type ValidateOption
type validateOptions (line 25) | type validateOptions struct
function WithProjectDir (line 32) | func WithProjectDir(dir string) ValidateOption {
function WithRequirementsFS (line 39) | func WithRequirementsFS(fsys fs.FS) ValidateOption {
function WithStrictDeprecations (line 46) | func WithStrictDeprecations() ValidateOption {
function ValidateConfigFile (line 55) | func ValidateConfigFile(cfg *configFile, opts ...ValidateOption) *Valida...
function validateSchema (line 90) | func validateSchema(cfg *configFile) error {
function validatePredict (line 109) | func validatePredict(cfg *configFile, result *ValidationResult) {
function validateTrain (line 125) | func validateTrain(cfg *configFile, result *ValidationResult) {
function validateBuild (line 141) | func validateBuild(cfg *configFile, opts *validateOptions, result *Valid...
function validatePythonVersion (line 189) | func validatePythonVersion(version string) error {
function validateCUDAVersion (line 230) | func validateCUDAVersion(cudaVersion string) error {
function validateRequirementsFile (line 261) | func validateRequirementsFile(reqPath string, opts *validateOptions) err...
function validateGPUConfig (line 292) | func validateGPUConfig(cfg *configFile, opts *validateOptions, result *V...
function loadRequirementsForValidation (line 327) | func loadRequirementsForValidation(reqPath string, opts *validateOptions...
function parseRequirementsContent (line 349) | func parseRequirementsContent(content string) []string {
function validateFrameworkCompatibility (line 363) | func validateFrameworkCompatibility(cfg *configFile, reqs []string, resu...
function findPackageVersion (line 396) | func findPackageVersion(reqs []string, name string) string {
function validateEnvironment (line 410) | func validateEnvironment(cfg *configFile, result *ValidationResult) {
function validateConcurrency (line 425) | func validateConcurrency(cfg *configFile, result *ValidationResult) {
function checkDeprecatedFields (line 458) | func checkDeprecatedFields(cfg *configFile, result *ValidationResult) {
function getMostSpecificSchemaError (line 481) | func getMostSpecificSchemaError(errors []gojsonschema.ResultError) *Sche...
function getSchemaErrorDescription (line 513) | func getSchemaErrorDescription(err gojsonschema.ResultError, allErrors [...
function humanReadableSchemaType (line 528) | func humanReadableSchemaType(definition string) string {
function schemaErrorSpecificity (line 549) | func schemaErrorSpecificity(err gojsonschema.ResultError) int {
FILE: pkg/config/validate_test.go
function TestValidateConfigFile (line 9) | func TestValidateConfigFile(t *testing.T) {
function TestValidateConfigFileSuccess (line 25) | func TestValidateConfigFileSuccess(t *testing.T) {
function TestValidateConfigFilePythonVersionNumerical (line 44) | func TestValidateConfigFilePythonVersionNumerical(t *testing.T) {
function TestValidateConfigFileNullListsAllowed (line 63) | func TestValidateConfigFileNullListsAllowed(t *testing.T) {
function TestValidateConfigFilePredictFormat (line 78) | func TestValidateConfigFilePredictFormat(t *testing.T) {
function TestValidateConfigFileConcurrencyType (line 97) | func TestValidateConfigFileConcurrencyType(t *testing.T) {
function TestValidateConfigFileDeprecatedPythonPackages (line 117) | func TestValidateConfigFileDeprecatedPythonPackages(t *testing.T) {
function TestValidateConfigFileDeprecatedPreInstall (line 133) | func TestValidateConfigFileDeprecatedPreInstall(t *testing.T) {
function TestValidateConfigFileMissingPythonVersion (line 149) | func TestValidateConfigFileMissingPythonVersion(t *testing.T) {
function TestValidateConfigFileMissingPythonVersionEmptyBuild (line 161) | func TestValidateConfigFileMissingPythonVersionEmptyBuild(t *testing.T) {
function TestValidateConfigFileNilBuildSkipsPythonVersionCheck (line 171) | func TestValidateConfigFileNilBuildSkipsPythonVersionCheck(t *testing.T) {
function ptr (line 180) | func ptr[T any](v T) *T { return &v }
FILE: pkg/config/version.go
type ArgumentType (line 4) | type ArgumentType
constant ArgumentTypeString (line 7) | ArgumentTypeString ArgumentType = "str"
constant ArgumentTypeInt (line 8) | ArgumentTypeInt ArgumentType = "int"
constant ArgumentTypeFloat (line 9) | ArgumentTypeFloat ArgumentType = "float"
constant ArgumentTypeBool (line 10) | ArgumentTypeBool ArgumentType = "bool"
constant ArgumentTypePath (line 11) | ArgumentTypePath ArgumentType = "Path"
type RunArgument (line 15) | type RunArgument struct
FILE: pkg/docker/build_secrets.go
function ParseSecretsFromHost (line 14) | func ParseSecretsFromHost(workingDir string, secrets []string) (secrets....
function parseSecretFromHost (line 28) | func parseSecretFromHost(workingDir, secret string) (*secretsprovider.So...
FILE: pkg/docker/buildkit.go
function prepareDockerfileDir (line 25) | func prepareDockerfileDir(buildDir string, dockerfileContents string) (s...
function solveOptFromImageOptions (line 34) | func solveOptFromImageOptions(buildDir string, opts command.ImageBuildOp...
function newDisplay (line 155) | func newDisplay(statusCh chan *buildkitclient.SolveStatus, displayMode s...
function newBuildkitAuthProvider (line 177) | func newBuildkitAuthProvider(registryHosts ...string) session.Attachable {
type buildkitAuthProvider (line 187) | type buildkitAuthProvider struct
method Register (line 191) | func (ap *buildkitAuthProvider) Register(server *grpc.Server) {
method Credentials (line 195) | func (ap *buildkitAuthProvider) Credentials(ctx context.Context, req *...
method FetchToken (line 209) | func (ap *buildkitAuthProvider) FetchToken(ctx context.Context, req *a...
method GetTokenAuthority (line 213) | func (ap *buildkitAuthProvider) GetTokenAuthority(ctx context.Context,...
method VerifyTokenAuthority (line 217) | func (ap *buildkitAuthProvider) VerifyTokenAuthority(ctx context.Conte...
FILE: pkg/docker/command/command.go
type Command (line 11) | type Command interface
type ImageBuildOptions (line 35) | type ImageBuildOptions struct
type RunOptions (line 54) | type RunOptions struct
type Port (line 69) | type Port struct
type Volume (line 74) | type Volume struct
FILE: pkg/docker/command/errors.go
type NotFoundError (line 9) | type NotFoundError struct
method Error (line 16) | func (e *NotFoundError) Error() string {
method Is (line 24) | func (e *NotFoundError) Is(target error) bool {
function IsNotFoundError (line 29) | func IsNotFoundError(err error) bool {
FILE: pkg/docker/command/manifest.go
type Config (line 5) | type Config struct
type Manifest (line 10) | type Manifest struct
constant R8CogVersionEnvVarName (line 15) | R8CogVersionEnvVarName = "R8_COG_VERSION"
constant R8TorchVersionEnvVarName (line 16) | R8TorchVersionEnvVarName = "R8_TORCH_VERSION"
constant R8CudaVersionEnvVarName (line 17) | R8CudaVersionEnvVarName = "R8_CUDA_VERSION"
constant R8CudnnVersionEnvVarName (line 18) | R8CudnnVersionEnvVarName = "R8_CUDNN_VERSION"
constant R8PythonVersionEnvVarName (line 19) | R8PythonVersionEnvVarName = "R8_PYTHON_VERSION"
FILE: pkg/docker/command/user_info.go
type UserInfo (line 3) | type UserInfo struct
FILE: pkg/docker/credential_helper_input.go
type CredentialHelperInput (line 3) | type CredentialHelperInput struct
FILE: pkg/docker/credentials.go
function loadUserInformation (line 22) | func loadUserInformation(ctx context.Context, registryHost string) (*com...
function loadAuthFromConfig (line 45) | func loadAuthFromConfig(conf *configfile.ConfigFile, registryHost string...
function loadRegistryAuths (line 49) | func loadRegistryAuths(ctx context.Context, registryHosts ...string) (ma...
function tryLoadAuthForHost (line 78) | func tryLoadAuthForHost(ctx context.Context, conf *configfile.ConfigFile...
function loadAuthFromCredentialsStore (line 106) | func loadAuthFromCredentialsStore(ctx context.Context, credsStore string...
function dockerCredentialBinary (line 149) | func dockerCredentialBinary(credsStore string) string {
FILE: pkg/docker/credentials_test.go
function TestLoadRegistryAuths_Fallback (line 16) | func TestLoadRegistryAuths_Fallback(t *testing.T) {
function TestTryLoadAuthForHost (line 133) | func TestTryLoadAuthForHost(t *testing.T) {
FILE: pkg/docker/docker.go
function ptrVal (line 36) | func ptrVal[T any](v T) *T { return &v }
function NewClient (line 38) | func NewClient(ctx context.Context, opts ...Option) (*apiClient, error) {
type apiClient (line 88) | type apiClient struct
method Pull (line 93) | func (c *apiClient) Pull(ctx context.Context, imageRef string, force b...
method ContainerStop (line 132) | func (c *apiClient) ContainerStop(ctx context.Context, containerID str...
method ContainerInspect (line 147) | func (c *apiClient) ContainerInspect(ctx context.Context, containerID ...
method ContainerLogs (line 160) | func (c *apiClient) ContainerLogs(ctx context.Context, containerID str...
method Push (line 197) | func (c *apiClient) Push(ctx context.Context, imageRef string) error {
method ImageSave (line 258) | func (c *apiClient) ImageSave(ctx context.Context, imageRef string) (i...
method LoadUserInformation (line 264) | func (c *apiClient) LoadUserInformation(ctx context.Context, registryH...
method Inspect (line 270) | func (c *apiClient) Inspect(ctx context.Context, ref string) (*image.I...
method RemoveImage (line 288) | func (c *apiClient) RemoveImage(ctx context.Context, ref string) error {
method ImageExists (line 302) | func (c *apiClient) ImageExists(ctx context.Context, ref string) (bool...
method ImageBuild (line 315) | func (c *apiClient) ImageBuild(ctx context.Context, options command.Im...
method containerRun (line 380) | func (c *apiClient) containerRun(ctx context.Context, options command....
method Run (line 581) | func (c *apiClient) Run(ctx context.Context, options command.RunOption...
method ContainerStart (line 595) | func (c *apiClient) ContainerStart(ctx context.Context, options comman...
function parseGPURequest (line 604) | func parseGPURequest(opts command.RunOptions) (container.DeviceRequest, ...
function shouldAttachStdin (line 639) | func shouldAttachStdin(stdin io.Reader) (attach bool, tty bool) {
FILE: pkg/docker/docker_client_test.go
function TestDockerClient (line 22) | func TestDockerClient(t *testing.T) {
function assertImageExists (line 400) | func assertImageExists(t *testing.T, dockerClient command.Command, image...
function assertNoImageExists (line 408) | func assertNoImageExists(t *testing.T, dockerClient command.Command, ima...
function assertNotFoundError (line 416) | func assertNotFoundError(t *testing.T, err error, ref string, object str...
FILE: pkg/docker/dockertest/command_mocks.go
function NewMockCommand2 (line 19) | func NewMockCommand2(t interface {
type MockCommand2 (line 32) | type MockCommand2 struct
method EXPECT (line 40) | func (_m *MockCommand2) EXPECT() *MockCommand2_Expecter {
method ContainerInspect (line 45) | func (_mock *MockCommand2) ContainerInspect(ctx context.Context, id st...
method ContainerLogs (line 113) | func (_mock *MockCommand2) ContainerLogs(ctx context.Context, containe...
method ContainerStart (line 176) | func (_mock *MockCommand2) ContainerStart(ctx context.Context, options...
method ContainerStop (line 242) | func (_mock *MockCommand2) ContainerStop(ctx context.Context, containe...
method ImageBuild (line 299) | func (_mock *MockCommand2) ImageBuild(ctx context.Context, options com...
method ImageSave (line 365) | func (_mock *MockCommand2) ImageSave(ctx context.Context, imageRef str...
method ImageExists (line 433) | func (_mock *MockCommand2) ImageExists(ctx context.Context, ref string...
method Inspect (line 499) | func (_mock *MockCommand2) Inspect(ctx context.Context, ref string) (*...
method LoadUserInformation (line 567) | func (_mock *MockCommand2) LoadUserInformation(ctx context.Context, re...
method Pull (line 635) | func (_mock *MockCommand2) Pull(ctx context.Context, ref string, force...
method Push (line 709) | func (_mock *MockCommand2) Push(ctx context.Context, ref string) error {
method RemoveImage (line 766) | func (_mock *MockCommand2) RemoveImage(ctx context.Context, ref string...
method Run (line 823) | func (_mock *MockCommand2) Run(ctx context.Context, options command.Ru...
type MockCommand2_Expecter (line 36) | type MockCommand2_Expecter struct
method ContainerInspect (line 80) | func (_e *MockCommand2_Expecter) ContainerInspect(ctx interface{}, id ...
method ContainerLogs (line 138) | func (_e *MockCommand2_Expecter) ContainerLogs(ctx interface{}, contai...
method ContainerStart (line 209) | func (_e *MockCommand2_Expecter) ContainerStart(ctx interface{}, optio...
method ContainerStop (line 266) | func (_e *MockCommand2_Expecter) ContainerStop(ctx interface{}, contai...
method ImageBuild (line 332) | func (_e *MockCommand2_Expecter) ImageBuild(ctx interface{}, options i...
method ImageSave (line 400) | func (_e *MockCommand2_Expecter) ImageSave(ctx interface{}, imageRef i...
method ImageExists (line 466) | func (_e *MockCommand2_Expecter) ImageExists(ctx interface{}, ref inte...
method Inspect (line 534) | func (_e *MockCommand2_Expecter) Inspect(ctx interface{}, ref interfac...
method LoadUserInformation (line 602) | func (_e *MockCommand2_Expecter) LoadUserInformation(ctx interface{}, ...
method Pull (line 671) | func (_e *MockCommand2_Expecter) Pull(ctx interface{}, ref interface{}...
method Push (line 733) | func (_e *MockCommand2_Expecter) Push(ctx interface{}, ref interface{}...
method RemoveImage (line 790) | func (_e *MockCommand2_Expecter) RemoveImage(ctx interface{}, ref inte...
method Run (line 847) | func (_e *MockCommand2_Expecter) Run(ctx interface{}, options interfac...
type MockCommand2_ContainerInspect_Call (line 73) | type MockCommand2_ContainerInspect_Call struct
method Run (line 84) | func (_c *MockCommand2_ContainerInspect_Call) Run(run func(ctx context...
method Return (line 102) | func (_c *MockCommand2_ContainerInspect_Call) Return(inspectResponse *...
method RunAndReturn (line 107) | func (_c *MockCommand2_ContainerInspect_Call) RunAndReturn(run func(ct...
type MockCommand2_ContainerLogs_Call (line 130) | type MockCommand2_ContainerLogs_Call struct
method Run (line 142) | func (_c *MockCommand2_ContainerLogs_Call) Run(run func(ctx context.Co...
method Return (line 165) | func (_c *MockCommand2_ContainerLogs_Call) Return(err error) *MockComm...
method RunAndReturn (line 170) | func (_c *MockCommand2_ContainerLogs_Call) RunAndReturn(run func(ctx c...
type MockCommand2_ContainerStart_Call (line 202) | type MockCommand2_ContainerStart_Call struct
method Run (line 213) | func (_c *MockCommand2_ContainerStart_Call) Run(run func(ctx context.C...
method Return (line 231) | func (_c *MockCommand2_ContainerStart_Call) Return(s string, err error...
method RunAndReturn (line 236) | func (_c *MockCommand2_ContainerStart_Call) RunAndReturn(run func(ctx ...
type MockCommand2_ContainerStop_Call (line 259) | type MockCommand2_ContainerStop_Call struct
method Run (line 270) | func (_c *MockCommand2_ContainerStop_Call) Run(run func(ctx context.Co...
method Return (line 288) | func (_c *MockCommand2_ContainerStop_Call) Return(err error) *MockComm...
method RunAndReturn (line 293) | func (_c *MockCommand2_ContainerStop_Call) RunAndReturn(run func(ctx c...
type MockCommand2_ImageBuild_Call (line 325) | type MockCommand2_ImageBuild_Call struct
method Run (line 336) | func (_c *MockCommand2_ImageBuild_Call) Run(run func(ctx context.Conte...
method Return (line 354) | func (_c *MockCommand2_ImageBuild_Call) Return(imageID string, err err...
method RunAndReturn (line 359) | func (_c *MockCommand2_ImageBuild_Call) RunAndReturn(run func(ctx cont...
type MockCommand2_ImageSave_Call (line 393) | type MockCommand2_ImageSave_Call struct
method Run (line 404) | func (_c *MockCommand2_ImageSave_Call) Run(run func(ctx context.Contex...
method Return (line 422) | func (_c *MockCommand2_ImageSave_Call) Return(rc io.ReadCloser, err er...
method RunAndReturn (line 427) | func (_c *MockCommand2_ImageSave_Call) RunAndReturn(run func(ctx conte...
type MockCommand2_ImageExists_Call (line 459) | type MockCommand2_ImageExists_Call struct
method Run (line 470) | func (_c *MockCommand2_ImageExists_Call) Run(run func(ctx context.Cont...
method Return (line 488) | func (_c *MockCommand2_ImageExists_Call) Return(b bool, err error) *Mo...
method RunAndReturn (line 493) | func (_c *MockCommand2_ImageExists_Call) RunAndReturn(run func(ctx con...
type MockCommand2_Inspect_Call (line 527) | type MockCommand2_Inspect_Call struct
method Run (line 538) | func (_c *MockCommand2_Inspect_Call) Run(run func(ctx context.Context,...
method Return (line 556) | func (_c *MockCommand2_Inspect_Call) Return(inspectResponse *image.Ins...
method RunAndReturn (line 561) | func (_c *MockCommand2_Inspect_Call) RunAndReturn(run func(ctx context...
type MockCommand2_LoadUserInformation_Call (line 595) | type MockCommand2_LoadUserInformation_Call struct
method Run (line 606) | func (_c *MockCommand2_LoadUserInformation_Call) Run(run func(ctx cont...
method Return (line 624) | func (_c *MockCommand2_LoadUserInformation_Call) Return(userInfo *comm...
method RunAndReturn (line 629) | func (_c *MockCommand2_LoadUserInformation_Call) RunAndReturn(run func...
type MockCommand2_Pull_Call (line 663) | type MockCommand2_Pull_Call struct
method Run (line 675) | func (_c *MockCommand2_Pull_Call) Run(run func(ctx context.Context, re...
method Return (line 698) | func (_c *MockCommand2_Pull_Call) Return(inspectResponse *image.Inspec...
method RunAndReturn (line 703) | func (_c *MockCommand2_Pull_Call) RunAndReturn(run func(ctx context.Co...
type MockCommand2_Push_Call (line 726) | type MockCommand2_Push_Call struct
method Run (line 737) | func (_c *MockCommand2_Push_Call) Run(run func(ctx context.Context, re...
method Return (line 755) | func (_c *MockCommand2_Push_Call) Return(err error) *MockCommand2_Push...
method RunAndReturn (line 760) | func (_c *MockCommand2_Push_Call) RunAndReturn(run func(ctx context.Co...
type MockCommand2_RemoveImage_Call (line 783) | type MockCommand2_RemoveImage_Call struct
method Run (line 794) | func (_c *MockCommand2_RemoveImage_Call) Run(run func(ctx context.Cont...
method Return (line 812) | func (_c *MockCommand2_RemoveImage_Call) Return(err error) *MockComman...
method RunAndReturn (line 817) | func (_c *MockCommand2_RemoveImage_Call) RunAndReturn(run func(ctx con...
type MockCommand2_Run_Call (line 840) | type MockCommand2_Run_Call struct
method Run (line 851) | func (_c *MockCommand2_Run_Call) Run(run func(ctx context.Context, opt...
method Return (line 869) | func (_c *MockCommand2_Run_Call) Return(err error) *MockCommand2_Run_C...
method RunAndReturn (line 874) | func (_c *MockCommand2_Run_Call) RunAndReturn(run func(ctx context.Con...
FILE: pkg/docker/dockertest/helper_client.go
function NewHelperClient (line 25) | func NewHelperClient(t testing.TB) *HelperClient {
type HelperClient (line 67) | type HelperClient struct
method Close (line 74) | func (c *HelperClient) Close() error {
method PullImage (line 78) | func (c *HelperClient) PullImage(t testing.TB, ref string) error {
method MustPullImage (line 103) | func (c *HelperClient) MustPullImage(t testing.TB, ref string) {
method PushImage (line 108) | func (c *HelperClient) PushImage(t testing.TB, ref string) error {
method MustPushImage (line 134) | func (c *HelperClient) MustPushImage(t testing.TB, ref string) {
method RunContainer (line 139) | func (c *HelperClient) RunContainer(t testing.TB, imageName string) st...
method StopContainer (line 180) | func (c *HelperClient) StopContainer(t testing.TB, containerID string) {
method InspectImage (line 190) | func (c *HelperClient) InspectImage(t testing.TB, imageRef string) *im...
method ImageExists (line 199) | func (c *HelperClient) ImageExists(t testing.TB, imageRef string) bool {
method DeleteImage (line 206) | func (c *HelperClient) DeleteImage(t testing.TB, imageRef string) error {
method MustDeleteImage (line 216) | func (c *HelperClient) MustDeleteImage(t testing.TB, imageRef string) {
method CleanupImage (line 226) | func (c *HelperClient) CleanupImage(t testing.TB, imageRef string) {
method CleanupImages (line 240) | func (c *HelperClient) CleanupImages(t testing.TB) {
method InspectContainer (line 269) | func (c *HelperClient) InspectContainer(t testing.TB, containerID stri...
method ImageFixture (line 278) | func (c *HelperClient) ImageFixture(t testing.TB, name string, tag str...
method loadImageFixture (line 292) | func (c *HelperClient) loadImageFixture(t testing.TB, name string) *im...
type imageFixture (line 341) | type imageFixture struct
FILE: pkg/docker/dockertest/image.go
function ImageRef (line 13) | func ImageRef(t *testing.T, label string) string {
function ImageRefWithRegistry (line 21) | func ImageRefWithRegistry(t *testing.T, registryAddr string, label strin...
FILE: pkg/docker/dockertest/mock_command.go
type MockCommand (line 21) | type MockCommand struct
method Pull (line 27) | func (c *MockCommand) Pull(ctx context.Context, image string, force bo...
method Push (line 31) | func (c *MockCommand) Push(ctx context.Context, image string) error {
method LoadUserInformation (line 35) | func (c *MockCommand) LoadUserInformation(ctx context.Context, registr...
method CreateTarFile (line 43) | func (c *MockCommand) CreateTarFile(ctx context.Context, image string,...
method CreateAptTarFile (line 53) | func (c *MockCommand) CreateAptTarFile(ctx context.Context, tmpDir str...
method Inspect (line 63) | func (c *MockCommand) Inspect(ctx context.Context, ref string) (*image...
method ImageExists (line 85) | func (c *MockCommand) ImageExists(ctx context.Context, ref string) (bo...
method ContainerLogs (line 89) | func (c *MockCommand) ContainerLogs(ctx context.Context, containerID s...
method ContainerInspect (line 93) | func (c *MockCommand) ContainerInspect(ctx context.Context, id string)...
method ContainerStop (line 97) | func (c *MockCommand) ContainerStop(ctx context.Context, containerID s...
method RemoveImage (line 101) | func (c *MockCommand) RemoveImage(ctx context.Context, ref string) err...
method ImageBuild (line 105) | func (c *MockCommand) ImageBuild(ctx context.Context, options command....
method Run (line 109) | func (c *MockCommand) Run(ctx context.Context, options command.RunOpti...
method ContainerStart (line 113) | func (c *MockCommand) ContainerStart(ctx context.Context, options comm...
method ImageSave (line 117) | func (c *MockCommand) ImageSave(ctx context.Context, imageRef string) ...
function NewMockCommand (line 23) | func NewMockCommand() *MockCommand {
FILE: pkg/docker/dockertest/ref.go
type Ref (line 11) | type Ref struct
method WithTag (line 35) | func (r Ref) WithTag(tagName string) Ref {
method WithDigest (line 40) | func (r Ref) WithDigest(digest string) Ref {
method WithRegistry (line 45) | func (r Ref) WithRegistry(registry string) Ref {
method WithoutRegistry (line 64) | func (r Ref) WithoutRegistry() Ref {
method String (line 80) | func (r Ref) String() string {
function NewRef (line 16) | func NewRef(t *testing.T) Ref {
FILE: pkg/docker/dockertest/ref_test.go
function TestRef (line 9) | func TestRef(t *testing.T) {
FILE: pkg/docker/env.go
constant DockerCommandEnvVarName (line 5) | DockerCommandEnvVarName = "R8_DOCKER_COMMAND"
function DockerCommandFromEnvironment (line 7) | func DockerCommandFromEnvironment() string {
FILE: pkg/docker/errors.go
function isTagNotFoundError (line 12) | func isTagNotFoundError(err error) bool {
function isAuthorizationFailedError (line 18) | func isAuthorizationFailedError(err error) bool {
function isRepositoryNotFoundError (line 39) | func isRepositoryNotFoundError(err error) bool {
function isMissingDeviceDriverError (line 45) | func isMissingDeviceDriverError(err error) bool {
function isNetworkError (line 52) | func isNetworkError(err error) bool {
FILE: pkg/docker/host.go
function determineDockerHost (line 16) | func determineDockerHost() (string, error) {
function dockerHostFromContext (line 44) | func dockerHostFromContext(contextName string) (string, string, error) {
FILE: pkg/docker/host_unix.go
constant defaultDockerHost (line 6) | defaultDockerHost = "unix:///var/run/docker.sock"
FILE: pkg/docker/host_windows.go
constant defaultDockerHost (line 4) | defaultDockerHost = "npipe:////.pipe/docker_engine"
FILE: pkg/docker/login.go
function SaveLoginToken (line 18) | func SaveLoginToken(ctx context.Context, registryHost string, username s...
function saveAuthToConfig (line 27) | func saveAuthToConfig(conf *configfile.ConfigFile, registryHost string, ...
function saveAuthToCredentialsStore (line 39) | func saveAuthToCredentialsStore(ctx context.Context, credsStore string, ...
FILE: pkg/docker/options.go
type clientOptions (line 5) | type clientOptions struct
type Option (line 10) | type Option
function WithAuthConfig (line 12) | func WithAuthConfig(authConfig registry.AuthConfig) Option {
function WithHost (line 18) | func WithHost(host string) Option {
FILE: pkg/docker/progress.go
type ProgressWriter (line 20) | type ProgressWriter struct
method Write (line 48) | func (p *ProgressWriter) Write(id, status string, current, total int64) {
method WriteStatus (line 62) | func (p *ProgressWriter) WriteStatus(id, status string) {
method writeMessage (line 70) | func (p *ProgressWriter) writeMessage(msg jsonmessage.JSONMessage) {
method Close (line 87) | func (p *ProgressWriter) Close() {
function NewProgressWriter (line 29) | func NewProgressWriter() *ProgressWriter {
FILE: pkg/docker/push.go
type BuildInfo (line 13) | type BuildInfo struct
function Push (line 18) | func Push(ctx context.Context, image string, projectDir string, command ...
FILE: pkg/docker/run.go
function Run (line 19) | func Run(ctx context.Context, dockerClient command.Command, options comm...
function RunWithIO (line 23) | func RunWithIO(ctx context.Context, dockerClient command.Command, option...
function RunDaemon (line 32) | func RunDaemon(ctx context.Context, dockerClient command.Command, option...
function GetHostPortForContainer (line 37) | func GetHostPortForContainer(ctx context.Context, dockerCommand command....
FILE: pkg/docker/run_test.go
function TestGetHostPortForContainer (line 14) | func TestGetHostPortForContainer(t *testing.T) {
FILE: pkg/docker/standard_push.go
function StandardPush (line 9) | func StandardPush(ctx context.Context, image string, command command.Com...
FILE: pkg/docker/standard_push_test.go
function TestStandardPush (line 11) | func TestStandardPush(t *testing.T) {
FILE: pkg/dockercontext/build_tempdir.go
function CogBuildArtifactsDirPath (line 11) | func CogBuildArtifactsDirPath(dir string) (string, error) {
function CogTempDir (line 20) | func CogTempDir(dir string, contextDir string) (string, error) {
function BuildCogTempDir (line 28) | func BuildCogTempDir(dir string, subDir string) (string, error) {
function BuildTempDir (line 39) | func BuildTempDir(dir string) (string, error) {
FILE: pkg/dockercontext/build_tempdir_test.go
function TestBuildCogTempDir (line 10) | func TestBuildCogTempDir(t *testing.T) {
FILE: pkg/dockercontext/directories.go
constant StandardBuildDirectory (line 5) | StandardBuildDirectory = "."
constant ContextBuildDir (line 7) | ContextBuildDir = "context"
constant AptBuildContextName (line 8) | AptBuildContextName = "apt"
constant RequirementsBuildContextName (line 9) | RequirementsBuildContextName = "requirements"
constant SrcBuildContextName (line 10) | SrcBuildContextName = "src"
FILE: pkg/dockerfile/base.go
constant MinimumCUDAVersion (line 16) | MinimumCUDAVersion = "11.6"
constant MinimumPythonVersion (line 17) | MinimumPythonVersion = "3.10"
constant MinimumTorchVersion (line 18) | MinimumTorchVersion = "1.13.1"
constant CogBaseImageName (line 19) | CogBaseImageName = "cog-base"
type CUDAVersion (line 53) | type CUDAVersion struct
type PyTorchVersion (line 57) | type PyTorchVersion struct
type PythonVersion (line 61) | type PythonVersion struct
type AvailableBaseImageConfigurations (line 67) | type AvailableBaseImageConfigurations struct
type BaseImageConfiguration (line 71) | type BaseImageConfiguration struct
method MarshalJSON (line 85) | func (b BaseImageConfiguration) MarshalJSON() ([]byte, error) {
type BaseImageGenerator (line 77) | type BaseImageGenerator struct
method GenerateDockerfile (line 184) | func (g *BaseImageGenerator) GenerateDockerfile(ctx context.Context) (...
method makeConfig (line 205) | func (g *BaseImageGenerator) makeConfig() (*config.Config, error) {
method pythonPackages (line 222) | func (g *BaseImageGenerator) pythonPackages() []string {
method runStatements (line 260) | func (g *BaseImageGenerator) runStatements() []config.RunItem {
function BaseImageConfigurations (line 110) | func BaseImageConfigurations() []BaseImageConfiguration {
function NewBaseImageGenerator (line 167) | func NewBaseImageGenerator(ctx context.Context, client registry.Client, ...
function baseImageComponentNormalisation (line 264) | func baseImageComponentNormalisation(cudaVersion string, pythonVersion s...
function BaseImageName (line 290) | func BaseImageName(cudaVersion string, pythonVersion string, torchVersio...
function BaseImageConfigurationExists (line 312) | func BaseImageConfigurationExists(ctx context.Context, client registry.C...
function isVersionCompatible (line 343) | func isVersionCompatible(confVersion, requestedVersion string) bool {
FILE: pkg/dockerfile/base_test.go
function TestBaseImageName (line 14) | func TestBaseImageName(t *testing.T) {
function TestGenerateDockerfile (line 37) | func TestGenerateDockerfile(t *testing.T) {
function TestBaseImageNameWithVersionModifier (line 59) | func TestBaseImageNameWithVersionModifier(t *testing.T) {
function TestBaseImageConfigurationExists (line 64) | func TestBaseImageConfigurationExists(t *testing.T) {
function TestBaseImageConfigurationExistsNoTorch (line 76) | func TestBaseImageConfigurationExistsNoTorch(t *testing.T) {
function TestBaseImageConfigurationExistsNoCUDA (line 87) | func TestBaseImageConfigurationExistsNoCUDA(t *testing.T) {
function TestIsVersionCompatible (line 99) | func TestIsVersionCompatible(t *testing.T) {
function TestPythonPackages (line 104) | func TestPythonPackages(t *testing.T) {
function TestInvalidBaseImage (line 122) | func TestInvalidBaseImage(t *testing.T) {
function TestBaseImageConfigurationNoTorchPythonVersionDoesNotExist (line 129) | func TestBaseImageConfigurationNoTorchPythonVersionDoesNotExist(t *testi...
FILE: pkg/dockerfile/cacert.go
constant CACertEnvVar (line 15) | CACertEnvVar = "COG_CA_CERT"
constant CACertFilename (line 18) | CACertFilename = "cog-ca-cert.crt"
constant CACertContainerPath (line 21) | CACertContainerPath = "/usr/local/share/ca-certificates/" + CACertFilename
constant SystemCertBundle (line 24) | SystemCertBundle = "/etc/ssl/certs/ca-certificates.crt"
function ReadCACert (line 38) | func ReadCACert() ([]byte, error) {
function readCACertFile (line 69) | func readCACertFile(path string) ([]byte, error) {
function readCACertDirectory (line 78) | func readCACertDirectory(dir string) ([]byte, error) {
function validatePEM (line 120) | func validatePEM(data []byte) ([]byte, error) {
function GenerateCACertInstall (line 144) | func GenerateCACertInstall(certData []byte, writeTemp func(filename stri...
FILE: pkg/dockerfile/cacert_test.go
constant testCertPEM (line 13) | testCertPEM = `-----BEGIN CERTIFICATE-----
constant testCertPEM2 (line 23) | testCertPEM2 = `-----BEGIN CERTIFICATE-----
function TestReadCACert_NotSet (line 33) | func TestReadCACert_NotSet(t *testing.T) {
function TestReadCACert_FilePath (line 41) | func TestReadCACert_FilePath(t *testing.T) {
function TestReadCACert_Directory (line 55) | func TestReadCACert_Directory(t *testing.T) {
function TestReadCACert_InlinePEM (line 74) | func TestReadCACert_InlinePEM(t *testing.T) {
function TestReadCACert_Base64EncodedPEM (line 83) | func TestReadCACert_Base64EncodedPEM(t *testing.T) {
function TestReadCACert_InvalidPEM (line 93) | func TestReadCACert_InvalidPEM(t *testing.T) {
function TestReadCACert_MissingFile (line 102) | func TestReadCACert_MissingFile(t *testing.T) {
function TestReadCACert_EmptyDirectory (line 111) | func TestReadCACert_EmptyDirectory(t *testing.T) {
function TestReadCACert_InvalidFileInDirectory (line 121) | func TestReadCACert_InvalidFileInDirectory(t *testing.T) {
function TestReadCACert_TrimsWhitespace (line 134) | func TestReadCACert_TrimsWhitespace(t *testing.T) {
function TestGenerateCACertInstall (line 144) | func TestGenerateCACertInstall(t *testing.T) {
function TestGenerateCACertInstall_EmptyData (line 168) | func TestGenerateCACertInstall_EmptyData(t *testing.T) {
FILE: pkg/dockerfile/env.go
function envLineFromConfig (line 10) | func envLineFromConfig(c *config.Config) (string, error) {
FILE: pkg/dockerfile/generator.go
type Generator (line 9) | type Generator interface
FILE: pkg/dockerfile/generator_factory.go
function NewGenerator (line 9) | func NewGenerator(config *config.Config, dir string, configFilename stri...
FILE: pkg/dockerfile/generator_factory_test.go
function TestGeneratorFactoryStandardGenerator (line 13) | func TestGeneratorFactoryStandardGenerator(t *testing.T) {
FILE: pkg/dockerfile/standard_generator.go
constant DockerignoreHeader (line 23) | DockerignoreHeader = `# generated by replicate/cog
constant LDConfigCacheBuildCommand (line 45) | LDConfigCacheBuildCommand = "RUN find / -type f -name \"*python*.so\" -p...
constant StripDebugSymbolsCommand (line 46) | StripDebugSymbolsCommand = "find / -type f -name \"*python*.so\" -not -n...
constant CFlags (line 47) | CFlags = "ENV CFLAGS=\"-O3 -funroll-loops -fno-strict-aliasing -flto -S\""
constant UVVersion (line 48) | UVVersion = "0.9.26"
constant uvCacheMount (line 49) | uvCacheMount = "--mount=type=cache,target=/root/.cache/uv"
constant uvPip (line 50) | uvPip = "uv pip"
constant PrecompilePythonCommand (line 51) | PrecompilePythonCommand = "RUN find / -type f -name \"*.py[co]\" -delete...
constant STANDARD_GENERATOR_NAME (line 52) | STANDARD_GENERATOR_NAME = "STANDARD_GENERATOR"
type StandardGenerator (line 54) | type StandardGenerator struct
method SetUseCudaBaseImage (line 131) | func (g *StandardGenerator) SetUseCudaBaseImage(argumentValue string) {
method SetUseCogBaseImage (line 136) | func (g *StandardGenerator) SetUseCogBaseImage(useCogBaseImage bool) {
method SetUseCogBaseImagePtr (line 141) | func (g *StandardGenerator) SetUseCogBaseImagePtr(useCogBaseImage *boo...
method IsUsingCogBaseImage (line 145) | func (g *StandardGenerator) IsUsingCogBaseImage() bool {
method SetStrip (line 153) | func (g *StandardGenerator) SetStrip(strip bool) {
method SetPrecompile (line 157) | func (g *StandardGenerator) SetPrecompile(precompile bool) {
method GenerateInitialSteps (line 161) | func (g *StandardGenerator) GenerateInitialSteps(ctx context.Context) ...
method GenerateModelBase (line 243) | func (g *StandardGenerator) GenerateModelBase(ctx context.Context) (st...
method GenerateDockerfileWithoutSeparateWeights (line 259) | func (g *StandardGenerator) GenerateDockerfileWithoutSeparateWeights(c...
method GenerateModelBaseWithSeparateWeights (line 280) | func (g *StandardGenerator) GenerateModelBaseWithSeparateWeights(ctx c...
method cogEnvVars (line 326) | func (g *StandardGenerator) cogEnvVars() []string {
method cpCogYaml (line 340) | func (g *StandardGenerator) cpCogYaml() string {
method generateForWeights (line 348) | func (g *StandardGenerator) generateForWeights() (string, []string, []...
method Cleanup (line 376) | func (g *StandardGenerator) Cleanup() error {
method BaseImage (line 383) | func (g *StandardGenerator) BaseImage(ctx context.Context) (string, er...
method Name (line 402) | func (g *StandardGenerator) Name() string {
method BuildDir (line 406) | func (g *StandardGenerator) BuildDir() (string, error) {
method BuildContexts (line 410) | func (g *StandardGenerator) BuildContexts() (map[string]string, error) {
method preamble (line 414) | func (g *StandardGenerator) preamble() string {
method installTini (line 421) | func (g *StandardGenerator) installTini() string {
method aptInstalls (line 441) | func (g *StandardGenerator) aptInstalls() (string, error) {
method installPython (line 459) | func (g *StandardGenerator) installPython() (string, error) {
method installUV (line 466) | func (g *StandardGenerator) installUV() string {
method installPythonCUDA (line 471) | func (g *StandardGenerator) installPythonCUDA() (string, error) {
method resolveCogWheelConfigs (line 504) | func (g *StandardGenerator) resolveCogWheelConfigs() error {
method isLegacySDKVersion (line 556) | func (g *StandardGenerator) isLegacySDKVersion() bool {
method installCog (line 572) | func (g *StandardGenerator) installCog() (string, error) {
method installCogFromPyPI (line 657) | func (g *StandardGenerator) installCogFromPyPI(config *wheels.WheelCon...
method installWheelFromURL (line 672) | func (g *StandardGenerator) installWheelFromURL(url string) (string, e...
method installWheelFromFile (line 702) | func (g *StandardGenerator) installWheelFromFile(path string) (string,...
method installCogletWheel (line 741) | func (g *StandardGenerator) installCogletWheel(config *wheels.WheelCon...
method installCogletFromPyPI (line 756) | func (g *StandardGenerator) installCogletFromPyPI(config *wheels.Wheel...
method installCogletFromURL (line 771) | func (g *StandardGenerator) installCogletFromURL(url string) (string, ...
method installCogletFromFile (line 781) | func (g *StandardGenerator) installCogletFromFile(path string) (string...
method filterManagedPackages (line 806) | func (g *StandardGenerator) filterManagedPackages(reqContents string) ...
method pipInstalls (line 859) | func (g *StandardGenerator) pipInstalls() (string, error) {
method runCommands (line 912) | func (g *StandardGenerator) runCommands() (string, error) {
method envVars (line 945) | func (g *StandardGenerator) envVars() (string, error) {
method installCACert (line 951) | func (g *StandardGenerator) installCACert() (string, error) {
method writeTemp (line 964) | func (g *StandardGenerator) writeTemp(filename string, contents []byte...
method GenerateWeightsManifest (line 994) | func (g *StandardGenerator) GenerateWeightsManifest(ctx context.Contex...
method determineBaseImageName (line 1023) | func (g *StandardGenerator) determineBaseImageName(ctx context.Context...
function NewStandardGenerator (line 94) | func NewStandardGenerator(config *config.Config, dir string, configFilen...
function makeDockerignoreForWeights (line 365) | func makeDockerignoreForWeights(dirs, files []string) string {
constant cogletMinSDKVersion (line 551) | cogletMinSDKVersion = "0.17.0"
function joinStringsWithoutLineSpace (line 975) | func joinStringsWithoutLineSpace(chunks []string) string {
function filterEmpty (line 984) | func filterEmpty(list []string) []string {
function stripPatchVersion (line 1049) | func stripPatchVersion(versionString string) (string, bool, error) {
FILE: pkg/dockerfile/standard_generator_test.go
function testTini (line 19) | func testTini() string {
function testInstallCog (line 34) | func testInstallCog(stripped bool) string {
function pypiWheels (line 48) | func pypiWheels(gen *StandardGenerator) {
function testInstallPython (line 53) | func testInstallPython(version string) string {
function TestGenerateEmptyCPU (line 70) | func TestGenerateEmptyCPU(t *testing.T) {
function TestGenerateEmptyGPU (line 108) | func TestGenerateEmptyGPU(t *testing.T) {
function TestGenerateFullCPU (line 146) | func TestGenerateFullCPU(t *testing.T) {
function TestGenerateFullGPU (line 205) | func TestGenerateFullGPU(t *testing.T) {
function TestPreInstall (line 264) | func TestPreInstall(t *testing.T) {
function TestPythonRequirements (line 306) | func TestPythonRequirements(t *testing.T) {
type mockFileInfo (line 330) | type mockFileInfo struct
method Size (line 334) | func (mfi mockFileInfo) Size() int64 {
method Name (line 337) | func (mfi mockFileInfo) Name() string {
method Mode (line 340) | func (mfi mockFileInfo) Mode() os.FileMode {
method ModTime (line 343) | func (mfi mockFileInfo) ModTime() time.Time {
method IsDir (line 346) | func (mfi mockFileInfo) IsDir() bool {
method Sys (line 349) | func (mfi mockFileInfo) Sys() any {
constant sizeThreshold (line 353) | sizeThreshold = 10 * 1024 * 1024
function TestGenerateWithLargeModels (line 355) | func TestGenerateWithLargeModels(t *testing.T) {
function TestGenerateDockerfileWithoutSeparateWeights (line 463) | func TestGenerateDockerfileWithoutSeparateWeights(t *testing.T) {
function TestGenerateEmptyCPUWithCogBaseImage (line 500) | func TestGenerateEmptyCPUWithCogBaseImage(t *testing.T) {
function TestGeneratePythonCPUWithCogBaseImage (line 534) | func TestGeneratePythonCPUWithCogBaseImage(t *testing.T) {
function TestGenerateFullGPUWithCogBaseImage (line 585) | func TestGenerateFullGPUWithCogBaseImage(t *testing.T) {
function TestGenerateTorchWithStrippedModifiedVersion (line 650) | func TestGenerateTorchWithStrippedModifiedVersion(t *testing.T) {
function TestGenerateWithStrip (line 707) | func TestGenerateWithStrip(t *testing.T) {
function TestGenerateDoesNotContainDangerousCFlags (line 765) | func TestGenerateDoesNotContainDangerousCFlags(t *testing.T) {
function TestGenerateWithPrecompile (line 800) | func TestGenerateWithPrecompile(t *testing.T) {
function TestGenerateWithCoglet (line 860) | func TestGenerateWithCoglet(t *testing.T) {
function TestCOGWheelDefault (line 923) | func TestCOGWheelDefault(t *testing.T) {
function TestCOGWheelEnvPyPI (line 951) | func TestCOGWheelEnvPyPI(t *testing.T) {
function TestCOGWheelEnvPyPIWithVersion (line 979) | func TestCOGWheelEnvPyPIWithVersion(t *testing.T) {
function TestCOGWheelEnvURL (line 1007) | func TestCOGWheelEnvURL(t *testing.T) {
function TestCOGWheelEnvFile (line 1036) | func TestCOGWheelEnvFile(t *testing.T) {
function TestCogletStrippedFromRequirements (line 1069) | func TestCogletStrippedFromRequirements(t *testing.T) {
function TestInstallCogWithSDKVersion (line 1094) | func TestInstallCogWithSDKVersion(t *testing.T) {
function TestInstallCogWithPreReleaseSDKVersion (line 1120) | func TestInstallCogWithPreReleaseSDKVersion(t *testing.T) {
function TestInstallCogSDKVersionBelowMinimum (line 1146) | func TestInstallCogSDKVersionBelowMinimum(t *testing.T) {
function TestCOGSDKWheelEnvVarOverridesSDKVersion (line 1170) | func TestCOGSDKWheelEnvVarOverridesSDKVersion(t *testing.T) {
FILE: pkg/dockerfile/version_check.go
function parse (line 11) | func parse(s string) (string, string, string) {
function CheckMajorOnly (line 23) | func CheckMajorOnly(s string) bool {
function CheckMajorMinorOnly (line 28) | func CheckMajorMinorOnly(s string) bool {
function CheckMajorMinorPatch (line 33) | func CheckMajorMinorPatch(s string) bool {
FILE: pkg/dockerignore/dockerignore.go
constant DockerIgnoreFilename (line 13) | DockerIgnoreFilename = ".dockerignore"
function CreateMatcher (line 15) | func CreateMatcher(dir string) (*ignore.GitIgnore, error) {
function Walk (line 32) | func Walk(root string, ignoreMatcher *ignore.GitIgnore, fn filepath.Walk...
function readDockerIgnore (line 58) | func readDockerIgnore(dockerIgnorePath string) ([]string, error) {
FILE: pkg/dockerignore/dockerignore_test.go
function TestWalk (line 11) | func TestWalk(t *testing.T) {
FILE: pkg/env/env.go
constant SchemeEnvVarName (line 5) | SchemeEnvVarName = "R8_SCHEME"
constant WebHostEnvVarName (line 6) | WebHostEnvVarName = "R8_WEB_HOST"
constant APIHostEnvVarName (line 7) | APIHostEnvVarName = "R8_API_HOST"
constant PytorchHostEnvVarName (line 8) | PytorchHostEnvVarName = "R8_PYTORCH_HOST"
function SchemeFromEnvironment (line 10) | func SchemeFromEnvironment() string {
function WebHostFromEnvironment (line 18) | func WebHostFromEnvironment() string {
function APIHostFromEnvironment (line 26) | func APIHostFromEnvironment() string {
function PytorchHostFromEnvironment (line 34) | func PytorchHostFromEnvironment() string {
FILE: pkg/env/env_test.go
function TestSchemeFromEnvironment (line 9) | func TestSchemeFromEnvironment(t *testing.T) {
function TestWebHostFromEnvironment (line 15) | func TestWebHostFromEnvironment(t *testing.T) {
FILE: pkg/errors/errors.go
constant CodeConfigNotFound (line 4) | CodeConfigNotFound = "CONFIG_NOT_FOUND"
type CodedError (line 9) | type CodedError interface
type codedError (line 13) | type codedError struct
method Error (line 18) | func (e *codedError) Error() string {
method Code (line 22) | func (e *codedError) Code() string {
function ConfigNotFound (line 29) | func ConfigNotFound(msg string) error {
function IsConfigNotFound (line 38) | func IsConfigNotFound(err error) bool {
function Code (line 43) | func Code(err error) string {
FILE: pkg/global/global.go
constant DefaultReplicateRegistryHost (line 6) | DefaultReplicateRegistryHost = "r8.im"
constant ReplicateWebsiteHost (line 7) | ReplicateWebsiteHost = "replicate.com"
function getDefaultRegistryHost (line 23) | func getDefaultRegistryHost() string {
FILE: pkg/http/client.go
constant UserAgentHeader (line 12) | UserAgentHeader = "User-Agent"
constant BearerHeaderPrefix (line 13) | BearerHeaderPrefix = "Bearer "
function ProvideHTTPClient (line 15) | func ProvideHTTPClient(ctx context.Context, dockerCommand command.Comman...
FILE: pkg/http/client_test.go
function TestClientDecoratesUserAgent (line 13) | func TestClientDecoratesUserAgent(t *testing.T) {
FILE: pkg/http/transport.go
constant AuthorizationHeader (line 8) | AuthorizationHeader = "Authorization"
type Transport (line 10) | type Transport struct
method RoundTrip (line 16) | func (t *Transport) RoundTrip(req *http.Request) (*http.Response, erro...
FILE: pkg/http/transport_test.go
function TestTransportAddsHeaders (line 12) | func TestTransportAddsHeaders(t *testing.T) {
function TestTransportOnlyAddsHeaderIfMissing (line 33) | func TestTransportOnlyAddsHeaderIfMissing(t *testing.T) {
function TestTransportSendsErrorWithMissingToken (line 56) | func TestTransportSendsErrorWithMissingToken(t *testing.T) {
FILE: pkg/http/user_agent.go
function UserAgent (line 10) | func UserAgent() string {
FILE: pkg/http/user_agent_test.go
function TestUserAgent (line 10) | func TestUserAgent(t *testing.T) {
FILE: pkg/image/build.go
constant dockerignoreBackupPath (line 37) | dockerignoreBackupPath = ".dockerignore.cog.bak"
constant weightsManifestPath (line 38) | weightsManifestPath = ".cog/cache/weights_manifest.json"
constant bundledSchemaFile (line 39) | bundledSchemaFile = ".cog/openapi_schema.json"
function Build (line 46) | func Build(
function BuildAddLabelsAndSchemaToImage (line 415) | func BuildAddLabelsAndSchemaToImage(ctx context.Context, dockerClient co...
constant staticSchemaGenMinSDKVersion (line 440) | staticSchemaGenMinSDKVersion = "0.17.0"
function canUseStaticSchemaGen (line 448) | func canUseStaticSchemaGen(cfg *config.Config) bool {
function resolveSDKVersion (line 477) | func resolveSDKVersion(cfg *config.Config) string {
function generateStaticSchema (line 496) | func generateStaticSchema(cfg *config.Config, dir string) ([]byte, error) {
function writeAndValidateSchema (line 506) | func writeAndValidateSchema(schemaJSON []byte) error {
function isGitWorkTree (line 526) | func isGitWorkTree(ctx context.Context, dir string) bool {
function gitHead (line 538) | func gitHead(ctx context.Context, dir string) (string, error) {
function gitTag (line 558) | func gitTag(ctx context.Context, dir string) (string, error) {
function buildWeightsImage (line 578) | func buildWeightsImage(ctx context.Context, dockerClient command.Command...
function buildRunnerImage (line 599) | func buildRunnerImage(ctx context.Context, dockerClient command.Command,...
function makeDockerignoreForWeightsImage (line 623) | func makeDockerignoreForWeightsImage() error {
function writeDockerignore (line 634) | func writeDockerignore(contents string) error {
function backupDockerignore (line 647) | func backupDockerignore() error {
function restoreDockerignore (line 660) | func restoreDockerignore() error {
function checkCompatibleDockerIgnore (line 676) | func checkCompatibleDockerIgnore(dir string) error {
FILE: pkg/image/build_test.go
function gitRun (line 21) | func gitRun(ctx context.Context, argv []string, t *testing.T) {
function setupGitWorkTree (line 31) | func setupGitWorkTree(t *testing.T) string {
function TestIsGitWorkTree (line 52) | func TestIsGitWorkTree(t *testing.T) {
function TestGitHead (line 60) | func TestGitHead(t *testing.T) {
function TestGitTag (line 92) | func TestGitTag(t *testing.T) {
function TestCanUseStaticSchemaGen (line 123) | func TestCanUseStaticSchemaGen(t *testing.T) {
FILE: pkg/image/config.go
function CogConfigFromManifest (line 14) | func CogConfigFromManifest(ctx context.Context, manifest *image.InspectR...
function friendlyName (line 32) | func friendlyName(manifest *image.InspectResponse) string {
FILE: pkg/image/openapi_schema.go
function GenerateOpenAPISchema (line 20) | func GenerateOpenAPISchema(ctx context.Context, dockerClient command.Com...
FILE: pkg/image/pip_freeze.go
function GeneratePipFreeze (line 14) | func GeneratePipFreeze(ctx context.Context, dockerClient command.Command...
FILE: pkg/model/artifact.go
type ArtifactType (line 6) | type ArtifactType
method String (line 16) | func (t ArtifactType) String() string {
constant ArtifactTypeImage (line 10) | ArtifactTypeImage ArtifactType = iota + 1
constant ArtifactTypeWeight (line 12) | ArtifactTypeWeight
type ArtifactSpec (line 30) | type ArtifactSpec interface
type Artifact (line 37) | type Artifact interface
FILE: pkg/model/artifact_image.go
type ImageSource (line 14) | type ImageSource
constant ImageSourceLocal (line 17) | ImageSourceLocal ImageSource = "local"
constant ImageSourceRemote (line 18) | ImageSourceRemote ImageSource = "remote"
constant ImageSourceBuild (line 19) | ImageSourceBuild ImageSource = "build"
type Platform (line 23) | type Platform struct
type ImageSpecOption (line 42) | type ImageSpecOption
function WithImageSecrets (line 45) | func WithImageSecrets(secrets []string) ImageSpecOption {
function WithImageNoCache (line 52) | func WithImageNoCache(noCache bool) ImageSpecOption {
type ImageSpec (line 64) | type ImageSpec struct
method Type (line 85) | func (s *ImageSpec) Type() ArtifactType { return ArtifactTypeImage }
method Name (line 88) | func (s *ImageSpec) Name() string { return s.name }
function NewImageSpec (line 73) | func NewImageSpec(name, imageName string, opts ...ImageSpecOption) *Imag...
type ImageArtifact (line 98) | type ImageArtifact struct
method Type (line 121) | func (a *ImageArtifact) Type() ArtifactType { return ArtifactTypeImage }
method Name (line 124) | func (a *ImageArtifact) Name() string { return a.name }
method Descriptor (line 127) | func (a *ImageArtifact) Descriptor() v1.Descriptor { return a.descript...
method IsCogModel (line 134) | func (a *ImageArtifact) IsCogModel() bool {
method CogVersion (line 143) | func (a *ImageArtifact) CogVersion() string {
method Config (line 151) | func (a *ImageArtifact) Config() string {
method OpenAPISchema (line 159) | func (a *ImageArtifact) OpenAPISchema() string {
method ParsedConfig (line 169) | func (a *ImageArtifact) ParsedConfig() (*config.Config, error) {
method ParsedOpenAPISchema (line 185) | func (a *ImageArtifact) ParsedOpenAPISchema() (*openapi3.T, error) {
method ToModel (line 201) | func (a *ImageArtifact) ToModel() (*Model, error) {
function NewImageArtifact (line 112) | func NewImageArtifact(name string, desc v1.Descriptor, reference string)...
FILE: pkg/model/artifact_image_test.go
function TestImageSpec_ImplementsArtifactSpec (line 10) | func TestImageSpec_ImplementsArtifactSpec(t *testing.T) {
function TestImageSpec_Fields (line 19) | func TestImageSpec_Fields(t *testing.T) {
function TestImageSpec_DefaultFields (line 30) | func TestImageSpec_DefaultFields(t *testing.T) {
function TestImageArtifact_ImplementsArtifact (line 38) | func TestImageArtifact_ImplementsArtifact(t *testing.T) {
function TestImageArtifact_Reference (line 52) | func TestImageArtifact_Reference(t *testing.T) {
FILE: pkg/model/artifact_test.go
function TestArtifactType_String (line 9) | func TestArtifactType_String(t *testing.T) {
function TestArtifactType_Values (line 27) | func TestArtifactType_Values(t *testing.T) {
FILE: pkg/model/artifact_weight.go
constant MediaTypeWeightArtifact (line 12) | MediaTypeWeightArtifact = "application/vnd.cog.weight.v1"
constant MediaTypeWeightConfig (line 14) | MediaTypeWeightConfig = "application/vnd.cog.weight.config.v1+json"
constant MediaTypeWeightLayer (line 16) | MediaTypeWeightLayer = "application/vnd.cog.weight.layer.v1"
constant MediaTypeWeightLayerGzip (line 18) | MediaTypeWeightLayerGzip = "application/vnd.cog.weight.layer.v1+gzip"
constant MediaTypeWeightLayerZstd (line 20) | MediaTypeWeightLayerZstd = "application/vnd.cog.weight.layer.v1+zstd"
constant AnnotationWeightName (line 25) | AnnotationWeightName = "vnd.cog.weight.name"
constant AnnotationWeightDest (line 26) | AnnotationWeightDest = "vnd.cog.weight.dest"
constant AnnotationWeightDigestOriginal (line 27) | AnnotationWeightDigestOriginal = "vnd.cog.weight.digest.original"
constant AnnotationWeightSizeUncompressed (line 28) | AnnotationWeightSizeUncompressed = "vnd.cog.weight.size.uncompressed"
type WeightSpec (line 33) | type WeightSpec struct
method Type (line 51) | func (s *WeightSpec) Type() ArtifactType { return ArtifactTypeWeight }
method Name (line 54) | func (s *WeightSpec) Name() string { return s.name }
function NewWeightSpec (line 42) | func NewWeightSpec(name, source, target string) *WeightSpec {
type WeightArtifact (line 58) | type WeightArtifact struct
method Type (line 82) | func (a *WeightArtifact) Type() ArtifactType { return ArtifactTypeWeig...
method Name (line 85) | func (a *WeightArtifact) Name() string { return a.name }
method Descriptor (line 88) | func (a *WeightArtifact) Descriptor() v1.Descriptor { return a.descrip...
function NewWeightArtifact (line 71) | func NewWeightArtifact(name string, desc v1.Descriptor, filePath, target...
type WeightConfig (line 93) | type WeightConfig struct
FILE: pkg/model/artifact_weight_test.go
function TestWeightSpec_ImplementsArtifactSpec (line 12) | func TestWeightSpec_ImplementsArtifactSpec(t *testing.T) {
function TestWeightSpec_Fields (line 21) | func TestWeightSpec_Fields(t *testing.T) {
function TestWeightArtifact_ImplementsArtifact (line 28) | func TestWeightArtifact_ImplementsArtifact(t *testing.T) {
function TestWeightArtifact_Fields (line 49) | func TestWeightArtifact_Fields(t *testing.T) {
function TestWeightConfig_JSONRoundTrip (line 68) | func TestWeightConfig_JSONRoundTrip(t *testing.T) {
function TestWeightMediaTypeConstants (line 100) | func TestWeightMediaTypeConstants(t *testing.T) {
FILE: pkg/model/builder.go
type Builder (line 7) | type Builder interface
FILE: pkg/model/builder_test.go
type mockBuilder (line 12) | type mockBuilder struct
method Build (line 16) | func (m *mockBuilder) Build(ctx context.Context, spec ArtifactSpec) (A...
function TestBuilderInterface_Satisfiable (line 20) | func TestBuilderInterface_Satisfiable(t *testing.T) {
FILE: pkg/model/errors_test.go
function TestSentinelErrors (line 11) | func TestSentinelErrors(t *testing.T) {
FILE: pkg/model/factory.go
type Factory (line 13) | type Factory interface
type DockerfileFactory (line 24) | type DockerfileFactory struct
method Name (line 35) | func (f *DockerfileFactory) Name() string {
method Build (line 40) | func (f *DockerfileFactory) Build(ctx context.Context, src *Source, op...
function NewDockerfileFactory (line 30) | func NewDockerfileFactory(docker command.Command, registry registry.Clie...
function defaultFactory (line 80) | func defaultFactory(docker command.Command, registry registry.Client) Fa...
FILE: pkg/model/factory_test.go
function TestDockerfileFactory_Name (line 12) | func TestDockerfileFactory_Name(t *testing.T) {
function TestDockerfileFactory_ImplementsInterface (line 21) | func TestDockerfileFactory_ImplementsInterface(t *testing.T) {
function TestDefaultFactory_ReturnsDockerfileFactory (line 29) | func TestDefaultFactory_ReturnsDockerfileFactory(t *testing.T) {
FILE: pkg/model/format.go
function OCIIndexEnabled (line 9) | func OCIIndexEnabled() bool {
FILE: pkg/model/format_test.go
function TestOCIIndexEnabled_Default (line 9) | func TestOCIIndexEnabled_Default(t *testing.T) {
function TestOCIIndexEnabled_Enabled (line 14) | func TestOCIIndexEnabled_Enabled(t *testing.T) {
function TestOCIIndexEnabled_OtherValue (line 19) | func TestOCIIndexEnabled_OtherValue(t *testing.T) {
FILE: pkg/model/hash.go
function hashFile (line 11) | func hashFile(path string) (digest string, size int64, err error) {
FILE: pkg/model/image_builder.go
type ImageBuilder (line 16) | type ImageBuilder struct
method Build (line 37) | func (b *ImageBuilder) Build(ctx context.Context, spec ArtifactSpec) (...
function NewImageBuilder (line 24) | func NewImageBuilder(factory Factory, docker command.Command, source *So...
FILE: pkg/model/image_builder_test.go
function TestImageBuilder_HappyPath (line 16) | func TestImageBuilder_HappyPath(t *testing.T) {
function TestImageBuilder_ErrorWrongSpecType (line 74) | func TestImageBuilder_ErrorWrongSpecType(t *testing.T) {
function TestImageBuilder_ErrorFactoryBuildFails (line 85) | func TestImageBuilder_ErrorFactoryBuildFails(t *testing.T) {
function TestImageBuilder_ErrorInspectFails (line 102) | func TestImageBuilder_ErrorInspectFails(t *testing.T) {
function TestImageBuilder_ImplementsBuilderInterface (line 128) | func TestImageBuilder_ImplementsBuilderInterface(t *testing.T) {
FILE: pkg/model/image_pusher.go
type ImagePusher (line 30) | type ImagePusher struct
method Push (line 73) | func (p *ImagePusher) Push(ctx context.Context, artifact *ImageArtifac...
method canOCIPush (line 106) | func (p *ImagePusher) canOCIPush() bool {
method ociPush (line 112) | func (p *ImagePusher) ociPush(ctx context.Context, imageRef string, op...
method pushImage (line 158) | func (p *ImagePusher) pushImage(ctx context.Context, imageRef string, ...
method pushLayers (line 179) | func (p *ImagePusher) pushLayers(ctx context.Context, repo string, img...
method pushLayer (line 205) | func (p *ImagePusher) pushLayer(ctx context.Context, repo string, laye...
method pushConfig (line 243) | func (p *ImagePusher) pushConfig(ctx context.Context, repo string, img...
function newImagePusher (line 36) | func newImagePusher(docker command.Command, reg registry.Client) *ImageP...
type imagePushOptions (line 44) | type imagePushOptions struct
type ImagePushOption (line 50) | type ImagePushOption
function WithProgressFn (line 53) | func WithProgressFn(fn func(PushProgress)) ImagePushOption {
function WithOnFallback (line 62) | func WithOnFallback(fn func()) ImagePushOption {
function shouldFallbackToDocker (line 270) | func shouldFallbackToDocker(err error) bool {
function sanitizeError (line 292) | func sanitizeError(err error) error {
type configBlobLayer (line 302) | type configBlobLayer struct
method Digest (line 307) | func (c *configBlobLayer) Digest() (v1.Hash, error) {
method DiffID (line 314) | func (c *configBlobLayer) DiffID() (v1.Hash, error) {
method Compressed (line 318) | func (c *configBlobLayer) Compressed() (io.ReadCloser, error) {
method Uncompressed (line 322) | func (c *configBlobLayer) Uncompressed() (io.ReadCloser, error) {
method Size (line 326) | func (c *configBlobLayer) Size() (int64, error) {
method MediaType (line 330) | func (c *configBlobLayer) MediaType() (types.MediaType, error) {
FILE: pkg/model/image_pusher_test.go
type ociMockClient (line 27) | type ociMockClient struct
method WriteLayer (line 36) | func (m *ociMockClient) WriteLayer(_ context.Context, opts registry.Wr...
method PushImage (line 57) | func (m *ociMockClient) PushImage(_ context.Context, ref string, _ v1....
method Inspect (line 67) | func (m *ociMockClient) Inspect(context.Context, string, *registry.Pla...
method GetImage (line 70) | func (m *ociMockClient) GetImage(context.Context, string, *registry.Pl...
method Exists (line 73) | func (m *ociMockClient) Exists(context.Context, string) (bool, error) ...
method GetDescriptor (line 74) | func (m *ociMockClient) GetDescriptor(context.Context, string) (v1.Des...
method PushIndex (line 77) | func (m *ociMockClient) PushIndex(context.Context, string, v1.ImageInd...
function testArtifact (line 80) | func testArtifact(ref string) *ImageArtifact {
function fakeImageSaveFunc (line 86) | func fakeImageSaveFunc(img v1.Image, tagStr string) func(context.Context...
function TestImagePusher_Push (line 105) | func TestImagePusher_Push(t *testing.T) {
function TestImagePusher_PushArtifact (line 242) | func TestImagePusher_PushArtifact(t *testing.T) {
function TestImagePusher_Fallback (line 301) | func TestImagePusher_Fallback(t *testing.T) {
function TestShouldFallbackToDocker (line 434) | func TestShouldFallbackToDocker(t *testing.T) {
function TestSanitizeError (line 463) | func TestSanitizeError(t *testing.T) {
function TestImagePusher_OnFallback (line 509) | func TestImagePusher_OnFallback(t *testing.T) {
function TestConfigBlobLayer (line 564) | func TestConfigBlobLayer(t *testing.T) {
function TestGetPushConcurrency (line 617) | func TestGetPushConcurrency(t *testing.T) {
FILE: pkg/model/image_test.go
function TestImage_IsCogModel (line 12) | func TestImage_IsCogModel(t *testing.T) {
function TestImage_CogVersion (line 65) | func TestImage_CogVersion(t *testing.T) {
function TestImage_Config (line 109) | func TestImage_Config(t *testing.T) {
function TestImage_OpenAPISchema (line 139) | func TestImage_OpenAPISchema(t *testing.T) {
function TestImageSource_Values (line 169) | func TestImageSource_Values(t *testing.T) {
function TestLabelKeys (line 176) | func TestLabelKeys(t *testing.T) {
function TestImage_ParsedConfig (line 188) | func TestImage_ParsedConfig(t *testing.T) {
function TestImage_ToModel (line 267) | func TestImage_ToModel(t *testing.T) {
function TestImage_ParsedOpenAPISchema (line 357) | func TestImage_ParsedOpenAPISchema(t *testing.T) {
FILE: pkg/model/index.go
type Index (line 5) | type Index struct
type IndexManifest (line 17) | type IndexManifest struct
type ManifestType (line 33) | type ManifestType
constant ManifestTypeImage (line 37) | ManifestTypeImage ManifestType = "image"
constant ManifestTypeWeights (line 39) | ManifestTypeWeights ManifestType = "weights"
constant AnnotationReferenceType (line 44) | AnnotationReferenceType = "vnd.cog.reference.type"
constant AnnotationReferenceDigest (line 45) | AnnotationReferenceDigest = "vnd.cog.reference.digest"
constant AnnotationValueWeights (line 51) | AnnotationValueWeights = "weights"
constant PlatformUnknown (line 57) | PlatformUnknown = "unknown"
FILE: pkg/model/index_factory.go
type IndexBuilder (line 13) | type IndexBuilder struct
method SetImageDescriptor (line 33) | func (b *IndexBuilder) SetImageDescriptor(desc v1.Descriptor, platform...
method AddWeightDescriptor (line 41) | func (b *IndexBuilder) AddWeightDescriptor(desc v1.Descriptor, imageDi...
method BuildFromDescriptors (line 53) | func (b *IndexBuilder) BuildFromDescriptors() (v1.ImageIndex, error) {
type weightDescEntry (line 20) | type weightDescEntry struct
function NewIndexBuilder (line 28) | func NewIndexBuilder() *IndexBuilder {
type descriptorAppendable (line 106) | type descriptorAppendable struct
method MediaType (line 110) | func (d *descriptorAppendable) MediaType() (types.MediaType, error) {
method Digest (line 114) | func (d *descriptorAppendable) Digest() (v1.Hash, error) {
method Size (line 118) | func (d *descriptorAppendable) Size() (int64, error) {
FILE: pkg/model/index_factory_test.go
function TestIndexBuilder_BuildFromDescriptors (line 11) | func TestIndexBuilder_BuildFromDescriptors(t *testing.T) {
FILE: pkg/model/index_test.go
function TestModel_IsBundle (line 11) | func TestModel_IsBundle(t *testing.T) {
function TestManifestType (line 37) | func TestManifestType(t *testing.T) {
FILE: pkg/model/model.go
type Model (line 12) | type Model struct
method HasGPU (line 32) | func (m *Model) HasGPU() bool {
method SchemaJSON (line 37) | func (m *Model) SchemaJSON() ([]byte, error) {
method ImageRef (line 45) | func (m *Model) ImageRef() string {
method IsBundle (line 53) | func (m *Model) IsBundle() bool {
method GetImageArtifact (line 59) | func (m *Model) GetImageArtifact() *ImageArtifact {
method WeightArtifacts (line 69) | func (m *Model) WeightArtifacts() []*WeightArtifact {
method ArtifactsByType (line 80) | func (m *Model) ArtifactsByType(t ArtifactType) []Artifact {
FILE: pkg/model/model_test.go
function TestModel_HasGPU (line 14) | func TestModel_HasGPU(t *testing.T) {
function TestModel_SchemaJSON (line 50) | func TestModel_SchemaJSON(t *testing.T) {
function TestModel_ImageRef (line 88) | func TestModel_ImageRef(t *testing.T) {
function TestModel_GetImageArtifact (line 123) | func TestModel_GetImageArtifact(t *testing.T) {
function TestModel_WeightArtifacts (line 175) | func TestModel_WeightArtifacts(t *testing.T) {
function TestModel_ArtifactsByType (line 210) | func TestModel_ArtifactsByType(t *testing.T) {
FILE: pkg/model/options.go
type BuildOptions (line 7) | type BuildOptions struct
method WithDefaults (line 73) | func (o BuildOptions) WithDefaults(src *Source) BuildOptions {
FILE: pkg/model/options_test.go
function TestBuildOptions_WithDefaults_ImageName (line 11) | func TestBuildOptions_WithDefaults_ImageName(t *testing.T) {
function TestBuildOptions_WithDefaults_PreservesExplicitImageName (line 24) | func TestBuildOptions_WithDefaults_PreservesExplicitImageName(t *testing...
function TestBuildOptions_WithDefaults_ProgressOutput (line 36) | func TestBuildOptions_WithDefaults_ProgressOutput(t *testing.T) {
function TestBuildOptions_WithDefaults_PreservesExplicitProgressOutput (line 48) | func TestBuildOptions_WithDefaults_PreservesExplicitProgressOutput(t *te...
function TestBuildOptions_WithDefaults_NilBuildConfig (line 60) | func TestBuildOptions_WithDefaults_NilBuildConfig(t *testing.T) {
function TestBuildOptions_WithDefaults_NilConfig (line 74) | func TestBuildOptions_WithDefaults_NilConfig(t *testing.T) {
function TestBuildOptions_AllFieldsPreserved (line 88) | func TestBuildOptions_AllFieldsPreserved(t *testing.T) {
function TestBuildOptions_WeightsLockPath (line 129) | func TestBuildOptions_WeightsLockPath(t *testing.T) {
FILE: pkg/model/push_helpers.go
constant DefaultPushConcurrency (line 17) | DefaultPushConcurrency = 5
constant envPushConcurrency (line 20) | envPushConcurrency = "COG_PUSH_CONCURRENCY"
function GetPushConcurrency (line 25) | func GetPushConcurrency() int {
type PushProgress (line 36) | type PushProgress struct
function writeLayerWithProgress (line 51) | func writeLayerWithProgress(ctx context.Context, reg registry.Client, op...
FILE: pkg/model/pusher.go
type PushOptions (line 17) | type PushOptions struct
type BundlePusher (line 50) | type BundlePusher struct
method Push (line 70) | func (p *BundlePusher) Push(ctx context.Context, m *Model, opts PushOp...
method pushWeights (line 142) | func (p *BundlePusher) pushWeights(ctx context.Context, repo string, w...
function NewBundlePusher (line 60) | func NewBundlePusher(docker command.Command, reg registry.Client) *Bundl...
function repoFromReference (line 170) | func repoFromReference(ref string) string {
FILE: pkg/model/pusher_test.go
function TestBundlePusher_Push (line 22) | func TestBundlePusher_Push(t *testing.T) {
function TestResolver_Push (line 420) | func TestResolver_Push(t *testing.T) {
function TestPushOptions (line 537) | func TestPushOptions(t *testing.T) {
function TestRepoFromReference (line 558) | func TestRepoFromReference(t *testing.T) {
FILE: pkg/model/ref.go
type ParseOption (line 12) | type ParseOption
type parseOptions (line 14) | type parseOptions struct
function Insecure (line 21) | func Insecure() ParseOption {
function WithDefaultRegistry (line 29) | func WithDefaultRegistry(registry string) ParseOption {
function WithDefaultTag (line 37) | func WithDefaultTag(tag string) ParseOption {
type ParsedRef (line 44) | type ParsedRef struct
method String (line 71) | func (p *ParsedRef) String() string {
method Registry (line 76) | func (p *ParsedRef) Registry() string {
method Repository (line 81) | func (p *ParsedRef) Repository() string {
method Tag (line 86) | func (p *ParsedRef) Tag() string {
method Digest (line 94) | func (p *ParsedRef) Digest() string {
method IsTag (line 102) | func (p *ParsedRef) IsTag() bool {
method IsDigest (line 108) | func (p *ParsedRef) IsDigest() bool {
method IsReplicate (line 114) | func (p *ParsedRef) IsReplicate() bool {
function ParseRef (line 53) | func ParseRef(ref string, opts ...ParseOption) (*ParsedRef, error) {
FILE: pkg/model/ref_test.go
function TestParseRef (line 9) | func TestParseRef(t *testing.T) {
function TestParsedRef_IsTag (line 146) | func TestParsedRef_IsTag(t *testing.T) {
function TestParsedRef_String (line 158) | func TestParsedRef_String(t *testing.T) {
function TestParseOptions (line 190) | func TestParseOptions(t *testing.T) {
FILE: pkg/model/ref_types.go
type Ref (line 9) | type Ref interface
method Resolve (line 17) | func (r *Resolver) Resolve(ctx context.Context, ref Ref) (*Model, error) {
type TagRef (line 28) | type TagRef struct
method resolve (line 42) | func (t *TagRef) resolve(ctx context.Context, r *Resolver) (*Model, er...
function FromTag (line 34) | func FromTag(ref string) (*TagRef, error) {
type LocalRef (line 53) | type LocalRef struct
method resolve (line 67) | func (l *LocalRef) resolve(ctx context.Context, r *Resolver) (*Model, ...
function FromLocal (line 59) | func FromLocal(ref string) (*LocalRef, error) {
type RemoteRef (line 77) | type RemoteRef struct
method resolve (line 91) | func (rr *RemoteRef) resolve(ctx context.Context, r *Resolver) (*Model...
function FromRemote (line 83) | func FromRemote(ref string) (*RemoteRef, error) {
type BuildRef (line 101) | type BuildRef struct
method resolve (line 113) | func (b *BuildRef) resolve(ctx context.Context, r *Resolver) (*Model, ...
function FromBuild (line 109) | func FromBuild(src *Source, opts BuildOptions) *BuildRef {
FILE: pkg/model/ref_types_test.go
function TestFromTag_ValidRef (line 21) | func TestFromTag_ValidRef(t *testing.T) {
function TestFromTag_ValidRefWithRegistry (line 30) | func TestFromTag_ValidRefWithRegistry(t *testing.T) {
function TestFromTag_InvalidRef (line 39) | func TestFromTag_InvalidRef(t *testing.T) {
function TestFromLocal_ValidRef (line 51) | func TestFromLocal_ValidRef(t *testing.T) {
function TestFromLocal_InvalidRef (line 60) | func TestFromLocal_InvalidRef(t *testing.T) {
function TestFromRemote_ValidRef (line 72) | func TestFromRemote_ValidRef(t *testing.T) {
function TestFromRemote_InvalidRef (line 81) | func TestFromRemote_InvalidRef(t *testing.T) {
function TestFromBuild (line 93) | func TestFromBuild(t *testing.T) {
function TestFromBuild_NilSource (line 111) | func TestFromBuild_NilSource(t *testing.T) {
function TestTagRef_Resolve_Success (line 123) | func TestTagRef_Resolve_Success(t *testing.T) {
function TestTagRef_Resolve_FallsBackToLocal (line 152) | func TestTagRef_Resolve_FallsBackToLocal(t *testing.T) {
function TestLocalRef_Resolve_Success (line 196) | func TestLocalRef_Resolve_Success(t *testing.T) {
function TestLocalRef_Resolve_NotFound (line 226) | func TestLocalRef_Resolve_NotFound(t *testing.T) {
function TestRemoteRef_Resolve_Success (line 253) | func TestRemoteRef_Resolve_Success(t *testing.T) {
function TestRemoteRef_Resolve_NotFound (line 284) | func TestRemoteRef_Resolve_NotFound(t *testing.T) {
function TestBuildRef_Resolve_Success (line 306) | func TestBuildRef_Resolve_Success(t *testing.T) {
function TestBuildRef_Resolve_BuildError (line 350) | func TestBuildRef_Resolve_BuildError(t *testing.T) {
function TestResolver_Resolve_DispatchesCorrectly (line 376) | func TestResolver_Resolve_DispatchesCorrectly(t *testing.T) {
FILE: pkg/model/resolver.go
type Option (line 18) | type Option
type options (line 20) | type options struct
function defaultOptions (line 27) | func defaultOptions() *options {
function LocalOnly (line 33) | func LocalOnly() Option {
function RemoteOnly (line 43) | func RemoteOnly() Option {
function PreferLocal (line 52) | func PreferLocal() Option {
function PreferRemote (line 62) | func PreferRemote() Option {
function WithPlatform (line 71) | func WithPlatform(p *registry.Platform) Option {
type Resolver (line 78) | type Resolver struct
method WithFactory (line 96) | func (r *Resolver) WithFactory(f Factory) *Resolver {
method Inspect (line 105) | func (r *Resolver) Inspect(ctx context.Context, ref *ParsedRef, opts ....
method InspectByID (line 144) | func (r *Resolver) InspectByID(ctx context.Context, id string) (*Model...
method Pull (line 169) | func (r *Resolver) Pull(ctx context.Context, ref *ParsedRef, opts ...O...
method Build (line 213) | func (r *Resolver) Build(ctx context.Context, src *Source, opts BuildO...
method Push (line 272) | func (r *Resolver) Push(ctx context.Context, m *Model, opts PushOption...
method loadLocal (line 294) | func (r *Resolver) loadLocal(ctx context.Context, ref *ParsedRef) (*Mo...
method loadRemote (line 306) | func (r *Resolver) loadRemote(ctx context.Context, ref *ParsedRef, pla...
method modelFromImage (line 319) | func (r *Resolver) modelFromImage(img *ImageArtifact, cfg *config.Conf...
method modelFromInspect (line 335) | func (r *Resolver) modelFromInspect(ref *ParsedRef, resp *image.Inspec...
method modelFromManifest (line 352) | func (r *Resolver) modelFromManifest(ref *ParsedRef, manifest *registr...
method modelFromIndex (line 375) | func (r *Resolver) modelFromIndex(ref *ParsedRef, manifest *registry.M...
function NewResolver (line 86) | func NewResolver(docker command.Command, reg registry.Client) *Resolver {
function isOCIIndex (line 435) | func isOCIIndex(mr *registry.ManifestResult) bool {
function findWeightsManifest (line 441) | func findWeightsManifest(manifests []registry.PlatformManifest) *registr...
function findImageManifest (line 454) | func findImageManifest(manifests []registry.PlatformManifest, platform *...
function isNotFoundError (line 474) | func isNotFoundError(err error) bool {
FILE: pkg/model/resolver_test.go
type mockDocker (line 24) | type mockDocker struct
method Inspect (line 31) | func (m *mockDocker) Inspect(ctx context.Context, ref string) (*image....
method Pull (line 38) | func (m *mockDocker) Pull(ctx context.Context, ref string, force bool)...
method Push (line 45) | func (m *mockDocker) Push(ctx context.Context, ref string) error {
method LoadUserInformation (line 52) | func (m *mockDocker) LoadUserInformation(ctx context.Context, registry...
method ImageExists (line 56) | func (m *mockDocker) ImageExists(ctx context.Context, ref string) (boo...
method ContainerLogs (line 60) | func (m *mockDocker) ContainerLogs(ctx context.Context, containerID st...
method ContainerInspect (line 64) | func (m *mockDocker) ContainerInspect(ctx context.Context, id string) ...
method ContainerStop (line 68) | func (m *mockDocker) ContainerStop(ctx context.Context, containerID st...
method RemoveImage (line 72) | func (m *mockDocker) RemoveImage(ctx context.Context, ref string) error {
method ImageBuild (line 76) | func (m *mockDocker) ImageBuild(ctx context.Context, options command.I...
method Run (line 80) | func (m *mockDocker) Run(ctx context.Context, options command.RunOptio...
method ContainerStart (line 84) | func (m *mockDocker) ContainerStart(ctx context.Context, options comma...
method ImageSave (line 88) | func (m *mockDocker) ImageSave(ctx context.Context, imageRef string) (...
type mockRegistry (line 96) | type mockRegistry struct
method Inspect (line 105) | func (m *mockRegistry) Inspect(ctx context.Context, ref string, platfo...
method GetImage (line 112) | func (m *mockRegistry) GetImage(ctx context.Context, ref string, platf...
method GetDescriptor (line 119) | func (m *mockRegistry) GetDescriptor(ctx context.Context, ref string) ...
method Exists (line 126) | func (m *mockRegistry) Exists(ctx context.Context, ref string) (bool, ...
method PushImage (line 130) | func (m *mockRegistry) PushImage(ctx context.Context, ref string, img ...
method PushIndex (line 137) | func (m *mockRegistry) PushIndex(ctx context.Context, ref string, idx ...
method WriteLayer (line 144) | func (m *mockRegistry) WriteLayer(ctx context.Context, opts registry.W...
type mockFactory (line 153) | type mockFactory struct
method Build (line 158) | func (f *mockFactory) Build(ctx context.Context, src *Source, opts Bui...
method Name (line 165) | func (f *mockFactory) Name() string {
function TestNewResolver (line 169) | func TestNewResolver(t *testing.T) {
function TestResolver_WithFactory (line 179) | func TestResolver_WithFactory(t *testing.T) {
function TestResolver_Inspect_LocalOnly_Found (line 194) | func TestResolver_Inspect_LocalOnly_Found(t *testing.T) {
function TestResolver_Inspect_LocalOnly_NotFound (line 227) | func TestResolver_Inspect_LocalOnly_NotFound(t *testing.T) {
function TestResolver_Inspect_RemoteOnly_Found (line 250) | func TestResolver_Inspect_RemoteOnly_Found(t *testing.T) {
function TestResolver_Inspect_RemoteOnly_NotFound (line 283) | func TestResolver_Inspect_RemoteOnly_NotFound(t *testing.T) {
function TestResolver_Inspect_RemoteOnly_NotCogModel (line 301) | func TestResolver_Inspect_RemoteOnly_NotCogModel(t *testing.T) {
function TestResolver_Inspect_PreferLocal_FoundLocally (line 327) | func TestResolver_Inspect_PreferLocal_FoundLocally(t *testing.T) {
function TestResolver_Inspect_PreferLocal_Fallback (line 367) | func TestResolver_Inspect_PreferLocal_Fallback(t *testing.T) {
function TestResolver_Inspect_PreferLocal_NoFallbackOnRealError (line 402) | func TestResolver_Inspect_PreferLocal_NoFallbackOnRealError(t *testing.T) {
function TestResolver_Inspect_PreferRemote_FoundRemotely (line 426) | func TestResolver_Inspect_PreferRemote_FoundRemotely(t *testing.T) {
function TestResolver_Inspect_PreferRemote_Fallback (line 461) | func TestResolver_Inspect_PreferRemote_Fallback(t *testing.T) {
function TestResolver_Inspect_PreferRemote_NoFallbackOnRealError (line 501) | func TestResolver_Inspect_PreferRemote_NoFallbackOnRealError(t *testing....
function TestResolver_Inspect_WithPlatform (line 525) | func TestResolver_Inspect_WithPlatform(t *testing.T) {
function TestResolver_Inspect_ParsesConfigFromLabels (line 555) | func TestResolver_Inspect_ParsesConfigFromLabels(t *testing.T) {
function TestResolver_Inspect_InvalidConfigJSON (line 587) | func TestResolver_Inspect_InvalidConfigJSON(t *testing.T) {
function TestResolver_Inspect_NoConfigLabel_ReturnsErrNotCogModel (line 615) | func TestResolver_Inspect_NoConfigLabel_ReturnsErrNotCogModel(t *testing...
function TestResolver_Inspect_NotCogModel (line 644) | func TestResolver_Inspect_NotCogModel(t *testing.T) {
function TestResolver_InspectByID_Found (line 673) | func TestResolver_InspectByID_Found(t *testing.T) {
function TestResolver_InspectByID_FullSHA (line 707) | func TestResolver_InspectByID_FullSHA(t *testing.T) {
function TestResolver_InspectByID_NotCogModel (line 736) | func TestResolver_InspectByID_NotCogModel(t *testing.T) {
function TestResolver_InspectByID_NotFound (line 762) | func TestResolver_InspectByID_NotFound(t *testing.T) {
function TestResolver_Pull_AlreadyLocal (line 781) | func TestResolver_Pull_AlreadyLocal(t *testing.T) {
function TestResolver_Pull_NotLocal_PullsAndReturns (line 817) | func TestResolver_Pull_NotLocal_PullsAndReturns(t *testing.T) {
function TestResolver_Pull_NotCogModel (line 871) | func TestResolver_Pull_NotCogModel(t *testing.T) {
function TestResolver_Pull_LocalOnly_NotFound (line 919) | func TestResolver_Pull_LocalOnly_NotFound(t *testing.T) {
function TestResolver_Pull_PullFails (line 940) | func TestResolver_Pull_PullFails(t *testing.T) {
function TestResolver_Pull_LocalInspectRealError (line 960) | func TestResolver_Pull_LocalInspectRealError(t *testing.T) {
function TestResolver_Build_NoWeightsManifestWithoutWeights (line 985) | func TestResolver_Build_NoWeightsManifestWithoutWeights(t *testing.T) {
function TestResolver_Build_PopulatesArtifacts (line 1022) | func TestResolver_Build_PopulatesArtifacts(t *testing.T) {
function TestResolver_Build_PopulatesWeightArtifacts (line 1075) | func TestResolver_Build_PopulatesWeightArtifacts(t *testing.T) {
function TestResolver_Build_WithWeightsLoadsManifest (line 1153) | func TestResolver_Build_WithWeightsLoadsManifest(t *testing.T) {
function TestIndexDetectionHelpers (line 1215) | func TestIndexDetectionHelpers(t *testing.T) {
function TestIsNotFoundError (line 1301) | func TestIsNotFoundError(t *testing.T) {
FILE: pkg/model/source.go
type Source (line 13) | type Source struct
method ArtifactSpecs (line 77) | func (s *Source) ArtifactSpecs() []ArtifactSpec {
function NewSource (line 23) | func NewSource(configPath string) (*Source, error) {
function NewSourceFromConfig (line 66) | func NewSourceFromConfig(cfg *config.Config, projectDir string) *Source {
FILE: pkg/model/source_test.go
function TestNewSourceFromConfig (line 11) | func TestNewSourceFromConfig(t *testing.T) {
function TestNewSourceFromConfig_NilConfig (line 27) | func TestNewSourceFromConfig_NilConfig(t *testing.T) {
function TestSource_ArtifactSpecs_NoWeights (line 35) | func TestSource_ArtifactSpecs_NoWeights(t *testing.T) {
function TestSource_ArtifactSpecs_WithWeights (line 57) | func TestSource_ArtifactSpecs_WithWeights(t *testing.T) {
function TestSource_ArtifactSpecs_EmptyImageName (line 92) | func TestSource_ArtifactSpecs_EmptyImageName(t *testing.T) {
function TestSource_ArtifactSpecs_NilConfig (line 106) | func TestSource_ArtifactSpecs_NilConfig(t *testing.T) {
FILE: pkg/model/weight_builder.go
type WeightBuilder (line 15) | type WeightBuilder struct
method Build (line 34) | func (b *WeightBuilder) Build(ctx context.Context, spec ArtifactSpec) ...
method findCachedEntry (line 107) | func (b *WeightBuilder) findCachedEntry(name string, fileSize int64) *...
method updateLockfile (line 125) | func (b *WeightBuilder) updateLockfile(ws *WeightSpec, digest string, ...
function NewWeightBuilder (line 23) | func NewWeightBuilder(source *Source, cogVersion, lockPath string) *Weig...
FILE: pkg/model/weight_builder_test.go
function TestWeightBuilder_HappyPath (line 16) | func TestWeightBuilder_HappyPath(t *testing.T) {
function TestWeightBuilder_WritesLockfile (line 71) | func TestWeightBuilder_WritesLockfile(t *testing.T) {
function TestWeightBuilder_UpdatesExistingLockfile (line 111) | func TestWeightBuilder_UpdatesExistingLockfile(t *testing.T) {
function TestWeightBuilder_CacheHit (line 157) | func TestWeightBuilder_CacheHit(t *testing.T) {
function TestWeightBuilder_CacheMiss_SizeChanged (line 199) | func TestWeightBuilder_CacheMiss_SizeChanged(t *testing.T) {
function TestWeightBuilder_ErrorWrongSpecType (line 237) | func TestWeightBuilder_ErrorWrongSpecType(t *testing.T) {
function TestWeightBuilder_ErrorFileNotFound (line 250) | func TestWeightBuilder_ErrorFileNotFound(t *testing.T) {
function TestWeightBuilder_ErrorContextCancelled (line 262) | func TestWeightBuilder_ErrorContextCancelled(t *testing.T) {
function TestWeightBuilder_ImplementsBuilderInterface (line 280) | func TestWeightBuilder_ImplementsBuilderInterface(t *testing.T) {
FILE: pkg/model/weight_pusher.go
type WeightPushOptions (line 24) | type WeightPushOptions struct
type WeightRetryEvent (line 33) | type WeightRetryEvent struct
type WeightPushResult (line 47) | type WeightPushResult struct
type WeightPusher (line 58) | type WeightPusher struct
method Push (line 71) | func (p *WeightPusher) Push(ctx context.Context, repo string, artifact...
function NewWeightPusher (line 63) | func NewWeightPusher(reg registry.Client) *WeightPusher {
function buildWeightImage (line 168) | func buildWeightImage(artifact *WeightArtifact) (v1.Image, error) {
function descriptorFromImage (line 204) | func descriptorFromImage(img v1.Image) (v1.Descriptor, error) {
type weightOCIManifest (line 225) | type weightOCIManifest struct
type weightManifestImage (line 241) | type weightManifestImage struct
method RawConfigFile (line 250) | func (w *weightManifestImage) RawConfigFile() ([]byte, error) {
method Digest (line 255) | func (w *weightManifestImage) Digest() (v1.Hash, error) {
method ArtifactType (line 268) | func (w *weightManifestImage) ArtifactType() (string, error) {
method Manifest (line 273) | func (w *weightManifestImage) Manifest() (*v1.Manifest, error) {
method RawManifest (line 297) | func (w *weightManifestImage) RawManifest() ([]byte, error) {
constant weightTagPrefix (line 325) | weightTagPrefix = "weights-"
function WeightTag (line 331) | func WeightTag(name, digest string) string {
FILE: pkg/model/weight_pusher_test.go
function TestWeightPusher_Push_ReturnsErrorForNilArtifact (line 20) | func TestWeightPusher_Push_ReturnsErrorForNilArtifact(t *testing.T) {
function TestWeightPusher_Push_ReturnsErrorForMissingFile (line 30) | func TestWeightPusher_Push_ReturnsErrorForMissingFile(t *testing.T) {
function TestWeightPusher_Push_PushesCorrectOCIArtifact (line 48) | func TestWeightPusher_Push_PushesCorrectOCIArtifact(t *testing.T) {
function TestWeightPusher_Push_PropagatesPushError (line 125) | func TestWeightPusher_Push_PropagatesPushError(t *testing.T) {
function TestWeightPusher_Push_RawManifestContainsArtifactType (line 152) | func TestWeightPusher_Push_RawManifestContainsArtifactType(t *testing.T) {
function TestWeightPusher_Push_ReturnsErrorForEmptyRepo (line 202) | func TestWeightPusher_Push_ReturnsErrorForEmptyRepo(t *testing.T) {
function TestWeightPusher_Push_ReportsProgressViaWriteLayer (line 224) | func TestWeightPusher_Push_ReportsProgressViaWriteLayer(t *testing.T) {
function TestWeightPusher_Push_ForwardsRetryCallback (line 282) | func TestWeightPusher_Push_ForwardsRetryCallback(t *testing.T) {
function TestWeightPusher_Push_WriteLayerErrorReported (line 332) | func TestWeightPusher_Push_WriteLayerErrorReported(t *testing.T) {
function TestWeightPusher_Push_PropagatesContextCancellation (line 359) | func TestWeightPusher_Push_PropagatesContextCancellation(t *testing.T) {
FILE: pkg/model/weights.go
type WeightFile (line 5) | type WeightFile struct
FILE: pkg/model/weights_lock.go
constant WeightsLockFilename (line 12) | WeightsLockFilename = "weights.lock"
type WeightsLock (line 16) | type WeightsLock struct
method Save (line 44) | func (wl *WeightsLock) Save(path string) error {
function ParseWeightsLock (line 26) | func ParseWeightsLock(data []byte) (*WeightsLock, error) {
function LoadWeightsLock (line 35) | func LoadWeightsLock(path string) (*WeightsLock, error) {
FILE: pkg/model/weights_lock_test.go
function TestWeightsLock (line 13) | func TestWeightsLock(t *testing.T) {
FILE: pkg/model/weights_test.go
function TestWeightFile (line 9) | func TestWeightFile(t *testing.T) {
FILE: pkg/path/path.go
function TrimExt (line 9) | func TrimExt(s string) string {
function IsExtInteger (line 13) | func IsExtInteger(ext string) bool {
FILE: pkg/path/path_test.go
function TestTrimExt (line 9) | func TestTrimExt(t *testing.T) {
function TestIsExtInteger (line 14) | func TestIsExtInteger(t *testing.T) {
FILE: pkg/predict/api.go
type HelpResponse (line 5) | type HelpResponse struct
FILE: pkg/predict/input.go
type Input (line 19) | type Input struct
type Inputs (line 28) | type Inputs
method toMap (line 149) | func (inputs *Inputs) toMap() (map[string]any, error) {
function NewInputs (line 30) | func NewInputs(keyVals map[string][]string, schema *openapi3.T) (Inputs,...
function NewInputsForMode (line 34) | func NewInputsForMode(keyVals map[string][]string, schema *openapi3.T, i...
function NewInputsWithBaseDir (line 136) | func NewInputsWithBaseDir(keyVals map[string]string, baseDir string) Inp...
function fileToDataURL (line 192) | func fileToDataURL(filePath string) (string, error) {
function resolveSchemaType (line 212) | func resolveSchemaType(s *openapi3.Schema) *openapi3.Schema {
FILE: pkg/predict/predictor.go
type status (line 21) | type status
type HealthcheckResponse (line 23) | type HealthcheckResponse struct
type RequestContext (line 27) | type RequestContext struct
type Request (line 31) | type Request struct
type Response (line 37) | type Response struct
type ValidationErrorResponse (line 43) | type ValidationErrorResponse struct
type Predictor (line 51) | type Predictor struct
method Start (line 75) | func (p *Predictor) Start(ctx context.Context, logsWriter io.Writer, t...
method waitForContainerReady (line 103) | func (p *Predictor) waitForContainerReady(ctx context.Context, timeout...
method Stop (line 165) | func (p *Predictor) Stop(ctx context.Context) error {
method Predict (line 169) | func (p *Predictor) Predict(inputs Inputs, context RequestContext) (*R...
method GetSchema (line 219) | func (p *Predictor) GetSchema() (*openapi3.T, error) {
method endpoint (line 235) | func (p *Predictor) endpoint() string {
method url (line 242) | func (p *Predictor) url() string {
method buildInputValidationErrorMessage (line 246) | func (p *Predictor) buildInputValidationErrorMessage(errorResponse *Va...
function NewPredictor (line 61) | func NewPredictor(ctx context.Context, runOptions command.RunOptions, is...
FILE: pkg/provider/generic/generic.go
type GenericProvider (line 18) | type GenericProvider struct
method Name (line 25) | func (p *GenericProvider) Name() string {
method MatchesRegistry (line 29) | func (p *Ge
Condensed preview — 575 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,542K chars).
[
{
"path": ".all-contributorsrc",
"chars": 10850,
"preview": "{\n \"projectName\": \"cog\",\n \"projectOwner\": \"replicate\",\n \"repoType\": \"github\",\n \"repoHost\": \"https://github.com\",\n \""
},
{
"path": ".git_archival.txt",
"chars": 102,
"preview": "node: $Format:%H$\nnode-date: $Format:%cI$\ndescribe-name: $Format:%(describe:tags=true,match=*[0-9]*)$\n"
},
{
"path": ".gitattributes",
"chars": 99,
"preview": ".git_archival.txt export-subst\nMakefile -linguist-detectable\ndocs/llms.txt linguist-generated=true\n"
},
{
"path": ".github/CODEOWNERS",
"chars": 65,
"preview": "# Default code owners for the entire repository\n* @replicate/cog\n"
},
{
"path": ".github/dependabot.yml",
"chars": 434,
"preview": "version: 2\nupdates:\n - package-ecosystem: \"gomod\"\n directory: \"/\"\n schedule:\n interval: \"weekly\"\n - package"
},
{
"path": ".github/workflows/README.md",
"chars": 12207,
"preview": "# CI Architecture\n\nThis document describes the CI/CD architecture for the Cog repository.\n\n## Design Principles\n\n1. **Si"
},
{
"path": ".github/workflows/ci.yaml",
"chars": 35051,
"preview": "name: CI\n\non:\n merge_group:\n push:\n branches: [main]\n pull_request:\n workflow_dispatch:\n\n# Cancel in-progress run"
},
{
"path": ".github/workflows/codeql.yml",
"chars": 2732,
"preview": "# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# Y"
},
{
"path": ".github/workflows/docs.yaml",
"chars": 684,
"preview": "name: Deploy docs\n\non:\n push:\n branches:\n - main\n\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n -"
},
{
"path": ".github/workflows/release-build.yaml",
"chars": 9152,
"preview": "---\nname: Release Build\n\n# Triggered on version tags to build release artifacts and create a GitHub release.\n#\n# THREE R"
},
{
"path": ".github/workflows/release-publish.yaml",
"chars": 8262,
"preview": "---\nname: Release Publish\n\n# Publishes packages to PyPI and crates.io when a release is published.\n#\n# For stable releas"
},
{
"path": ".gitignore",
"chars": 881,
"preview": "/cog\n.ipynb_checkpoints/\nUntitled*.ipynb\n__pycache__\n.cog\n.hypothesis/\nbuild\ndist\n*.egg-info\npkg/wheels/*.whl\n# Used by "
},
{
"path": ".golangci.yaml",
"chars": 2349,
"preview": "version: \"2\"\n\nrun:\n timeout: 20m\n\noutput:\n # Show all issues, not just first few per linter\n show-stats: true\n\nlinter"
},
{
"path": ".goreleaser.yaml",
"chars": 2480,
"preview": "version: 2\nbefore:\n hooks:\n - go mod tidy\ndist: ./dist/go\nenv:\n # CGo required for go-tree-sitter (static Python sc"
},
{
"path": ".mockery.yml",
"chars": 542,
"preview": "all: false\ndir: '{{.InterfaceDir}}'\nfilename: mocks_test.go\nforce-file-write: true\nformatter: goimports\nlog-level: info\n"
},
{
"path": ".vscode/extensions.json",
"chars": 129,
"preview": "{\n \"recommendations\": [\n \"charliermarsh.ruff\",\n \"golang.go\",\n \"ms-python.python\",\n \"ms-python.vscode-pylanc"
},
{
"path": ".vscode/settings.json",
"chars": 1079,
"preview": "{\n \"editor.formatOnSave\": true,\n \"editor.formatOnType\": true,\n \"editor.formatOnPaste\": true,\n \"editor.renderControlC"
},
{
"path": "AGENTS.md",
"chars": 15093,
"preview": "# AGENTS.md\n\nThis file provides guidance to coding agents when working with code in this repository.\n\n## Project Overvie"
},
{
"path": "CONTRIBUTING.md",
"chars": 10044,
"preview": "# Contributing guide\n\n## Development environment\n\nDevelopment tasks are managed with [mise](https://mise.jdx.dev/). Run "
},
{
"path": "DESIGN.md",
"chars": 4951,
"preview": "# Design\n\n## Background\n\nCog came from Andreas's experience at Spotify and Ben's experience at Docker.\n\nAt Spotify, Andr"
},
{
"path": "LICENSE",
"chars": 11347,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "Makefile",
"chars": 3637,
"preview": "# Makefile - Shim that delegates to mise tasks\n#\n# This Makefile provides backward compatibility for common targets.\n# A"
},
{
"path": "README.md",
"chars": 24714,
"preview": "# Cog: Containers for machine learning\n\nCog is an open-source tool that lets you package machine learning models in a st"
},
{
"path": "architecture/00-overview.md",
"chars": 4736,
"preview": "# Cog Architecture Overview\n\nCog packages machine learning models into production-ready OCI images.\n\n## The Big Picture\n"
},
{
"path": "architecture/01-model-source.md",
"chars": 8685,
"preview": "# Model Source\n\nThis document covers what a model author provides to Cog and the primitives they work with.\n\n## What Use"
},
{
"path": "architecture/02-schema.md",
"chars": 13636,
"preview": "# Schema\n\nThe schema is an **OpenAPI 3.0.2 specification** that describes a model's interface. It's the contract between"
},
{
"path": "architecture/05-build-system.md",
"chars": 8692,
"preview": "# Build System\n\nThe build system transforms [Model Source](./01-model-source.md) (cog.yaml + predict.py + weights) into "
},
{
"path": "architecture/06-cli.md",
"chars": 6371,
"preview": "# CLI\n\nThe Cog CLI is a Go binary that provides commands for the full model lifecycle: development, building, testing, a"
},
{
"path": "architecture/ffi/03-prediction-api.md",
"chars": 10594,
"preview": "# Prediction API (FFI/Rust)\n\nThe FFI runtime implements the same Prediction API as the legacy runtime, using the same en"
},
{
"path": "architecture/ffi/04-container-runtime.md",
"chars": 18198,
"preview": "# Container Runtime (FFI/Rust)\n\nThis document covers the FFI runtime implementation using Rust with PyO3 bindings. This "
},
{
"path": "architecture/ffi/README.md",
"chars": 1805,
"preview": "# FFI Runtime (Rust + PyO3)\n\nThis directory documents the next-generation Cog runtime implementation using Rust with PyO"
},
{
"path": "architecture/legacy/03-prediction-api.md",
"chars": 8574,
"preview": "# Prediction API\n\nThe Prediction API is the HTTP interface for running model inference. It uses a fixed **envelope forma"
},
{
"path": "architecture/legacy/04-container-runtime.md",
"chars": 8646,
"preview": "# Container Runtime\n\nThis document covers what happens when a Cog container runs. It's where the [Model Source](./01-mod"
},
{
"path": "architecture/legacy/README.md",
"chars": 1026,
"preview": "# Legacy Python Runtime (FastAPI)\n\nThis directory documents the original Cog runtime implementation using Python's FastA"
},
{
"path": "cmd/cog/cog.go",
"chars": 275,
"preview": "package main\n\nimport (\n\t\"github.com/replicate/cog/pkg/cli\"\n\t\"github.com/replicate/cog/pkg/util/console\"\n)\n\nfunc main() {"
},
{
"path": "crates/.gitignore",
"chars": 9,
"preview": "/target/\n"
},
{
"path": "crates/Cargo.toml",
"chars": 1200,
"preview": "[workspace]\nresolver = \"2\"\nmembers = [\"coglet\", \"coglet-python\"]\n\n[workspace.package]\nversion = \"0.17.0-rc.2\"\nedition = "
},
{
"path": "crates/README.md",
"chars": 12597,
"preview": "# Coglet: Rust Runtime for Cog\n\nCoglet is the Rust-based prediction server that powers Cog's subprocess isolation model."
},
{
"path": "crates/coglet/Cargo.toml",
"chars": 1336,
"preview": "[package]\nname = \"coglet\"\ndescription = \"High-performance prediction server for Cog ML models\"\nversion.workspace = true\n"
},
{
"path": "crates/coglet/README.md",
"chars": 8805,
"preview": "# coglet\n\nCore Rust library for the coglet prediction server. Pure Rust with no Python\ndependencies - the Python binding"
},
{
"path": "crates/coglet/src/bridge/codec.rs",
"chars": 5938,
"preview": "//! Framed codec for worker communication.\n//!\n//! Uses LengthDelimitedCodec for framing + serde_json for serialization."
},
{
"path": "crates/coglet/src/bridge/mod.rs",
"chars": 421,
"preview": "//! IPC bridge for coglet parent-worker communication.\n//!\n//! This module provides the wire protocol and codec for comm"
},
{
"path": "crates/coglet/src/bridge/protocol.rs",
"chars": 20995,
"preview": "//! Wire protocol types for parent-worker communication.\n//!\n//! Two channels:\n//! - **Control channel** (stdin/stdout):"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_cancel_serializes.snap",
"chars": 135,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: req\n---\n{\n \"type\": \"cancel\",\n \"slot\": \"550e8400-e29b-41d4-a716-4"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_cancelled_serializes.snap",
"chars": 139,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"cancelled\",\n \"slot\": \"550e8400-e29b-41d4-a7"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_failed_serializes.snap",
"chars": 159,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"failed\",\n \"slot\": \"550e8400-e29b-41d4-a716-"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_healthcheck_result_healthy_serializes.snap",
"chars": 139,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"healthcheck_result\",\n \"id\": \"hc_123\",\n \"st"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_healthcheck_result_unhealthy_serializes.snap",
"chars": 187,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"healthcheck_result\",\n \"id\": \"hc_123\",\n \"st"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_healthcheck_serializes.snap",
"chars": 108,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: req\n---\n{\n \"type\": \"healthcheck\",\n \"id\": \"hc_123\"\n}\n"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_idle_serializes.snap",
"chars": 134,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"idle\",\n \"slot\": \"550e8400-e29b-41d4-a716-44"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_init_serializes.snap",
"chars": 293,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: req\n---\n{\n \"type\": \"init\",\n \"predictor_ref\": \"predict.py:Predict"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_ready_serializes.snap",
"chars": 146,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"ready\",\n \"slots\": [\n \"550e8400-e29b-41d4"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_ready_with_schema_serializes.snap",
"chars": 256,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"ready\",\n \"slots\": [\n \"550e8400-e29b-41d4"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__control_shutdown_serializes.snap",
"chars": 87,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: req\n---\n{\n \"type\": \"shutdown\"\n}\n"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_cancelled_serializes.snap",
"chars": 109,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"cancelled\",\n \"id\": \"pred_123\"\n}\n"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_done_serializes.snap",
"chars": 157,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"done\",\n \"id\": \"pred_123\",\n \"output\": \"fina"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_failed_serializes.snap",
"chars": 146,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"failed\",\n \"id\": \"pred_123\",\n \"error\": \"Val"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_log_serializes.snap",
"chars": 132,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"log\",\n \"source\": \"stdout\",\n \"data\": \"Proce"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_metric_append_serializes.snap",
"chars": 145,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"metric\",\n \"name\": \"logprobs\",\n \"value\": -1"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_metric_complex_value_serializes.snap",
"chars": 189,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"metric\",\n \"name\": \"timing\",\n \"value\": {\n "
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_metric_delete_serializes.snap",
"chars": 146,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"metric\",\n \"name\": \"unwanted\",\n \"value\": nu"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_metric_increment_serializes.snap",
"chars": 148,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"metric\",\n \"name\": \"token_count\",\n \"value\":"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_metric_replace_serializes.snap",
"chars": 148,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"metric\",\n \"name\": \"temperature\",\n \"value\":"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_output_serializes.snap",
"chars": 109,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: resp\n---\n{\n \"type\": \"output\",\n \"output\": \"chunk 1\"\n}\n"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_predict_file_input_serializes.snap",
"chars": 257,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: req\n---\n{\n \"type\": \"predict\",\n \"id\": \"pred_456\",\n \"input_file\":"
},
{
"path": "crates/coglet/src/bridge/snapshots/coglet__bridge__protocol__tests__slot_predict_serializes.snap",
"chars": 221,
"preview": "---\nsource: coglet/src/bridge/protocol.rs\nexpression: req\n---\n{\n \"type\": \"predict\",\n \"id\": \"pred_123\",\n \"input\": {\n "
},
{
"path": "crates/coglet/src/bridge/transport.rs",
"chars": 11567,
"preview": "//! Slot socket transport for parent-worker IPC.\n//!\n//! Platform-specific implementations:\n//! - **NamedSocketTransport"
},
{
"path": "crates/coglet/src/fd_redirect.rs",
"chars": 9353,
"preview": "//! File descriptor redirection for subprocess isolation.\n//!\n//! Worker uses fd 1 (stdout) as the control channel to th"
},
{
"path": "crates/coglet/src/health.rs",
"chars": 4937,
"preview": "//! Health status types for coglet runtime.\n\nuse serde::{Deserialize, Serialize};\n\n/// Health status of the coglet runti"
},
{
"path": "crates/coglet/src/input_validation.rs",
"chars": 12673,
"preview": "//! Input validation against the OpenAPI schema.\n//!\n//! Validates prediction inputs before dispatching to the Python wo"
},
{
"path": "crates/coglet/src/lib.rs",
"chars": 1022,
"preview": "//! coglet: Rust execution engine for cog models.\n\nmod health;\npub mod input_validation;\nmod prediction;\nmod predictor;\n"
},
{
"path": "crates/coglet/src/orchestrator.rs",
"chars": 55735,
"preview": "//! Orchestrator - manages worker subprocess lifecycle and event loop.\n//!\n//! Flow:\n//! 1. Spawn worker subprocess\n//! "
},
{
"path": "crates/coglet/src/permit/mod.rs",
"chars": 862,
"preview": "//! Permit pool for concurrent slot management.\n//!\n//! The permit system uses typestate to enforce valid state transiti"
},
{
"path": "crates/coglet/src/permit/pool.rs",
"chars": 16114,
"preview": "//! Permit pool implementation with typestate for compile-time state transition safety.\n//!\n//! Slot poisoning is a pool"
},
{
"path": "crates/coglet/src/permit/slot.rs",
"chars": 8764,
"preview": "//! PredictionSlot - holds Prediction and Permit side-by-side.\n//!\n//! This separation allows the prediction to be behin"
},
{
"path": "crates/coglet/src/prediction.rs",
"chars": 25088,
"preview": "//! Prediction state tracking.\n\nuse std::collections::HashMap;\nuse std::sync::Arc;\nuse std::time::Instant;\n\nuse tokio::s"
},
{
"path": "crates/coglet/src/predictor.rs",
"chars": 3616,
"preview": "//! Predictor traits and prediction lifecycle types.\n\nuse std::collections::HashMap;\nuse std::time::{Duration, Instant};"
},
{
"path": "crates/coglet/src/service.rs",
"chars": 43439,
"preview": "//! PredictionService: Transport-agnostic prediction lifecycle management.\n//!\n//! This service is the single owner of p"
},
{
"path": "crates/coglet/src/setup_log_accumulator.rs",
"chars": 2264,
"preview": "//! Tracing layer that accumulates all logs from coglet server during setup.\n//!\n//! Captures every tracing event from t"
},
{
"path": "crates/coglet/src/snapshots/coglet__health__tests__health_all_variants.snap",
"chars": 238,
"preview": "---\nsource: coglet/src/health.rs\nexpression: \"[Health::Unknown, Health::Starting, Health::Ready, Health::Busy,\\nHealth::"
},
{
"path": "crates/coglet/src/snapshots/coglet__health__tests__health_response_all_variants.snap",
"chars": 329,
"preview": "---\nsource: coglet/src/health.rs\nexpression: \"[HealthResponse::Unknown, HealthResponse::Starting, HealthResponse::Ready,"
},
{
"path": "crates/coglet/src/snapshots/coglet__health__tests__setup_status_all_variants.snap",
"chars": 165,
"preview": "---\nsource: coglet/src/health.rs\nexpression: \"[SetupStatus::Starting, SetupStatus::Succeeded, SetupStatus::Failed,]\"\n---"
},
{
"path": "crates/coglet/src/snapshots/coglet__predictor__tests__output_single.snap",
"chars": 67,
"preview": "---\nsource: coglet/src/predictor.rs\nexpression: single\n---\n\"hello\"\n"
},
{
"path": "crates/coglet/src/snapshots/coglet__predictor__tests__output_stream.snap",
"chars": 72,
"preview": "---\nsource: coglet/src/predictor.rs\nexpression: stream\n---\n[\n 1,\n 2\n]\n"
},
{
"path": "crates/coglet/src/snapshots/coglet__version__tests__version_full.snap",
"chars": 196,
"preview": "---\nsource: coglet/src/version.rs\nexpression: info\n---\n{\n \"coglet\": \"0.1.0\",\n \"git_sha\": \"abc1234-dirty\",\n \"build_tim"
},
{
"path": "crates/coglet/src/snapshots/coglet__version__tests__version_minimal.snap",
"chars": 79,
"preview": "---\nsource: coglet/src/version.rs\nexpression: info\n---\n{\n \"coglet\": \"0.1.0\"\n}\n"
},
{
"path": "crates/coglet/src/transport/http/mod.rs",
"chars": 107,
"preview": "//! HTTP transport for coglet using axum.\n\nmod routes;\nmod server;\n\npub use server::{ServerConfig, serve};\n"
},
{
"path": "crates/coglet/src/transport/http/routes.rs",
"chars": 41728,
"preview": "//! HTTP route handlers.\n\nuse std::sync::Arc;\n\nuse axum::{\n Router,\n extract::{DefaultBodyLimit, Path, State},\n "
},
{
"path": "crates/coglet/src/transport/http/server.rs",
"chars": 3591,
"preview": "//! HTTP server implementation.\n\nuse std::net::SocketAddr;\nuse std::sync::Arc;\n\nuse tokio::net::TcpListener;\nuse tokio::"
},
{
"path": "crates/coglet/src/transport/mod.rs",
"chars": 210,
"preview": "//! Transport layer for coglet.\n//!\n//! Currently provides HTTP transport via axum. Future transports\n//! (gRPC, bnet) w"
},
{
"path": "crates/coglet/src/version.rs",
"chars": 3435,
"preview": "//! Version information for coglet.\n\n/// Coglet version from Cargo.toml\npub const COGLET_VERSION: &str = env!(\"CARGO_PKG"
},
{
"path": "crates/coglet/src/webhook.rs",
"chars": 20522,
"preview": "//! Webhook sender for async predictions.\n//!\n//! Implements the cog webhook protocol:\n//! - Throttling (default 500ms b"
},
{
"path": "crates/coglet/src/worker.rs",
"chars": 33925,
"preview": "//! Worker subprocess - runs inside the Python subprocess.\n//!\n//! This module provides the child-side of the worker sub"
},
{
"path": "crates/coglet/src/worker_tracing_layer.rs",
"chars": 3989,
"preview": "//! Custom tracing layer for worker subprocess.\n//!\n//! Ships structured tracing events over IPC to orchestrator, preser"
},
{
"path": "crates/coglet-python/Cargo.toml",
"chars": 832,
"preview": "[package]\nname = \"coglet-python\"\nversion.workspace = true\nedition.workspace = true\nlicense.workspace = true\npublish = fa"
},
{
"path": "crates/coglet-python/README.md",
"chars": 9736,
"preview": "# coglet-python\n\nPyO3 bindings that bridge the Rust coglet library to Python. This crate implements\nthe `PredictHandler`"
},
{
"path": "crates/coglet-python/build.rs",
"chars": 4681,
"preview": "//! Build script for coglet-python.\n//!\n//! Captures build metadata and converts semver to PEP 440 for Python compatibil"
},
{
"path": "crates/coglet-python/coglet/__init__.py",
"chars": 265,
"preview": "\"\"\"coglet — high-performance Rust prediction server for Cog ML models.\"\"\"\n\nfrom coglet._impl import CancelationException"
},
{
"path": "crates/coglet-python/coglet/__init__.pyi",
"chars": 318,
"preview": "# This file is automatically generated by stub_gen\n# ruff: noqa: E501, F401\n\nfrom coglet._impl import __build__ as __bui"
},
{
"path": "crates/coglet-python/coglet/_impl.pyi",
"chars": 2238,
"preview": "# This file is automatically generated by pyo3_stub_gen\n# ruff: noqa: E501, F401, F403, F405\n\nimport builtins\nimport typ"
},
{
"path": "crates/coglet-python/coglet/_sdk/__init__.pyi",
"chars": 7553,
"preview": "# This file is automatically generated by pyo3_stub_gen\n# ruff: noqa: E501, F401, F403, F405\n\nimport builtins\nimport typ"
},
{
"path": "crates/coglet-python/coglet/py.typed",
"chars": 0,
"preview": ""
},
{
"path": "crates/coglet-python/pyproject.toml",
"chars": 1692,
"preview": "[build-system]\nrequires = [\"maturin>=1.0,<2.0\"]\nbuild-backend = \"maturin\"\n\n[project]\nname = \"coglet\"\ndescription = \"High"
},
{
"path": "crates/coglet-python/src/audit.rs",
"chars": 9987,
"preview": "//! Audit hooks to protect Rust-injected runtime objects.\n//!\n//! Uses sys.addaudithook to intercept operations that cou"
},
{
"path": "crates/coglet-python/src/bin/stub_gen.rs",
"chars": 3205,
"preview": "//! Generate Python stub files for coglet.\n//!\n//! Run with: cargo run --bin stub_gen\n//!\n//! Custom generate logic: pyo"
},
{
"path": "crates/coglet-python/src/cancel.rs",
"chars": 3613,
"preview": "//! Cancellation support for predictions.\n//!\n//! Sync predictors use `PyThreadState_SetAsyncExc` to inject a\n//! `Cance"
},
{
"path": "crates/coglet-python/src/input.rs",
"chars": 16876,
"preview": "//! Input processing for cog predictors.\n//!\n//! This module handles file downloads for cog predictor inputs.\n//! Input "
},
{
"path": "crates/coglet-python/src/lib.rs",
"chars": 19905,
"preview": "//! coglet-python: PyO3 bindings for coglet.\n\nmod audit;\nmod cancel;\nmod input;\nmod log_writer;\nmod metric_scope;\nmod ou"
},
{
"path": "crates/coglet-python/src/log_writer.rs",
"chars": 23048,
"preview": "//! Log routing via prediction_id ContextVar.\n//!\n//! Architecture:\n//! - Rust owns a ContextVar `_coglet_prediction_id`"
},
{
"path": "crates/coglet-python/src/metric_scope.rs",
"chars": 17178,
"preview": "//! Metric scope: type-safe metric recording with ContextVar routing.\n//!\n//! Two PyO3 classes:\n//! - `Scope` — the per-"
},
{
"path": "crates/coglet-python/src/output.rs",
"chars": 18542,
"preview": "//! Output processing for prediction results.\n//!\n//! Converts Python prediction output to JSON-serializable format:\n//!"
},
{
"path": "crates/coglet-python/src/predictor.rs",
"chars": 49254,
"preview": "//! Python predictor loading and invocation.\n\nuse std::sync::{Arc, OnceLock};\n\nuse pyo3::prelude::*;\nuse pyo3::types::Py"
},
{
"path": "crates/coglet-python/src/worker_bridge.rs",
"chars": 27387,
"preview": "//! Bridge between coglet-worker's PredictHandler trait and PythonPredictor.\n\nuse std::collections::HashMap;\nuse std::sy"
},
{
"path": "crates/coglet-python/tests/test_coglet.py",
"chars": 22606,
"preview": "\"\"\"Tests for coglet Python bindings.\"\"\"\n\nimport queue\nimport re\nimport socket\nimport subprocess\nimport sys\nimport thread"
},
{
"path": "crates/deny.toml",
"chars": 1641,
"preview": "# cargo-deny configuration for coglet crates\n# See: https://embarkstudios.github.io/cargo-deny/\n\n[graph]\nall-features = "
},
{
"path": "docs/CNAME",
"chars": 8,
"preview": "cog.run\n"
},
{
"path": "docs/cli.md",
"chars": 9609,
"preview": "# CLI reference\n\n<!-- This file is auto-generated. Do not edit manually. -->\n\n## `cog`\n\nContainers for machine learning."
},
{
"path": "docs/deploy.md",
"chars": 2665,
"preview": "# Deploy models with Cog\n\nCog containers are Docker containers that serve an HTTP server\nfor running predictions on your"
},
{
"path": "docs/environment.md",
"chars": 4089,
"preview": "# Environment variables\n\nThis guide lists the environment variables that change how Cog functions.\n\n## Build-time variab"
},
{
"path": "docs/getting-started-own-model.md",
"chars": 6299,
"preview": "# Getting started with your own model\n\nThis guide will show you how to put your own machine learning model in a Docker i"
},
{
"path": "docs/getting-started.md",
"chars": 6581,
"preview": "# Getting started\n\nThis guide will walk you through what you can do with Cog by using an example model.\n\n> [!TIP]\n> Usin"
},
{
"path": "docs/http.md",
"chars": 13362,
"preview": "# HTTP API\n\n> [!TIP]\n> For information about how to run the HTTP server,\n> see [our documentation on deploying models](d"
},
{
"path": "docs/llms.txt",
"chars": 95715,
"preview": "# Cog: Containers for machine learning\n\nCog is an open-source tool that lets you package machine learning models in a st"
},
{
"path": "docs/notebooks.md",
"chars": 1146,
"preview": "# Notebooks\n\nCog plays nicely with Jupyter notebooks.\n\n## Install the jupyterlab Python package\n\nFirst, add `jupyterlab`"
},
{
"path": "docs/private-package-registry.md",
"chars": 1707,
"preview": "# Private package registry\n\nThis guide describes how to build a Docker image with Cog that fetches Python packages from "
},
{
"path": "docs/python.md",
"chars": 21960,
"preview": "# Prediction interface reference\n\nThis document defines the API of the `cog` Python module, which is used to define the "
},
{
"path": "docs/stylesheets/extra.css",
"chars": 256,
"preview": ".md-typeset h1,\n.md-typeset h2,\n.md-typeset h3 {\n font-weight: 600;\n}\n\n/* move the \"Cog\" header to the left */\n[dir=\"lt"
},
{
"path": "docs/training.md",
"chars": 5076,
"preview": "# Training interface reference\n\n> [!WARNING] \n> The `cog train` command is deprecated and will be removed in the next v"
},
{
"path": "docs/wsl2/wsl2.md",
"chars": 8875,
"preview": "# Using `cog` on Windows 11 with WSL 2\n\n- [0. Prerequisites](#0-prerequisites)\n- [1. Install the GPU driver](#1-install-"
},
{
"path": "docs/yaml.md",
"chars": 6932,
"preview": "# `cog.yaml` reference\n\n`cog.yaml` defines how to build a Docker image and how to run predictions on your model inside t"
},
{
"path": "go.mod",
"chars": 7906,
"preview": "module github.com/replicate/cog\n\ngo 1.26\n\nrequire (\n\tgithub.com/anaskhan96/soup v1.2.5\n\tgithub.com/containerd/errdefs v1"
},
{
"path": "go.sum",
"chars": 38687,
"preview": "cyphar.com/go-pathrs v0.2.1 h1:9nx1vOgwVvX1mNBWDu93+vaceedpbsDqo+XuBGL40b8=\ncyphar.com/go-pathrs v0.2.1/go.mod h1:y8f1EM"
},
{
"path": "integration-tests/.gitignore",
"chars": 6,
"preview": ".bin/\n"
},
{
"path": "integration-tests/README.md",
"chars": 12576,
"preview": "# Cog Integration Tests\n\nThis directory contains Go-based integration tests for the Cog CLI using the [testscript](https"
},
{
"path": "integration-tests/concurrent/concurrent_test.go",
"chars": 14164,
"preview": "//go:build integration\n\npackage concurrent_test\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"os\"\n\t\"o"
},
{
"path": "integration-tests/harness/cmd_pty.go",
"chars": 4692,
"preview": "package harness\n\nimport (\n\t\"bytes\"\n\t\"io\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/creack/pty\"\n\t\"github."
},
{
"path": "integration-tests/harness/command.go",
"chars": 949,
"preview": "package harness\n\nimport \"github.com/rogpeppe/go-internal/testscript\"\n\n// Command defines the interface for testscript co"
},
{
"path": "integration-tests/harness/harness.go",
"chars": 45094,
"preview": "// Package harness provides utilities for running cog integration tests.\npackage harness\n\nimport (\n\t\"context\"\n\tcryptoran"
},
{
"path": "integration-tests/login/login_test.go",
"chars": 14231,
"preview": "//go:build integration\n\n// Package login provides integration tests for the cog login command.\n//\n// These tests verify:"
},
{
"path": "integration-tests/suite_test.go",
"chars": 2014,
"preview": "//go:build integration\n\npackage integration_test\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/signal\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"sort\""
},
{
"path": "integration-tests/tests/apt_packages.txtar",
"chars": 635,
"preview": "# Skip for cog-dataclass and coglet (Rust) which require Python 3.10+\n# Test that system packages are installed correctl"
},
{
"path": "integration-tests/tests/async_generator_precollect.txtar",
"chars": 983,
"preview": "# Test that async generator output is pre-collected before response.\n#\n# Coglet collects all async generator yields into"
},
{
"path": "integration-tests/tests/async_predictor.txtar",
"chars": 358,
"preview": "# Build the image\ncog build -t $TEST_IMAGE\n\n# Async prediction works\ncog predict $TEST_IMAGE -i s=world\nstdout 'hello wo"
},
{
"path": "integration-tests/tests/async_sleep.txtar",
"chars": 517,
"preview": "# Test async predictor with sleep\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Async prediction with sleep works\ncog p"
},
{
"path": "integration-tests/tests/bad_dockerignore.txtar",
"chars": 506,
"preview": "# Skip for cog-dataclass and coglet (Rust) which require Python 3.10+\n# Test that build fails with proper error when .co"
},
{
"path": "integration-tests/tests/bool_input_output.txtar",
"chars": 585,
"preview": "# Test bool as a direct predict input and output type\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Bool input and outp"
},
{
"path": "integration-tests/tests/build_base_image_sha.txtar",
"chars": 1689,
"preview": "# Test that base image SHA is recorded in labels with --use-cog-base-image\n# Source: test_build.py::test_build_base_imag"
},
{
"path": "integration-tests/tests/build_cog_init.txtar",
"chars": 308,
"preview": "# Test that cog init creates a buildable project\n# Source: test_build.py::test_build_with_cog_init_templates\n\n# Initiali"
},
{
"path": "integration-tests/tests/build_cog_version_match.txtar",
"chars": 6419,
"preview": "# Note: This test can be flaky if the wheel build time and CI run time\n# cross day boundaries (version date mismatch). I"
},
{
"path": "integration-tests/tests/build_gpu_labels.txtar",
"chars": 1368,
"preview": "# Test GPU build labels\n# Source: test_build.py::test_build_gpu_model_on_cpu\n# Requires git init/tag for version labels\n"
},
{
"path": "integration-tests/tests/build_image_option.txtar",
"chars": 651,
"preview": "# Test that image: option in cog.yaml names the built image\n# Source: test_build.py::test_build_names_uses_image_option_"
},
{
"path": "integration-tests/tests/build_openapi_schema.txtar",
"chars": 988,
"preview": "# Test that OpenAPI schema is embedded in image labels\n# Source: test_build.py::test_build_with_model\n\n# Build the image"
},
{
"path": "integration-tests/tests/build_openapi_schema_complex.txtar",
"chars": 1722,
"preview": "# Test that the OpenAPI schema for complex input/output types is correct.\n#\n# Verifies schema generation for:\n# - Multip"
},
{
"path": "integration-tests/tests/build_pip_freeze.txtar",
"chars": 851,
"preview": "\n# Test that pip freeze label is embedded in image\n# Source: test_build.py::test_pip_freeze\n\n# Build the image\ncog build"
},
{
"path": "integration-tests/tests/build_python313_base_image.txtar",
"chars": 843,
"preview": "# Test Python 3.13 works with --use-cog-base-image\n# Source: test_build.py::test_python_313_base_images\n#\n# Uses a local"
},
{
"path": "integration-tests/tests/build_torch_version_required.txtar",
"chars": 571,
"preview": "# Test that build fails with proper error when torch is specified without version and GPU is enabled\n# This validates th"
},
{
"path": "integration-tests/tests/ca_cert.txtar",
"chars": 6077,
"preview": "# Test CA certificate injection via COG_CA_CERT\n#\n# This test verifies that custom CA certificates can be injected into\n"
},
{
"path": "integration-tests/tests/cancel_async_prediction.txtar",
"chars": 1213,
"preview": "# Test cancellation of a running async prediction.\n#\n# Submits an async prediction (PUT with Prefer: respond-async) that"
},
{
"path": "integration-tests/tests/cancel_repeated.txtar",
"chars": 1548,
"preview": "# Test that cancelling the same prediction multiple times doesn't panic or break.\n#\n# Uses time.sleep() (C-level nanosle"
},
{
"path": "integration-tests/tests/cancel_sync_prediction.txtar",
"chars": 1345,
"preview": "# Test cancellation of a running sync prediction.\n#\n# Submits an async prediction (PUT with Prefer: respond-async) that "
},
{
"path": "integration-tests/tests/coglet_iterator_path_output.txtar",
"chars": 882,
"preview": "# Test iterator prediction with Path outputs (no upload URL — files written to disk)\n\ncog build -t $TEST_IMAGE\ncog predi"
},
{
"path": "integration-tests/tests/coglet_iterator_upload_url.txtar",
"chars": 1133,
"preview": "# Test that iterator Path outputs are uploaded per-yield to --upload-url.\n\ncog build -t $TEST_IMAGE\n\n# Start mock upload"
},
{
"path": "integration-tests/tests/coglet_large_file_upload_serial.txtar",
"chars": 1200,
"preview": "[short] skip 'large file test - slow'\n\n# Test that a large binary file (50 MiB) is successfully uploaded via --upload-ur"
},
{
"path": "integration-tests/tests/coglet_large_input.txtar",
"chars": 1672,
"preview": "# Test that inputs larger than the 6 MiB IPC inline threshold spill to disk\n# and are rehydrated correctly by the worker"
},
{
"path": "integration-tests/tests/coglet_large_output.txtar",
"chars": 1364,
"preview": "# Test that outputs larger than the 8MiB IPC frame limit spill to disk\n# and are reconstructed correctly by the orchestr"
},
{
"path": "integration-tests/tests/coglet_list_path_single_element.txtar",
"chars": 1797,
"preview": "# Test that List[Path] with a single element returns an array, not a scalar.\n# Regression test: the orchestrator must no"
},
{
"path": "integration-tests/tests/coglet_list_path_upload_url.txtar",
"chars": 1309,
"preview": "# Test that List[Path] outputs are uploaded to --upload-url.\n# This verifies that list returns (not just iterators) go t"
},
{
"path": "integration-tests/tests/coglet_metrics.txtar",
"chars": 1799,
"preview": "# Test that user-emitted metrics appear in sync prediction responses.\n#\n# Verifies:\n# 1. record_metric() with default mo"
},
{
"path": "integration-tests/tests/coglet_metrics_webhook.txtar",
"chars": 1325,
"preview": "# Test that user-emitted metrics appear in webhook payloads.\n#\n# Uses async prediction with webhook to verify metrics fl"
},
{
"path": "integration-tests/tests/coglet_single_path_output.txtar",
"chars": 1226,
"preview": "# Test that a single Path return (not List[Path]) returns a scalar string, not an array.\n# This complements coglet_list_"
},
{
"path": "integration-tests/tests/complex_output.txtar",
"chars": 694,
"preview": "# Test complex/structured output type using cog.BaseModel (dataclass)\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Pre"
},
{
"path": "integration-tests/tests/concatenate_iterator_output.txtar",
"chars": 689,
"preview": "# Test ConcatenateIterator[str] as predict output type\n#\n# ConcatenateIterator is the primary streaming text output type"
},
{
"path": "integration-tests/tests/config_subdirectory.txtar",
"chars": 350,
"preview": "# Test that cog.yaml is discovered from subdirectories\n# Source: test_config.py::test_config\n\n# Create a subdirectory st"
},
{
"path": "integration-tests/tests/debug_secrets.txtar",
"chars": 684,
"preview": "# Test that cog debug shows secret mount syntax in Dockerfile output\n# Source: test_run.py::test_run_with_secret\n\n# Run "
},
{
"path": "integration-tests/tests/dict_output.txtar",
"chars": 488,
"preview": "# Test bare dict return type works for predict output\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Predict returns a d"
},
{
"path": "integration-tests/tests/emit_metric_deprecated.txtar",
"chars": 931,
"preview": "# Test that a predictor using the deprecated emit_metric() still builds,\n# runs, and records metrics correctly.\n#\n# emit"
},
{
"path": "integration-tests/tests/env_vars.txtar",
"chars": 506,
"preview": "# Build the image\ncog build -t $TEST_IMAGE\n\n# Environment variables are set\ncog predict $TEST_IMAGE -i name=TEST_VAR\nstd"
},
{
"path": "integration-tests/tests/experimental_feature_warning.txtar",
"chars": 607,
"preview": "# Test that a predictor importing the deprecated ExperimentalFeatureWarning\n# still builds and runs successfully.\n\n# Bui"
},
{
"path": "integration-tests/tests/ffmpeg_package.txtar",
"chars": 578,
"preview": "# Test that ffmpeg system package is installed (common ML dependency)\n\n# Build the image (the run command verifies ffmpe"
},
{
"path": "integration-tests/tests/file_input.txtar",
"chars": 405,
"preview": "# Build the image\ncog build -t $TEST_IMAGE\n\n# File input works\ncog predict $TEST_IMAGE -i file=@input.txt\nstdout 'hello "
},
{
"path": "integration-tests/tests/file_list_input.txtar",
"chars": 786,
"preview": "\n# Test list[File] input type (multiple file inputs using File type)\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Pred"
},
{
"path": "integration-tests/tests/float_input_output.txtar",
"chars": 518,
"preview": "# Test float input and output types work correctly\ncog build -t $TEST_IMAGE\n\n# Float input and output works\ncog predict "
},
{
"path": "integration-tests/tests/function_predictor.txtar",
"chars": 406,
"preview": "# Test function-based predictor (no class, just a function)\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Predict using"
},
{
"path": "integration-tests/tests/future_annotations.txtar",
"chars": 839,
"preview": "\n# Test from __future__ import annotations support\n# This tests that future annotations work correctly with Path types\n\n"
},
{
"path": "integration-tests/tests/glb_project.txtar",
"chars": 630,
"preview": "# Test GLB (3D model) file output\n\n# Create a minimal GLB placeholder file (GLB files start with \"glTF\" magic bytes)\nexe"
},
{
"path": "integration-tests/tests/granite_project.txtar",
"chars": 517,
"preview": "# Test that Pydantic 2 is not clobbered to a <2 version\n\n# Build the image\ncog build -t $TEST_IMAGE\n\n# Predict and verif"
},
{
"path": "integration-tests/tests/healthcheck.txtar",
"chars": 910,
"preview": "# Test custom healthcheck functionality\n# This tests the user-defined healthcheck() method in predictors\n\n# Build the im"
},
{
"path": "integration-tests/tests/healthcheck_async.txtar",
"chars": 884,
"preview": "# Test async healthcheck function\n# Ensures async healthchecks work correctly\n\n# Build the image\ncog build -t $TEST_IMAG"
},
{
"path": "integration-tests/tests/healthcheck_async_exception.txtar",
"chars": 820,
"preview": "# Test async healthcheck that raises an exception\n# Tests that async def healthcheck() exceptions are handled\n\n# Build t"
},
{
"path": "integration-tests/tests/healthcheck_async_timeout.txtar",
"chars": 1203,
"preview": "# Test async healthcheck timeout behavior\n# Tests that async def healthcheck() timeouts are handled (5 second limit)\n\n# "
},
{
"path": "integration-tests/tests/healthcheck_async_unhealthy.txtar",
"chars": 766,
"preview": "# Test async unhealthy healthcheck behavior\n# Tests that async def healthcheck() returning False works correctly\n\n# Buil"
},
{
"path": "integration-tests/tests/healthcheck_during_prediction.txtar",
"chars": 1499,
"preview": "# Test healthcheck called during active prediction\n# Ensures healthcheck pipe doesn't interfere with prediction pipe\n\n# "
},
{
"path": "integration-tests/tests/healthcheck_exception.txtar",
"chars": 916,
"preview": "# Test healthcheck that raises an exception\n# This tests error handling when healthcheck throws\n\n# Build the image\ncog b"
},
{
"path": "integration-tests/tests/healthcheck_immediately_after_prediction.txtar",
"chars": 1147,
"preview": "# Test healthcheck immediately after prediction completes\n# Ensures healthcheck works correctly in quick succession with"
},
{
"path": "integration-tests/tests/healthcheck_repeated_calls.txtar",
"chars": 1177,
"preview": "# Test repeated healthcheck calls (simulates supervisor container polling pattern)\n# This ensures no resource leaks over"
},
{
"path": "integration-tests/tests/healthcheck_timeout.txtar",
"chars": 1160,
"preview": "# Test healthcheck timeout behavior\n# This tests when sync healthcheck takes too long (>5 seconds)\n\n# Build the image\nco"
},
{
"path": "integration-tests/tests/healthcheck_unhealthy.txtar",
"chars": 859,
"preview": "# Test unhealthy healthcheck behavior\n# This tests when healthcheck returns False\n\n# Build the image\ncog build -t $TEST_"
},
{
"path": "integration-tests/tests/int_input_output.txtar",
"chars": 516,
"preview": "# Test integer input and output types work correctly\ncog build -t $TEST_IMAGE\n\n# Integer input and output works\ncog pred"
},
{
"path": "integration-tests/tests/int_none_output.txtar",
"chars": 529,
"preview": "\n# Test int return type that returns None\n# This tests the handling of None values for typed outputs\n\n# Build the image\n"
},
{
"path": "integration-tests/tests/int_predictor.txtar",
"chars": 417,
"preview": "# Build the image\ncog build -t $TEST_IMAGE\n\n# Integer input and output works\ncog predict $TEST_IMAGE -i num=5\nstdout '10"
}
]
// ... and 375 more files (download for full content)
About this extraction
This page contains the full source code of the replicate/cog GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 575 files (3.2 MB), approximately 856.0k tokens, and a symbol index with 3199 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.