# Path: clustertools/datacube.py
# def build_datacube(exp_name, storage_factory=PickleStorage, force=True,
#                    autopacking=False, **default_meta):
#     """
#     default_meta: mapping str -> str
#         The (potientially) missing metadata
#     """
#     storage = storage_factory(experiment_name=exp_name)
#     parameters_ls, results_ls = storage.load_params_and_results(**default_meta)
#     return Datacube(parameters_ls, results_ls, exp_name, force=force,
#                     autopacking=autopacking)


import sys
from clustertools import build_datacube
# -*- coding: utf-8 -*-
#!/usr/bin/env python

"""
This result example is dedicated to the script `005_adding_parameters.py`. Make
sure you have run that one before proceeding.

In this example, we will see how to handle the addition of new parameters when
working with the datacube. The datacube cannot handle it because parts of the
results were saved without an explicit value for the missing parameter.
Therefore, when the `build_datacube` function sees some results with the new
parameter, it does not know what to do of it.

For this, there is an easy solution: the
`build_datacube` function accepts key-based optional parameters where the key
is the name of the parameter and the value is its default value.
"""


if __name__ == '__main__':

    # Compare to `002_results.py`, we simply add the n=0 kwarg to tell the
    # function to use this default value when `n` is missing. We can of course
    # have more than one such default values

# Path: clustertools/datacube.py
# def build_datacube(exp_name, storage_factory=PickleStorage, force=True,
#                    autopacking=False, **default_meta):
#     """
#     default_meta: mapping str -> str
#         The (potientially) missing metadata
#     """
#     storage = storage_factory(experiment_name=exp_name)
#     parameters_ls, results_ls = storage.load_params_and_results(**default_meta)
#     return Datacube(parameters_ls, results_ls, exp_name, force=force,
#                     autopacking=autopacking)


# Path: examples/005_results_with_default_params.py
import sys
from clustertools import build_datacube

# -*- coding: utf-8 -*-
#!/usr/bin/env python

"""
This result example is dedicated to the script `005_adding_parameters.py`. Make
sure you have run that one before proceeding.

In this example, we will see how to handle the addition of new parameters when
working with the datacube. The datacube cannot handle it because parts of the
results were saved without an explicit value for the missing parameter.
Therefore, when the `build_datacube` function sees some results with the new
parameter, it does not know what to do of it.

For this, there is an easy solution: the
`build_datacube` function accepts key-based optional parameters where the key
is the name of the parameter and the value is its default value.
"""


if __name__ == '__main__':

    # Compare to `002_results.py`, we simply add the n=0 kwarg to tell the
    # function to use this default value when `n` is missing. We can of course
    # have more than one such default values

    cube = build_datacube('BasicUsage', n=0)