|
6 | 6 |
|
7 | 7 | from tests import utils |
8 | 8 |
|
9 | | -@pytest.mark.parametrize( |
10 | | - "create_tmp_simulation_config_file", |
11 | | - [{"simconfig_fixture": "ringtest_baseconfig"}], |
12 | | - indirect=True, |
13 | | -) |
14 | | -def test_cli_color(create_tmp_simulation_config_file): |
15 | | - out = subprocess.run( |
16 | | - ["neurodamus", create_tmp_simulation_config_file], |
17 | | - check=False, |
18 | | - capture_output=True, |
19 | | - cwd=str(Path(create_tmp_simulation_config_file).parent) |
20 | | - ) |
21 | | - assert b"\033[0m" in out.stdout |
22 | | - |
23 | | - out = subprocess.run( |
24 | | - ["neurodamus", create_tmp_simulation_config_file, "--use-color=OFF"], |
25 | | - check=False, |
26 | | - capture_output=True, |
27 | | - cwd=str(Path(create_tmp_simulation_config_file).parent) |
28 | | - ) |
29 | | - assert b"\033[0m" not in out.stdout |
30 | | - |
31 | | - |
32 | | -@pytest.mark.parametrize( |
33 | | - "create_tmp_simulation_config_file", |
34 | | - [{"simconfig_fixture": "ringtest_baseconfig"}], |
35 | | - indirect=True, |
36 | | -) |
37 | | -def test_cli_prcellgid(create_tmp_simulation_config_file): |
38 | | - tmp_path = Path(create_tmp_simulation_config_file).parent |
39 | | - subprocess.run( |
40 | | - ["neurodamus", create_tmp_simulation_config_file, "--dump-cell-state=1", "--keep-build"], |
41 | | - check=True, |
42 | | - ) |
43 | | - assert (tmp_path / "output" / "2_py_Neuron_t0.0.nrndat").is_file() |
44 | | - assert (tmp_path / "output" / "2_py_Neuron_t50.0.nrndat").is_file() |
45 | | - |
46 | | - |
47 | | -@pytest.mark.parametrize( |
48 | | - "create_tmp_simulation_config_file", |
49 | | - [ |
50 | | - { |
51 | | - "simconfig_fixture": "ringtest_baseconfig", |
52 | | - "extra_config": {"target_simulator": "CORENEURON"}, |
53 | | - } |
54 | | - ], |
55 | | - indirect=True, |
56 | | -) |
57 | | -def test_cli_keep_build(create_tmp_simulation_config_file): |
58 | | - tmp_path = Path(create_tmp_simulation_config_file).parent |
59 | | - subprocess.run(["neurodamus", create_tmp_simulation_config_file, "--keep-build"], check=True) |
60 | | - coreneuron_input_dir = tmp_path / "build" / "coreneuron_input" |
61 | | - assert coreneuron_input_dir.is_dir(), "Directory 'coreneuron_input' not found." |
62 | | - |
63 | | - |
64 | | -@pytest.mark.parametrize( |
65 | | - "create_tmp_simulation_config_file", |
66 | | - [ |
67 | | - { |
68 | | - "simconfig_fixture": "ringtest_baseconfig", |
69 | | - "extra_config": {"target_simulator": "CORENEURON"}, |
70 | | - } |
71 | | - ], |
72 | | - indirect=True, |
73 | | -) |
74 | | -def test_cli_build_model(create_tmp_simulation_config_file): |
75 | | - res = subprocess.run( |
76 | | - [ |
77 | | - "neurodamus", |
78 | | - create_tmp_simulation_config_file, |
79 | | - "--simulate-model=OFF", |
80 | | - "--disable-reports", |
81 | | - ], |
82 | | - check=True, |
83 | | - capture_output=True, |
84 | | - text=True, |
85 | | - ) |
86 | | - assert "[SKIPPED] SIMULATION (MODEL BUILD ONLY)" in res.stdout |
87 | | - |
88 | | - res = subprocess.run( |
89 | | - ["neurodamus", create_tmp_simulation_config_file, "--disable-reports"], |
90 | | - check=True, |
91 | | - capture_output=True, |
92 | | - text=True, |
93 | | - ) |
94 | | - assert "SIMULATION (SKIP MODEL BUILD)" in res.stdout |
95 | | - |
96 | | - # run it once to create the data, so that the --build-model=OFF works |
97 | | - subprocess.run( |
98 | | - [ |
99 | | - "neurodamus", |
100 | | - create_tmp_simulation_config_file, |
101 | | - "--simulate-model=OFF", |
102 | | - "--disable-reports", |
103 | | - ], |
104 | | - check=True, |
105 | | - ) |
106 | | - res = subprocess.run( |
107 | | - ["neurodamus", create_tmp_simulation_config_file, "--build-model=OFF", "--disable-reports"], |
108 | | - check=True, |
109 | | - capture_output=True, |
110 | | - text=True, |
111 | | - ) |
112 | | - assert "SIMULATION (SKIP MODEL BUILD)" in res.stdout |
113 | | - |
114 | | - |
115 | | -@pytest.mark.parametrize( |
116 | | - "create_tmp_simulation_config_file", |
117 | | - [{"simconfig_fixture": "ringtest_baseconfig"}], |
118 | | - indirect=True, |
119 | | -) |
120 | | -def test_cli_lb_mode(create_tmp_simulation_config_file): |
121 | | - tmp_path = Path(create_tmp_simulation_config_file).parent |
122 | | - for lb_mode in ("WholeCell", "MultiSplit"): |
123 | | - res = subprocess.run( |
124 | | - [ |
125 | | - "neurodamus", |
126 | | - create_tmp_simulation_config_file, |
127 | | - f"--lb-mode={lb_mode}", |
128 | | - "--disable-reports", |
129 | | - ], |
130 | | - check=True, |
131 | | - capture_output=True, |
132 | | - text=True, |
133 | | - ) |
134 | | - assert f"Load Balancing ENABLED. Mode: {lb_mode}" in res.stdout |
135 | | - assert (tmp_path / "mcomplex.dat").is_file(), "File 'mcomplex.dat' not found." |
136 | | - assert (tmp_path / "sim_conf").is_dir(), "Directory 'sim_conf' not found." |
137 | | - |
| 9 | +# @pytest.mark.parametrize( |
| 10 | +# "create_tmp_simulation_config_file", |
| 11 | +# [{"simconfig_fixture": "ringtest_baseconfig"}], |
| 12 | +# indirect=True, |
| 13 | +# ) |
| 14 | +# def test_cli_color(create_tmp_simulation_config_file): |
| 15 | +# out = subprocess.run( |
| 16 | +# ["neurodamus", create_tmp_simulation_config_file], |
| 17 | +# check=False, |
| 18 | +# capture_output=True, |
| 19 | +# cwd=str(Path(create_tmp_simulation_config_file).parent) |
| 20 | +# ) |
| 21 | +# assert b"\033[0m" in out.stdout |
| 22 | + |
| 23 | +# out = subprocess.run( |
| 24 | +# ["neurodamus", create_tmp_simulation_config_file, "--use-color=OFF"], |
| 25 | +# check=False, |
| 26 | +# capture_output=True, |
| 27 | +# cwd=str(Path(create_tmp_simulation_config_file).parent) |
| 28 | +# ) |
| 29 | +# assert b"\033[0m" not in out.stdout |
| 30 | + |
| 31 | + |
| 32 | +# @pytest.mark.parametrize( |
| 33 | +# "create_tmp_simulation_config_file", |
| 34 | +# [{"simconfig_fixture": "ringtest_baseconfig"}], |
| 35 | +# indirect=True, |
| 36 | +# ) |
| 37 | +# def test_cli_prcellgid(create_tmp_simulation_config_file): |
| 38 | +# tmp_path = Path(create_tmp_simulation_config_file).parent |
| 39 | +# subprocess.run( |
| 40 | +# ["neurodamus", create_tmp_simulation_config_file, "--dump-cell-state=1", "--keep-build"], |
| 41 | +# check=True, |
| 42 | +# ) |
| 43 | +# assert (tmp_path / "output" / "2_py_Neuron_t0.0.nrndat").is_file() |
| 44 | +# assert (tmp_path / "output" / "2_py_Neuron_t50.0.nrndat").is_file() |
| 45 | + |
| 46 | + |
| 47 | +# @pytest.mark.parametrize( |
| 48 | +# "create_tmp_simulation_config_file", |
| 49 | +# [ |
| 50 | +# { |
| 51 | +# "simconfig_fixture": "ringtest_baseconfig", |
| 52 | +# "extra_config": {"target_simulator": "CORENEURON"}, |
| 53 | +# } |
| 54 | +# ], |
| 55 | +# indirect=True, |
| 56 | +# ) |
| 57 | +# def test_cli_keep_build(create_tmp_simulation_config_file): |
| 58 | +# tmp_path = Path(create_tmp_simulation_config_file).parent |
| 59 | +# subprocess.run(["neurodamus", create_tmp_simulation_config_file, "--keep-build"], check=True) |
| 60 | +# coreneuron_input_dir = tmp_path / "build" / "coreneuron_input" |
| 61 | +# assert coreneuron_input_dir.is_dir(), "Directory 'coreneuron_input' not found." |
| 62 | + |
| 63 | + |
| 64 | +# @pytest.mark.parametrize( |
| 65 | +# "create_tmp_simulation_config_file", |
| 66 | +# [ |
| 67 | +# { |
| 68 | +# "simconfig_fixture": "ringtest_baseconfig", |
| 69 | +# "extra_config": {"target_simulator": "CORENEURON"}, |
| 70 | +# } |
| 71 | +# ], |
| 72 | +# indirect=True, |
| 73 | +# ) |
| 74 | +# def test_cli_build_model(create_tmp_simulation_config_file): |
| 75 | +# res = subprocess.run( |
| 76 | +# [ |
| 77 | +# "neurodamus", |
| 78 | +# create_tmp_simulation_config_file, |
| 79 | +# "--simulate-model=OFF", |
| 80 | +# "--disable-reports", |
| 81 | +# ], |
| 82 | +# check=True, |
| 83 | +# capture_output=True, |
| 84 | +# text=True, |
| 85 | +# ) |
| 86 | +# assert "[SKIPPED] SIMULATION (MODEL BUILD ONLY)" in res.stdout |
| 87 | + |
| 88 | +# res = subprocess.run( |
| 89 | +# ["neurodamus", create_tmp_simulation_config_file, "--disable-reports"], |
| 90 | +# check=True, |
| 91 | +# capture_output=True, |
| 92 | +# text=True, |
| 93 | +# ) |
| 94 | +# assert "SIMULATION (SKIP MODEL BUILD)" in res.stdout |
| 95 | + |
| 96 | +# # run it once to create the data, so that the --build-model=OFF works |
| 97 | +# subprocess.run( |
| 98 | +# [ |
| 99 | +# "neurodamus", |
| 100 | +# create_tmp_simulation_config_file, |
| 101 | +# "--simulate-model=OFF", |
| 102 | +# "--disable-reports", |
| 103 | +# ], |
| 104 | +# check=True, |
| 105 | +# ) |
| 106 | +# res = subprocess.run( |
| 107 | +# ["neurodamus", create_tmp_simulation_config_file, "--build-model=OFF", "--disable-reports"], |
| 108 | +# check=True, |
| 109 | +# capture_output=True, |
| 110 | +# text=True, |
| 111 | +# ) |
| 112 | +# assert "SIMULATION (SKIP MODEL BUILD)" in res.stdout |
| 113 | + |
| 114 | + |
| 115 | +# @pytest.mark.parametrize( |
| 116 | +# "create_tmp_simulation_config_file", |
| 117 | +# [{"simconfig_fixture": "ringtest_baseconfig"}], |
| 118 | +# indirect=True, |
| 119 | +# ) |
| 120 | +# def test_cli_lb_mode(create_tmp_simulation_config_file): |
| 121 | +# tmp_path = Path(create_tmp_simulation_config_file).parent |
| 122 | +# for lb_mode in ("WholeCell", "MultiSplit"): |
| 123 | +# res = subprocess.run( |
| 124 | +# [ |
| 125 | +# "neurodamus", |
| 126 | +# create_tmp_simulation_config_file, |
| 127 | +# f"--lb-mode={lb_mode}", |
| 128 | +# "--disable-reports", |
| 129 | +# ], |
| 130 | +# check=True, |
| 131 | +# capture_output=True, |
| 132 | +# text=True, |
| 133 | +# ) |
| 134 | +# assert f"Load Balancing ENABLED. Mode: {lb_mode}" in res.stdout |
| 135 | +# assert (tmp_path / "mcomplex.dat").is_file(), "File 'mcomplex.dat' not found." |
| 136 | +# assert (tmp_path / "sim_conf").is_dir(), "Directory 'sim_conf' not found." |
| 137 | + |
| 138 | + |
| 139 | +# @pytest.mark.parametrize( |
| 140 | +# "create_tmp_simulation_config_file", |
| 141 | +# [{"simconfig_fixture": "ringtest_baseconfig"}], |
| 142 | +# indirect=True, |
| 143 | +# ) |
| 144 | +# def test_cli_output_path(create_tmp_simulation_config_file): |
| 145 | +# tmp_path = Path(create_tmp_simulation_config_file).parent |
| 146 | +# new_output = "new-output" |
| 147 | +# subprocess.run( |
| 148 | +# ["neurodamus", create_tmp_simulation_config_file, f"--output-path={new_output}"], |
| 149 | +# check=True, |
| 150 | +# text=True, |
| 151 | +# ) |
| 152 | +# sc = libsonata.SimulationConfig.from_file(create_tmp_simulation_config_file) |
| 153 | +# # Output directory from simulation configuration is overridden |
| 154 | +# simconfig_output_path = tmp_path / sc.output.output_dir |
| 155 | +# assert not simconfig_output_path.is_dir(), ( |
| 156 | +# f"Directory '{simconfig_output_path}' should NOT exist." |
| 157 | +# ) |
| 158 | +# assert (tmp_path / new_output).is_dir(), f"Directory '{new_output}' not found." |
| 159 | + |
| 160 | +# @pytest.mark.skip(reason="to be enabled with #337") |
| 161 | +# @pytest.mark.parametrize( |
| 162 | +# "create_tmp_simulation_config_file", [ |
| 163 | +# { |
| 164 | +# "simconfig_fixture": "ringtest_baseconfig", |
| 165 | +# "extra_config": { |
| 166 | +# "target_simulator": "CORENEURON", |
| 167 | +# "reports": { |
| 168 | +# "soma_v": { |
| 169 | +# "type": "compartment", |
| 170 | +# "variable_name": "v", |
| 171 | +# "sections": "soma", |
| 172 | +# "dt": 0.1, |
| 173 | +# "start_time": 0.0, |
| 174 | +# "end_time": 40.0 |
| 175 | +# } |
| 176 | +# }, |
| 177 | +# } |
| 178 | +# } |
| 179 | +# ], indirect=True) |
| 180 | +# def test_cli_report_buff_size(create_tmp_simulation_config_file): |
| 181 | +# command = ["neurodamus", create_tmp_simulation_config_file, "--report-buffer-size=64", "--keep-build"] |
| 182 | +# subprocess.run(command, check=True, capture_output=True) |
| 183 | + |
| 184 | +# report_confs = utils.ReportConf.load("build/report.conf") |
| 185 | +# assert report_confs.reports["soma_v.h5"].buffer_size == 64 |
| 186 | + |
| 187 | +# @pytest.mark.skip(reason="to be enabled with #337") |
| 188 | +# @pytest.mark.parametrize( |
| 189 | +# "create_tmp_simulation_config_file", |
| 190 | +# [{"simconfig_fixture": "ringtest_baseconfig"}], |
| 191 | +# indirect=True, |
| 192 | +# ) |
| 193 | +# def test_cli_report_buff_invalid(create_tmp_simulation_config_file): |
| 194 | +# for value in [-64, 0]: |
| 195 | +# command = ["neurodamus", create_tmp_simulation_config_file, f"--report-buffer-size={value}"] |
| 196 | +# result = subprocess.run(command, check=False, capture_output=True, text=True) |
| 197 | + |
| 198 | +# assert "Report buffer size must be > 0" in result.stdout |
138 | 199 |
|
139 | | -@pytest.mark.parametrize( |
140 | | - "create_tmp_simulation_config_file", |
141 | | - [{"simconfig_fixture": "ringtest_baseconfig"}], |
142 | | - indirect=True, |
143 | | -) |
144 | | -def test_cli_output_path(create_tmp_simulation_config_file): |
145 | | - tmp_path = Path(create_tmp_simulation_config_file).parent |
146 | | - new_output = "new-output" |
147 | | - subprocess.run( |
148 | | - ["neurodamus", create_tmp_simulation_config_file, f"--output-path={new_output}"], |
149 | | - check=True, |
150 | | - text=True, |
151 | | - ) |
152 | | - sc = libsonata.SimulationConfig.from_file(create_tmp_simulation_config_file) |
153 | | - # Output directory from simulation configuration is overridden |
154 | | - simconfig_output_path = tmp_path / sc.output.output_dir |
155 | | - assert not simconfig_output_path.is_dir(), ( |
156 | | - f"Directory '{simconfig_output_path}' should NOT exist." |
157 | | - ) |
158 | | - assert (tmp_path / new_output).is_dir(), f"Directory '{new_output}' not found." |
159 | | - |
160 | | -@pytest.mark.skip(reason="to be enabled with #337") |
161 | 200 | @pytest.mark.parametrize( |
162 | 201 | "create_tmp_simulation_config_file", [ |
163 | 202 | { |
164 | 203 | "simconfig_fixture": "ringtest_baseconfig", |
165 | 204 | "extra_config": { |
166 | 205 | "target_simulator": "CORENEURON", |
167 | | - "reports": { |
168 | | - "soma_v": { |
169 | | - "type": "compartment", |
170 | | - "variable_name": "v", |
171 | | - "sections": "soma", |
172 | | - "dt": 0.1, |
173 | | - "start_time": 0.0, |
174 | | - "end_time": 40.0 |
175 | | - } |
176 | | - }, |
177 | 206 | } |
178 | 207 | } |
179 | 208 | ], indirect=True) |
180 | | -def test_cli_report_buff_size(create_tmp_simulation_config_file): |
181 | | - command = ["neurodamus", create_tmp_simulation_config_file, "--report-buffer-size=64", "--keep-build"] |
| 209 | +def test_cli_cell_permute(create_tmp_simulation_config_file): |
| 210 | + command = ["neurodamus", create_tmp_simulation_config_file, "--cell-permute=1"] |
182 | 211 | subprocess.run(command, check=True, capture_output=True) |
183 | | - |
184 | | - report_confs = utils.ReportConf.load("build/report.conf") |
185 | | - assert report_confs.reports["soma_v.h5"].buffer_size == 64 |
186 | | - |
187 | | -@pytest.mark.skip(reason="to be enabled with #337") |
188 | | -@pytest.mark.parametrize( |
189 | | - "create_tmp_simulation_config_file", |
190 | | - [{"simconfig_fixture": "ringtest_baseconfig"}], |
191 | | - indirect=True, |
192 | | -) |
193 | | -def test_cli_report_buff_invalid(create_tmp_simulation_config_file): |
194 | | - for value in [-64, 0]: |
195 | | - command = ["neurodamus", create_tmp_simulation_config_file, f"--report-buffer-size={value}"] |
196 | | - result = subprocess.run(command, check=False, capture_output=True, text=True) |
197 | | - |
198 | | - assert "Report buffer size must be > 0" in result.stdout |
|
0 commit comments