# Path: automlk/grapher.py
# def grapher_loop():
#     """
#     periodically pool the grapher queue for a job
# 
#     :return: 
#     """
#     while True:
#         heart_beep('grapher', '')
#         # check the list of datasets
#         for dt in get_dataset_list():
#             if dt.status != 'created' and not dt.grapher:
#                 heart_beep('grapher', {'dataset_id': dt.dataset_id, 'dataset_name': dt.name})
#                 logging.info('grapher on dataset: %s' % dt.dataset_id)
#                 create_graph_data(dt.dataset_id)
#         time.sleep(60)
# 
# Path: automlk/context.py
# def get_data_folder():
#     """
#     retrieves root folder from 'automlk.json' configuration file
#     :return: storage folder name of the data
#     """
#     return get_config()['data']


import logging
import sys
import os
from automlk.grapher import grapher_loop
from automlk.context import get_data_folder

logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(module)s %(lineno)d %(message)s',
                    handlers=[
                        logging.FileHandler(get_data_folder() + '/grapher.log'),
                        logging.StreamHandler()
                    ]
                    )
while True:
    try:

# Path: automlk/grapher.py
# def grapher_loop():
#     """
#     periodically pool the grapher queue for a job
# 
#     :return: 
#     """
#     while True:
#         heart_beep('grapher', '')
#         # check the list of datasets
#         for dt in get_dataset_list():
#             if dt.status != 'created' and not dt.grapher:
#                 heart_beep('grapher', {'dataset_id': dt.dataset_id, 'dataset_name': dt.name})
#                 logging.info('grapher on dataset: %s' % dt.dataset_id)
#                 create_graph_data(dt.dataset_id)
#         time.sleep(60)
# 
# Path: automlk/context.py
# def get_data_folder():
#     """
#     retrieves root folder from 'automlk.json' configuration file
#     :return: storage folder name of the data
#     """
#     return get_config()['data']


# Path: run/run_grapher.py
import logging
import sys
import os
from automlk.grapher import grapher_loop
from automlk.context import get_data_folder


logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(module)s %(lineno)d %(message)s',
                    handlers=[
                        logging.FileHandler(get_data_folder() + '/grapher.log'),
                        logging.StreamHandler()
                    ]
                    )
while True:
    try:

        grapher_loop()