Facebook
From Round Prairie Dog, 2 Years ago, written in Python.
This paste is a reply to Re: Re: Re: Re: Re: Re: Re: Re: Untitled from Tiny Crane - view diff
Embed
Download Paste or View Raw
Hits: 199
  1. import json
  2. import os
  3. import sys
  4. import click
  5. from aihub.domain.experiment_config import ExperimentConfig
  6. from log import logger as aihub_logger
  7.  
  8. class ExperimentFileManager(object):
  9.     """
  10.    Manages .ai-exp file in the current directory
  11.    """
  12.  
  13.     CONFIG_FILE_PATH = os.path.join(os.getcwd() + "/.ai-exp")
  14.  
  15.     @classmethod
  16.     def set_config(self, experiment_config):
  17.         with open(self.CONFIG_FILE_PATH, "w") as config_file:
  18.             config_file.write(json.dumps(experiment_config.to_dict()))
  19.  
  20.     @classmethod
  21.     def get_config(self):
  22.         if not os.path.isfile(self.CONFIG_FILE_PATH):
  23.             raise Exception("[ERROR] Missing .ai-exp file, run init first")
  24.  
  25.         with open(self.CONFIG_FILE_PATH, "r") as config_file:
  26.             experiment_config = json.loads(config_file.read())
  27.  
  28.         return ExperimentConfig.from_dict(experiment_config)
  29.  
  30.     @classmethod
  31.     def exist_config(self):
  32.         is_init_already = os.path.isfile(self.CONFIG_FILE_PATH)
  33.         if is_init_already is True:
  34.             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'))
  35.             sys.exit()

Replies to Re: Re: Re: Re: Re: Re: Re: Re: Re: Untitled rss

Title Name Language When
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Untitled Reliable Frog python 2 Years ago.