compose-runner 0.13.0__tar.gz → 0.14.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {compose_runner-0.13.0 → compose_runner-0.14.0}/PKG-INFO +2 -2
  2. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/_version.py +2 -2
  3. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/run.py +121 -35
  4. compose_runner-0.14.0/compose_runner/tests/test_reference_studyset.py +208 -0
  5. {compose_runner-0.13.0 → compose_runner-0.14.0}/pyproject.toml +4 -3
  6. {compose_runner-0.13.0 → compose_runner-0.14.0}/.gitignore +0 -0
  7. {compose_runner-0.13.0 → compose_runner-0.14.0}/Dockerfile +0 -0
  8. {compose_runner-0.13.0 → compose_runner-0.14.0}/LICENSE +0 -0
  9. {compose_runner-0.13.0 → compose_runner-0.14.0}/README.md +0 -0
  10. {compose_runner-0.13.0 → compose_runner-0.14.0}/aws_lambda/.dockerignore +0 -0
  11. {compose_runner-0.13.0 → compose_runner-0.14.0}/aws_lambda/Dockerfile +0 -0
  12. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/__init__.py +0 -0
  13. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/__init__.py +0 -0
  14. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/common.py +0 -0
  15. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/cost_check_handler.py +0 -0
  16. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/log_poll_handler.py +0 -0
  17. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/results_handler.py +0 -0
  18. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/run_handler.py +0 -0
  19. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/aws_lambda/status_handler.py +0 -0
  20. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/cli.py +0 -0
  21. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/coverage.py +0 -0
  22. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/ecs_task.py +0 -0
  23. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/images.py +0 -0
  24. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/metadata.py +0 -0
  25. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/sentry.py +0 -0
  26. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_cli/test_cli.yaml +0 -0
  27. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_lambda_handlers/test_select_task_size_uses_large_for_montecarlo.yaml +0 -0
  28. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_lambda_handlers/test_select_task_size_uses_standard_for_fdr.yaml +0 -0
  29. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_download_bundle.yaml +0 -0
  30. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_download_bundle_dev_meta_analysis_shape.yaml +0 -0
  31. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_download_bundle_dev_string_id_shape.yaml +0 -0
  32. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_download_bundle_production_cached_snapshot_shape.yaml +0 -0
  33. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_incorrect_id.yaml +0 -0
  34. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_missing_column_workflow.yaml +0 -0
  35. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_mkdachis_comparison_workflow.yaml +0 -0
  36. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_mkdachis_no_corrector_workflow.yaml +0 -0
  37. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_run_database_workflow.yaml +0 -0
  38. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_run_group_comparison_workflow.yaml +0 -0
  39. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_run_string_group_comparison_workflow.yaml +0 -0
  40. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/cassettes/test_run/test_run_workflow.yaml +0 -0
  41. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/conftest.py +0 -0
  42. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_apply_filter.py +0 -0
  43. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_cli.py +0 -0
  44. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_coverage.py +0 -0
  45. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_ecs_task.py +0 -0
  46. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_ibma_dispatch.py +0 -0
  47. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_ibma_end_to_end.py +0 -0
  48. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_images.py +0 -0
  49. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_lambda_handlers.py +0 -0
  50. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_metadata.py +0 -0
  51. {compose_runner-0.13.0 → compose_runner-0.14.0}/compose_runner/tests/test_run.py +0 -0
  52. {compose_runner-0.13.0 → compose_runner-0.14.0}/docs/ibma.md +0 -0
  53. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/app.py +0 -0
  54. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/cdk.json +0 -0
  55. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/requirements.txt +0 -0
  56. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/stacks/__init__.py +0 -0
  57. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/stacks/compose_runner_stack.py +0 -0
  58. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/stacks/image_repositories_stack.py +0 -0
  59. {compose_runner-0.13.0 → compose_runner-0.14.0}/infra/cdk/tests/test_compose_runner_stack.py +0 -0
  60. {compose_runner-0.13.0 → compose_runner-0.14.0}/scripts/simulate_ibma_bundle.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: compose-runner
