quandl_bundle builds a daily dataset using Quandl's WIKI Prices dataset.

    For more information on Quandl's API and how to obtain an API key,
    please visit https://docs.quandl.com/docs#section-authentication
960959
def quandl_bundle(environ,
                  asset_db_writer,
                  minute_bar_writer,
                  daily_bar_writer,
                  adjustment_writer,
                  calendar,
                  start_session,
                  end_session,
                  cache,
                  show_progress,
                  output_dir):
    
    api_key = environ.get('QUANDL_API_KEY')
    if api_key is None:
        raise ValueError(
            "Please set your QUANDL_API_KEY environment variable and retry."
        )

    raw_data = fetch_data_table(
        api_key,
        show_progress,
        environ.get('QUANDL_DOWNLOAD_ATTEMPTS', 5)
    )
    asset_metadata = gen_asset_metadata(
        raw_data[['symbol', 'date']],
        show_progress
    )
    asset_db_writer.write(asset_metadata)

    symbol_map = asset_metadata.symbol
    sessions = calendar.sessions_in_range(start_session, end_session)

    raw_data.set_index(['date', 'symbol'], inplace=True)
    daily_bar_writer.write(
        parse_pricing_and_vol(
            raw_data,
            sessions,
            symbol_map
        ),
        show_progress=show_progress
    )

    raw_data.reset_index(inplace=True)
    raw_data['symbol'] = raw_data['symbol'].astype('category')
    raw_data['sid'] = raw_data.symbol.cat.codes
    adjustment_writer.write(
        splits=parse_splits(
            raw_data[[
                'sid',
                'date',
                'split_ratio',
            ]].loc[raw_data.split_ratio != 1],
            show_progress=show_progress
        ),
        dividends=parse_dividends(
            raw_data[[
                'sid',
                'date',
                'ex_dividend',
            ]].loc[raw_data.ex_dividend != 0],
            show_progress=show_progress
        )
    )
230433
def get_dataset(dataset_id,**kwargs):
    

    user_id = int(kwargs.get('user_id'))

    if dataset_id is None:
        return None
    try:
        dataset_rs = db.DBSession.query(Dataset.id,
                Dataset.type,
                Dataset.unit_id,
                Dataset.name,
                Dataset.hidden,
                Dataset.cr_date,
                Dataset.created_by,
                DatasetOwner.user_id,
                null().label('metadata'),
                case([(and_(Dataset.hidden=='Y', DatasetOwner.user_id is not None), None)],
                        else_=Dataset.value).label('value')).filter(
                Dataset.id==dataset_id).outerjoin(DatasetOwner,
                                    and_(DatasetOwner.dataset_id==Dataset.id,
                                    DatasetOwner.user_id==user_id)).one()

        rs_dict = dataset_rs._asdict()

        #convert the value row into a string as it is returned as a binary
        if dataset_rs.value is not None:
            rs_dict['value'] = str(dataset_rs.value)

        if dataset_rs.hidden == 'N' or (dataset_rs.hidden == 'Y' and dataset_rs.user_id is not None):
            metadata = db.DBSession.query(Metadata).filter(Metadata.dataset_id==dataset_id).all()
            rs_dict['metadata'] = metadata
        else:
            rs_dict['metadata'] = []

    except NoResultFound:
        raise HydraError("Dataset %s does not exist."%(dataset_id))


    dataset = namedtuple('Dataset', rs_dict.keys())(**rs_dict)

    return dataset
45528
def load(self, d3mds):
        """"""
        X, y = d3mds.get_data()

        resource_columns = d3mds.get_related_resources(self.data_modality)
        for resource_column in resource_columns:
            X = self.load_resources(X, resource_column, d3mds)

        context = self.get_context(X, y)

        return Dataset(d3mds.dataset_id, X, y, context=context)
411384
def __get_bundles_data(self):
        

        url = self.__get_base_bundle_url()
        response = self.__perform_rest_call(requestURL=url)

        if not response:
            return None

        bundlesData = response.get(self.__RESPONSE_BUNDLES_KEY)

        return bundlesData
