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

Overhaul snakebids create #336

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion snakebids/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def gen_parser() -> argparse.ArgumentParser:


def main() -> None:
"""Invoke snakebids cli."""
"""Invoke Snakebids cli."""

parser = gen_parser()
args = parser.parse_args()
Expand Down
3 changes: 1 addition & 2 deletions snakebids/project_template/copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ app_version:

build_system:
help: >
What build system would you like to use? If you don't know what this means,
choose setuptools
What build system would you like to use? If unsure, choose setuptools
choices:
- setuptools
- poetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ requires-python = ">=3.8,<3.12"
dependencies = [
"snakemake >= {{ snakemake_version }}",
"snakebids >= {{ snakebids_version }}",
{# Explicitely specify numpy version for py38 until snakebids 0.10.x to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitely > Explicitly

work around specification bug causing numpys too high for py38 to be
locked by pdm -#}
"numpy <=1.24.4; python_version < \"3.9\"",
]

[project.scripts]
Expand Down
7 changes: 6 additions & 1 deletion snakebids/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_fails_if_invalid_subcommand(
name=st.text()
.filter(lambda s: not re.match(r"^[a-zA-Z_][a-zA-Z_0-9]*$", s))
.filter(lambda s: is_valid_filename(s, Platform.LINUX))
.filter(lambda s: s not in {".", ".."})
)
@allow_function_scoped
def test_create_fails_with_invalid_filename(
Expand All @@ -55,7 +56,11 @@ def test_create_fails_with_invalid_filename(
assert "valid python module" in capture.err
assert name in capture.err

@given(name=st.text().filter(lambda s: is_valid_filename(s, Platform.LINUX)))
@given(
name=st.text()
.filter(lambda s: is_valid_filename(s, Platform.LINUX))
.filter(lambda s: s not in {".", ".."})
)
@allow_function_scoped
def test_create_fails_missing_parent_dir(
self,
Expand Down
2 changes: 1 addition & 1 deletion snakebids/tests/test_generate_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def get_subset(of: Iterable[T]) -> list[T]:

class TestCustomPaths:
@pytest.fixture()
def temp_dir(self, fakefs_tmpdir: Path):
def temp_dir(self, fakefs_tmpdir: Path, bids_fs: Path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the added bids_fs parameter here do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to clean this up a bit, basically there's a bunch of real fs paths that need to be added to the fake filesystem, but I have the fakefs setup and path addition split into separate fixtures. The above has been broken for a long time, and the only mystery for me is why the tests ever worked... apparently inter-test environment isolation is not water-tight, because this was revealed I think when I started splitting this tests with pytest-split

return fakefs_tmpdir

def generate_test_directory(
Expand Down
10 changes: 8 additions & 2 deletions snakebids/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,17 @@ def test_template_dry_runs_successfully(tmp_path: Path, build: BuildSystems, ven
"-v",
f"{tmp_path / app_name}:/app",
"--rm",
"snakebids/test-template:dev",
f"snakebids/test-template:{platform.python_version()}",
venv,
app_name,
],
capture_output=True,
check=True,
check=False,
)
try:
cmd.check_returncode()
except Exception as err:
print(cmd.stdout)
print(cmd.stderr, file=sys.stderr)
raise err
assert "All set" in cmd.stdout.decode()