simpa icon indicating copy to clipboard operation
simpa copied to clipboard

TestPathManager test_instantiate_without_file fails with existing `path_config.env

Open TomTomRixRix opened this issue 1 year ago • 4 comments

Describe the bug The test fails in this line

self.assertEqual(path_manager.get_mcx_binary_path(), "test_mcx_path")

when the MCX_BINARY_PATH is set in path_config.env in the home directory.

Specify a priority (low, medium, high) medium

To Reproduce Steps to reproduce the behavior:

  1. Setup python 3
  2. Setup virtual environment
  3. Install SIMPA from develop 1226692
  4. Create path_config.env file in home directory with MCX_BINARY_PATH set to a path
  5. Run simpa_tests/automatic_tests/test_path_manager.py
  6. See failing test

Current Behavior Test fails with: AssertionError: '/home/tom/dev/mcx/bin/mcx' != 'test_mcx_path'

Expected behavior Test passes

Environment (please complete the following information):

  • OS: Ubuntu 22.04
  • SIMPA version: 1226692
  • IDE VSCode

Additional context Add any other context about the problem here, e.g. possible solution(s).

TomTomRixRix avatar Jun 25 '24 14:06 TomTomRixRix

Maybe @leoyala knows more? Is there a solution with @patch.dict decorators?

TomTomRixRix avatar Jun 25 '24 14:06 TomTomRixRix

Theoretically, the decorator in that test should set the environment variable for the mcx path to "test_mcx_path". This should be the path that MCX uses for the path manager. I do see that there might be some conflicts if botht eh path in the home directory is set and when not. @TomTomRixRix are you working on this?

leoyala avatar Jun 25 '24 15:06 leoyala

Ok, I see. With the new option to set the SIMPA_SAVE_PATH in environment variables it is unclear which option is prioritized in the order: https://github.com/IMSY-DKFZ/simpa/tree/develop?tab=readme-ov-file#path-management

I would suggest the following order:

  1. The optional path you give the PathManager
  2. The environment variables
  3. Your home directory
  4. The current working directory
  5. The SIMPA home directory path

TomTomRixRix avatar Jun 25 '24 16:06 TomTomRixRix

That order of priority seems good to me

leoyala avatar Jun 26 '24 12:06 leoyala

Fixed by #347

kdreher avatar Aug 15 '24 12:08 kdreher