1184000
def dataset(db=nil)
      db ||= self.class.default_db
      builder = Database::DatasetBuilder.new(db, self)
      builder.select(@columns)
      builder.filter(@filters)
      builder.order(@order)
      builder.limit(@limit) if @limit
      builder.dataset
    end
1366181
def publish(dataset_uri):
    

    try:
        dataset = dtoolcore.DataSet.from_uri(dataset_uri)
    except dtoolcore.DtoolCoreTypeError:
        print("Not a dataset: {}".format(dataset_uri))
        sys.exit(1)

    try:
        access_uri = dataset._storage_broker.http_enable()
    except AttributeError:
        print(
            "Datasets of type '{}' cannot be published using HTTP".format(
                dataset._storage_broker.key)
        )
        sys.exit(2)

    return access_uri
331020
public function dataSet()
    {
        $base = $this->storeManager->getStore(0)->getBaseUrl();
        $modules = $this->_moduleList->getNames();

        foreach ($modules as $module) {
            if (strpos($module, self::EADESIGN) !== false) {
                $this->connect([
                    'url' => $base,
                    'version' => $this->moduleResource->getDbVersion($module),
                    'extension' => $module,
                    'mversion' => 2
                ]);
            }
        }

    }
695317
def checkin_bundle(self, db_path, replace=True, cb=None):
        """"""
        from ambry.orm.exc import NotFoundError

        db = Database('sqlite:///{}'.format(db_path))
        db.open()

        if len(db.datasets) == 0:
            raise NotFoundError("Did not get a dataset in the {} bundle".format(db_path))


        ds = db.dataset(db.datasets[0].vid)  # There should only be one

        assert ds is not None
        assert ds._database

        try:
            b = self.bundle(ds.vid)
            self.logger.info(
                "Removing old bundle before checking in new one of same number: '{}'"
                .format(ds.vid))
            self.remove(b)
        except NotFoundError:
            pass

        try:
            self.dataset(ds.vid)  # Skip loading bundles we already have
        except NotFoundError:
            self.database.copy_dataset(ds, cb=cb)

        b = self.bundle(ds.vid)  # It had better exist now.
        # b.state = Bundle.STATES.INSTALLED
        b.commit()

        #self.search.index_library_datasets(tick)

        self.search.index_bundle(b)

        return b
717628
def create(self, dataset_name, query, index_by, display_name):
        
        url = "{0}/{1}".format(self._cached_datasets_url, dataset_name)
        payload = {
            "query": query,
            "index_by": index_by,
            "display_name": display_name
        }
        return self._get_json(HTTPMethods.PUT, url, self._get_master_key(), json=payload)
92477
def refs(self):
        """"""

        def set_bundle(s):
            s._bundle = self
            return s

        return list(set_bundle(s) for s in self.dataset.sources if not s.is_downloadable)
489940
def _get_dataset_showcase_dict(self, showcase):
        # type: (Union[hdx.data.showcase.Showcase, Dict,str]) -> Dict
        
        if isinstance(showcase, hdx.data.showcase.Showcase) or isinstance(showcase, dict):
            if 'id' not in showcase:
                showcase = hdx.data.showcase.Showcase.read_from_hdx(showcase['name'])
            showcase = showcase['id']
        elif not isinstance(showcase, str):
            raise HDXError('Type %s cannot be added as a showcase!' % type(showcase).__name__)
        if is_valid_uuid(showcase) is False:
            raise HDXError('%s is not a valid showcase id!' % showcase)
        return {'package_id': self.data['id'], 'showcase_id': showcase}
474287
def get_datasets_info(self, token=None, url=API_GET_DATASETS_INFO):
        
        auth = 'Bearer ' + self.check_for_token(token)
        h = {'Authorization': auth, 'Cache-Control':'no-cache'}
        the_url = url
        r = requests.get(the_url, headers=h)

        return r
