Ejemplo n.º 1
0
 def test_module_load_in_map(self):
     analysis = self.create_analysis(
         RequirementsAnalysis,
         'requirements', [FilesetFilter('ones', 'ones', text_format)],
         environment=ModulesEnv())
     threes = analysis.data('threes', derive=True)
     fours = analysis.data('fours', derive=True)
     self.assertEqual(next(iter(threes)).value, 3)
     self.assertEqual(next(iter(fours)).value, 4)
     self.assertEqual(ModulesEnv.loaded(), {})
Ejemplo n.º 2
0
 def test_module_load_in_map(self):
     study = self.create_study(RequirementsStudy,
                               'requirements',
                               [InputFilesets('ones', 'ones', text_format)],
                               environment=ModulesEnv())
     threes = study.data('threes')
     fours = study.data('fours')
     self.assertEqual(next(iter(threes)).value, 3)
     self.assertEqual(next(iter(fours)).value, 4)
     self.assertEqual(ModulesEnv.loaded(), {})
Ejemplo n.º 3
0
 def test_run_cmd(self):
     ModulesEnv._run_module_cmd('avail')  # pylint: disable=protected-access
     self.assertRaises(
         ArcanaModulesError,
         ModulesEnv._run_module_cmd,  # pylint: disable=protected-access
         'badcmd')
     self.assertRaises(
         ArcanaModulesError,
         ModulesEnv._run_module_cmd,  # pylint: disable=protected-access
         'load',
         'somereallyunlikelymodulename')
Ejemplo n.º 4
0
 def _run_interface(self, runtime):
     loaded_modules = ModulesEnv.loaded()
     if first_req.name not in loaded_modules:
         raise ArcanaError("First Test module was not loaded in Node")
     if second_req.name not in loaded_modules:
         raise ArcanaError("Second Test module was not loaded in Node")
     return runtime
Ejemplo n.º 5
0
 def detect_version_str(self):
     try:
         return os.environ[self.name.upper() + '_VERSION']
     except KeyError:
         loaded_modules = ModulesEnv.loaded()
         raise ArcanaError(
             "Did not find {} in environment variables, found '{}'. "
             "The loaded modules are {}".format(
                 self.name.upper() + '_VERSION',
                 "', '".join(os.environ.keys()), ', '.join(loaded_modules)))
Ejemplo n.º 6
0
from unittest import TestCase
from nipype.interfaces.utility import IdentityInterface
from arcana.utils.testing import BaseTestCase
from banana.interfaces.mrtrix import MRConvert
from arcana.exceptions import ArcanaModulesNotInstalledException
from banana.file_format import (dicom_format, mrtrix_image_format,
                                nifti_gz_format)
from arcana.study.base import Study, StudyMetaClass
from arcana.data import InputFilesets, FilesetSpec, InputFilesetSpec
from arcana.environment import ModulesEnv, StaticEnv

try:
    ModulesEnv._run_module_cmd('avail')
except ArcanaModulesNotInstalledException:
    environment = StaticEnv()
else:
    environment = ModulesEnv(fail_on_missing=False)


class DummyStudy(Study, metaclass=StudyMetaClass):

    add_data_specs = [
        InputFilesetSpec('input_fileset', dicom_format),
        FilesetSpec('output_fileset', nifti_gz_format, 'a_pipeline')
    ]

    def a_pipeline(self):
        pipeline = self.new_pipeline(
            name='a_pipeline',
            inputs=[FilesetSpec('input_fileset', nifti_gz_format)],
            outputs=[FilesetSpec('output_fileset', nifti_gz_format)],
Ejemplo n.º 7
0
 def test_module_load(self):
     analysis = self.create_analysis(RequirementsAnalysis,
                                     'requirements', {'ones': 'ones'},
                                     environment=ModulesEnv())
     self.assertContentsEqual(analysis.data('twos', derive=True), 2.0)
     self.assertEqual(ModulesEnv.loaded(), {})
Ejemplo n.º 8
0
 def setUp(self):
     super().setUp()
     ModulesEnv._run_module_cmd('purge')  # pylint: disable=protected-access
Ejemplo n.º 9
0
        try:
            return os.environ[self.name.upper() + '_VERSION']
        except KeyError:
            loaded_modules = ModulesEnv.loaded()
            raise ArcanaError(
                "Did not find {} in environment variables, found '{}'. "
                "The loaded modules are {}".format(
                    self.name.upper() + '_VERSION',
                    "', '".join(os.environ.keys()), ', '.join(loaded_modules)))


first_req = DummyRequirement('firsttestmodule')
second_req = DummyRequirement('secondtestmodule')

try:
    ModulesEnv._run_module_cmd('avail')  # pylint: disable=protected-access
except ArcanaModulesNotInstalledException:
    MODULES_NOT_INSTALLED = True
else:
    MODULES_NOT_INSTALLED = False

SKIP_ARGS = (MODULES_NOT_INSTALLED, "Environment modules are not installed")


class TestMathWithReq(TestMath):
    def _run_interface(self, runtime):
        loaded_modules = ModulesEnv.loaded()
        if first_req.name not in loaded_modules:
            raise ArcanaError("First Test module was not loaded in Node")
        if second_req.name not in loaded_modules:
            raise ArcanaError("Second Test module was not loaded in Node")
Ejemplo n.º 10
0
 def test_run_cmd(self):
     ModulesEnv._run_module_cmd('avail')
     self.assertRaises(ArcanaModulesError, ModulesEnv._run_module_cmd,
                       'badcmd')
     self.assertRaises(ArcanaModulesError, ModulesEnv._run_module_cmd,
                       'load', 'somereallyunlikelymodulename')
Ejemplo n.º 11
0
 def test_module_load(self):
     study = self.create_study(RequirementsStudy,
                               'requirements', {'ones': 'ones'},
                               environment=ModulesEnv())
     self.assertContentsEqual(study.data('twos'), 2.0)
     self.assertEqual(ModulesEnv.loaded(), {})
Ejemplo n.º 12
0
        try:
            return os.environ[self.name.upper() + '_VERSION']
        except KeyError:
            loaded_modules = ModulesEnv.loaded()
            raise ArcanaError(
                "Did not find {} in environment variables, found '{}'. "
                "The loaded modules are {}".format(
                    self.name.upper() + '_VERSION',
                    "', '".join(os.environ.keys()), ', '.join(loaded_modules)))


first_req = DummyRequirement('firsttestmodule')
second_req = DummyRequirement('secondtestmodule')

try:
    ModulesEnv._run_module_cmd('avail')
except ArcanaModulesNotInstalledException:
    MODULES_NOT_INSTALLED = True
else:
    MODULES_NOT_INSTALLED = False

SKIP_ARGS = (MODULES_NOT_INSTALLED, "Environment modules are not installed")


class TestMathWithReq(TestMath):
    def _run_interface(self, runtime):
        loaded_modules = ModulesEnv.loaded()
        if first_req.name not in loaded_modules:
            raise ArcanaError("First Test module was not loaded in Node")
        if second_req.name not in loaded_modules:
            raise ArcanaError("Second Test module was not loaded in Node")