コード例 #1
0
def fstring_decoded_reward_function(reward_function_local_path_preprocessed):
    try:
        reward_function_local_path_processed = os.path.join(
            CUSTOM_FILES_PATH, "customer_reward_function.py")
        with open(reward_function_local_path_preprocessed,
                  'rb') as filepointer:
            text, _ = future_fstrings.fstring_decode(filepointer.read())
        with open(reward_function_local_path_processed, 'wb') as filepointer:
            filepointer.write(text.encode('UTF-8'))
    except Exception as e:
        utils.log_and_exit(
            "Failed to decode the fstring format in reward function: {}".
            format(e), utils.SIMAPP_SIMULATION_WORKER_EXCEPTION,
            utils.SIMAPP_EVENT_ERROR_CODE_500)
コード例 #2
0
    def _fstring_decoded_reward_function(self):
        """ python 3.6 supports fstring and console lambda function validates using python3.6.
        But all the simapp code is runs in python3.5 which does not support fstring. This funciton
        support fstring in python 3.5"""

        try:
            with open(self._local_path_preprocessed, 'rb') as filepointer:
                text, _ = future_fstrings.fstring_decode(filepointer.read())
            with open(self._local_path_processed, 'wb') as filepointer:
                filepointer.write(text.encode('UTF-8'))
        except Exception as e:
            log_and_exit("Failed to decode the fstring format in reward function: {}".format(e),
                         SIMAPP_S3_DATA_STORE_EXCEPTION,
                         SIMAPP_EVENT_ERROR_CODE_500)
コード例 #3
0
def fstring_decoded_reward_function(reward_function_local_path_preprocessed):
    """ python 3.6 supports fstring and console lambda function validates using python3.6.
    But all the simapp code is runs in python3.5 which does not support fstring. This funciton
    support fstring in python 3.5

    Arguments:
        reward_function_local_path_preprocessed {[str]} -- [Reward function file path]
    """
    try:
        reward_function_local_path_processed = os.path.join(CUSTOM_FILES_PATH, "customer_reward_function.py")
        with open(reward_function_local_path_preprocessed, 'rb') as filepointer:
            text, _ = future_fstrings.fstring_decode(filepointer.read())
        with open(reward_function_local_path_processed, 'wb') as filepointer:
            filepointer.write(text.encode('UTF-8'))
    except Exception as e:
        utils.log_and_exit("Failed to decode the fstring format in reward function: {}".format(e),
                           utils.SIMAPP_SIMULATION_WORKER_EXCEPTION,
                           utils.SIMAPP_EVENT_ERROR_CODE_500)