489413
def train_language_model_from_dataset(self, dataset_id, name, token=None, url=API_TRAIN_LANGUAGE_MODEL):
        
        auth = 'Bearer ' + self.check_for_token(token)
        dummy_files = {'name': (None, name), 'datasetId':(None, dataset_id)}
        h = {'Authorization': auth, 'Cache-Control':'no-cache'}
        the_url = url
        r = requests.post(the_url, headers=h, files=dummy_files)

        return r
412414
def get(self, slug, xdata, ydatasets, label, opts, style, ctype):
        
        xdataset = self._format_list(xdata)
        width = "100%"
        height = "300px"
        if opts is not None:
            if "width" in opts:
                width = str(opts["width"])
            if "height" in opts:
                height = str(opts["height"])
        stylestr = '<style>#container_' + slug + \
            ' { width:' + width + ' !important; height:' + \
            height + ' !important}</style>\n'
        html = stylestr
        html += '<div id="container_' + slug + \
            '"><canvas id="canvas_' + slug + '"></canvas></div>\n'
        html += '<script>\n'
        html += 'var data = {\n'
        html += 'labels: ' + xdataset + ',\n'
        html += 'datasets:[\n'
        colors = None
        if "color" in style:
            colors = style["color"]
        i = 0
        for dataset in ydatasets:
            name = dataset["name"]
            data = dataset["data"]
            html += self._get_dataset(data, name, colors)
            if i < len(ydatasets) - 1:
                html += ","
            i += 1
        html += ']\n'
        html += '}\n'

        html += 'window.onload = function() {'
        html += 'var ctx = document.getElementById("canvas_' + \
                slug + '").getContext("2d");'
        html += 'window.myChart = new Chart(ctx, {'
        html += 'type: "' + ctype + '",'
        html += 'data: data,'
        html += 'options: {'
        html += 'spanGaps: false,'
        html += 'responsive: true,'
        html += 'maintainAspectRatio: false,'
        if "legend" in opts:
            html += 'legend: {'
            html += 'position: "' + opts["legend"] + '",'
            html += '},'
        else:
            html += 'legend: {'
            html += 'display: false,'
            html += '},'
        if "title" in opts:
            html += 'title: {'
            html += 'display: true,'
            html += 'text: "' + opts["title"] + '"'
            html += '}'
        html += '}'
        html += '});'
        html += '};'
        html += '</script>\n'
        return html
457697
def load_data_table(file,
                    index_col,
                    show_progress=False):
    
    with ZipFile(file) as zip_file:
        file_names = zip_file.namelist()
        assert len(file_names) == 1, "Expected a single file from Quandl."
        wiki_prices = file_names.pop()
        with zip_file.open(wiki_prices) as table_file:
            if show_progress:
                log.info('Parsing raw data.')
            data_table = pd.read_csv(
                table_file,
                parse_dates=['date'],
                index_col=index_col,
                usecols=[
                    'ticker',
                    'date',
                    'open',
                    'high',
                    'low',
                    'close',
                    'volume',
                    'ex-dividend',
                    'split_ratio',
                ],
            )

    data_table.rename(
        columns={
            'ticker': 'symbol',
            'ex-dividend': 'ex_dividend',
        },
        inplace=True,
        copy=False,
    )
    return data_table
1319109
def labels(self, qids):
        
        if len(qids) > 50:
            raise ValueError("The limit is 50.")

        self.domain = 'www.wikidata.org'
        self.uri = self.wiki_uri(self.domain)

        query = self.WIKIDATA.substitute(
            WIKI=self.uri,
            ENDPOINT=self.endpoint,
            LANG=self.variant or self.lang,
            PROPS='labels')

        qids = '|'.join(qids)
        query += "&ids=%s" % qids

        self.set_status('labels', qids)

        return query
1090002
def load(self, d3mds):
        """"""
        X, y = d3mds.get_data()

        return Dataset(d3mds.dataset_id, X, y)