Add a single dataset to a dataset collection.
358060
def add_dataset_to_collection(dataset_id, collection_id, **kwargs):
    
    collection_i = _get_collection(collection_id)
    collection_item = _get_collection_item(collection_id, dataset_id)
    if collection_item is not None:
        raise HydraError("Dataset Collection %s already contains dataset %s", collection_id, dataset_id)

    new_item = DatasetCollectionItem()
    new_item.dataset_id=dataset_id
    new_item.collection_id=collection_id

    collection_i.items.append(new_item)

    db.DBSession.flush()

    return 'OK'
448697
def addRnaQuantificationSet(self):
        
        self._openRepo()
        dataset = self._repo.getDatasetByName(self._args.datasetName)
        if self._args.name is None:
            name = getNameFromPath(self._args.filePath)
        else:
            name = self._args.name
        rnaQuantificationSet = rna_quantification.SqliteRnaQuantificationSet(
            dataset, name)
        referenceSetName = self._args.referenceSetName
        if referenceSetName is None:
            raise exceptions.RepoManagerException(
                "A reference set name must be provided")
        referenceSet = self._repo.getReferenceSetByName(referenceSetName)
        rnaQuantificationSet.setReferenceSet(referenceSet)
        rnaQuantificationSet.populateFromFile(self._args.filePath)
        rnaQuantificationSet.setAttributes(json.loads(self._args.attributes))
        self._updateRepo(
            self._repo.insertRnaQuantificationSet, rnaQuantificationSet)
