initialize a folder with a a dataset configuration (metadata) file

            Parameters
            ==========
            folder: the folder to initialize the metadata file in
507192
def dataset_initialize(self, folder):
        
        if not os.path.isdir(folder):
            raise ValueError('Invalid folder: ' + folder)

        ref = self.config_values[self.CONFIG_NAME_USER] + '/INSERT_SLUG_HERE'
        licenses = []
        default_license = {'name': 'CC0-1.0'}
        licenses.append(default_license)

        meta_data = {
            'title': 'INSERT_TITLE_HERE',
            'id': ref,
            'licenses': licenses
        }
        meta_file = os.path.join(folder, self.DATASET_METADATA_FILE)
        with open(meta_file, 'w') as f:
            json.dump(meta_data, f, indent=2)

        print('Data package template written to: ' + meta_file)
        return meta_file
81497
def load_metadata(self, path, *args, **kwargs):
        
        if not os.path.exists(path):
            raise ValueError("no metadata file '" + path + "' found!")

        if path.endswith('csv'):
            df = pd.read_csv(path, *args, **kwargs)
        else:
            xl = pd.ExcelFile(path)
            if len(xl.sheet_names) > 1 and 'sheet_name' not in kwargs:
                kwargs['sheet_name'] = 'meta'
            df = pd.read_excel(path, *args, **kwargs)

        req_cols = ['model', 'scenario', 'exclude']
        if not set(req_cols).issubset(set(df.columns)):
            e = 'File `{}` does not have required columns ({})!'
            raise ValueError(e.format(path, req_cols))

        # set index, filter to relevant scenarios from imported metadata file
        df.set_index(META_IDX, inplace=True)
        idx = self.meta.index.intersection(df.index)

        n_invalid = len(df) - len(idx)
        if n_invalid > 0:
            msg = 'Ignoring {} scenario{} from imported metadata'
            logger().info(msg.format(n_invalid, 's' if n_invalid > 1 else ''))

        if idx.empty:
            raise ValueError('No valid scenarios in imported metadata file!')

        df = df.loc[idx]

        # Merge in imported metadata
        msg = 'Importing metadata for {} scenario{} (for total of {})'
        logger().info(msg.format(len(df), 's' if len(df) > 1 else '',
                                 len(self.meta)))

        for col in df.columns:
            self._new_meta_column(col)
            self.meta[col] = df[col].combine_first(self.meta[col])
        # set column `exclude` to bool
        self.meta.exclude = self.meta.exclude.astype('bool')
1356819
def index_dir(self, folder):
        
        folder_path = folder
        print('Indexing folder: ' + folder_path)
        nested_dir = {}
        folder = folder_path.rstrip(os.sep)
        start = folder.rfind(os.sep) + 1
        for root, dirs, files in os.walk(folder):
            folders = root[start:].split(os.sep)
            # subdir = dict.fromkeys(files)
            subdir = {}
            for f in files:
                # Create an entry for every markdown file
                if os.path.splitext(f)[1] == '.md':
                    with open(os.path.abspath(os.path.join(root, f)), encoding='utf-8') as fp:
                        try:
                            _, meta = self.mrk.extract_meta(fp.read())
                        except:
                            print("Skipping indexing " + f +"; Could not parse metadata")
                            meta = {'title': f}
                            pass
                    # Value of the entry (the key) is it's metadata
                    subdir[f] = meta
            parent = nested_dir
            for fold in folders[:-1]:
                parent = parent.get(fold)
            # Attach the config of all children nodes onto the parent
            parent[folders[-1]] = subdir
        return nested_dir
512445
def set_folder(self, folder='assets'):
        
        folder = folder.replace('/', '.')
        self._endpoint = 'files/{folder}'.format(folder=folder)
151501
private void initFileSystem() throws IOException {
		if (fs == null) {
			Path path = new Path(basePath);
			fs = createHadoopFileSystem(path, fsConfig);
		}
	}
927518
def _init_metadata(self, **kwargs):
        """"""
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        self._learning_objectives_default = self._mdata['learning_objectives']['default_id_values']
158656
def init(dataset_name):
    
    dataset_obj = DatasetClient().get_by_name(dataset_name)

    if not dataset_obj:
        namespace, name = get_namespace_from_name(dataset_name)
        create_dataset_base_url = "{}/datasets/create".format(floyd.floyd_web_host)
        create_dataset_url = "{}?name={}&namespace={}".format(create_dataset_base_url, name, namespace)
        floyd_logger.info(("Dataset name does not match your list of datasets. "
                           "Create your new dataset in the web dashboard:\n\t%s"),
                          create_dataset_base_url)
        webbrowser.open(create_dataset_url)

        name = click.prompt('Press ENTER to use dataset name "%s" or enter a different name' % dataset_name, default=dataset_name, show_default=False)

        dataset_name = name.strip() or dataset_name
        dataset_obj = DatasetClient().get_by_name(dataset_name)

        if not dataset_obj:
            raise FloydException('Dataset "%s" does not exist on floydhub.com. Ensure it exists before continuing.' % dataset_name)

    namespace, name = get_namespace_from_name(dataset_name)
    data_config = DataConfig(name=name,
                             namespace=namespace,
                             family_id=dataset_obj.id)
    DataConfigManager.set_config(data_config)
    floyd_logger.info("Data source \"{}\" initialized in current directory".format(dataset_name))
    floyd_logger.info("""
    You can now upload your data to Floyd by:
        floyd data upload
    """)
