Skip to content

Dev#267

Merged
mmcdermott merged 32 commits intomainfrom
dev
Apr 10, 2026
Merged

Dev#267
mmcdermott merged 32 commits intomainfrom
dev

Conversation

@mmcdermott
Copy link
Copy Markdown
Collaborator

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 16, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
105 1 104 21
View the full list of 1 ❄️ flaky test(s)
tests.test_2_supervised_models::test_supervised[mortality/in_icu/first_24h-MIMIC-IV-meds_tab/tiny]

Flake rate in main: 100.00% (Passed 0 times, Failed 1 times)

Stack Traces | 8.99s run time
request = <SubRequest 'supervised_model' for <Function test_supervised[.../in_icu/first_24h-MIMIC-IV-meds_tab/tiny]>>
unsupervised_model = ('meds_tab/tiny', None)
demo_dataset = ('MIMIC-IV', PosixPath('.............../tmp/tmp6drnp9im/MIMIC-IV'))
task_labels = ('mortality/in_icu/first_24h', PosixPath('.../mortality/in_icu/first_24h'))
venv_cache = PosixPath('.../tmp/tmpcvxbyxkz/venvs')

    @pytest.fixture(scope="session")
    def supervised_model(
        request,
        unsupervised_model: NAME_AND_DIR,
        demo_dataset: NAME_AND_DIR,
        task_labels: NAME_AND_DIR,
        venv_cache: Path,
    ) -> NAME_AND_DIR:
        model, unsupervised_train_dir = unsupervised_model
        dataset_name, dataset_dir = demo_dataset
        task_name, task_labels_dir = task_labels
    
        venv_dir = venv_cache / "model"
        model_fp = venv_dir / "model_name.txt"
        if model_fp.is_file():
            other_model_name = model_fp.read_text().strip()
            if other_model_name != model:
                logger.info(f"Deleting venv for {other_model_name} at {venv_dir}")
                shutil.rmtree(venv_dir)
        else:
            model_fp.parent.mkdir(parents=True, exist_ok=True)
            model_fp.write_text(model)
    
        missing_splits = missing_labels_in_splits(task_labels_dir, dataset_dir)
        if missing_splits:
            pytest.skip(
                f"Labels not found for {dataset_name} and {task_name} in split(s): {', '.join(missing_splits)}. "
                f"Skipping {model} test."
            )
    
        _, _, reuse_models = get_and_validate_reuse_settings(request)
    
        do_overwrite = model not in reuse_models
    
        persistent_cache_dir, (_, _, cache_models) = get_and_validate_cache_settings(request)
    
        shared_kwargs = {
            "model": model,
            "dataset_type": "supervised",
            "mode": "full",
            "dataset_dir": str(dataset_dir.resolve()),
            "labels_dir": str(task_labels_dir.resolve()),
            "dataset_name": dataset_name,
            "task_name": task_name,
            "demo": True,
        }
        if unsupervised_train_dir is not None:
            shared_kwargs["model_initialization_dir"] = str(unsupervised_train_dir.resolve())
    
        with cache_dir(persistent_cache_dir if model in cache_models else None) as root_dir:
            check_fp = root_dir / f".{model}.{dataset_name}.{task_name}.check"
            model_dir = root_dir / model
    
            already_tested = check_fp.exists() and model_dir.is_dir()
    
            if do_overwrite or not already_tested:
>               run_command(
                    "meds-dev-model",
                    test_name=f"Model {model} should run on {dataset_name} and {task_name}",
                    hydra_kwargs={
                        **shared_kwargs,
                        "output_dir": str(model_dir.resolve()),
                        "venv_dir": str(venv_dir.resolve()),
                    },
                )

tests/conftest.py:604: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