391230
def insertDataset(self, blockcontent, otptIdList, migration=False):
        
        dataset = blockcontent['dataset']
        conn = self.dbi.connection()

        # First, check and see if the dataset exists.
        try:
            datasetID = self.datasetid.execute(conn, dataset['dataset'])
            dataset['dataset_id'] = datasetID
        except KeyError as ex:
            if conn:conn.close()
            dbsExceptionHandler("dbsException-invalid-input2", "DBSBlockInsert/InsertDataset: Dataset is required.\
                Exception: %s.  troubled dataset are: %s" %(ex.args[0], dataset),
	        self.logger.exception, "DBSBlockInsert/InsertDataset: Dataset is required.\
                Exception: %s.  troubled dataset are: %s" %(ex.args[0], dataset	))
        except Exception as ex1:
            if conn:conn.close()
            raise ex1
        if datasetID > 0:
            # Then we already have a valid dataset. We only need to fill the map (dataset & output module config)
            # Skip to the END
            try:
                self.insertDatasetWOannex(dataset = dataset,
                                          blockcontent = blockcontent,
                                          otptIdList = otptIdList, conn = conn,
                                          insertDataset = False, migration=migration)
            finally:
                if conn:conn.close()
            return datasetID

        # Else, we need to do the work
        #Start a new transaction
        tran = conn.begin()
        primary_ds_name = ''
        try:
            #1. Deal with primary dataset. Most primary datasets are
            #pre-installed in db
            primds = blockcontent["primds"]
            primary_ds_name = primds["primary_ds_name"]
            primds["primary_ds_id"] = self.primdsid.execute(conn,
                                      primds["primary_ds_name"], transaction=tran)
            if primds["primary_ds_id"] <= 0:
                #primary dataset is not in db yet.
                try:
                    primds["primary_ds_id"] = self.sm.increment(conn, "SEQ_PDS")
                    primds["creation_date"] = primds.get("creation_date", dbsUtils().getTime())
                    if not migration:
                        primds["create_by"] = dbsUtils().getCreateBy()
                    self.primdsin.execute(conn, primds, tran)
                except exceptions.IntegrityError as ex:
                    if (str(ex).find("ORA-00001") != -1 and str(ex).find("TUC_PDS_PRIMARY_DS_NAME") != -1)\
                        or str(ex).lower().find("duplicate") !=-1:
                        primds["primary_ds_id"] = self.primdsid.execute(conn,
                                                primds["primary_ds_name"],
                                                transaction=tran)
                        if primds["primary_ds_id"] <= 0:
                            if tran:tran.rollback()
                            if conn:conn.close()
                            dbsExceptionHandler('dbsException-conflict-data',
                                'Primary dataset not yet inserted by concurrent insert. ',
                                self.logger.exception,
                                'Primary dataset not yet inserted by concurrent insert. '+ str(ex))

                    elif str(ex).find("ORA-01400") > -1:
                        if tran:tran.rollback()
                        if conn:conn.close()
                        dbsExceptionHandler('dbsException-missing-data',
                            'Missing data when insert primary_datasets. ',
                            self.logger.exception,
                            'Missing data when insert primary_datasets. '+ str(ex))
                    else:
                        if tran:tran.rollback()
                        if conn:conn.close()
                        dbsExceptionHandler('dbsException-invalid-input2',
                            'Invalid data when insert primary_datasets. ',
                            self.logger.exception,
                            'Invalid data when insert primary_datasets. '+ str(ex))
                except Exception as ex:
                    if tran:tran.rollback()
                    if conn:conn.close()
                    raise
            dataset['primary_ds_id'] = primds["primary_ds_id"]
            #2 Deal with processed ds
            #processed ds is handled inside of dataset insertion, However we need to make sure it is formatted correctly.
            #processed_ds_name is not required pre-exist in the db. will insert with the dataset if not in yet
            #
            #         processed_ds_name=acquisition_era_name[-filter_name][-processing_str]-vprocessing_version
            #         Note [-filterName] is new as 4/30/2012. See ticket #3655. YG
            #
            #althrough acquisition era and processing version is not required for a dataset
            #in the schema(the schema is build this way because
            #we need to accommodate the DBS2 data), but we impose the requirement on the API.
            #So both acquisition and processing eras are required.
            #We do the format checking after we deal with acquisition era and processing era.
            #
            #YG 12/07/2011  TK-362

            #3 Deal with Acquisition era
            aq = blockcontent.get('acquisition_era', {})
            has_acquisition_era_name = 'acquisition_era_name' in aq
            has_start_date = 'start_date' in aq

            def insert_acquisition_era():
                try:
                    #insert acquisition era into db
                    aq['acquisition_era_id'] = self.sm.increment(conn, "SEQ_AQE")
                    self.acqin.execute(conn, aq, tran)
                    dataset['acquisition_era_id'] = aq['acquisition_era_id']
                except exceptions.IntegrityError as ei:
                    #ORA-01400: cannot insert NULL into required columns, usually it is the NULL on start_date
                    if "ORA-01400" in str(ei) :
                        if tran:tran.rollback()
                        if conn:conn.close()
                        dbsExceptionHandler("dbsException-invalid-input2",
                                            "BlockInsert: acquisition_era_name and start_date are required. \
                                            NULL was received from user input. Please correct your data.")
                    #ok, already in db?
                    if (str(ei).find("ORA-00001") != -1 and str(ei).find("TUC_AQE_ACQUISITION_ERA_NAME") != -1)\
                        or str(ei).lower().find("duplicate") !=-1:
                        dataset['acquisition_era_id'] = self.acqid.execute(conn, aq['acquisition_era_name'])
                        if dataset['acquisition_era_id'] <= 0:
                            if tran:tran.rollback()
                            if conn:conn.close()
                            dbsExceptionHandler("dbsException-invalid-input2", "BlockInsert: \
Check the spelling of acquisition Era name. The db may already have the same \
acquisition era, but with different cases.", self.logger.exception, "BlockInsert: \
Check the spelling of acquisition Era name. The db may already have the same \
acquisition era, but with different cases.")
                    else:
                        if tran:tran.rollback()
                        if conn:conn.close()
                        dbsExceptionHandler('dbsException-invalid-input2',
                            'Invalid data when insert acquisition_eras . ',
                            self.logger.exception,
                            'Invalid data when insert acquisition_eras. '+ str(ei))
 
                except Exception:
                    if tran:tran.rollback()
                    if conn:conn.close()
                    raise

            if has_acquisition_era_name and has_start_date:
                insert_acquisition_era()

            elif migration and not has_acquisition_era_name:
                #if no processing era is available, for example for old DBS 2 data, skip insertion
                aq['acquisition_era_id'] = None
                dataset['acquisition_era_id'] = None

            elif migration and not aq['start_date']:
                aq['start_date'] = 0
                insert_acquisition_era()

            else:
                if tran:tran.rollback()
                if conn:conn.close()
                dbsExceptionHandler("dbsException-invalid-input2", "BlockInsert: Acquisition Era is required", 
			self.logger.exception, "BlockInsert: Acquisition Era is required")

            #4 Deal with Processing era
            pera = blockcontent.get('processing_era', {})

            if 'processing_version' in pera:
                try:
                    #insert processing era into db
                    pera['processing_era_id'] = self.sm.increment(conn, "SEQ_PE")
                    #pera['processing_version'] = pera['processing_version'].upper()
                    self.procsingin.execute(conn, pera, tran)
                    dataset['processing_era_id'] = pera['processing_era_id']
                except exceptions.IntegrityError as ex:
                    if (str(ex).find("ORA-00001: unique constraint") != -1 and \
                                str(ex).find("TUC_PE_PROCESSING_VERSION") != -1) or \
                                str(ex).lower().find("duplicate") !=-1:
                        #ok, already in db
                        dataset['processing_era_id'] = self.procsingid.execute(conn, pera['processing_version'])
                    elif str(ex).find("ORA-01400") > -1:
                        if tran:tran.rollback()
                        if conn:conn.close()
                        dbsExceptionHandler('dbsException-missing-data',
                            'Missing data when insert processing_eras. ',
                            self.logger.exception,
                            'Missing data when insert Processing_eras. '+ str(ex))
                    else:
                        if tran: tran.rollback()
                        if conn: conn.close()
                        dbsExceptionHandler('dbsException-invalid-input2',
                            'Invalid data when insert Processing_ears. ',
                            self.logger.exception,
                            'Invalid data when insert Processing_eras. '+ str(ex))
                except Exception as ex:
                    if tran: tran.rollback()
                    if conn: conn.close()
                    raise
            elif migration:
                #if no processing era is available, for example for old DBS 2 data, skip insertion
                pera['processing_era_id'] = None
                dataset['processing_era_id'] = None
            else:
                if tran: tran.rollback()
                if conn: conn.close()
                dbsExceptionHandler('dbsException-invalid-input2', 'BlockInsert:processing version is required')

            #Make sure processed_ds_name is right format.
            #processed_ds_name=acquisition_era_name[-filter_name][-processing_str]-vprocessing_version
            #In order to accommodate DBS2 data for migration, we turn off this check in migration.
            #These will not cause any problem to none DBS2 data because when we migration, the none DBS2 data is
            #already checked when they were inserted into the source dbs.  YG 7/12/2012
            if not migration and aq["acquisition_era_name"] != "CRAB" and aq["acquisition_era_name"] != "LHE":
                erals=dataset["processed_ds_name"].rsplit('-')
                if erals[0] != aq["acquisition_era_name"] or erals[len(erals)-1] != "%s%s"%("v", pera["processing_version"]):
                    if tran:tran.rollback()
                    if conn:conn.close()
                    dbsExceptionHandler('dbsException-invalid-input2', "BlockInsert:\
                   processed_ds_name=acquisition_era_name[-filter_name][-processing_str]-vprocessing_version must be satisified.",
		   self.logger.exception, 
		   "BlockInsert: processed_ds_name=acquisition_era_name[-filter_name][-processing_str]-vprocessing_version must be satisified."	)

            #So far so good, let's commit first 4 db activities before going on.
            tran.commit()
        except KeyError as ex:
            if tran:tran.rollback()
            if conn:conn.close()
            dbsExceptionHandler("dbsException-invalid-input2", "DBSBlockInsert/insertOutputModuleConfig: \
                                         KeyError exception: %s. " %ex.args[0], self.logger.exception,
				         "DBSBlockInsert/insertOutputModuleConfig: KeyError exception: %s." %ex.args[0]	)            
        except:
        
            if tran:tran.rollback()
            if conn:conn.close()
            raise

        #Continue for the rest.
        tran = conn.begin()
        try:
            #5 Deal with physics gruop
            phg = dataset['physics_group_name']
            if phg:
                #Yes, the dataset has physica group.
                phgId = self.phygrpid.execute(conn, phg, transaction=tran)
                if phgId <= 0 :
                    #not in db yet, insert it
                    phgId = self.sm.increment(conn, "SEQ_PG")
                    phygrp = {'physics_group_id':phgId, 'physics_group_name':phg}
                    try:
                        self.phygrpin.execute(conn, phygrp, tran)
                    except exceptions.IntegrityError as ex:
                        if str(ex).find("ORA-00001") != -1 and str(ex).find("PK_PG") != -1:
                            if tran:tran.rollback()
                            if conn:conn.close()
                            dbsExceptionHandler(message='InsertPhysicsGroup Error', logger=self.logger.exception, serverError="InsertPhysicsGroup: "+ str(ex))
                        if (str(ex).find("ORA-00001") != -1 and str(ex).find("TUC_PG_PHYSICS_GROUP_NAME") != -1) or\
                            str(ex).lower().find("duplicate") != -1:
                            phgId = self.phygrpid.execute(conn, phg, transaction=tran)
                            if phgId <= 0:
                                if tran:tran.rollback()
                                if conn:conn.close()
                                dbsExceptionHandler(message='InsertPhysicsGroup Error ', logger=self.logger.exception, serverError="InsertPhysicsGroup: "+str(ex))
                        elif str(ex).find("ORA-01400") > -1:
                            if tran:tran.rollback()
                            if conn:conn.close()
                            dbsExceptionHandler('dbsException-missing-data',
                                'Missing data when insert Physics_groups. ',
                                self.logger.exception,
                                'Missing data when insert Physics_groups. '+ str(ex))
                        else:
                            if tran: tran.rollback()
                            if conn: conn.close()
                            dbsExceptionHandler('dbsException-invalid-input2',
                            'Invalid data when insert Physics_groups. ',
                            self.logger.exception,
                            'Invalid data when insert Physics_groups. '+ str(ex))                        
                    except Exception as ex:
                        if tran:tran.rollback()
                        if conn:conn.close()
                        raise
                dataset['physics_group_id'] = phgId
                #self.logger.debug("***PHYSICS_GROUP_ID=%s***" %phgId)
            else:
                #no physics gruop for the dataset.
                dataset['physics_group_id'] = None
            del dataset['physics_group_name']
            #6 Deal with Data tier. A dataset must has a data tier
            dataset['data_tier_name'] = dataset['data_tier_name'].upper()
            #We no longer handle Tier inside dataset insert. If a data tier is no in DBS before the dataset 
            # is inserted. We will report error back to the user as missing data. See github issue #466.
            # This is to prevent users to insert random data tiers into phys* DB. YG May-15-2015
            dtId = 0
            dtId = self.tierid.execute(conn, dataset['data_tier_name'])   
            #When no data tier found, it return tier id -1
            if dtId <= 0:
                dbsExceptionHandler('dbsException-missing-data', 'Required data tier %s not found in DBS when insert dataset. Ask your admin adding the tier before insert/migrate the block/dataset.' %dataset['data_tier_name'],
                         self.logger.exception, 'Required data tier not found in DBS when insert dataset. ')
            #7 Deal with dataset access type. A dataset must have a data type
            dataset['dataset_access_type'] = dataset['dataset_access_type'].upper()
            #handle dataset access type inside dataset insertion with Inser2.
            tran.commit()
        except Exception as ex:
            if tran:tran.rollback()
            if conn:conn.close()
            raise
        #Before we insert the dataset, we need to make sure dataset=/primary_dataset_name/processed_dataset_name/data_tier 
        d2 = dataset['dataset'].rsplit('/')
        if (d2[1] != primary_ds_name or d2[2] != dataset["processed_ds_name"] or d2[3] != dataset['data_tier_name']):
            if tran:tran.rollback()
            if conn:conn.close()
            dbsExceptionHandler('dbsException-invalid-input2', 
                                'dataset=/primary_dataset_name/processed_dataset_name/data_tier is not matched.',
                                self.logger.exception, 'dataset=/primary_dataset_name/processed_dataset_name/data_tier is not matched.')      
        try:
            #self.logger.debug("*** Trying to insert the dataset***")
            dataset['dataset_id'] = self.insertDatasetWOannex(dataset = dataset,
                                           blockcontent = blockcontent,
                                           otptIdList = otptIdList,
                                           conn = conn, insertDataset = True, migration=migration)
        finally:
            if tran:tran.rollback()
            if conn:conn.close()

        return dataset['dataset_id']
