import json
import os
import sys
import click
from aihub.domain.experiment_config import ExperimentConfig
from log import logger as aihub_logger
class ExperimentFileManager(object):
"""
Manages .ai-exp file in the current directory
"""
CONFIG_FILE_PATH = os.path.join(os.getcwd() + "/.ai-exp")
@classmethod
def set_config(self, experiment_config):
with open(self.CONFIG_FILE_PATH, "w") as config_file:
config_file.write(json.dumps(experiment_config.to_dict()))
@classmethod
def get_config(self):
if not os.path.isfile(self.CONFIG_FILE_PATH):
raise Exception("[ERROR] Missing .ai-exp file, run init first")
with open(self.CONFIG_FILE_PATH, "r") as config_file:
experiment_config = json.loads(config_file.read())
return ExperimentConfig.from_dict(experiment_config)
@classmethod
def exist_config(self):
is_init_already = os.path.isfile(self.CONFIG_FILE_PATH)
if is_init_already is True:
click.echo(click.style('[INFO] There is already initialized AIHUB project in that folder! Init skipped.' +
'You can delete manually .ai-exp file.', fg='yellow'))
sys.exit()
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}