How to use the emmental.meta.Meta.update_config function in emmental

To help you get started, we’ve selected a few emmental examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_no_writer(caplog):
    """Unit test of logging_manager (no writer)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "epoch",
                "evaluation_freq": 1,
                "checkpointing": False,
                "checkpointer_config": {"checkpoint_freq": 2},
                "writer_config": {"writer": None},
            }
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=2)

    logging_manager.update(5)

    assert logging_manager.writer is None
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_wrong_counter_unit(caplog):
    """Unit test of logging_manager (wrong counter_unit)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "epochs",
                "evaluation_freq": 1,
                "checkpointing": False,
                "checkpointer_config": {"checkpoint_freq": 2},
            }
        }
    )

    with pytest.raises(ValueError):
        logging_manager = LoggingManager(n_batches_per_epoch=2)
        logging_manager.update(5)
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_json(caplog):
    """Unit test of logging_manager (json)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "epoch",
                "evaluation_freq": 1,
                "checkpointing": False,
                "checkpointer_config": {"checkpoint_freq": 2},
                "writer_config": {"writer": "json"},
            }
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=2)

    logging_manager.update(5)

    assert type(logging_manager.writer) == LogWriter
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_batch(caplog):
    """Unit test of logging_manager (batch)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "batch",
                "evaluation_freq": 2,
                "checkpointing": True,
                "checkpointer_config": {"checkpoint_freq": 2},
            }
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=5)

    logging_manager.update(5)
    assert logging_manager.trigger_evaluation() is False
    assert logging_manager.trigger_checkpointing() is False
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_epoch(caplog):
    """Unit test of logging_manager (epoch)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "meta_config": {"verbose": False},
            "logging_config": {
                "counter_unit": "epoch",
                "evaluation_freq": 1,
                "checkpointing": True,
                "checkpointer_config": {"checkpoint_freq": 2},
            },
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=2)

    logging_manager.update(5)
    assert logging_manager.trigger_evaluation() is False
    assert logging_manager.trigger_checkpointing() is False
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_tensorboard(caplog):
    """Unit test of logging_manager (tensorboard)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "epoch",
                "evaluation_freq": 1,
                "checkpointing": False,
                "checkpointer_config": {"checkpoint_freq": 2},
                "writer_config": {"writer": "tensorboard"},
            }
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=2)

    logging_manager.update(5)

    assert type(logging_manager.writer) == TensorBoardWriter
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_sample(caplog):
    """Unit test of logging_manager (sample)."""
    caplog.set_level(logging.INFO)

    Meta.reset()

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "sample",
                "evaluation_freq": 10,
                "checkpointing": True,
                "checkpointer_config": {"checkpoint_freq": 2},
            }
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=10)

    logging_manager.update(5)
    assert logging_manager.trigger_evaluation() is False
    assert logging_manager.trigger_checkpointing() is False
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_no_checkpointing(caplog):
    """Unit test of logging_manager (no checkpointing)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "meta_config": {"verbose": False},
            "logging_config": {
                "counter_unit": "epoch",
                "evaluation_freq": 1,
                "checkpointing": False,
                "checkpointer_config": {"checkpoint_freq": 2},
                "writer_config": {"writer": "json"},
            },
        }
    )

    logging_manager = LoggingManager(n_batches_per_epoch=2)

    logging_manager.update(5)
    assert logging_manager.trigger_evaluation() is False
github SenWu / emmental / tests / logging / test_logging_manager.py View on Github external
def test_logging_manager_wrong_writer(caplog):
    """Unit test of logging_manager (wrong writer)."""
    caplog.set_level(logging.INFO)

    emmental.init()
    Meta.update_config(
        config={
            "logging_config": {
                "counter_unit": "epoch",
                "evaluation_freq": 1,
                "checkpointing": False,
                "checkpointer_config": {"checkpoint_freq": 2},
                "writer_config": {"writer": "a"},
            }
        }
    )

    with pytest.raises(ValueError):
        logging_manager = LoggingManager(n_batches_per_epoch=2)
        logging_manager.update(5)