Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into 561-switch-api-from-studie…
Browse files Browse the repository at this point in the history
…s-to-abstract-studies
  • Loading branch information
nicoalee committed Aug 22, 2023
2 parents 17e4c90 + 57a9dcd commit 092e3cc
Show file tree
Hide file tree
Showing 34 changed files with 232 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = .git,*.pdf,*.svg,*.ts,*.tsx,package-lock.json,data-*vocabulary.txt,sample_*.csv
# regexes
ignore-regex = r"\(\?i\).*\\\\1
ignore-words-list = te,fwe,connexion,zoon,covert,rime
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Codespell

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
-e "AUTH0_AUTH_URL=${AUTH0_AUTH_URL}" \
--rm -w /neurostore \
neurostore \
python -m pytest neurostore/tests
bash -c "python -m pytest neurostore/tests && python -m pytest --auth neurostore/tests/test_auth.py"
neurosynth_compose_backend_tests:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ First, set up the main environment variables in `.env` (see: `.env.example`).

Edit the `.env` template to set the correct variables

## Initalizing backend
## Initializing backend
Create the network, build the containers, and start services using the development configuration:

docker network create nginx-proxy # if this does not already exist
Expand Down
12 changes: 6 additions & 6 deletions compose/neurosynth-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified compose/neurosynth-frontend/public/favicon.ico
Binary file not shown.
19 changes: 11 additions & 8 deletions compose/neurosynth-frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<meta name="description" content="Neurosynth-Compose App" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -14,11 +14,6 @@
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- <link
rel="preload"
as="font"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap"
/> -->

<link rel="preload" as="image" href="/static/brain-analysis.png" type="image/png">

Expand All @@ -43,7 +38,15 @@
src="https://cdn.jsdelivr.net/gh/rii-mango/Papaya@build-1449/release/current/standard/papaya.js"
></script>


<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-0L9Y0HT9NR"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-0L9Y0HT9NR');
</script>

<!-- Appzi: Capture Insightful Feedback -->
<script defer src="https://w.appzi.io/w.js?token=jFjBf"></script>
Expand All @@ -58,7 +61,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Neurosynth</title>
<title>neurosynth compose</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"default": 10000
},
"xyz": {
"description": "Tab-delimited file of coordinates from database or numpy array with XYZ coordinates. Voxels are rows and x, y, z (meaning coordinates) values are the three columnns.",
"description": "Tab-delimited file of coordinates from database or numpy array with XYZ coordinates. Voxels are rows and x, y, z (meaning coordinates) values are the three columns.",
"type": "str",
"default": null
},
Expand Down
2 changes: 1 addition & 1 deletion compose/neurosynth-frontend/src/neurostore-typescript-sdk
2 changes: 1 addition & 1 deletion compose/neurosynth_compose/openapi
Submodule openapi updated 1 files
+211 −0 neurostore-openapi.yml
2 changes: 1 addition & 1 deletion compose/neurosynth_compose/schemas/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class MetaAnalysisResultSchema(BaseSchema):

@post_load
def process_data(self, data, **kwargs):
# propogate meta-analysis id to the neurovault collection
# propagate meta-analysis id to the neurovault collection
if data.get("neurovault_collection", None):
data["neurovault_collection"]["meta_analysis_id"] = data["meta_analysis_id"]

Expand Down
2 changes: 1 addition & 1 deletion compose/neurosynth_compose/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def mock_ns(monkeysession):


"""
Session / db managment tools
Session / db management tools
"""


Expand Down
2 changes: 1 addition & 1 deletion docs/taxonomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The study is connected to the original journal it was published in.

### Functions

Studies can be created, cloned, and edited to accomodate your needs for your meta-analysis
Studies can be created, cloned, and edited to accommodate your needs for your meta-analysis

## Analysis

Expand Down
2 changes: 1 addition & 1 deletion docs/typical-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If the study does indeed use a finger tapping task, she wants to keep track of t
To the left of the study there is a plus button.
She clicks on the plus button and sees she can add the study to a "study-set".
She names the studyset "finger tapping" and adds the selected study.
When she is done reading and adding all relevent studies, she notices
When she is done reading and adding all relevant studies, she notices
that the finger tapping task typically falls under three categories:
1) right handed index finger,
2) right handed multiple fingers, and
Expand Down
2 changes: 1 addition & 1 deletion store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ First, set up the main environment variables in `.env` (see: `.env.example`).

