-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor data testing and take the french data for a spin
- Loading branch information
Showing
4 changed files
with
74 additions
and
70 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
import os.path | ||
|
||
from montage.rdb import User, Campaign, Round, Base, create_initial_tasks | ||
from montage.loaders import load_full_csv | ||
|
||
CUR_PATH = os.path.dirname(os.path.abspath(__file__)) | ||
DATA_PATH = os.path.join(CUR_PATH, 'test_data') | ||
|
||
|
||
def make_rdb_session(db_url='sqlite:///tmp_montage.db', echo=True): | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
# echo="debug" also prints results of selects, etc. | ||
engine = create_engine(db_url, echo=echo) | ||
Base.metadata.create_all(engine) | ||
|
||
session_type = sessionmaker() | ||
session_type.configure(bind=engine) | ||
session = session_type() | ||
return session | ||
|
||
|
||
def make_fake_data(debug=True, echo=True): | ||
rdb_session = make_rdb_session(echo=echo) | ||
coord = User(username='Slaporte') | ||
juror = User(username='MahmoudHashemi') | ||
|
||
campaign = Campaign(name='Test Campaign 2016') | ||
rdb_session.add(campaign) | ||
|
||
campaign.coords.append(coord) | ||
round = Round(name='Test Round 1', quorum=1) | ||
campaign.rounds.append(round) | ||
round.jurors.append(juror) | ||
|
||
CSV_PATH = DATA_PATH + '/wlm2015_fr_11k.csv' | ||
|
||
with open(CSV_PATH) as f: | ||
entries = load_full_csv(f) | ||
|
||
for entry in entries: | ||
round.entries.append(entry) | ||
rdb_session.commit() | ||
|
||
tasks = create_initial_tasks(rdb_session, round) | ||
rdb_session.add_all(tasks) | ||
|
||
rdb_session.commit() | ||
if debug: | ||
import pdb;pdb.set_trace() | ||
return | ||
|
||
|
||
def main(): | ||
make_fake_data(False, False) | ||
return | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
File renamed without changes.