29018
def upsert(self, dataset_identifier, payload, content_type="json"):
        '''
        
        '''
        resource = _format_new_api_request(dataid=dataset_identifier, content_type=content_type)

        return self._perform_update("post", resource, payload)
704003
def add(client, name, urls, link, relative_to, target, force):
    """"""
    try:
        with client.with_dataset(name=name) as dataset:
            target = target if target else None
            with progressbar(urls, label='Adding data to dataset') as bar:
                for url in bar:
                    client.add_data_to_dataset(
                        dataset,
                        url,
                        link=link,
                        target=target,
                        relative_to=relative_to,
                        force=force,
                    )
    except FileNotFoundError:
        raise BadParameter('Could not process {0}'.format(url))
269544
public static DatasetId of(String project, String dataset) {
    return new DatasetId(checkNotNull(project), checkNotNull(dataset));
  }
864671
def dataset(self, **kwargs):
        
        kwargs_copy = self.base_dict.copy()
        kwargs_copy.update(**kwargs)
        self._replace_none(kwargs_copy)
        try:
            return NameFactory.dataset_format.format(**kwargs_copy)
        except KeyError:
            return None
1318924
def stack(datasets):
    """"""
    base = datasets[0].copy()
    for dataset in datasets[1:]:
        base = base.where(dataset.isnull(), dataset)
    return base
