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

wip: add feature tables #842

Merged
merged 12 commits into from
Jan 17, 2025
Prev Previous commit
Next Next commit
run black
  • Loading branch information
jdkent committed Jan 13, 2025
commit 3796e662b76f815a38ab83e4d203055a9c34a2be
9 changes: 7 additions & 2 deletions store/neurostore/models/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,9 @@ class PipelineConfig(BaseMixin, db.Model):
)
config = db.Column(JSONB)
config_hash = db.Column(db.String, index=True)
pipeline = relationship("Pipeline", backref=backref("configs", passive_deletes=True))
pipeline = relationship(
"Pipeline", backref=backref("configs", passive_deletes=True)
)


class PipelineRun(BaseMixin, db.Model):
Expand All @@ -571,7 +573,9 @@ class PipelineRun(BaseMixin, db.Model):
config_id = db.Column(
db.Text, db.ForeignKey("pipeline_configs.id", ondelete="CASCADE"), index=True
)
config = relationship("PipelineConfig", backref=backref("runs", passive_deletes=True))
config = relationship(
"PipelineConfig", backref=backref("runs", passive_deletes=True)
)
run_index = db.Column(db.Integer())


Expand All @@ -591,6 +595,7 @@ class PipelineRunResult(BaseMixin, db.Model):
# value = db.Column(db.Float) # 0.67, 0.3, 0.5 (some measure of confidence for the result)
run = relationship("PipelineRun", backref=backref("results", passive_deletes=True))


# from . import event_listeners # noqa E402

# del event_listeners
2 changes: 1 addition & 1 deletion store/neurostore/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def search(self):
validate_search_query(s)
except errors.SyntaxError as e:
abort(400, description=e.args[0])
tsquery = func.to_tsquery('english', pubmed_to_tsquery(s))
tsquery = func.to_tsquery("english", pubmed_to_tsquery(s))
q = q.filter(m._ts_vector.op("@@")(tsquery))

# Alternatively (or in addition), search on individual fields.
Expand Down
23 changes: 12 additions & 11 deletions store/neurostore/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,16 +606,15 @@ def create_demographic_features(session, ingest_neurosynth, tmp_path):
}
with open(output_dir / "pipeline_info.json", "w") as f:
json.dump(pipeline_info, f)

studies = BaseStudy.query.all()
diseases = ["schizophrenia", "bipolar disorder", "depression", "healthy"]
studies_data = [
[
{
"age": random.randint(18, 100),
"group": group
} for group in random.sample(diseases, k=random.randint(1, 2))
] for study in studies
{"age": random.randint(18, 100), "group": group}
for group in random.sample(diseases, k=random.randint(1, 2))
]
for study in studies
]

for study, study_data in zip(studies, studies_data):
Expand All @@ -626,13 +625,17 @@ def create_demographic_features(session, ingest_neurosynth, tmp_path):
with open(study_dir / "info.json", "w") as f:
json.dump(
{
"inputs": {f"/path/to/input/{study.id}.txt": f"md5{random.randint(0, 100)}"},
"inputs": {
f"/path/to/input/{study.id}.txt": f"md5{random.randint(0, 100)}"
},
"date": f"2021-01-{random.randint(1, 30)}",
}, f
},
f,
)

return output_dir


"""
Queries for testing
"""
Expand All @@ -648,9 +651,7 @@ def create_demographic_features(session, ingest_neurosynth, tmp_path):
'OR ("ASD")) AND (("decision*" OR "Dec',
"Unmatched parentheses",
),
(
'smoking AND NOT memory', "Consecutive operators are not allowed"
)
("smoking AND NOT memory", "Consecutive operators are not allowed"),
]

valid_queries = [
Expand Down
2 changes: 2 additions & 0 deletions store/neurostore/tests/test_ingestion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Test Ingestion Functions"""

from neurostore.ingest.extracted_features import ingest_feature


def test_ingest_ace(ingest_neurosynth, ingest_ace, session):
pass

Expand Down
Loading