Exemple #1
0
    def write(new_user_set: UserSet):
        # TODO: don't overwrite user set each time, just insert new keys
        current_user_set: UserSet = ReadUserSet.read()

        # iteratively add user to UserSet
        for user in new_user_set.users.keys():
            # TODO: check if user exists
            logging.error(user)
            current_user_set.users[user] = {}

        #data: dict = {"users": [u.user_id for u in new_user_set.users]}
        # no list compresension since its a dict
        data: dict = {"users": current_user_set.users}
        users_file_location: str = USERS_FILE_LOCATION

        # write JSON object for user set
        WriteJSONFileFS(data, users_file_location)

        #TODO: write users to unique directory
        try:
            user_list: List = list(data["users"].keys())
            try:
                WriteListToDirectories(user_list, "storage/users")
            except Exception as e:
                logging.error(''.join([str(e), str(" -- ")]))
                raise e
        except Exception as e:
            logging.error(''.join(
                [str(e),
                 str(" -- could not convert data['users'].keys() ")]))
Exemple #2
0
    def write(user_set: UserSet):
        data: dict = {"users": [u.user_id for u in user_set.users]}
        users_file_location: str = USERS_FILE_LOCATION

        # write JSON object for user set
        WriteJSONFileFS(data, users_file_location)

        #TODO: write users to unique directory
        WriteListToDirectories(data["users"], "storage/users")
Exemple #3
0
    def __init__(self, metadata: dict, library: ModelLibrary):
        self.metadata: dict = metadata
        self.library: ModelLibrary = library

        #TODO: log model session has been initiated
        model_session_run_log_record: dict = {
            "session": metadata,
            "timestamp": Timestamp().readable
        }

        WriteJSONFileFS(model_session_run_log_record,
                        MODELS_SESSION_FILE_LOCATION)
Exemple #4
0
    def __init__(self):
        self.library: ModelLibrary = ModelLibrary()

        # check for model metadata storage
        try:
            '''
            import os.path
            from os import path
            path.exists()
            '''
            json_reader = ReadJSONFileFS(MODELS_LIBRARY_FILE_LOCATION)
            self.models: dict = json_reader.data
            logging.info("Model Engine:"+str(self.models.keys()))
        except Exception as e:
            logging.error("ModelEngine: ReadJSONFileFS failed: "+str(e))
            self.models: dict = DEFAULT_MODEL_LIBRARY
            WriteJSONFileFS(self.models, MODELS_LIBRARY_FILE_LOCATION)
            pass
Exemple #5
0
 def write(user_set: UserSet):
     data: dict = {"user": [u.user_id for u in user_set.users]}
     users_file_location: str = USERS_FILE_LOCATION
     WriteJSONFileFS(data, users_file_location)