Completed
Push — master ( a0f7c0...39b370 )
by Bart
23s
created

fuel.bin.main()   B

Complexity

Conditions 2

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 30
rs 8.8571
1
#!/usr/bin/env python
0 ignored issues
show
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.text).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.billion).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.binarized_mnist).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.svhn).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.cifar10).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.mnist).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.hdf5).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.iris).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.caltech101_silhouettes).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.cifar100).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.adult).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.celeba).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
Bug introduced by
There seems to be a cyclic import (fuel.datasets -> fuel.datasets.dogs_vs_cats).

Cyclic imports may cause partly loaded modules to be returned. This might lead to unexpected runtime behavior which is hard to debug.

Loading history...
2
"""Fuel utility for extracting metadata."""
3
import argparse
4
import os
5
6
import h5py
7
8
message_prefix_template = 'Metadata for {}'
0 ignored issues
show
Coding Style Naming introduced by
The name message_prefix_template does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
9
message_body_template = """
0 ignored issues
show
Coding Style Naming introduced by
The name message_body_template does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
10
11
    The command used to generate this file is
12
13
        {}
14
15
    Relevant versions are
16
17
        H5PYDataset     {}
18
        fuel.converters {}
19
"""
20
21
22
def main(args=None):
23
    """Entry point for `fuel-info` script.
24
25
    This function can also be imported and used from Python.
26
27
    Parameters
28
    ----------
29
    args : iterable, optional (default: None)
30
        A list of arguments that will be passed to Fuel's information
31
        utility. If this argument is not specified, `sys.argv[1:]` will
32
        be used.
33
34
    """
35
    parser = argparse.ArgumentParser(
36
        description='Extracts metadata from a Fuel-converted HDF5 file.')
37
    parser.add_argument("filename", help="HDF5 file to analyze")
38
    args = parser.parse_args()
39
40
    with h5py.File(args.filename, 'r') as h5file:
41
        interface_version = h5file.attrs.get('h5py_interface_version', 'N/A')
42
        fuel_convert_version = h5file.attrs.get('fuel_convert_version', 'N/A')
43
        fuel_convert_command = h5file.attrs.get('fuel_convert_command', 'N/A')
44
45
    message_prefix = message_prefix_template.format(
46
        os.path.basename(args.filename))
47
    message_body = message_body_template.format(
48
        fuel_convert_command, interface_version, fuel_convert_version)
49
    message = ''.join(['\n', message_prefix, '\n', '=' * len(message_prefix),
50
                       message_body])
51
    print(message)
52
53
54
if __name__ == "__main__":
55
    main()
56