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 - go back
Embed
import json
import os
import sys
import click
import sys
from aihub.domain.auth experiment_config import AuthSettings

ExperimentConfig
from log import logger as aihub_logger

class AuthFileManager(object):
ExperimentFileManager(object):
    """
    Manages .ai-auth ai-exp file in the current directory
    """

    AUTH_FILE_PATH CONFIG_FILE_PATH = os.path.join(os.getcwd() + "/.ai-auth")

ai-exp")

    @classmethod
    def set_auth(self, auth_settings):
set_config(self, experiment_config):
        with open(self.AUTH_FILE_PATH, CONFIG_FILE_PATH, "w") as file:
            file.
config_file:
            config_file.
write(json.dumps(auth_settings.dumps(experiment_config.to_dict()))

    @classmethod
    def get_auth(self):
get_config(self):
        if not os.path.isfile(self.AUTH_FILE_PATH):
            
CONFIG_FILE_PATH):
            
raise Exception("Missing .ai-auth file")

Exception("[ERROR] Missing .ai-exp file, run init first")

        with open(self.AUTH_FILE_PATH, CONFIG_FILE_PATH, "r") as file:
            auth_settings 
config_file:
            experiment_config 
= json.loads(file.loads(config_file.read())

        return AuthSettings.from_dict(auth_settings)

ExperimentConfig.from_dict(experiment_config)

    @classmethod
    def exists_auth(self):
exist_config(self):
        is_init_already = os.path.isfile(self.AUTH_FILE_PATH)
        
CONFIG_FILE_PATH)
        
if is_init_already is False:
True:
            click.echo(click.style('[INFO] Please login first.There is already initialized AIHUB project in that folder! Init skipped. You can delete manually .ai-exp file.', fg='yellow'))
            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.