import os

from graph_crawler import GraphCrawler
from feature_extractor import FeatureExtractor
from feature_cleaner import FeatureCleaner
from classifier import Classifier
from csv import DictReader


def run_stages(stages, initial_input_data=None, check_clean=True, **kwargs):
    input_data = initial_input_data
    for i, stage in enumerate(stages):
        print("### STAGE", stage.__name__, "###")
        if check_clean:
            stage_path = stage._stagepath
            if os.path.exists(stage_path) and not os.listdir(stage_path) == []:
                raise RuntimeError(
                    "Make sure the folder %s is empty." % stage_path
                )
        if isinstance(input_data, str):
            with open(input_data) as input_dicts_file:
                input_dicts = list(DictReader(input_dicts_file))
        else:
            input_dicts = input_data
        if input_dicts:
            stage(input_dicts, **kwargs).execute()
        else:
            stage(**kwargs).execute()
        input_data = stage.resultspath


run_stages(
    [
        #GraphCrawler, 
        FeatureExtractor, 
        FeatureCleaner, 
        Classifier
    ],
    GraphCrawler.resultspath,
    #FeatureExtractor.resultspath,
    #FeatureCleaner.resultspath,
    check_clean=False,
    cores=4
)

02db378dcb41bac034c3d0f4034099171102c9e7
<mask token>

<mask token>


def run_stages(stages, initial_input_data=None, check_clean=True, **kwargs):
    input_data = initial_input_data
    for i, stage in enumerate(stages):
        print('### STAGE', stage.__name__, '###')
        if check_clean:
            stage_path = stage._stagepath
            if os.path.exists(stage_path) and not os.listdir(stage_path) == []:
                raise RuntimeError('Make sure the folder %s is empty.' %
                    stage_path)
        if isinstance(input_data, str):
            with open(input_data) as input_dicts_file:
                input_dicts = list(DictReader(input_dicts_file))
        else:
            input_dicts = input_data
        if input_dicts:
            stage(input_dicts, **kwargs).execute()
        else:
            stage(**kwargs).execute()
        input_data = stage.resultspath


<mask token>

<mask token>


def run_stages(stages, initial_input_data=None, check_clean=True, **kwargs):
    input_data = initial_input_data
    for i, stage in enumerate(stages):
        print('### STAGE', stage.__name__, '###')
        if check_clean:
            stage_path = stage._stagepath
            if os.path.exists(stage_path) and not os.listdir(stage_path) == []:
                raise RuntimeError('Make sure the folder %s is empty.' %
                    stage_path)
        if isinstance(input_data, str):
            with open(input_data) as input_dicts_file:
                input_dicts = list(DictReader(input_dicts_file))
        else:
            input_dicts = input_data
        if input_dicts:
            stage(input_dicts, **kwargs).execute()
        else:
            stage(**kwargs).execute()
        input_data = stage.resultspath


run_stages([FeatureExtractor, FeatureCleaner, Classifier], GraphCrawler.
    resultspath, check_clean=False, cores=4)

import os
from graph_crawler import GraphCrawler
from feature_extractor import FeatureExtractor
from feature_cleaner import FeatureCleaner
from classifier import Classifier
from csv import DictReader


def run_stages(stages, initial_input_data=None, check_clean=True, **kwargs):
    input_data = initial_input_data
    for i, stage in enumerate(stages):
        print('### STAGE', stage.__name__, '###')
        if check_clean:
            stage_path = stage._stagepath
            if os.path.exists(stage_path) and not os.listdir(stage_path) == []:
                raise RuntimeError('Make sure the folder %s is empty.' %
                    stage_path)
        if isinstance(input_data, str):
            with open(input_data) as input_dicts_file:
                input_dicts = list(DictReader(input_dicts_file))
        else:
            input_dicts = input_data
        if input_dicts:
            stage(input_dicts, **kwargs).execute()
        else:
            stage(**kwargs).execute()
        input_data = stage.resultspath


run_stages([FeatureExtractor, FeatureCleaner, Classifier], GraphCrawler.
    resultspath, check_clean=False, cores=4)

import os

from graph_crawler import GraphCrawler
from feature_extractor import FeatureExtractor
from feature_cleaner import FeatureCleaner
from classifier import Classifier
from csv import DictReader


def run_stages(stages, initial_input_data=None, check_clean=True, **kwargs):
    input_data = initial_input_data
    for i, stage in enumerate(stages):
        print("### STAGE", stage.__name__, "###")
        if check_clean:
            stage_path = stage._stagepath
            if os.path.exists(stage_path) and not os.listdir(stage_path) == []:
                raise RuntimeError(
                    "Make sure the folder %s is empty." % stage_path
                )
        if isinstance(input_data, str):
            with open(input_data) as input_dicts_file:
                input_dicts = list(DictReader(input_dicts_file))
        else:
            input_dicts = input_data
        if input_dicts:
            stage(input_dicts, **kwargs).execute()
        else:
            stage(**kwargs).execute()
        input_data = stage.resultspath


run_stages(
    [
        #GraphCrawler, 
        FeatureExtractor, 
        FeatureCleaner, 
        Classifier
    ],
    GraphCrawler.resultspath,
    #FeatureExtractor.resultspath,
    #FeatureCleaner.resultspath,
    check_clean=False,
    cores=4
)