Edit the `.env` template to set the correct variables

## Initalizing backend
## Initializing backend
Create the network, build the containers, and start services using the development configuration:

docker network create nginx-proxy
Expand Down
4 changes: 2 additions & 2 deletions store/neurostore/ingest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def ingest_neurosynth(max_rows=None):
base_study = base_studies[0]
elif len(base_studies) > 1:
source_base_study = base_studies[0]
# do not overwrite the verions column
# do not overwrite the versions column
# we want to append to this column
columns = [
c
Expand Down Expand Up @@ -484,7 +484,7 @@ def ace_ingestion_logic(coordinates_df, metadata_df, text_df):
other_base_studies = [
bs for bs in base_studies if bs.id != source_base_study.id
]
# do not overwrite the verions column
# do not overwrite the versions column
# we want to append to this column
columns = [
c.name
Expand Down
2 changes: 1 addition & 1 deletion store/neurostore/openapi
23 changes: 20 additions & 3 deletions store/neurostore/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@
from . import data as viewdata


def create_user():
from auth0.v3.authentication.users import Users
auth = request.headers.get("Authorization", None)
token = auth.split()[1]
profile_info = Users(
current_app.config["AUTH0_BASE_URL"].removeprefix("https://")
).userinfo(access_token=token)

# user signed up with auth0, but has not made any queries yet...
# should have endpoint to "create user" after sign on with auth0
current_user = User(
external_id=connexion.context["user"],
name=profile_info.get("name", "Unknown")
)

return current_user


class BaseView(MethodView):
_model = None
_nested = {}
Expand Down Expand Up @@ -64,9 +82,8 @@ def update_or_create(cls, data, id=None, commit=True):

current_user = get_current_user()
if not current_user:
# user signed up with auth0, but has not made any queries yet...
# should have endpoint to "create user" after sign on with auth0
current_user = User(external_id=connexion.context["user"])
current_user = create_user()

db.session.add(current_user)
db.session.commit()

Expand Down
6 changes: 3 additions & 3 deletions store/neurostore/tests/api/test_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ...schemas import AnalysisSchema


def test_get_nested_and_not_nested_analyses(auth_client, ingest_neurosynth):
def test_get_nested_and_not_nested_analyses(auth_client, ingest_neurosynth, session):
analysis_id = Analysis.query.first().id
non_nested = auth_client.get(f"/api/analyses/{analysis_id}?nested=false")
nested = auth_client.get(f"/api/analyses/{analysis_id}?nested=true")
Expand All @@ -12,12 +12,12 @@ def test_get_nested_and_not_nested_analyses(auth_client, ingest_neurosynth):
assert isinstance(nested.json["points"][0], dict)


def test_get_analyses(auth_client, ingest_neurosynth):
def test_get_analyses(auth_client, ingest_neurosynth, session):
# List of analyses
resp = auth_client.get("/api/analyses/")
assert resp.status_code == 200
analysis_list = decode_json(resp)["results"]
assert type(analysis_list) == list
assert isinstance(analysis_list, list)

assert len(analysis_list) == Analysis.query.count()

Expand Down
16 changes: 8 additions & 8 deletions store/neurostore/tests/api/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ...models import Studyset, User


def test_post_blank_annotation(auth_client, ingest_neurosynth):
def test_post_blank_annotation(auth_client, ingest_neurosynth, session):
dset = Studyset.query.first()
payload = {
"studyset": dset.id,
Expand All @@ -17,7 +17,7 @@ def test_post_blank_annotation(auth_client, ingest_neurosynth):
)


def test_post_annotation(auth_client, ingest_neurosynth):
def test_post_annotation(auth_client, ingest_neurosynth, session):
dset = Studyset.query.first()
# y for x in non_flat for y in x
data = [
Expand All @@ -37,7 +37,7 @@ def test_post_annotation(auth_client, ingest_neurosynth):

# for some reason output is no longer valid
@pytest.mark.xfail
def test_get_annotations(auth_client, ingest_neurosynth):
def test_get_annotations(auth_client, ingest_neurosynth, session):
import pandas as pd
from io import StringIO

Expand All @@ -59,7 +59,7 @@ def test_get_annotations(auth_client, ingest_neurosynth):
assert isinstance(df, pd.DataFrame)


def test_clone_annotation(auth_client, simple_neurosynth_annotation):
def test_clone_annotation(auth_client, simple_neurosynth_annotation, session):
annotation_entry = simple_neurosynth_annotation
resp = auth_client.post(
f"/api/annotations/?source_id={annotation_entry.id}", data={}
Expand All @@ -71,7 +71,7 @@ def test_clone_annotation(auth_client, simple_neurosynth_annotation):
assert data["source"] == "neurostore"


def test_single_analysis_delete(auth_client, user_data):
def test_single_analysis_delete(auth_client, user_data, session):
user = User.query.filter_by(name="user1").first()
# get relevant studyset
studysets = auth_client.get(f"/api/studysets/?user_id={user.external_id}")
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_analysis_addition_to_studyset(auth_client, session, user_data):
)


def test_mismatched_notes(auth_client, ingest_neurosynth):
def test_mismatched_notes(auth_client, ingest_neurosynth, session):
dset = Studyset.query.first()
# y for x in non_flat for y in x
data = [
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_mismatched_notes(auth_client, ingest_neurosynth):

# test push analysis id that does not exist
# Handle error better
def test_put_nonexistent_analysis(auth_client, ingest_neurosynth):
def test_put_nonexistent_analysis(auth_client, ingest_neurosynth, session):
dset = Studyset.query.first()
# y for x in non_flat for y in x
data = [
Expand Down Expand Up @@ -281,7 +281,7 @@ def test_put_nonexistent_analysis(auth_client, ingest_neurosynth):
)


def test_correct_note_overwrite(auth_client, ingest_neurosynth):
def test_correct_note_overwrite(auth_client, ingest_neurosynth, session):
dset = Studyset.query.first()
# y for x in non_flat for y in x
data = [
Expand Down
4 changes: 2 additions & 2 deletions store/neurostore/tests/api/test_base_studies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test Base Study Endpoint"""


def test_flat_base_study(auth_client, ingest_neurosynth):
def test_flat_base_study(auth_client, ingest_neurosynth, session):
flat_resp = auth_client.get("/api/base-studies/?flat=true")
reg_resp = auth_client.get("/api/base-studies/?flat=false")

Expand All @@ -11,7 +11,7 @@ def test_flat_base_study(auth_client, ingest_neurosynth):
assert "versions" in reg_resp.json["results"][0]


def test_info_base_study(auth_client, ingest_neurosynth):
def test_info_base_study(auth_client, ingest_neurosynth, session):
info_resp = auth_client.get("/api/base-studies/?info=true")

assert info_resp.status_code == 200
Expand Down
6 changes: 3 additions & 3 deletions store/neurostore/tests/api/test_conditions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def test_get_conditions(auth_client, ingest_neurovault):
def test_get_conditions(auth_client, ingest_neurovault, session):
resp = auth_client.get("/api/conditions/")
assert resp.status_code == 200
assert len(resp.json["results"]) > 1


def test_post_conditions(auth_client, ingest_neurovault):
my_condition = {"name": "ice cream", "description": "suprise, it's rocky road!"}
def test_post_conditions(auth_client, ingest_neurovault, session):
my_condition = {"name": "ice cream", "description": "surprise, it's rocky road!"}
post_resp = auth_client.post("/api/conditions/", data=my_condition)
assert post_resp.status_code == 200
post_data = post_resp.json
Expand Down
6 changes: 3 additions & 3 deletions store/neurostore/tests/api/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
("points", Point, PointSchema),
],
)
def test_create(auth_client, user_data, endpoint, model, schema):
def test_create(auth_client, user_data, endpoint, model, schema, session):
user = User.query.filter_by(name="user1").first()

rows = model.query.filter_by(user=user).all()
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_create(auth_client, user_data, endpoint, model, schema):
("points", Point, PointSchema),
],
)
def test_read(auth_client, user_data, endpoint, model, schema):
def test_read(auth_client, user_data, endpoint, model, schema, session):
user = User.query.filter_by(name="user1").first()
query = True
if hasattr(model, "public"):
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_read(auth_client, user_data, endpoint, model, schema):
("points", Point, PointSchema, {"space": "MNI"}),
],
)
def test_update(auth_client, user_data, endpoint, model, schema, update):
def test_update(auth_client, user_data, endpoint, model, schema, update, session):
user = User.query.filter_by(name="user1").first()
record = model.query.filter_by(user=user).first()

Expand Down
Loading

0 comments on commit 092e3cc

Please sign in to comment.