script = ['meds-dev-model', 'model=meds_tab/tiny dataset_type=supervised mode=full dataset_dir=.............../tmp/tmp6drnp9im/MIMIC-IV labels...=mortality/in_icu/first_24h demo=true output_dir=.../tmp1vijd6q1/meds_tab/tiny venv_dir=....../tmpcvxbyxkz/venvs/model']
test_name = 'Model meds_tab/tiny should run on MIMIC-IV and mortality/in_icu/first_24h'
hydra_kwargs = {'dataset_dir': '.............../tmp/tmp6drnp9im/MIMIC-IV', 'dataset_name': 'MIMIC-IV', 'dataset_type': 'supervised', 'demo': True, ...}
config_name = None, should_error = False, want_err_msg = None
do_use_config_yaml = False

    def run_command(
        script: Path | str,
        test_name: str,
        hydra_kwargs: dict[str, str] | None = None,
        config_name: str | None = None,
        should_error: bool = False,
        want_err_msg: str | None = None,
        do_use_config_yaml: bool = False,
    ):
        script = ["python", str(script.resolve())] if isinstance(script, Path) else [script]
        command_parts = script
    
        err_cmd_lines = []
    
        if config_name is not None and not config_name.startswith("_"):
            config_name = f"_{config_name}"
    
        if hydra_kwargs is None:
            hydra_kwargs = {}
    
        if do_use_config_yaml:
            if config_name is None:
                raise ValueError("config_name must be provided if do_use_config_yaml is True.")
    
            conf = OmegaConf.create(
                {
                    "defaults": [config_name],
                    **hydra_kwargs,
                }
            )
    
            conf_dir = tempfile.TemporaryDirectory()
            conf_path = Path(conf_dir.name) / "config.yaml"
            OmegaConf.save(conf, conf_path)
    
            command_parts.extend(
                [
                    f"--config-path={conf_path.parent.resolve()!s}",
                    "--config-name=config",
                    "'hydra.searchpath=[pkg://MEDS_transforms.configs]'",
                ]
            )
            err_cmd_lines.append(f"Using config yaml:\n{OmegaConf.to_yaml(conf)}")
        else:
            if config_name is not None:
                command_parts.append(f"--config-name={config_name}")
            command_parts.append(" ".join(dict_to_hydra_kwargs(hydra_kwargs)))
    
        full_cmd = " ".join(command_parts)
        err_cmd_lines.append(f"Running command: {full_cmd}")
        command_out = subprocess.run(full_cmd, shell=True, capture_output=True)
    
        command_errored = command_out.returncode != 0
    
        stderr = command_out.stderr.decode()
        err_cmd_lines.append(f"stderr:\n{stderr}")
        stdout = command_out.stdout.decode()
        err_cmd_lines.append(f"stdout:\n{stdout}")
    
        if should_error:
            err_cmd_str = "\n".join(err_cmd_lines)
            if not command_errored:
                if do_use_config_yaml:
                    conf_dir.cleanup()
                raise AssertionError(f"{test_name} failed as command did not error when expected!\n{err_cmd_str}")
            if want_err_msg is not None and want_err_msg not in stderr:
                if do_use_config_yaml:
                    conf_dir.cleanup()
                raise AssertionError(
                    f"{test_name} failed as expected error message not found in stderr!\n{err_cmd_str}"
                )
        elif not should_error and command_errored:
            if do_use_config_yaml:
                conf_dir.cleanup()
>           raise AssertionError(
                f"{test_name} failed as command errored when not expected!\n" + "\n".join(err_cmd_lines)
            )
