Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Upgrade pytest as a start to tackling CI errors. #945

Merged
merged 7 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions AFQ/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pandas.testing import assert_series_equal

import nibabel as nib
import nibabel.tmpdirs as nbtmp
import tempfile

import dipy.tracking.utils as dtu
import dipy.tracking.streamline as dts
Expand All @@ -29,10 +29,9 @@
import AFQ.data.fetch as afd
import AFQ.utils.streamlines as aus
import AFQ.utils.bin as afb
from AFQ.definitions.image import RoiImage,\
PFTImage, ImageFile
from AFQ.definitions.mapping import SynMap, AffMap, SlrMap, IdentityMap
from AFQ.definitions.image import TemplateImage, ImageFile, LabelledImageFile
from AFQ.definitions.image import (RoiImage, PFTImage, ImageFile,
TemplateImage, LabelledImageFile)


def touch(fname, times=None):
Expand All @@ -41,13 +40,12 @@ def touch(fname, times=None):


def get_temp_hardi():
tmpdir = nbtmp.InTemporaryDirectory()
afd.organize_stanford_data(path=tmpdir.name)
bids_path = op.join(tmpdir.name, 'stanford_hardi')
tmpdir = tempfile.mkdtemp()
bids_path = op.join(tmpdir, "stanford_hardi")
afd.organize_stanford_data(path=tmpdir)

sub_path = op.join(
tmpdir.name,
'stanford_hardi',
bids_path,
'derivatives',
'vistasoft',
'sub-01',
Expand Down Expand Up @@ -176,7 +174,7 @@ def create_dummy_bids_path(n_subjects, n_sessions, share_sessions=True):


def test_AFQ_missing_files():
tmpdir = nbtmp.InTemporaryDirectory()
tmpdir = tempfile.TemporaryDirectory()
bids_path = tmpdir.name

with pytest.raises(
Expand Down Expand Up @@ -291,7 +289,9 @@ def test_AFQ_no_derivs():
@pytest.mark.nightly_custom
@xvfb_it
def test_AFQ_fury():
_, bids_path, _ = get_temp_hardi()
tmpdir = tempfile.TemporaryDirectory()
bids_path = op.join(tmpdir.name, "stanford_hardi")
afd.organize_stanford_data(path=tmpdir.name)

myafq = GroupAFQ(
bids_path=bids_path,
Expand Down Expand Up @@ -603,19 +603,19 @@ def test_AFQ_pft():
ImageFile(suffix="WMprobseg"),
ImageFile(suffix="GMprobseg"),
ImageFile(suffix="CSFprobseg"))
t_output_dir = tempfile.TemporaryDirectory()

with nbtmp.InTemporaryDirectory() as t_output_dir:
myafq = GroupAFQ(
bids_path,
preproc_pipeline='vistasoft',
bundle_info=bundle_names,
output_dir=t_output_dir,
tracking_params={
"stop_mask": stop_mask,
"stop_threshold": "CMC",
"tracker": "pft"
})
myafq.export("streamlines")
myafq = GroupAFQ(
bids_path,
preproc_pipeline='vistasoft',
bundle_info=bundle_names,
output_dir=t_output_dir.name,
tracking_params={
"stop_mask": stop_mask,
"stop_threshold": "CMC",
"tracker": "pft"
})
myafq.export("streamlines")


@pytest.mark.nightly_custom
Expand Down Expand Up @@ -670,7 +670,7 @@ def test_multib_profile():
"""
Test using API to profile DKI/fwDTI
"""
tmpdir = nbtmp.InTemporaryDirectory()
tmpdir = tempfile.TemporaryDirectory()
afd.organize_cfin_data(path=tmpdir.name)
myafq = GroupAFQ(bids_path=op.join(tmpdir.name, 'cfin_multib'),
preproc_pipeline='dipy')
Expand All @@ -681,7 +681,7 @@ def test_multib_profile():


def test_auto_cli():
tmpdir = nbtmp.InTemporaryDirectory()
tmpdir = tempfile.TemporaryDirectory()
config_file = op.join(tmpdir.name, 'test.toml')

arg_dict = afb.func_dict_to_arg_dict()
Expand Down Expand Up @@ -718,8 +718,8 @@ def test_AFQ_data_waypoint():
Test with some actual data again, this time for track segmentation
"""
tmpdir, bids_path, _ = get_temp_hardi()
t1_path = op.join(tmpdir.name, "T1.nii.gz")
t1_path_other = op.join(tmpdir.name, "T1-untransformed.nii.gz")
t1_path = op.join(tmpdir, "T1.nii.gz")
t1_path_other = op.join(tmpdir, "T1-untransformed.nii.gz")
nib.save(
afd.read_mni_template(mask=True, weight="T1w"),
t1_path)
Expand Down Expand Up @@ -891,7 +891,7 @@ def test_AFQ_data_waypoint():
SEGMENTATION_PARAMS=segmentation_params,
CLEANING_PARAMS=clean_params)

config_file = op.join(tmpdir.name, "afq_config.toml")
config_file = op.join(tmpdir, "afq_config.toml")
with open(config_file, 'w') as ff:
toml.dump(config, ff)

Expand Down
4 changes: 2 additions & 2 deletions AFQ/tests/test_tractography.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

import nibabel as nib
import nibabel.tmpdirs as nbtmp
import tempfile

from AFQ.models.csd import fit_csd
from AFQ.models.dti import fit_dti
Expand All @@ -18,7 +18,7 @@
[-81, -120, -60]])


tmpdir = nbtmp.InTemporaryDirectory()
tmpdir = tempfile.TemporaryDirectory()
fbval = op.join(tmpdir.name, 'dti.bval')
fbvec = op.join(tmpdir.name, 'dti.bvec')
fdata = op.join(tmpdir.name, 'dti.nii.gz')
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
markers = [
"nightly",
"nightly_basic",
"nightly_anisotropic",
"nightly_reco",
"nightly_reco80",
"nightly_pft",
"nightly_custom",
"nightly",
]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ packages = find:
dev =
docutils==0.15.2
sphinx
pytest==6.0.1
pytest==7.2.0
pytest-cov==2.10.0
flake8
sphinx_gallery
Expand Down