1001868
private void addRecords(HBaseDataWrapper columnWrapper, List<HBaseDataWrapper> embeddableData,
            List<HBaseDataWrapper> dataSet)
    {
        dataSet.add(columnWrapper);

        if (!embeddableData.isEmpty())
        {
            dataSet.addAll(embeddableData);
        }
    }
134033
protected final void setUp(DataSet dataSet, Set<Integer> categoricalToRemove, Set<Integer> numericalToRemove)
    {
        for(int i : categoricalToRemove)
            if (i >= dataSet.getNumCategoricalVars())
                throw new RuntimeException("The data set does not have a categorical value " + i + " to remove");
        for(int i : numericalToRemove)
            if (i >= dataSet.getNumNumericalVars())
                throw new RuntimeException("The data set does not have a numercal value " + i + " to remove");
        
        catIndexMap = new int[dataSet.getNumCategoricalVars()-categoricalToRemove.size()];
        newCatHeader = new CategoricalData[catIndexMap.length];
        numIndexMap = new int[dataSet.getNumNumericalVars()-numericalToRemove.size()];
        int k = 0;
        for(int i = 0; i < dataSet.getNumCategoricalVars(); i++)
        {
            if(categoricalToRemove.contains(i))
                continue;
            newCatHeader[k] = dataSet.getCategories()[i].clone();
            catIndexMap[k++] = i;
        }
        k = 0;
        for(int i = 0; i < dataSet.getNumNumericalVars(); i++)
        {
            if(numericalToRemove.contains(i))
                continue;
            numIndexMap[k++] = i;
        }
    }
