# Path: libml/data.py
# DATA_DIR = os.environ['ML_DATA']


import collections
import gzip
import os
import sys
import tarfile
import tempfile
import numpy as np
import scipy.io
import tensorflow as tf
from urllib import request
from easydict import EasyDict
from libml.data import DATA_DIR
from tqdm import trange
def _save_files(files, *args, **kwargs):
    del args, kwargs
    for folder in frozenset(os.path.dirname(x) for x in files):
        os.makedirs(os.path.join(DATA_DIR, folder), exist_ok=True)
    for filename, contents in files.items():
        with open(os.path.join(DATA_DIR, filename), 'w') as f:
            f.write(contents)


def _is_installed_folder(name, folder):
    return os.path.exists(os.path.join(DATA_DIR, name, folder))


CONFIGS = dict(
    cifar10=dict(loader=_load_cifar10,
                 checksums=dict(train=None, test=None)),
    cifar100=dict(loader=_load_cifar100,
                  checksums=dict(train=None, test=None)),
    svhn=dict(loader=_load_svhn,
              checksums=dict(train=None, test=None, extra=None)),
    stl10=dict(loader=_load_stl10,
               checksums=dict(train=None, test=None)),
)

if __name__ == '__main__':
    if len(sys.argv[1:]):
        subset = set(sys.argv[1:])
    else:
        subset = set(CONFIGS.keys())
    try:

# Path: libml/data.py
# DATA_DIR = os.environ['ML_DATA']


# Path: scripts/create_datasets.py
import collections
import gzip
import os
import sys
import tarfile
import tempfile
import numpy as np
import scipy.io
import tensorflow as tf
from urllib import request
from easydict import EasyDict
from libml.data import DATA_DIR
from tqdm import trange

def _save_files(files, *args, **kwargs):
    del args, kwargs
    for folder in frozenset(os.path.dirname(x) for x in files):
        os.makedirs(os.path.join(DATA_DIR, folder), exist_ok=True)
    for filename, contents in files.items():
        with open(os.path.join(DATA_DIR, filename), 'w') as f:
            f.write(contents)


def _is_installed_folder(name, folder):
    return os.path.exists(os.path.join(DATA_DIR, name, folder))


CONFIGS = dict(
    cifar10=dict(loader=_load_cifar10,
                 checksums=dict(train=None, test=None)),
    cifar100=dict(loader=_load_cifar100,
                  checksums=dict(train=None, test=None)),
    svhn=dict(loader=_load_svhn,
              checksums=dict(train=None, test=None, extra=None)),
    stl10=dict(loader=_load_stl10,
               checksums=dict(train=None, test=None)),
)

if __name__ == '__main__':
    if len(sys.argv[1:]):
        subset = set(sys.argv[1:])
    else:
        subset = set(CONFIGS.keys())
    try:

        os.makedirs(DATA_DIR)