feat: support presigned uploads for logged model artifacts (#30)
- feat: support presigned uploads for logged model artifacts
Detect logged-model S3 artifact roots and send model_id to servers that support model-scoped presigned uploads. Preserve existing run uploads, trace fail-closed behavior, streaming, and no-fallback semantics. Add unit coverage, a capability-gated real-server log_model integration test, and compatibility documentation.
Signed-off-by: Henish Borad henishb@amazon.com
- test: discover model upload support through server info
Use GET /api/3.0/mlflow/server-info and the explicit presigned_upload_model_id_supported field instead of inferring capability from an intentionally invalid POST response. Add response-matrix coverage for the discovery contract.
Signed-off-by: Henish Borad henishb@amazon.com
- refactor: use typed presigned upload targets
Replace raw field tuples with a structured target and fail closed for malformed or unsupported roots when presigned upload is active. Preserve feature-off and no-tracking direct-S3 behavior, and document the compatibility boundary.
Signed-off-by: Henish Borad henishb@amazon.com
- test: unify presigned upload capability discovery
Read run_id and model_id support from one module-scoped server-info request, remove the ambiguous fake-run POST probe, and cover false, missing, non-200, invalid JSON, and request failures.
Signed-off-by: Henish Borad henishb@amazon.com
- docs: highlight trace upload limitation
Promote the trace-upload limitation into a dedicated warning section and document the fail-closed behavior and direct-S3 opt-out.
Signed-off-by: Henish Borad henishb@amazon.com
Signed-off-by: Henish Borad henishb@amazon.com Co-authored-by: Henish Borad henishb@amazon.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
SageMaker MLflow Plugin
What does this Plugin do?
This plugin generates Signature V4 headers in each outgoing request to the Amazon SageMaker with MLflow capability, determines the URL of capability to connect to tracking servers, and registers models to the SageMaker Model Registry. It generates a token with the SigV4 Algorithm that the service will use to conduct Authentication and Authorization using AWS IAM.
Installation
To install this plugin (lightweight, depends on
mlflow-skinny):To install with the full
mlflowdependency set:To install from source:
Custom AWS session
By default, the plugin signs requests using credentials from the boto3 default credential chain (environment variables, shared config, instance role, etc.). Callers that need to sign with a specific
boto3.Session— for example a non-default profile or per-tenant credentials in a shared process — can inject one without mutatingos.environ:use_sessionis a context manager scoped to the current thread / asyncio task; the previous session is restored on exit (including on exception).sagemaker_mlflow.set_session(session)is also available for setting a default that lasts for the rest of the context. Resolution order insideAuthBoto: explicitboto3_session=kwarg →use_session/set_session→boto3.Session().Presigned S3 artifact uploads
Set
SAGEMAKER_PRESIGNED_URL_UPLOAD_ENABLED=trueto route recognized S3 artifact uploads through URLs issued by the MLflow tracking server. The tracking-server request uses SageMaker authentication, while the file is streamed directly to the returned S3 URL so those uploads do not require direct S3 write credentials.Once a presigned upload is attempted, request or PUT failures propagate to the caller; there is no silent fallback to direct S3. When the setting is disabled, the repository retains the standard MLflow direct-S3 behavior.
When the setting is enabled and the repository has a tracking URI, artifact roots that cannot be identified as run or logged-model targets fail before any server or S3 request; they do not fall back to direct S3. Repositories without a tracking URI retain the standard MLflow direct-S3 behavior.
Warning: trace logging is not supported with presigned uploads
Presigned uploads for MLflow 3 logged-model artifacts (
log_model) require both a client containing logged-model scope support and a tracking server containing mlflow/mlflow#24765. Upgrading only one side does not enable the flow: an older client still sends the model ID asrun_id, while a newer client sendsmodel_id, which an older server does not support.Development details
setup.py
setup.pyContains the primary entry points for the sdk.install_requiresInstallsmlflow-skinny(lightweight) by default. The[full]extra installs the fullmlflowpackage.entry_pointsContains the entry points for the sdk. See https://mlflow.org/docs/latest/plugins.html#defining-a-plugin for more details.Running tests
Setup
To run tests using tox, run:
Installing tox will enable users to run multi-environment tests. On the other hand, if running individual tests in a single environment, feel free to continue to use pytest instead.
Running format checks
Formatting code to comply with format checks
Running unit tests
Running integration tests
Available test environments by default
tox.ini contains support for:
To add test environments on tox for additional versions of python or mlflow, modify the environment configs in
envlist, as well asdepsanddependsin[testenv].