22
33import json
44import os .path as op
5- import re
65from pathlib import Path
76import hashlib
8-
9- import numpy as np
10- import pandas as pd
11- import requests
12- from scipy import sparse
137from dateutil .parser import parse as parse_date
14- from sqlalchemy import or_
158
169from neurostore .database import db
1710from neurostore .models import (
2215)
2316
2417
25- def ingest_feature (feature_directory , session ):
18+ def ingest_feature (feature_directory ):
2619 """Ingest demographics data into the database."""
2720 # read pipeline_info.json from the base feature directory
2821 with open (op .join (feature_directory , "pipeline_info.json" )) as f :
2922 pipeline_info = json .load (f )
3023
3124 # search if there is an existing pipeline with the same name and version
3225 pipeline = (
33- session .query (Pipeline )
26+ db . session .query (Pipeline )
3427 .filter (
3528 Pipeline .name == pipeline_info ["name" ],
3629 Pipeline .version == pipeline_info ["version" ],
@@ -48,7 +41,7 @@ def ingest_feature(feature_directory, session):
4841 pubget_compatible = pipeline_info .get ("pubget_compatible" , False ),
4942 derived_from = pipeline_info .get ("derived_from" , None ),
5043 )
51- session .add (pipeline )
44+ db . session .add (pipeline )
5245
5346 # search within the pipeline and see if there are any existing pipeline configs
5447 # that match the "arguements" field in the pipeline_info.json
@@ -57,7 +50,7 @@ def ingest_feature(feature_directory, session):
5750 json .dumps (pipeline_info ["arguments" ]).encode ()
5851 ).hexdigest ()
5952 pipeline_config = (
60- session .query (PipelineConfig )
53+ db . session .query (PipelineConfig )
6154 .filter (
6255 PipelineConfig .pipeline_id == pipeline .id ,
6356 PipelineConfig .config_hash == config_hash ,
@@ -71,7 +64,7 @@ def ingest_feature(feature_directory, session):
7164 config = pipeline_info ["arguments" ],
7265 config_hash = config_hash ,
7366 )
74- session .add (pipeline_config )
67+ db . session .add (pipeline_config )
7568
7669 # create a new pipeline run
7770 pipeline_run = PipelineRun (
@@ -104,7 +97,7 @@ def ingest_feature(feature_directory, session):
10497 )
10598 )
10699
107- session .add (pipeline_run )
108- session .add_all (pipeline_run_results )
100+ db . session .add (pipeline_run )
101+ db . session .add_all (pipeline_run_results )
109102
110- session .commit ()
103+ db . session .commit ()
0 commit comments