E           AssertionError: Model meds_tab/tiny should run on MIMIC-IV and mortality/in_icu/first_24h failed as command errored when not expected!
E           Running command: meds-dev-model model=meds_tab/tiny dataset_type=supervised mode=full dataset_dir=.............../tmp/tmp6drnp9im/MIMIC-IV labels_dir=.../mortality/in_icu/first_24h dataset_name=MIMIC-IV task_name=mortality/in_icu/first_24h demo=true output_dir=.../tmp1vijd6q1/meds_tab/tiny venv_dir=....../tmpcvxbyxkz/venvs/model
E           stderr:
E           Using CPython 3.11.15 interpreter at: .venv/bin/python
E           Creating virtual environment at: ....../tmpcvxbyxkz/venvs/model
E           Activate with: ....../tmpcvxbyxkz/venvs/model/bin/activate
E           Using Python 3.11.15 environment at: ....../tmpcvxbyxkz/venvs/model
E           Resolved 54 packages in 445ms
E           Downloading xgboost (125.6MiB)
E           Downloading nvidia-nccl-cu12 (280.0MiB)
E            Downloaded xgboost
E            Downloaded nvidia-nccl-cu12
E              Building scipy==1.6.1
E             × Failed to build `scipy==1.6.1`
E             ├─▶ The build backend returned an error
E             ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit
E                 status: 1)
E           
E                 [stdout]
E                 INFO: lapack_opt_info:
E                 INFO: lapack_armpl_info:
E                 INFO: customize UnixCCompiler
E                 INFO:   libraries armpl_lp64_mp not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: lapack_mkl_info:
E                 INFO:   libraries mkl_rt not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: lapack_ssl2_info:
E                 INFO:   libraries fjlapackexsve not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: openblas_lapack_info:
E                 INFO:   libraries openblas not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: openblas_clapack_info:
E                 INFO:   libraries openblas,lapack not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: flame_info:
E                 INFO:   libraries flame not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: accelerate_info:
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: atlas_3_10_threads_info:
E                 INFO: Setting PTATLAS=ATLAS
E                 INFO:   libraries tatlas,tatlas not found in
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib
E                 INFO:   libraries tatlas,tatlas not found in ................................./usr/local/lib
E                 INFO:   libraries tatlas,tatlas not found in /usr/lib64
E                 INFO:   libraries tatlas,tatlas not found in /usr/lib
E                 INFO:   libraries tatlas,tatlas not found in ................................./usr/lib/x86_64-linux-gnu
E                 INFO: <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: atlas_3_10_info:
E                 INFO:   libraries satlas,satlas not found in
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib
E                 INFO:   libraries satlas,satlas not found in ................................./usr/local/lib
E                 INFO:   libraries satlas,satlas not found in /usr/lib64
E                 INFO:   libraries satlas,satlas not found in /usr/lib
E                 INFO:   libraries satlas,satlas not found in ................................./usr/lib/x86_64-linux-gnu
E                 INFO: <class 'numpy.distutils.system_info.atlas_3_10_info'>
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: atlas_threads_info:
E                 INFO: Setting PTATLAS=ATLAS
E                 INFO:   libraries ptf77blas,ptcblas,atlas not found in
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib
E                 INFO:   libraries ptf77blas,ptcblas,atlas not found in ................................./usr/local/lib
E                 INFO:   libraries ptf77blas,ptcblas,atlas not found in /usr/lib64
E                 INFO:   libraries ptf77blas,ptcblas,atlas not found in /usr/lib
E                 INFO:   libraries ptf77blas,ptcblas,atlas not found in
E                 ................................./usr/lib/x86_64-linux-gnu
E                 INFO: <class 'numpy.distutils.system_info.atlas_threads_info'>
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: atlas_info:
E                 INFO:   libraries f77blas,cblas,atlas not found in
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib
E                 INFO:   libraries f77blas,cblas,atlas not found in ................................./usr/local/lib
E                 INFO:   libraries f77blas,cblas,atlas not found in /usr/lib64
E                 INFO:   libraries f77blas,cblas,atlas not found in /usr/lib
E                 INFO:   libraries f77blas,cblas,atlas not found in
E                 ................................./usr/lib/x86_64-linux-gnu
E                 INFO: <class 'numpy.distutils.system_info.atlas_info'>
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: lapack_info:
E                 INFO:   libraries lapack not found in
E                 ['.../setup-uv-cache/builds-v0/.tmpfNpSYx/lib',
E                 '................................./usr/local/lib', '/usr/lib64', '/usr/lib', '................................./usr/lib/x86_64-linux-gnu']
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO: lapack_src_info:
E                 INFO:   NOT AVAILABLE
E                 INFO:
E                 INFO:   NOT AVAILABLE
E                 INFO:
E           
E                 [stderr]
E                 setup.py:563: DeprecationWarning:
E           
E                   `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
E                   of the deprecation of `distutils` itself. It will be removed for
E                   Python >= 3.12. For older Python versions it will remain present.
E                   It is recommended to use `setuptools < 60.0` for those Python
E                 versions.
E                   For more details, see:
E                     https://numpy..../devdocs/reference/distutils_status_migration.html
E           
E           
E                   from numpy.distutils.core import setup
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11.../site-packages/wheel/bdist_wheel.py:4:
E                 FutureWarning: The 'wheel' package is no longer the canonical location
E                 of the 'bdist_wheel' command, and will be removed in a future release.
E                 Please update to setuptools v70.1 or later which contains an integrated
E                 version of this command.
E                   warn(
E                 Running from SciPy source directory.
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11.../numpy/distutils/system_info.py:1973:
E                 UserWarning:
E                     Lapack (http://www.netlib.org/lapack/) libraries not found.
E                     Directories to search for the libraries can be specified in the
E                     numpy/distutils/site.cfg file (section [lapack]) or by setting
E                     the LAPACK environment variable.
E                   return getattr(self, '_calc_info_{}'.format(name))()
E                 .../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11.../numpy/distutils/system_info.py:1973:
E                 UserWarning:
E                     Lapack (http://www.netlib.org/lapack/) sources not found.
E                     Directories to search for the sources can be specified in the
E                     numpy/distutils/site.cfg file (section [lapack_src]) or by setting
E                     the LAPACK_SRC environment variable.
E                   return getattr(self, '_calc_info_{}'.format(name))()
E                 Traceback (most recent call last):
E                   File "<string>", line 11, in <module>
E                   File
E                 ".../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11............/site-packages/setuptools/build_meta.py",
E                 line 216, in build_wheel
E                     return self._build_with_temp_dir(['bdist_wheel'], '.whl',
E                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E                   File
E                 ".../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11............/site-packages/setuptools/build_meta.py",
E                 line 202, in _build_with_temp_dir
E                     self.run_setup()
E                   File
E                 ".../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11............/site-packages/setuptools/build_meta.py",
E                 line 254, in run_setup
E                     self).run_setup(setup_script=setup_script)
E                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E                   File
E                 ".../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11............/site-packages/setuptools/build_meta.py",
E                 line 145, in run_setup
E                     exec(compile(code, __file__, 'exec'), locals())
E                   File "setup.py", line 588, in <module>
E                     setup_package()
E                   File "setup.py", line 584, in setup_package
E                     setup(**metadata)
E                   File
E                 ".../setup-uv-cache/builds-v0/.tmpfNpSYx/lib/python3.11.../numpy/distutils/core.py",
E                 line 135, in setup
E                     config = configuration()
E                              ^^^^^^^^^^^^^^^
E                   File "setup.py", line 499, in configuration
E                     raise NotFoundError(msg)
E                 numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries
E                 found.
E                 To build Scipy from sources, BLAS & LAPACK libraries need to be
E                 installed.
E                 See site.cfg.example in the Scipy source directory and
E                 https://docs.scipy..../reference/building/index.html for
E                 details.
E           
E                 hint: This usually indicates a problem with the package or the build
E                 environment.
E             help: `scipy` (v1.6.1) was included because `meds-tab` (v0.1) depends on
E                   `scipy`
E           Error executing job with overrides: ['model=meds_tab/tiny', 'dataset_type=supervised', 'mode=full', 'dataset_dir=.............../tmp/tmp6drnp9im/MIMIC-IV', 'labels_dir=.../mortality/in_icu/first_24h', 'dataset_name=MIMIC-IV', 'task_name=mortality/in_icu/first_24h', 'demo=true', 'output_dir=.../tmp1vijd6q1/meds_tab/tiny', 'venv_dir=....../tmpcvxbyxkz/venvs/model']
E           Traceback (most recent call last):
E             File ".../MEDS_DEV/models/__main__.py", line 30, in main
E               with temp_env(cfg, requirements) as (temp_dir, env):
E             File ".../hostedtoolcache/Python/3.11.15....../x64/lib/python3.11/contextlib.py", line 137, in __enter__
E               return next(self.gen)
E                      ^^^^^^^^^^^^^^
E             File ".../src/MEDS_DEV/utils.py", line 344, in temp_env
E               install_venv(venv_dir, requirements)
E             File ".../src/MEDS_DEV/utils.py", line 300, in install_venv
E               subprocess.run(
E             File ".../hostedtoolcache/Python/3.11.15....../x64/lib/python3.11/subprocess.py", line 571, in run
E               raise CalledProcessError(retcode, process.args,
E           subprocess.CalledProcessError: Command '['.../MEDS-DEV/MEDS-DEV/.venv/bin/uv', 'pip', 'install', '-r', '.../meds_tab/tiny/requirements.txt', '--python', '....../tmpcvxbyxkz/venvs/model/bin/python']' returned non-zero exit status 1.
E           
E           Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
E           
E           stdout:
E           [2026-04-10 18:06:13,065][MEDS_DEV.utils][INFO] - Installing requirements from .../meds_tab/tiny/requirements.txt into virtual environment.

tests/utils.py:146: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

mmcdermott and others added 8 commits April 4, 2026 15:44
- Fix doctest in conftest.py: use pytest.UsageError instead of
  _pytest.config.exceptions.UsageError
- Update MIMIC-IV dataset.yaml for MIMIC-IV-MEDS 0.1.0: replace
  MEDS_cohort_dir with MEDS_output_dir and add root_output_dir
- Bump cehrbert to 1.4.9 (1.3.5 had numpy/pandas conflict) and add
  tf-keras to fix Keras 3 compatibility with transformers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add uv as a project dependency and use it in install_venv() instead of
stdlib venv + pip. This avoids the need for the python3.X-venv system
package and enables future support for creating venvs with different
Python versions (e.g. uv venv --python 3.11 for models that need older
packages).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use 2-space indent for bash continuation lines to match CI's
mdformat-shfmt formatting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Pass --clear to uv venv so it tolerates pre-existing directories
  (the test fixture writes model_name.txt inside the venv dir before
  install_venv runs)
- Pin all mdformat plugin versions in .pre-commit-config.yaml and add
  shfmt-py so the shfmt binary is bundled in the hook environment,
  making formatting deterministic across local and CI
- Update CLAUDE.md bash indentation to match pinned shfmt output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This fixes some test and PR issues, and makes the venv installation more robust and fast -- there is an outstanding failure with meds-tab which is an upstream issue.
mmcdermott and others added 3 commits April 10, 2026 13:52
- Bump meds-tab from 0.1 to 0.2.0, which no longer pins scipy==1.6.1
  (fixes the build failure on Python 3.11+)
- Remove hydra-optuna-sweeper==1.3.0.dev0 pin (meds-tab 0.2.0 pulls
  in its own compatible version)
- Remove hydra.sweeper.max_failure_rate override which is not supported
  by hydra-optuna-sweeper 1.2.0

Closes #274

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…-v0.2

Upgrade meds-tab to 0.2.0 (fixes scipy build failure)
@mmcdermott mmcdermott merged commit 9d6fa08 into main Apr 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant