class labscript_utils.h5_lock.File(name, mode=None, driver=None, libver=None, **kwds)[source]

Bases: File

__init__(name, mode=None, driver=None, libver=None, **kwds)[source]

Create a new file object.

See the h5py user guide for a detailed explanation of the options.


Name of the file on disk, or file-like object. Note: for files created with the ‘core’ driver, HDF5 still requires this be non-empty.


r Readonly, file must exist (default) r+ Read/write, file must exist w Create file, truncate if exists w- or x Create file, fail if exists a Read/write if exists, create otherwise


Name of the driver to use. Legal values are None (default, recommended), ‘core’, ‘sec2’, ‘direct’, ‘stdio’, ‘mpio’, ‘ros3’.


Library version bounds. Supported values: ‘earliest’, ‘v108’, ‘v110’, ‘v112’ and ‘latest’. The ‘v108’, ‘v110’ and ‘v112’ options can only be specified with the HDF5 1.10.2 library or later.


Desired size of user block. Only allowed when creating a new file (mode w, w- or x).


Open the file in SWMR read mode. Only used when mode = ‘r’.


Total size of the dataset chunk cache in bytes. The default size is 1024**2 (1 MiB) per dataset. Applies to all datasets unless individually changed.


The chunk preemption policy for all datasets. This must be between 0 and 1 inclusive and indicates the weighting according to which chunks which have been fully read or written are penalized when determining which chunks to flush from cache. A value of 0 means fully read or written chunks are treated no differently than other chunks (the preemption is strictly LRU) while a value of 1 means fully read or written chunks are always preempted before other chunks. If your application only reads or writes data once, this can be safely set to 1. Otherwise, this should be set lower depending on how often you re-read or re-write the same data. The default value is 0.75. Applies to all datasets unless individually changed.


The number of chunk slots in the raw data chunk cache for this file. Increasing this value reduces the number of cache collisions, but slightly increases the memory used. Due to the hashing strategy, this value should ideally be a prime number. As a rule of thumb, this value should be at least 10 times the number of chunks that can fit in rdcc_nbytes bytes. For maximum performance, this value should be set approximately 100 times that number of chunks. The default value is 521. Applies to all datasets unless individually changed.


Track dataset/group/attribute creation order under root group if True. If None use global default h5.get_config().track_order.


The file space handling strategy to be used. Only allowed when creating a new file (mode w, w- or x). Defined as: “fsm” FSM, Aggregators, VFD “page” Paged FSM, VFD “aggregate” Aggregators, VFD “none” VFD If None use HDF5 defaults.


File space page size in bytes. Only used when fs_strategy=”page”. If None use the HDF5 default (4096 bytes).


A boolean value to indicate whether free space should be persistent or not. Only allowed when creating a new file. The default value is False.


The smallest free-space section size that the free space manager will track. Only allowed when creating a new file. The default value is 1.


Page buffer size in bytes. Only allowed for HDF5 files created with fs_strategy=”page”. Must be a power of two value and greater or equal than the file space page size when creating the file. It is not used by default.


Minimum percentage of metadata to keep in the page buffer before allowing pages containing metadata to be evicted. Applicable only if page_buf_size is set. Default value is zero.


Minimum percentage of raw data to keep in the page buffer before allowing pages containing raw data to be evicted. Applicable only if page_buf_size is set. Default value is zero.


The file locking behavior. Defined as:

  • False (or “false”) – Disable file locking

  • True (or “true”) – Enable file locking

  • “best-effort” – Enable file locking but ignore some errors

  • None – Use HDF5 defaults


The HDF5_USE_FILE_LOCKING environment variable can override this parameter.

Only available with HDF5 >= 1.12.1 or 1.10.x >= 1.10.7.


Together with alignment_interval, this property ensures that any file object greater than or equal in size to the alignement threshold (in bytes) will be aligned on an address which is a multiple of alignment interval.


This property should be used in conjunction with alignment_threshold. See the description above. For more details, see


Set the current minimum size, in bytes, of new metadata block allocations. See

Additional keywords

Passed on to the selected file driver.


__init__(name[, mode, driver, libver])

Create a new file object.

build_virtual_dataset(name, shape, dtype[, ...])

Assemble a virtual dataset in this group.



Close the file.

copy(source, dest[, name, shallow, ...])

Copy an object or group.

create_dataset(name[, shape, dtype, data])

Create a new HDF5 dataset

create_dataset_like(name, other, **kwupdate)

Create a dataset similar to other.

create_group(name[, track_order])

Create and return a new subgroup.

create_virtual_dataset(name, layout[, fillvalue])

Create a new virtual dataset in this group.


Tell the HDF5 library to flush its buffers.

get(name[, default, getclass, getlink])

Retrieve an item or other information.


Get a view object on member items


Get a view object on member names

move(source, dest)

Move a link to a new location in the file.


If key is not found, d is returned if given, otherwise KeyError is raised.


as a 2-tuple; but raise KeyError if D is empty.

require_dataset(name, shape, dtype[, exact])

Open a dataset, creating it if it doesn't exist.


Return a group, creating it if it doesn't exist.


update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v


Get a view object on member objects


Recursively visit all names in this group and subgroups.


Recursively visit names and objects in this group.



Attributes attached to this object


Low-level HDF5 file driver used to open file


Return a File instance associated with this object


File name on disk


Low-level identifier appropriate for this object


low, high)


Meta block size (in bytes)


Python mode used to open file


Return the full name of this object.


Return the parent group of this object.


An (opaque) HDF5 reference to this object


Create a region reference (Datasets only).


Controls single-writer multiple-reader mode


User block size (in bytes)


Close the file. All open objects become invalid