Configuration

Blocks allows module-wide configuration values to be set using a YAML configuration file and environment variables. Environment variables override the configuration file which in its turn overrides the defaults.

The configuration is read from ~/.blocksrc if it exists. A custom configuration file can be used by setting the BLOCKS_CONFIG environment variable. A configuration file is of the form:

data_path: /home/user/datasets

If a setting is not configured and does not provide a default, a ConfigurationError is raised when it is accessed.

Configuration values can be accessed as attributes of blocks.config.config.

>>> from blocks.config import config
>>> print(config.default_seed) 
1

The following configurations are supported:

default_seed

The seed used when initializing random number generators (RNGs) such as NumPy RandomState objects as well as Theano’s MRG_RandomStreams objects. Must be an integer. By default this is set to 1.

recursion_limit

The recursion max depth limit used in MainLoop as well as in other situations when deep recursion is required. The most notable example of such a situation is pickling or unpickling a complex structure with lots of objects, such as a big Theano computation graph.

profile, BLOCKS_PROFILE

A boolean value which determines whether to print profiling information at the end of a call to MainLoop.run().

log_backend

The backend to use for logging experiments. Defaults to python, which stores the log as a Python object in memory. The other option is sqlite.

sqlite_database, BLOCKS_SQLITEDB

The SQLite database file to use.

max_blob_size

The maximum size of an object to store in an SQLite database in bytes. Objects beyond this size will trigger a warning. Defaults to 4 kilobyte.

temp_dir, BLOCKS_TEMPDIR

The directory in which Blocks will create temporary files. If unspecified, the platform-dependent default chosen by the Python tempfile module is used.

class blocks.config.ConfigurationError[source]

Bases: exceptions.Exception

Error raised when a configuration value is requested but not set.