427678
def cli():
    """"""
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        "dataset_directory",
        help="Directory with datasets to be served"
    )
    parser.add_argument(
        "-p",
        "--port",
        type=int,
        default=8081,
        help="Port to serve datasets on (default 8081)"
    )
    args = parser.parse_args()
    if not os.path.isdir(args.dataset_directory):
        parser.error("Not a directory: {}".format(args.dataset_directory))

    serve_dtool_directory(args.dataset_directory, args.port)
1328249
def set_dataset(self):
        '''
        
        '''

        keys = list(self.model.datasets.keys())
        labels = [item.split()[0].lower() for item in keys]
        if self.set_type == 'best':
            self.dataset = self.model.datasets[keys[labels.index('best')]]
        elif self.set_type == 'latest':
            self.dataset = self.model.datasets[keys[labels.index('latest')]]
        elif self.set_type == 'full':
            self.dataset = self.model.datasets[keys[labels.index('full')]]

        self.access_url = self.dataset.access_urls[self.access_url_key]
        self.ncss = NCSS(self.access_url)
        self.query = self.ncss.query()
323627
def insertDatasetWOannex(self, dataset, blockcontent, otptIdList, conn,
                             insertDataset = True, migration = False):
        

        tran = conn.begin()
        try:
            #8 Finally, we have everything to insert a dataset
            if insertDataset:
                # Then we have to get a new dataset ID
                dataset['dataset_id'] = self.datasetid.execute(conn,
                                                dataset['dataset'])
                if dataset['dataset_id'] <= 0:
                    dataset['dataset_id'] = self.sm.increment(conn, "SEQ_DS")
                    if not migration:
                        dataset['last_modified_by'] = dbsUtils().getCreateBy()
                        dataset['create_by'] = dbsUtils().getCreateBy()
                        dataset['creation_date'] = dataset.get('creation_date', dbsUtils().getTime())
                        dataset['last_modification_date'] = dataset.get('last_modification_date', dbsUtils().getTime())
                    dataset['xtcrosssection'] = dataset.get('xtcrosssection', None)
                    dataset['prep_id'] = dataset.get('prep_id', None)
                    try:
                        self.datasetin.execute(conn, dataset, tran)
                    except exceptions.IntegrityError as ei:
                        if str(ei).find("ORA-00001") != -1 or str(ei).lower().find("duplicate") !=-1:
                            if conn.closed:
                                conn = self.dbi.connection()
                            dataset['dataset_id'] = self.datasetid.execute(conn, dataset['dataset'])
                            if dataset['dataset_id'] <= 0:
                                if tran:tran.rollback()
                                if conn:conn.close()
                                dbsExceptionHandler('dbsException-conflict-data',
                                                    'Dataset/[processed DS]/[dataset access type] not yet inserted by concurrent insert. ',
                                                    self.logger.exception,
                                                    'Dataset/[processed DS]/[dataset access type] not yet inserted by concurrent insert. '+ str(ei))
                        elif str(ei).find("ORA-01400") > -1:
                            if tran:tran.rollback()
                            if conn:conn.close()
                            dbsExceptionHandler('dbsException-missing-data',
                                'Missing data when insert Datasets. ',
                                self.logger.exception,
                                'Missing data when insert Datasets. '+ str(ei))
                        else:
                            if tran: tran.rollback()
                            if conn: conn.close()
                            dbsExceptionHandler('dbsException-invalid-input2',
                            'Invalid data when insert Datasets. ',
                            self.logger.exception,
                            'Invalid data when insert Datasets. '+ str(ei))

                    except Exception:
                        #should catch all above exception to rollback. YG Jan 17, 2013
                        if tran:tran.rollback()
                        if conn:conn.close()
                        raise

            #9 Fill Dataset Parentage
            #All parentage are deduced from file parentage.

            #10 Before we commit, make dataset and output module configuration
            #mapping.  We have to try to fill the map even if dataset is
            #already in dest db
            for c in otptIdList:
                try:
                    dcObj = {
                             'dataset_id' : dataset['dataset_id'],
                             'output_mod_config_id' : c }
                    self.dcin.execute(conn, dcObj, tran)
                except exceptions.IntegrityError as ei:
                    #FIXME YG 01/17/2013
                    if (str(ei).find("ORA-00001") != -1 and str(ei).find("TUC_DC_1") != -1) or \
                            str(ei).lower().find("duplicate")!=-1:
                    #ok, already in db
                    #FIXME: What happens when there are partially in db?
                    #YG 11/17/2010
                        pass
                    else:
                        if tran:tran.rollback()
                        if conn:conn.close()
                        dbsExceptionHandler('dbsException-invalid-input2',
                            'Invalid data when insert dataset_configs. ',
                            self.logger.exception,
                            'Invalid data when insert dataset_configs. '+ str(ei))
                except Exception as ex:
                    if tran:tran.rollback()
                    if conn:conn.close()
                    raise
            #Now commit everything.
            tran.commit()
        except exceptions.IntegrityError as ei:
            # Then is it already in the database?
            # Not really. We have to check it again. YG Jan 17, 2013
            # we don't check the unique key here, since there are more than one unique key might
            # be violated: such as data_tier, processed_dataset, dataset_access_types.
            if str(ei).find("ORA-00001") != -1 or str(ei).lower().find("duplicate")!=-1:
                # For now, we assume most cases are the same dataset was instered by different thread. If not,
                # one has to call the insert dataset again. But we think this is a rare case and let the second
                # DBSBlockInsert call fix it if it happens.
                if conn.closed:
                    conn = self.dbi.connection()
                dataset_id = self.datasetid.execute(conn, dataset['dataset'])
                if dataset_id <= 0:
                    dbsExceptionHandler('dbsException-conflict-data',
                                        'Dataset not yet inserted by concurrent insert',
                                        self.logger.exception,
                                        'Dataset not yet inserted by concurrent insert')

                else:
                    dataset['dataset_id'] = dataset_id
            else:
                if tran:tran.rollback()
                if conn:conn.close()
                dbsExceptionHandler('dbsException-invalid-input2',
                    'Invalid data when insert Datasets. ',
                    self.logger.exception,
                    'Invalid data when insert Datasets. '+ str(ei))
        except Exception as ex:
            if tran:tran.rollback()
            if conn:conn.close()
            raise
        finally:
            if tran:tran.rollback()
            if conn:conn.close()
        return dataset['dataset_id']