3
- Version: 0.13.0
3
+ Version: 0.14.0
4
4
  Summary: A package for running neurosynth-compose analyses
5
5
  Project-URL: Repository, https://github.com/neurostuff/compose-runner
6
6
  Author-email: James Kent <jamesdkent21@gmail.com>
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
12
12
  Requires-Dist: click
13
13
  Requires-Dist: neurostore-sdk>=1.1
14
14
  Requires-Dist: neurosynth-compose-sdk>=1.2
15
- Requires-Dist: nimare==0.21.0rc2
15
+ Requires-Dist: nimare[parquet]==0.21.0rc3
16
16
  Requires-Dist: numpy
17
17
  Requires-Dist: requests
18
18
  Requires-Dist: sentry-sdk
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.13.0'
22
- __version_tuple__ = version_tuple = (0, 13, 0)
21
+ __version__ = version = '0.14.0'
22
+ __version_tuple__ = version_tuple = (0, 14, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -5,6 +5,8 @@ import hashlib
5
5
  import json
6
6
  import io
7
7
  import pickle
8
+ import tarfile
9
+ import tempfile
8
10
  from copy import deepcopy
9
11
  from datetime import date, datetime
10
12
  from importlib import import_module
@@ -27,7 +29,7 @@ from nimare.correct import FDRCorrector
27
29
  from nimare.workflows import CBMAWorkflow, IBMAWorkflow, PairwiseCBMAWorkflow
28
30
  from nimare.meta.cbma.base import CBMAEstimator, PairwiseCBMAEstimator
29
31
  from nimare.meta.ibma import IBMAEstimator
30
- from nimare.nimads import Studyset
32
+ from nimare.nimads import Studyset, from_parquet
31
33
  from nimare.meta.cbma import ALE, ALESubtraction, SCALE
32
34
 
33
35
  from compose_runner import coverage
@@ -41,6 +43,30 @@ def gen_database_url(branch, database):
41
43
  return f"https://github.com/neurostuff/neurostore_database/raw/{branch}/{database}.json.gz"
42
44
 
43
45
 
46
+ def gen_release_url(store_host, version):
47
+ """URL for one of neurostore's parquet studyset releases."""
48
+ host = store_host.rstrip("/")
49
+ return f"{host}/neurostore-studyset-releases/{version}/download"
50
+
51
+
52
+ def _extract_studyset_release(archive, destination):
53
+ """Unpack a studyset release and return the directory holding its tables.
54
+
55
+ The archive carries a single directory named for the release, so the
56
+ ``studyset.json`` manifest sits one level below the root rather than at it.
57
+ """
58
+ with tarfile.open(archive, "r:gz") as tar:
59
+ tar.extractall(destination, filter="data")
60
+
61
+ manifests = sorted(destination.glob("**/studyset.json"))
62
+ if not manifests:
63
+ raise ValueError(
64
+ f"{archive.name} is not a studyset parquet release: it has no "
65
+ "studyset.json manifest."
66
+ )
67
+ return manifests[0].parent
68
+
69
+
44
70
  def _annotation_column(studyset, column):
45
71
  """Read one annotation column off a studyset.
46
72
 
@@ -98,6 +124,13 @@ class Runner:
98
124
 
99
125
  _TARGET_SPACE = "mni152_2mm"
100
126
 
127
+ # Which reference studysets come from neurostore's studyset release API, as
128
+ # a tarball of parquet tables, rather than from a static NIMADS dump. Only
129
+ # neurostore's own: a release carries no record of which database a study
130
+ # came from, so a neurosynth or neuroquery subset cannot be cut out of one.
131
+ _RELEASE_REFERENCES = frozenset({"neurostore"})
132
+ _REFERENCE_RELEASE_VERSION = "nightly"
133
+
101
134
  _ENTITY_SNAPSHOT_ID_KEYS = {
102
135
  "studyset": ("snapshot_studyset_id",),
103
136
  "annotation": ("snapshot_annotation_id",),
@@ -133,12 +166,17 @@ class Runner:
133
166
  self.compose_url = compose_host
134
167
 
135
168
  ref_branch = "main" if environment == "production" else "staging"
136
- ref_dbs = ["neurosynth", "neuroquery", "neurostore"]
169
+ ref_dbs = ["neurosynth", "neuroquery"]
137
170
  if environment != "production":
138
171
  ref_dbs.append("neurostore_small")
139
172
  self.reference_studysets = {
140
173
  db: gen_database_url(ref_branch, db) for db in ref_dbs
141
174
  }
175
+ # Served by this environment's own API, so the comparison group is the
176
+ # database the studyset was selected from as it stands tonight.
177
+ self.reference_studysets["neurostore"] = gen_release_url(
178
+ store_host, self._REFERENCE_RELEASE_VERSION
179
+ )
142
180
 
143
181
  self._compose_config = neurosynth_compose_sdk.Configuration(host=compose_host)
144
182
  self.compose_api = ComposeApi(
@@ -599,40 +637,9 @@ class Runner:
599
637
  elif len(conditions) <= 1 and database_studyset:
600
638
  # collect user study IDs cheaply before loading the large reference database
601
639
  study_ids = set(studyset.study_ids)
602
-
603
- # Download the gzip file
604
- response = requests.get(self.reference_studysets[database_studyset])
605
-
606
- try:
607
- response.raise_for_status()
608
- except requests.exceptions.HTTPError as e:
609
- raise requests.exceptions.HTTPError(
610
- f"Could not download reference studyset {database_studyset}."
611
- ) from e
612
-
613
- # Wrap the content of the response in a BytesIO object
614
- gzip_content = io.BytesIO(response.content)
615
-
616
- # Decompress the gzip content
617
- with gzip.GzipFile(fileobj=gzip_content, mode="rb") as gz_file:
618
- # Read and decode the JSON data
619
- json_data = gz_file.read().decode("utf-8")
620
-
621
- # Load the JSON data into a dictionary
622
- reference_studyset_dict = json.loads(json_data)
623
-
624
- # pre-filter at the dict level to exclude user studies before constructing
625
- # Studyset, keeping the object small and avoiding expensive materialize calls
626
- reference_studyset_dict["studies"] = [
627
- s
628
- for s in reference_studyset_dict.get("studies", [])
629
- if s["id"] not in study_ids
630
- ]
631
-
632
- reference_studyset = Studyset(
633
- reference_studyset_dict, target=self._TARGET_SPACE
640
+ reference_studyset = self._load_reference_studyset(
641
+ database_studyset, study_ids
634
642
  )
635
- del reference_studyset_dict
636
643
 
637
644
  second_studyset = (
638
645
  reference_studyset.combine_analyses() if combine else reference_studyset
@@ -640,6 +647,85 @@ class Runner:
640
647
 
641
648
  return first_studyset, second_studyset
642
649
 
650
+ def _load_reference_studyset(self, database_studyset, exclude_study_ids):
651
+ """The comparison group for a database meta-analysis.
652
+
653
+ The user's own studies are excluded from it: they are already the other
654
+ group, and an analysis cannot be in both.
655
+ """
656
+ if database_studyset in self._RELEASE_REFERENCES:
657
+ return self._load_release_reference(database_studyset, exclude_study_ids)
658
+ return self._load_dump_reference(database_studyset, exclude_study_ids)
659
+
660
+ def _get_reference_studyset(self, database_studyset, **kwargs):
661
+ """Request a reference studyset, naming it in the error if it is not served."""
662
+ response = requests.get(self.reference_studysets[database_studyset], **kwargs)
663
+
664
+ try:
665
+ response.raise_for_status()
666
+ except requests.exceptions.HTTPError as e:
667
+ response.close()
668
+ raise requests.exceptions.HTTPError(
669
+ f"Could not download reference studyset {database_studyset}."
670
+ ) from e
671
+
672
+ return response
673
+
674
+ def _load_release_reference(self, database_studyset, exclude_study_ids):
675
+ """Read a reference studyset from a parquet studyset release.
676
+
677
+ Streamed to disk rather than held in memory: the archive is tens of
678
+ megabytes and has to be unpacked to a directory for NiMARE to read it.
679
+ """
680
+ with tempfile.TemporaryDirectory() as workdir:
681
+ archive = Path(workdir) / "release.tar.gz"
682
+ with self._get_reference_studyset(
683
+ database_studyset, stream=True
684
+ ) as response, archive.open("wb") as handle:
685
+ for chunk in response.iter_content(chunk_size=1024 * 1024):
686
+ handle.write(chunk)
687
+
688
+ release_dir = _extract_studyset_release(archive, Path(workdir) / "release")
689
+ # The reference is only ever the comparison group, so nothing reads
690
+ # its notes: its annotation columns are pure cost here.
691
+ store = from_parquet(str(release_dir), load_annotations=False)
692
+
693
+ # The tables are read eagerly, so the studyset outlives the directory.
694
+ reference_studyset = Studyset(store, target=self._TARGET_SPACE)
695
+ # As a list: the ids are matched with ``numpy.isin``, which reads a set
696
+ # as one opaque object and so quietly excludes nothing.
697
+ return reference_studyset.exclude_study_ids(list(exclude_study_ids))
698
+
699
+ def _load_dump_reference(self, database_studyset, exclude_study_ids):
700
+ """Read a reference studyset from a gzipped NIMADS dump."""
701
+ response = self._get_reference_studyset(database_studyset)
702
+
703
+ # Wrap the content of the response in a BytesIO object
704
+ gzip_content = io.BytesIO(response.content)
705
+
706
+ # Decompress the gzip content
707
+ with gzip.GzipFile(fileobj=gzip_content, mode="rb") as gz_file:
708
+ # Read and decode the JSON data
709
+ json_data = gz_file.read().decode("utf-8")
710
+
711
+ # Load the JSON data into a dictionary
712
+ reference_studyset_dict = json.loads(json_data)
713
+
714
+ # pre-filter at the dict level to exclude user studies before constructing
715
+ # Studyset, keeping the object small and avoiding expensive materialize calls
716
+ reference_studyset_dict["studies"] = [
717
+ s
718
+ for s in reference_studyset_dict.get("studies", [])
719
+ if s["id"] not in exclude_study_ids
720
+ ]
721
+
722
+ reference_studyset = Studyset(
723
+ reference_studyset_dict, target=self._TARGET_SPACE
724
+ )
725
+ del reference_studyset_dict
726
+
727
+ return reference_studyset
728
+
643
729
  def _is_image_based(self):
644
730
  """Whether the specification asks for an image-based meta-analysis."""
645
731
  spec_type = str((self.cached_specification or {}).get("type") or "").strip()
@@ -0,0 +1,208 @@
1
+ """Tests for the reference studyset a database meta-analysis compares against.
2
+
3
+ The neurostore reference is served by the studyset release API as a tarball of
4
+ parquet tables, rebuilt nightly; the other databases are static NIMADS dumps
5
+ committed to a GitHub repo. Both have to arrive as a studyset with the user's own
6
+ studies taken out of it.
7
+ """
8
+
9
+ import gzip
10
+ import io
11
+ import json
12
+ import tarfile
13
+
14
+ import pytest
15
+ import requests
16
+ from nimare.nimads import Studyset
17
+
18
+ from compose_runner.run import Runner, _extract_studyset_release, gen_release_url
19
+
20
+ _TARGET = "mni152_2mm"
21
+
22
+
23
+ def _analysis(analysis_id, x):
24
+ return {
25
+ "id": analysis_id,
26
+ "name": analysis_id,
27
+ "conditions": [],
28
+ "weights": [],
29
+ "points": [
30
+ {
31
+ "id": f"p-{analysis_id}",
32
+ "coordinates": [x, x, x],
33
+ "space": "MNI",
34
+ "values": [],
35
+ }
36
+ ],
37
+ "metadata": {},
38
+ "images": [],
39
+ }
40
+
41
+
42
+ def _reference_dict():
43
+ """A three-study reference database, one of whose studies is the user's."""
44
+ return {
45
+ "id": "reference",
46
+ "name": "reference",
47
+ "studies": [
48
+ {
49
+ "id": f"s{i}",
50
+ "name": f"s{i}",
51
+ "metadata": {},
52
+ "analyses": [_analysis(f"a{i}", i)],
53
+ }
54
+ for i in (1, 2, 3)
55
+ ],
56
+ }
57
+
58
+
59
+ def _release_archive(tmp_path, source=None):
60
+ """A studyset release tarball, laid out as the API serves one."""
61
+ release = tmp_path / "neurostore-studyset-nightly"
62
+ Studyset(source or _reference_dict(), target=None).to_parquet(release)
63
+
64
+ archive = tmp_path / "release.tar.gz"
65
+ with tarfile.open(archive, "w:gz") as tar:
66
+ tar.add(release, arcname=release.name)
67
+ return archive.read_bytes()
68
+
69
+
70
+ class _FakeResponse:
71
+ """Enough of a ``requests`` response for either reference loader."""
72
+
73
+ def __init__(self, content, status=200):
74
+ self.content = content
75
+ self._status = status
76
+
77
+ def __enter__(self):
78
+ return self
79
+
80
+ def __exit__(self, *exc):
81
+ self.close()
82
+ return False
83
+
84
+ def raise_for_status(self):
85
+ if self._status >= 400:
86
+ raise requests.exceptions.HTTPError(f"{self._status}")
87
+
88
+ def iter_content(self, chunk_size=1):
89
+ for start in range(0, len(self.content), chunk_size):
90
+ yield self.content[start : start + chunk_size]
91
+
92
+ def close(self):
93
+ self.closed = True
94
+
95
+
96
+ def _runner(environment="production"):
97
+ return Runner(meta_analysis_id="unused", environment=environment)
98
+
99
+
100
+ def _serve(monkeypatch, response):
101
+ """Answer every reference request with ``response``, recording the URL."""
102
+ requested = []
103
+
104
+ def fake_get(url, **kwargs):
105
+ requested.append((url, kwargs))
106
+ return response
107
+
108
+ monkeypatch.setattr(requests, "get", fake_get)
109
+ return requested
110
+
111
+
112
+ @pytest.mark.parametrize(
113
+ "environment,expected",
114
+ [
115
+ (
116
+ "production",
117
+ "https://neurostore.org/api/neurostore-studyset-releases/nightly/download",
118
+ ),
119
+ (
120
+ "staging",
121
+ "https://staging.neurostore.xyz/api"
122
+ "/neurostore-studyset-releases/nightly/download",
123
+ ),
124
+ ],
125
+ )
126
+ def test_neurostore_reference_comes_from_this_environments_release_api(
127
+ environment, expected
128
+ ):
129
+ runner = _runner(environment)
130
+
131
+ assert runner.reference_studysets["neurostore"] == expected
132
+
133
+
134
+ def test_the_other_references_are_still_github_dumps():
135
+ runner = _runner("production")
136
+
137
+ assert runner.reference_studysets["neurosynth"].endswith("/main/neurosynth.json.gz")
138
+ assert runner.reference_studysets["neuroquery"].endswith("/main/neuroquery.json.gz")
139
+
140
+
141
+ def test_gen_release_url_does_not_double_the_separator():
142
+ assert gen_release_url("https://neurostore.org/api/", "2026-08") == (
143
+ "https://neurostore.org/api/neurostore-studyset-releases/2026-08/download"
144
+ )
145
+
146
+
147
+ def test_release_reference_loads_and_drops_the_users_studies(tmp_path, monkeypatch):
148
+ runner = _runner()
149
+ requested = _serve(monkeypatch, _FakeResponse(_release_archive(tmp_path)))
150
+
151
+ reference = runner._load_reference_studyset("neurostore", {"s2"})
152
+
153
+ assert sorted(reference.study_ids) == ["s1", "s3"]
154
+ assert sorted(reference.ids) == ["s1-a1", "s3-a3"]
155
+ # Streamed rather than buffered whole, and read from the release API.
156
+ assert requested[0][1]["stream"] is True
157
+ assert requested[0][0] == runner.reference_studysets["neurostore"]
158
+
159
+
160
+ def test_release_reference_is_in_the_target_space(tmp_path, monkeypatch):
161
+ runner = _runner()
162
+ _serve(monkeypatch, _FakeResponse(_release_archive(tmp_path)))
163
+
164
+ reference = runner._load_reference_studyset("neurostore", set())
165
+
166
+ assert set(reference.coordinates["space"]) == {_TARGET}
167
+
168
+
169
+ def test_release_reference_survives_the_archive_being_cleaned_up(
170
+ tmp_path, monkeypatch
171
+ ):
172
+ """The tables are read eagerly, so nothing is left pointing at the temp dir."""
173
+ runner = _runner()
174
+ _serve(monkeypatch, _FakeResponse(_release_archive(tmp_path)))
175
+
176
+ reference = runner._load_reference_studyset("neurostore", set())
177
+
178
+ assert len(reference.coordinates) == 3
179
+
180
+
181
+ def test_a_reference_the_api_does_not_serve_is_named_in_the_error(monkeypatch):
182
+ runner = _runner()
183
+ _serve(monkeypatch, _FakeResponse(b"", status=404))
184
+
185
+ with pytest.raises(requests.exceptions.HTTPError, match="neurostore"):
186
+ runner._load_reference_studyset("neurostore", set())
187
+
188
+
189
+ def test_an_archive_without_a_manifest_is_not_a_release(tmp_path):
190
+ archive = tmp_path / "not-a-release.tar.gz"
191
+ stray = tmp_path / "stray.txt"
192
+ stray.write_text("nothing to load")
193
+ with tarfile.open(archive, "w:gz") as tar:
194
+ tar.add(stray, arcname="stray.txt")
195
+
196
+ with pytest.raises(ValueError, match="not a studyset parquet release"):
197
+ _extract_studyset_release(archive, tmp_path / "out")
198
+
199
+
200
+ def test_dump_reference_still_reads_gzipped_nimads(monkeypatch):
201
+ runner = _runner()
202
+ payload = gzip.compress(json.dumps(_reference_dict()).encode("utf-8"))
203
+ requested = _serve(monkeypatch, _FakeResponse(payload))
204
+
205
+ reference = runner._load_reference_studyset("neurosynth", {"s1"})
206
+
207
+ assert sorted(reference.study_ids) == ["s2", "s3"]
208
+ assert "stream" not in requested[0][1]
@@ -18,9 +18,10 @@ dependencies = [
18
18
  # IBMA support needs the dependence handling and `groupby` argument, and the
19
19
  # runner reads a studyset's annotations off the studyset itself, which the
20
20
  # columnar rewrite (NiMARE #1103) introduced. All of it releases as NiMARE
21
- # 0.21.0. Replace with `nimare>=0.21.0` once it is on PyPI, which publishing
22
- # this package requires anyway: PyPI rejects direct references.
23
- "nimare==0.21.0rc2",
21
+ # 0.21.0. Replace with `nimare[parquet]>=0.21.0` once it is on PyPI, which
22
+ # publishing this package requires anyway: PyPI rejects direct references.
23
+ # The `parquet` extra is pyarrow, which reading a studyset release needs.
24
+ "nimare[parquet]==0.21.0rc3",
24
25
  "click",
25
26
  "requests",
26
27
  "sentry-sdk",
File without changes