Skip to content

Commit

Permalink
adding shell=True for linux popen
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Sep 26, 2020
1 parent 002f132 commit 6668e6a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/test_output.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cellpose import io, models, metrics
from pathlib import Path
import subprocess
import subprocess, shlex
import os
import numpy as np

Expand All @@ -22,35 +22,38 @@ def clear_output(data_dir, image_names):
os.remove(output)

def test_cli_2D(data_dir, image_names):
clear_output(data_dir, image_names)
model_types = ['cyto', 'nuclei']
chan = [2,1]
chan2 = [1,0]
for m,model_type in enumerate(model_types):
process = subprocess.Popen('python -m cellpose --dir %s --pretrained_model %s --fast_mode --chan %d --chan2 %d --diameter 0 --save_png'%
(str(data_dir.joinpath('2D')), model_type, chan[m], chan2[m]),
cmd = 'python -m cellpose --dir %s --pretrained_model %s --fast_mode --chan %d --chan2 %d --diameter 0 --save_png'%(str(data_dir.joinpath('2D')), model_type, chan[m], chan2[m])
process = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
shell=True)
stdout, stderr = process.communicate()
print(stdout)
print(stderr)
check_output(data_dir, image_names, '2D', model_type)
clear_output(data_dir, image_names)

def test_cli_3D(data_dir, image_names):
clear_output(data_dir, image_names)
model_types = ['cyto', 'nuclei']
chan = [2,1]
chan2 = [1,0]
for m,model_type in enumerate(model_types):
process = subprocess.Popen('python -m cellpose --dir %s --do_3D --pretrained_model %s --fast_mode --chan %d --chan2 %d --diameter 25 --save_tif'%
(str(data_dir.joinpath('3D')), model_type, chan[m], chan2[m]),
cmd = 'python -m cellpose --dir %s --do_3D --pretrained_model %s --fast_mode --chan %d --chan2 %d --diameter 25 --save_tif'%(str(data_dir.joinpath('3D')), model_type, chan[m], chan2[m])
process = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
shell=True)
stdout, stderr = process.communicate()
print(stdout)
print(stderr)
check_output(data_dir, image_names, '3D', model_type)
clear_output(data_dir, image_names)


def check_output(data_dir, image_names, runtype, model_type):
"""
Helper function to check if outputs given by a test are exactly the same
Expand Down

0 comments on commit 6668e6a

Please sign in to comment.