Add M4Client capabilities and download endpoints#46
Merged
Conversation
Introduce M4Client and an explicit execution context for Python, CLI, and MCP data access. Route tool telemetry, backend selection, BigQuery billing project, and DuckDB path handling through context while preserving existing adapter output shapes and direct backend compatibility. CLI schema, describe-table, and query no longer use temporary runtime environment overrides for dataset or backend selection. Public module functions continue to preserve notebook-facing dataset configuration behavior.
Add NDJSON init progress reporting, credentialed PhysioNet download support, and richer status setup metadata so wrappers can drive dataset setup without parsing human output. Credentialed datasets now return raw_files_missing when local artifacts are absent and --download was not requested. Bump M4 to 0.5.0 and document the credential-file flow; no migration is required beyond callers handling the new failure code.
Expose the capabilities manifest through M4Client, the public Python API, CLI, and MCP while adding doctor/setup-agent helpers for agent workflows. Add the standalone download command on top of the existing PhysioNet downloader, including credential-file support, resumable manual guidance, NDJSON events, and stable JSON errors. Behavioral note: credentialed direct downloads require an explicit credentials file; without one the command returns blocked guidance. Verified with ruff, focused regression tests, full pytest, and manual CLI/MCP endpoint checks.
Compute the wget cut-dirs value from the PhysioNet listing URL and reuse the generated command in init guidance so manual downloads land in the raw layout expected by validation and initialization. Update credentialed download documentation and add structural capability-contract tests without introducing golden snapshots. Manual guidance now emits --cut-dirs=3 -nH for current built-in PhysioNet datasets; no schema version or migration change is required.
Make the init guidance assertion tolerant of Rich line wrapping in CI while still verifying that the generated command targets the expected raw files layout. This is a test-only fix; it has no behavioral, migration, or schema implications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
M4Client, the public Python API, CLI, and MCP tool/resourcem4 download DATASETon top of the branch's existing PhysioNet downloader, including credential-file support, manual blocked guidance, NDJSON events, and stable JSON errorsBehavioral notes
--physionet-credentials-file; without it,m4 downloadreturns blocked guidance and a resumable quotedwgetcommandm4 capabilities --jsonworks even when no active dataset is configureddoctoronly fails DuckDB setup for the active dataset, not every uninitialized registered datasetVerification
uv run ruff checkon touched Python filesuv run pytest tests/test_capabilities_download_setup.py tests/test_client.py tests/test_mcp_server.py tests/test_data_io.py tests/test_services_init.pyuv run pytestm4 capabilities --json,m4 doctor --json,m4 setup-agent --dataset mimic-iv-ed --backend duckdb --format json,m4 download mimic-iv-ed --json, and MCPcapabilitiestool/resource viafastmcp.Client