# Path: modl/utils/system.py
# def get_output_dir(data_dir=None):
#     """ Returns the directories in which cogspaces store results.
# 
#     Parameters
#     ----------
#     data_dir: string, optional
#         Path of the data directory. Used to force data storage in a specified
#         location. Default: None
# 
#     Returns
#     -------
#     paths: list of strings
#         Paths of the dataset directories.
# 
#     Notes
#     -----
#     This function retrieves the datasets directories using the following
#     priority :
#     1. the keyword argument data_dir
#     2. the global environment variable OUTPUT_MODL_DIR
#     4. output/modl in the user home folder
#     """
# 
#     paths = []
# 
#     # Check data_dir which force storage in a specific location
#     if data_dir is not None:
#         return str(data_dir)
#     else:
#         # If data_dir has not been specified, then we crawl default locations
#         output_dir = os.getenv('MODL_OUTPUT')
#         if output_dir is not None:
#             return str(output_dir)
#     return os.path.expanduser('~/output/modl')
# 
# Path: exps/exp_decompose_images.py
# def config():
# def decompose_images(batch_size,
#                      learning_rate,
#                      reduction,
#                      alpha,
#                      n_epochs,
#                      n_components,
#                      test_size,
#                      max_patches,
#                      patch_size,
#                      n_threads,
#                      verbose,
#                      method,
#                      step_size,
#                      setting,
#                      source,
#                      gray,
#                      scale,
#                      _run):


import os
import sys
import numpy as np
from os import path
from os.path import join
from sacred import Experiment
from sacred.observers import FileStorageObserver
from sklearn.externals.joblib import Parallel
from sklearn.externals.joblib import delayed
from sklearn.utils import check_random_state
from modl.utils.system import get_output_dir
from exps.exp_decompose_images import exp as single_exp
def config():
    n_jobs = 15
    n_seeds = 1
    seed = 1


@single_exp.config
def config():
    batch_size = 200
    learning_rate = 0.92
    reduction = 10
    alpha = 0.1
    n_epochs = 40
    n_components = 256
    test_size = 4000
    max_patches = 100000
    patch_size = (16, 16)
    n_threads = 2
    verbose = 100
    method = 'gram'
    step_size = 0.1
    setting = 'NMF'
    source = 'aviris'
    gray = False
    scale = 1


def single_run(config_updates, rundir, _id):
    for i in range(3):
        try:

# Path: modl/utils/system.py
# def get_output_dir(data_dir=None):
#     """ Returns the directories in which cogspaces store results.
# 
#     Parameters
#     ----------
#     data_dir: string, optional
#         Path of the data directory. Used to force data storage in a specified
#         location. Default: None
# 
#     Returns
#     -------
#     paths: list of strings
#         Paths of the dataset directories.
# 
#     Notes
#     -----
#     This function retrieves the datasets directories using the following
#     priority :
#     1. the keyword argument data_dir
#     2. the global environment variable OUTPUT_MODL_DIR
#     4. output/modl in the user home folder
#     """
# 
#     paths = []
# 
#     # Check data_dir which force storage in a specific location
#     if data_dir is not None:
#         return str(data_dir)
#     else:
#         # If data_dir has not been specified, then we crawl default locations
#         output_dir = os.getenv('MODL_OUTPUT')
#         if output_dir is not None:
#             return str(output_dir)
#     return os.path.expanduser('~/output/modl')
# 
# Path: exps/exp_decompose_images.py
# def config():
# def decompose_images(batch_size,
#                      learning_rate,
#                      reduction,
#                      alpha,
#                      n_epochs,
#                      n_components,
#                      test_size,
#                      max_patches,
#                      patch_size,
#                      n_threads,
#                      verbose,
#                      method,
#                      step_size,
#                      setting,
#                      source,
#                      gray,
#                      scale,
#                      _run):


# Path: exps/multi_decompose_images.py
import os
import sys
import numpy as np
from os import path
from os.path import join
from sacred import Experiment
from sacred.observers import FileStorageObserver
from sklearn.externals.joblib import Parallel
from sklearn.externals.joblib import delayed
from sklearn.utils import check_random_state
from modl.utils.system import get_output_dir
from exps.exp_decompose_images import exp as single_exp

def config():
    n_jobs = 15
    n_seeds = 1
    seed = 1


@single_exp.config
def config():
    batch_size = 200
    learning_rate = 0.92
    reduction = 10
    alpha = 0.1
    n_epochs = 40
    n_components = 256
    test_size = 4000
    max_patches = 100000
    patch_size = (16, 16)
    n_threads = 2
    verbose = 100
    method = 'gram'
    step_size = 0.1
    setting = 'NMF'
    source = 'aviris'
    gray = False
    scale = 1


def single_run(config_updates, rundir, _id):
    for i in range(3):
        try:

            run = single_exp._create_run(config_updates=config_updates)