import random


def train_model(model, X, Y, epochs=100, version=0, run_number=0):
    """
    Shorthand function for training a new model.
    This function names each run of the model
    using the TensorBoard naming conventions.
    
    Parameters
    ----------
    model: Keras model instance
        Compiled Keras model.

    X, Y: np.array
        Series of observations to be used in
        the training process.

    version: int
        Version of the model to run.
    
    run_number: int
        The number of the run. Used in case
        the same model version is run again.
    """
    hash = random.getrandbits(128)
    hex_code = '%032x' % hash
    model_name = 'bitcoin_lstm_v{version}_run_{run_number}_{hex_code}'.format(
        version=version, run_number=run_number, hex_code=hex_code[:6])

    #tensorboard = TensorBoard(log_dir='./logs/{}'.format(model_name))
    
    model_history = model.fit(
        x=X, y=Y,
        batch_size=1, epochs=epochs,
        verbose=0, #callbacks=[tensorboard],
        shuffle=False)
    
    return model_history