906930
def initialize(dirs):
    
    if biolite and dirs.get("work"):
        base_dir = utils.safe_makedir(os.path.join(dirs["work"], "provenance"))
        p_db = os.path.join(base_dir, "biolite.db")
        biolite.config.resources["database"] = p_db
        biolite.database.connect()
490859
def initialize(self):
        """"""
        mkdir_p(self.archive_path)
        mkdir_p(self.bin_path)
        mkdir_p(self.codebase_path)
        mkdir_p(self.input_basepath)
908263
def __init(self, folder='/'):
        """"""
        params = {
            "f" : "json"
        }
        if folder is None or folder == "/":
            folder = 'root'
        result_template = {
            "username": "",
            "total": 0,
            "start": 1,
            "num": 0,
            "nextStart": 0,
            "currentFolder": None,
            "items": [],
            "folders": []
        }
        nextStart = 1
        self._json_dict = {}
        self._json = ""
        while nextStart > -1:
            res = self.search(start=nextStart, num=100)
            if self._location.find(res['username'].lower()) > -1:
                self._location = self._location.replace(res['username'].lower(), res['username'])
                self._url = self._url.replace(res['username'].lower(), res['username'])

            nextStart = int(res['nextStart'])
            result_template['username'] = res['username']
            result_template["total"] = res["total"]
            result_template['nextStart'] = res['nextStart']
            result_template['start'] = res['start']
            result_template['num'] = res['num']

            #Added so the root has content to match when in a folder,
            #not sure if this is best practice or not.  Did not add
            #username and created
            #if res['currentFolder'] is None:
                #result_template['currentFolder'] = {
                    #'title': 'root',
                    #'id': None,
                    #'created' : None,
                    #'username' : None
                #}
                #result_template['folders'].insert(0, result_template['currentFolder'])
            #else:
            result_template['currentFolder'] = res['currentFolder']
            for item in res['items']:
                if item not in result_template['items']:
                    result_template['items'].append(item)
            #if 'folders' in res and \
               #folder.lower() == 'root':
                #for folder in res['folders']:
                    #if folder not in result_template['folders']:
                        #result_template['folders'].append(folder)

        self._json_dict = result_template
        self._json = json.dumps(result_template)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in result_template.items():
            if k in attributes:
                setattr(self, "_"+ k, result_template[k])
            else:
                print( k, " - attribute not implemented in Content.User class.")

        self._loadFolders()
729373
def convert_to_dataset_file_metadata(self, file_data, path):
        
        as_metadata = {
            'path': os.path.join(path, file_data['name']),
            'description': file_data['description']
        }

        schema = {}
        fields = []
        for column in file_data['columns']:
            field = {
                'name': column['name'],
                'title': column['description'],
                'type': column['type']
            }
            fields.append(field)
        schema['fields'] = fields
        as_metadata['schema'] = schema

        return as_metadata
1257354
def level1_initialize(self):
        
        self.dirname, self.basename = os.path.split(self.abspath)
        self.fname, self.ext = os.path.splitext(self.basename)
        self.ext = self.ext.lower()
843777
def _init_metadata(self, **kwargs):
        """"""
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        self._rubric_default = self._mdata['rubric']['default_id_values'][0]
        self._level_default = self._mdata['level']['default_id_values'][0]
1011305
private void createSystemDataFolder() throws IOException {
        if(!Files.exists(systemDataLocation.toPath()))
            Files.createDirectories(systemDataLocation.toPath());
    }
722050
def _init_metadata(self, **kwargs):
        """"""
        osid_objects.OsidContainableForm._init_metadata(self)
        osid_objects.OsidOperableForm._init_metadata(self)
        osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
        if 'assessment_part_id' not in kwargs:
            # Only "Section" Parts are allowed directly under Assessments
            self._mdata['sequestered']['is_read_only'] = True
            self._mdata['sequestered']['is_required'] = True
            self._mdata['sequestered']['default_boolean_values'] = [False]
        else:
            if 'mdata' in kwargs:
                self._mdata['sequestered'] = kwargs['mdata']['sequestered']
        self._assessment_part_default = self._mdata['assessment_part']['default_id_values'][0]
        self._assessment_default = self._mdata['assessment']['default_id_values'][0]
        self._weight_default = self._mdata['weight']['default_cardinal_values'][0]
        self._allocated_time_default = self._mdata['allocated_time']['default_duration_values'][0]
        self._items_sequential_default = None
        self._items_shuffled_default = None
        self._mdata['children'] = {
            'element_label': 'Children',
            'instructions': 'accepts an IdList',
            'required': False,
            'read_only': False,
            'linked': False,
            'array': False,
            'default_id_values': [''],
            'syntax': 'ID',
            'id_set': []
        }
1282689
public void setFolders(java.util.Collection<FolderMetadata> folders) {
        if (folders == null) {
            this.folders = null;
            return;
        }

        this.folders = new java.util.ArrayList<FolderMetadata>(folders);
    }
1072724
def load_metadata(self, data_dir, feature_name=None):
    """"""
    # Restore names if defined
    filepath = _get_metadata_filepath(data_dir, feature_name)
    if tf.io.gfile.exists(filepath):
      with tf.io.gfile.GFile(filepath, 'r') as f:
        info_data = json.load(f)
      self.set_encoding_format(info_data['encoding_format'])
      self.set_shape([None if d == -1 else d for d in info_data['shape']])