Exemplo n.º 1
0
def finished_experiment(shared_db_engine, shared_project_storage):
    """A successfully-run experiment. Its database schemas and project storage can be queried.

    Returns: (triage.experiments.SingleThreadedExperiment)
    """
    populate_source_data(shared_db_engine)
    base_config = sample_config()
    experiment = SingleThreadedExperiment(
        base_config,
        db_engine=shared_db_engine,
        project_path=shared_project_storage.project_path
    )
    experiment.run()
    return experiment
Exemplo n.º 2
0
def main():
    args = parse_args()

    dburl = os.environ['DBURL']
    hiv_engine = create_engine(dburl, pool_pre_ping=True)

    with open(args.config_path) as f:
        experiment_config = yaml.load(f)
    experiment = SingleThreadedExperiment(config=experiment_config,
                                          db_engine=hiv_engine,
                                          project_path=args.project_path,
                                          replace=False)

    experiment.validate()
    experiment.run()
Exemplo n.º 3
0
def finished_experiment(shared_db_engine, shared_project_storage):
    """A successfully-run experiment. Its database schemas and project storage can be queried.

    Returns: (triage.experiments.SingleThreadedExperiment)
    """
    populate_source_data(shared_db_engine)
    base_config = sample_config()
    with mock.patch("triage.util.conf.open", side_effect=open_side_effect) as mock_file:
        experiment = SingleThreadedExperiment(
            base_config,
            db_engine=shared_db_engine,
            project_path=shared_project_storage.project_path,
        )
    experiment.run()
    return experiment
Exemplo n.º 4
0
def test_experiment_tracker_exception(db_engine, project_path):
    experiment = SingleThreadedExperiment(
        config=sample_config(),
        db_engine=db_engine,
        project_path=project_path,
    )
    # no source data means this should blow up
    with pytest.raises(Exception):
        experiment.run()

    with scoped_session(db_engine) as session:
        experiment_run = session.query(ExperimentRun).get(experiment.run_id)
        assert experiment_run.current_status == ExperimentRunStatus.failed
        assert isinstance(experiment_run.last_updated_time, datetime.datetime)
        assert experiment_run.stacktrace
Exemplo n.º 5
0
def test_experiment_tracker_exception(db_engine, project_path):
    with mock.patch("triage.util.conf.open",
                    side_effect=open_side_effect) as mock_file:
        experiment = SingleThreadedExperiment(
            config=sample_config(),
            db_engine=db_engine,
            project_path=project_path,
        )
    # no source data means this should blow up
    with pytest.raises(Exception):
        experiment.run()

    with scoped_session(db_engine) as session:
        experiment_run = session.query(TriageRun).get(experiment.run_id)
        assert experiment_run.current_status == TriageRunStatus.failed
        assert isinstance(experiment_run.last_updated_time, datetime.datetime)
        assert experiment_run.stacktrace
Exemplo n.º 6
0
import os
import sqlalchemy
import yaml

from catwalk.storage import FSModelStorageEngine
from triage.experiments import SingleThreadedExperiment

food_db = os.environ.get('FOOD_DB_URL')

print(food_db)

with open('inspections-training.yaml') as f:
    experiment_config = yaml.load(f)

experiment = SingleThreadedExperiment(
    config=experiment_config,
    db_engine=sqlalchemy.create_engine(food_db),
    model_storage_class=FSModelStorageEngine,
    project_path='./triage-generated')

experiment.run()