Skip to content

Add a test to avoid regressions in query_snapshot_files #16

Description

@jhlegarreta

What happened?

The query.querying.query_snapshot_files function was no longer getting the directories and their contents, and thus the collect command does not get the list of relevant NIfTI files for subset selection purposes.

Changing the directory dictionary field to key solves the issue locally: #15

Thus, a test needs to be added to avoid this regression in the future. For example, we might want to query a specific dataset/tag (or some of them in case one fails on the server side) from OpenNeuro, and check that we are traversing the structure properly.

This was not being caught by the CI because we use monkey patching extensively to avoid server side issue. Thus, the test_query_snapshot_tree_recurses was not detecting this.

What command did you use?

niquery collect /mnt/data/nipreps/niquery_runs/openneuro_datasets.tsv
/mnt/data/nipreps/niquery_runs/dataset_files_debug
--species human --modality bold --modality mri --modality fmri -f

What version of the software are you running?

HEAD commit (d4d2c68)

How are you running this software?

Local installation ("bare-metal")

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

N/A

Additional information / screenshots

Running the query on the Apollo server does return the expected files/directories (the latter are not recursively explored):
https://openneuro.org/crn/graphql

Operation:

query getSnapshotFiles($datasetId: ID!, $tag: String!, $tree: String) {
  snapshot(datasetId: $datasetId, tag: $tag) {
    files(tree: $tree) {
      id
      filename
      size
      directory
      annexed
      key
      urls
    }
  }
}

Variables:

{
   "datasetId": "ds000149",
   "tag": "1.0.0",
   "tree": null
}

Running the following code snippet also gets the directories fine:

variables = {"datasetId": "ds000149", "tag": "1.0.0"}
# Only include tree key if not None (some servers behave differently for missing vs null)
if tree is not None:
    variables["tree"] = tree

payload = {"query": query, "variables": variables}
r = requests.post(gql_url, json=payload, headers={"Content-Type": "application/json", "Accept": "application/json"})
print(r.status_code)
print(r.text)
print(r.json())

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestimpact: highEstimated high impact task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions