def update_dataset(self, dataset_key, **kwargs): """Update an existing dataset Parameters ---------- description : str, optional Dataset description summary : str, optional Dataset summary markdown tags : list, optional Dataset tags license : {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} Dataset license visibility : {'OPEN', 'PRIVATE'}, optional Dataset visibility files : dict, optional File names and source URLs to add or update Raises ------ RestApiException If a server error occurs Examples -------- >>> import datadotworld as dw >>> api_client = dw.api_client() >>> api_client.update_dataset( ... 'username/test-dataset', ... tags=['demo', 'datadotworld']) # doctest: +SKIP """ request = self.__build_dataset_obj( lambda: _swagger.DatasetPatchRequest(), lambda name, url: _swagger.FileCreateOrUpdateRequest( name=name, source=_swagger.FileSourceCreateOrUpdateRequest(url=url)), kwargs) owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._datasets_api.patch_dataset(owner_id, dataset_id, request) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def update_dataset(self, dataset_key, **kwargs): """Update an existing dataset :param description: Dataset description :type description: str, optional :param summary: Dataset summary markdown :type summary: str, optional :param tags: Dataset tags :type tags: list, optional :param license: {'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} Dataset license :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY'} :param visibility: Dataset visibility :type visibility: {'OPEN', 'PRIVATE'}, optional :param files: File names and source URLs to add or update :type files: dict, optional :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param **kwargs: :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld as dw >>> api_client = dw.api_client() >>> api_client.update_dataset( ... 'username/test-dataset', ... tags=['demo', 'datadotworld']) # doctest: +SKIP """ request = self.__build_dataset_obj( lambda: _swagger.DatasetPatchRequest(), lambda name, url, expand_archive, description, labels: _swagger. FileCreateOrUpdateRequest( name=name, source=_swagger.FileSourceCreateOrUpdateRequest( url=url, expand_archive=expand_archive), description=description, labels=labels), kwargs) owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._datasets_api.patch_dataset(owner_id, dataset_id, request) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def add_files_via_url(self, dataset_key, files={}): """Add or update dataset files linked to source URLs :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param files: Dict containing the name of files and metadata Uses file name as a dict containing File description, labels and source URLs to add or update (Default value = {}) *description and labels are optional.* :type files: dict :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld as dw >>> url = 'http://www.acme.inc/example.csv' >>> api_client = dw.api_client() >>> api_client.add_files_via_url( ... 'username/test-dataset', ... 'example.csv': { ... 'url': url, ... 'labels': ['raw data'], ... 'description': 'file description'}) # doctest: +SKIP """ file_requests = [ _swagger.FileCreateOrUpdateRequest( name=file_name, source=_swagger.FileSourceCreateOrUpdateRequest( url=file_info['url'], expand_archive=file_info.get('expand_archive', False)), description=file_info.get('description'), labels=file_info.get('labels'), ) for file_name, file_info in files.items() ] owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._datasets_api.add_files_by_source( owner_id, dataset_id, _swagger.FileBatchUpdateRequest(files=file_requests)) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def add_files_via_url(self, dataset_key, files={}): """Add or update dataset files linked to source URLs Parameters ---------- dataset_key : str Dataset identifier, in the form of owner/id files : dict File names and source URLs to add or update Raises ------ RestApiException If a server error occurs Examples -------- >>> import datadotworld as dw >>> url = 'http://www.acme.inc/example.csv' >>> api_client = dw.api_client() >>> api_client.add_files_via_url( ... 'username/test-dataset', ... {'example.csv': url}) # doctest: +SKIP """ file_requests = [ _swagger.FileCreateOrUpdateRequest( name=name, source=_swagger.FileSourceCreateOrUpdateRequest(url=url)) for name, url in files.items() ] owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._datasets_api.add_files_by_source( owner_id, dataset_id, _swagger.FileBatchUpdateRequest(files=file_requests)) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)