1224724
def _addDatasetAction(self, dataset):
        
        # create the toolbar action
        action = QAction(dataset.name(), self)
        action.setIcon(XColorIcon(dataset.color()))
        action.setCheckable(True)
        action.setChecked(True)
        action.setData(wrapVariant(dataset))
        action.toggled.connect(self.toggleDataset)
        
        self.uiDatasetTBAR.addAction(action)
187859
public <D extends DataSet<?>> void add(int id, D set) {
		cacheSetType(id, SetType.DATA_SET);
		dataSets.put(id, set);
	}
467660
def datasets(ctx, client):
    """"""
    from renku.models._jsonld import asjsonld
    from renku.models.datasets import Dataset
    from renku.models.refs import LinkReference

    from ._checks.location_datasets import _dataset_metadata_pre_0_3_4

    for old_path in _dataset_metadata_pre_0_3_4(client):
        with old_path.open('r') as fp:
            dataset = Dataset.from_jsonld(yaml.safe_load(fp))

        name = str(old_path.parent.relative_to(client.path / 'data'))
        new_path = (
            client.renku_datasets_path / dataset.identifier.hex /
            client.METADATA
        )
        new_path.parent.mkdir(parents=True, exist_ok=True)

        dataset = dataset.rename_files(
            lambda key: os.path.
            relpath(str(old_path.parent / key), start=str(new_path.parent))
        )

        with new_path.open('w') as fp:
            yaml.dump(asjsonld(dataset), fp, default_flow_style=False)

        old_path.unlink()

        LinkReference.create(client=client,
                             name='datasets/' + name).set_reference(new_path)
979047
def create_dataset(
            self, group, chunk_size, compression=None, compression_opts=None):
        """"""
        group.attrs['format'] = self.dformat
        super(Features, self)._create_dataset(
            group, chunk_size, compression, compression_opts)

        # TODO attribute declared outside __init__ is not safe. Used
        # because Labels.create_dataset need it.
        if chunk_size != 'auto':
            self.nb_per_chunk = nb_per_chunk(
                self.dtype.itemsize, self.dim, chunk_size)
        else:
            self.nb_per_chunk = 'auto'