code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
tabular_resource = self.__tabular_resources[resource_name] try: # Sorting fields in the same order as they appear in the schema # is necessary for tables to be converted into pandas.DataFrame fields = [] if 'schema' in tabular_resource.descriptor...
def _load_table(self, resource_name)
Build table structure from resource data :param resource_name:
4.354889
4.479588
0.972163
try: import pandas except ImportError: raise RuntimeError('To enable dataframe support, ' 'run \'pip install datadotworld[pandas]\'') tabular_resource = self.__tabular_resources[resource_name] field_dtypes = fields_to_dtype...
def _load_dataframe(self, resource_name)
Build pandas.DataFrame from resource data Lazy load any optional dependencies in order to allow users to use package without installing pandas if so they wish. :param resource_name:
3.714784
3.790703
0.979972
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.append_records_with_http_info(owner, id, stream_id, body, **kwargs) else: (data) = self.append_records_with_http_info(owner, id, stream_id, body, **kwargs) return data
def append_records(self, owner, id, stream_id, body, **kwargs)
Append records to a stream. This endpoint appends JSON data to a stream associated with a dataset. Streams don't need to be created before you can append data to it. They will be created on-demand, the first time they are used. Multiple records can be appended at once by using JSON-L (`application/json-l`) as ...
1.386466
1.520571
0.911806
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.create_insight_with_http_info(project_owner, project_id, **kwargs) else: (data) = self.create_insight_with_http_info(project_owner, project_id, **kwargs) return data
def create_insight(self, project_owner, project_id, **kwargs)
Create an insight Create a new insight. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(respon...
1.438024
1.491673
0.964034
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.delete_insight_with_http_info(project_owner, project_id, id, **kwargs) else: (data) = self.delete_insight_with_http_info(project_owner, project_id, id, **kwargs) return dat...
def delete_insight(self, project_owner, project_id, id, **kwargs)
Delete an insight Delete an existing insight. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(...
1.398256
1.469292
0.951653
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.get_insight_with_http_info(project_owner, project_id, id, **kwargs) else: (data) = self.get_insight_with_http_info(project_owner, project_id, id, **kwargs) return data
def get_insight(self, project_owner, project_id, id, **kwargs)
Retrieve an insight Retrieve an insight. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(respo...
1.390843
1.464399
0.94977
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.get_insights_for_project_with_http_info(project_owner, project_id, **kwargs) else: (data) = self.get_insights_for_project_with_http_info(project_owner, project_id, **kwargs) ...
def get_insights_for_project(self, project_owner, project_id, **kwargs)
Get insights for project. Get insights for a project. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> ...
1.3654
1.425181
0.958054
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.replace_insight_with_http_info(project_owner, project_id, id, **kwargs) else: (data) = self.replace_insight_with_http_info(project_owner, project_id, id, **kwargs) return d...
def replace_insight(self, project_owner, project_id, id, **kwargs)
Replace an insight Replace an insight. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(respons...
1.396001
1.479292
0.943695
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.update_insight_with_http_info(project_owner, project_id, id, **kwargs) else: (data) = self.update_insight_with_http_info(project_owner, project_id, id, **kwargs) return dat...
def update_insight(self, project_owner, project_id, id, **kwargs)
Update an insight Update an insight. Note that only elements included in the request will be updated. All omitted elements will remain untouched. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invok...
1.415897
1.482951
0.954784
if summary is not None and len(summary) > 25000: raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") if summary is not None and len(summary) < 0: raise ValueError("Invalid value for `summary`, length must be greater than or equal...
def summary(self, summary)
Sets the summary of this DatasetPatchRequest. Long-form dataset summary (Markdown supported). :param summary: The summary of this DatasetPatchRequest. :type: str
1.798932
1.69703
1.060047
allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] if license not in allowed_values: raise ValueError( "Invalid value for `license` ({0}), must be one of {1}" .format(licen...
def license(self, license)
Sets the license of this DatasetPatchRequest. Dataset license. Find additional info for allowed values [here](https://data.world/license-help). :param license: The license of this DatasetPatchRequest. :type: str
2.385123
2.215008
1.076802
allowed_values = ["OPEN", "PRIVATE"] if visibility not in allowed_values: raise ValueError( "Invalid value for `visibility` ({0}), must be one of {1}" .format(visibility, allowed_values) ) self._visibility = visibility
def visibility(self, visibility)
Sets the visibility of this DatasetPatchRequest. Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. :param visibility: The visibility of this DatasetPatchRequest. :type: str
1.977667
1.891641
1.045477
if objective is not None and len(objective) > 120: raise ValueError("Invalid value for `objective`, length must be less than or equal to `120`") if objective is not None and len(objective) < 0: raise ValueError("Invalid value for `objective`, length must be greater than ...
def objective(self, objective)
Sets the objective of this ProjectPutRequest. Short project objective. :param objective: The objective of this ProjectPutRequest. :type: str
1.973549
1.760921
1.120748
if not klass.swagger_types: return data kwargs = {} for attr, attr_type in iteritems(klass.swagger_types): if data is not None \ and klass.attribute_map[attr] in data \ and isinstance(data, (list, dict)): value = dat...
def __deserialize_model(self, data, klass)
Deserializes list or dict to model. :param data: dict, list. :param klass: class literal. :return: model object.
2.586603
2.760828
0.936894
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.add_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, **kwargs) else: (data) = self.add_linked_dataset_with_http_info(owner, id, linked_dataset_owner, l...
def add_linked_dataset(self, owner, id, linked_dataset_owner, linked_dataset_id, **kwargs)
Link dataset Add a linked dataset to a project. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprin...
1.320603
1.397494
0.94498
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.create_project_with_http_info(owner, **kwargs) else: (data) = self.create_project_with_http_info(owner, **kwargs) return data
def create_project(self, owner, **kwargs)
Create a project Create a new project. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(respons...
1.582842
1.626312
0.973271
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.delete_project_with_http_info(owner, id, **kwargs) else: (data) = self.delete_project_with_http_info(owner, id, **kwargs) return data
def delete_project(self, owner, id, **kwargs)
Delete a project Permanently deletes a project and all data associated with it. This operation cannot be undone, although a new project may be created with the same id. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` funct...
1.474056
1.52138
0.968894
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.get_project_with_http_info(owner, id, **kwargs) else: (data) = self.get_project_with_http_info(owner, id, **kwargs) return data
def get_project(self, owner, id, **kwargs)
Retrieve a project Return details on a project. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprin...
1.47199
1.542798
0.954105
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.patch_project_with_http_info(owner, id, **kwargs) else: (data) = self.patch_project_with_http_info(owner, id, **kwargs) return data
def patch_project(self, owner, id, **kwargs)
Update a project Update an existing project. Note that only elements, files or linked datasets included in the request will be updated. All omitted elements, files or linked datasets will remain untouched. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP requ...
1.487815
1.571849
0.946538
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.remove_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, **kwargs) else: (data) = self.remove_linked_dataset_with_http_info(owner, id, linked_dataset_ow...
def remove_linked_dataset(self, owner, id, linked_dataset_owner, linked_dataset_id, **kwargs)
Unlink dataset Remove a linked dataset from a project. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> ...
1.316856
1.39599
0.943313
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.replace_project_with_http_info(owner, id, **kwargs) else: (data) = self.replace_project_with_http_info(owner, id, **kwargs) return data
def replace_project(self, owner, id, **kwargs)
Create / Replace a project Create a project with a given id or completely rewrite the project, including any previously added files or linked datasets, if one already exists with the given id. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please d...
1.472732
1.559954
0.944087
return _get_instance(profile, **kwargs). \ load_dataset(dataset_key, force_update=force_update, auto_update=auto_update)
def load_dataset(dataset_key, force_update=False, auto_update=False, profile='default', **kwargs)
Load a dataset from the local filesystem, downloading it from data.world first, if necessary. This function returns an object of type `LocalDataset`. The object allows access to metedata via it's `describe()` method and to all the data via three properties `raw_data`, `tables` and `dataframes`, all of ...
4.252951
7.541389
0.563948
return _get_instance(profile, **kwargs).query(dataset_key, query, query_type=query_type, parameters=parameters, **kwargs)
def query(dataset_key, query, query_type='sql', profile='default', parameters=None, **kwargs)
Query an existing dataset :param dataset_key: Dataset identifier, in the form of owner/id or of a url :type dataset_key: str :param query: SQL or SPARQL query :type query: str :param query_type: The type of the query. Must be either 'sql' or 'sparql'. (Default value = 'sql') :type query...
3.411622
6.866388
0.496858
return _get_instance(profile, **kwargs).open_remote_file( dataset_key, file_name, mode=mode, **kwargs)
def open_remote_file(dataset_key, file_name, profile='default', mode='w', **kwargs)
Open a remote file object that can be used to write to or read from a file in a data.world dataset :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param file_name: The name of the file to open :type file_name: str :param mode: the mode for the file - must...
4.238397
6.815855
0.621844
if self._table is None: self._table = list(self._iter_rows()) return self._table
def table(self)
Build and cache a table from query results
5.268587
4.076241
1.292511
if self._dataframe is None: try: import pandas as pd except ImportError: raise RuntimeError('To enable dataframe support, ' 'run \'pip install datadotworld[pandas]\'') self._dataframe = pd.DataFrame...
def dataframe(self)
Build and cache a dataframe from query results
4.308845
3.802791
1.133074
datetime_types = ['date', 'datetime'] datetime_fields = { f['name']: _TABLE_SCHEMA_DTYPE_MAPPING.get(f['type'], 'object') for f in schema['fields'] if f['type'] in datetime_types} other_fields = { f['name']: _TABLE_SCHEMA_DTYPE_MAPPING.get(f['type'], 'object') f...
def fields_to_dtypes(schema)
Maps table schema fields types to dtypes separating date fields :param schema:
2.47736
2.574674
0.962203
if 'schema' in r.descriptor: r.descriptor['schema'] = _sanitize_schema(r.descriptor['schema']) return r
def sanitize_resource_schema(r)
Sanitize table schema for increased compatibility Up to version 0.9.0 jsontableschema did not support year, yearmonth and duration field types https://github.com/frictionlessdata/jsontableschema-py/pull/152 :param r:
3.983369
5.275082
0.755129
if ('results' in sparql_results_json and 'bindings' in sparql_results_json['results'] and len(sparql_results_json['results']['bindings']) > 0): # SQL results include metadata, SPARQL results don't result_metadata = sparql_results_json.get('metadata', []) metadat...
def infer_table_schema(sparql_results_json)
Infer Table Schema from SPARQL results JSON SPARQL JSON Results Spec: https://www.w3.org/TR/2013/REC-sparql11-results-json-20130321 :param sparql_results_json: SPARQL JSON results of a query :returns: A schema descriptor for the inferred schema :rtype: dict (json)
2.828179
2.844773
0.994167
fields_idx = {f: pos for pos, f in enumerate(fields)} return OrderedDict(sorted(unordered_row.items(), key=lambda i: fields_idx[i[0]]))
def order_columns_in_row(fields, unordered_row)
Ensure columns appear in the same order for every row in table :param fields: :param unordered_row:
3.80702
4.507975
0.844508
total_bindings = len(sparql_results_json['results']['bindings']) homogeneous_types = {} for result_var in result_vars: var_types = set() var_datatypes = set() for i in range(0, min(total_bindings, 10)): binding = sparql_results_json['results']['bindings'][i] ...
def _get_types_from_sample(result_vars, sparql_results_json)
Return types if homogenous within sample Compare up to 10 rows of results to determine homogeneity. DESCRIBE and CONSTRUCT queries, for example, :param result_vars: :param sparql_results_json:
2.053899
2.061246
0.996436
with open(self._config_file_path, 'w') as file: self._config_parser.write(file)
def save(self)
Persist config changes
4.136896
3.460712
1.195389
for i in seq: obj = supplier_func(i) if obj is not None: return obj return None
def _first_not_none(seq, supplier_func)
Applies supplier_func to each element in seq, returns 1st not None :param seq: Sequence of object :type seq: iterable :param supplier_func: Function that extracts the desired value from elements in seq :type supplier_func: function
4.094953
3.930348
1.04188
if ctx.obj is None: ctx.obj = {} ctx.obj['profile'] = profile pass
def cli(ctx, profile)
dw commands support working with multiple data.world accounts \b Use a different <profile> value for each account. In the absence of a <profile>, 'default' will be used.
3.167611
4.64059
0.682588
config = obj.get('config') or FileConfig(obj['profile']) config.auth_token = token config.save()
def configure(obj, token)
Use this command to configure API tokens
7.579834
7.788216
0.973244
if request_entity is not None and len(request_entity) > 10000: raise ValueError("Invalid value for `request_entity`, length must be less than or equal to `10000`") self._request_entity = request_entity
def request_entity(self, request_entity)
Sets the request_entity of this FileSourceCreateOrUpdateRequest. :param request_entity: The request_entity of this FileSourceCreateOrUpdateRequest. :type: str
2.270246
2.020044
1.12386
if title is None: raise ValueError("Invalid value for `title`, must not be `None`") if title is not None and len(title) > 128: raise ValueError("Invalid value for `title`, length must be less than or equal to `128`") if title is not None and len(title) < 1: ...
def title(self, title)
Sets the title of this InsightPutRequest. Insight title. :param title: The title of this InsightPutRequest. :type: str
1.578904
1.410844
1.11912
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.sparql_get_with_http_info(owner, id, query, **kwargs) else: (data) = self.sparql_get_with_http_info(owner, id, query, **kwargs) return data
def sparql_get(self, owner, id, query, **kwargs)
SPARQL query (via GET) This endpoint executes SPARQL queries against a dataset or data project. SPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: - `ap...
1.464318
1.531932
0.955864
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.sparql_post_with_http_info(owner, id, query, **kwargs) else: (data) = self.sparql_post_with_http_info(owner, id, query, **kwargs) return data
def sparql_post(self, owner, id, query, **kwargs)
SPARQL query This endpoint executes SPARQL queries against a dataset or data project. SPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: - `applicatio...
1.448258
1.53769
0.94184
try: return self._datasets_api.get_dataset( *(parse_dataset_key(dataset_key))).to_dict() except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def get_dataset(self, dataset_key)
Retrieve an existing dataset definition This method retrieves metadata about an existing :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :returns: Dataset definition, with all attributes :rtype: dict :raises RestApiException: If a ...
7.516859
9.532334
0.788564
request = self.__build_dataset_obj( lambda: _swagger.DatasetCreateRequest( title=kwargs.get('title'), visibility=kwargs.get('visibility')), lambda name, url, expand_archive, description, labels: _swagger.FileCreateRequest( ...
def create_dataset(self, owner_id, **kwargs)
Create a new dataset :param owner_id: Username of the owner of the new dataset :type owner_id: str :param title: Dataset title (will be used to generate dataset id on creation) :type title: str :param description: Dataset description :type description: str, o...
4.44013
4.785564
0.927817
request = self.__build_dataset_obj( lambda: _swagger.DatasetPatchRequest(), lambda name, url, expand_archive, description, labels: _swagger.FileCreateOrUpdateRequest( name=name, source=_swagger.FileSourceCreateOrUpdateRequest( ...
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: Dataset license ...
4.799331
5.312483
0.903406
request = self.__build_dataset_obj( lambda: _swagger.DatasetPutRequest( title=kwargs.get('title'), visibility=kwargs.get('visibility') ), lambda name, url, expand_archive, description, labels: _swagger.FileCreateRequest( ...
def replace_dataset(self, dataset_key, **kwargs)
Replace an existing dataset *This method will completely overwrite an existing dataset.* :param description: Dataset description :type description: str, optional :param summary: Dataset summary markdown :type summary: str, optional :param tags: Dataset tags :typ...
5.041004
5.536165
0.910559
owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._datasets_api.delete_dataset(owner_id, dataset_id) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def delete_dataset(self, dataset_key)
Deletes a dataset and all associated data :params dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld as dw >>> api_client = dw.api_client() ...
4.476936
5.416165
0.826588
file_requests = [_swagger.FileCreateOrUpdateRequest( name=file_name, source=_swagger.FileSourceCreateOrUpdateRequest( url=file_info['url'], expand_archive=file_info.get('expand_archive', False)), ...
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 U...
3.633158
3.705178
0.980562
try: self._datasets_api.sync(*(parse_dataset_key(dataset_key))) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def sync_files(self, dataset_key)
Trigger synchronization process to update all dataset files linked to source URLs. :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld...
10.771892
13.707026
0.785866
owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._uploads_api.upload_files(owner_id, dataset_id, files, **kwargs) if files_metadata: self.update_dataset(dataset_key, files=files_metadata) e...
def upload_files(self, dataset_key, files, files_metadata={}, **kwargs)
Upload dataset files :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param files: The list of names/paths for files stored in the local filesystem :type files: list of str :param expand_archives: Boolean value to indicate files sho...
3.790221
5.302504
0.714798
owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._uploads_api.upload_file(owner_id, dataset_id, name, **kwargs) if file_metadata: self.update_dataset(dataset_key, files=file_metadata) except _swagger.rest.ApiException as e: ...
def upload_file(self, dataset_key, name, file_metadata={}, **kwargs)
Upload one file to a dataset :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param name: Name/path for files stored in the local filesystem :type name: str :param expand_archives: Boolean value to indicate files should be expanded ...
3.717373
5.273297
0.704943
owner_id, dataset_id = parse_dataset_key(dataset_key) try: self._datasets_api.delete_files_and_sync_sources( owner_id, dataset_id, names) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def delete_files(self, dataset_key, names)
Delete dataset file(s) :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param names: The list of names for files to be deleted :type names: list of str :raises RestApiException: If a server error occurs Examples -------- ...
5.439777
7.337428
0.741374
if path.isdir(dest_dir): raise ValueError('dest_dir must be a new directory, ' 'but {} already exists'.format(dest_dir)) owner_id, dataset_id = parse_dataset_key(dataset_key) url = "{0}://{1}/datapackage/{2}/{3}".format( self._protoc...
def download_datapackage(self, dataset_key, dest_dir)
Download and unzip a dataset's datapackage :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param dest_dir: Directory under which datapackage should be saved :type dest_dir: str or path :returns: Location of the datapackage descriptor (data...
2.501602
2.624119
0.953311
try: return self._user_api.get_user_data().to_dict() except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def get_user_data(self)
Retrieve data for authenticated user :returns: User data, with all attributes :rtype: dict :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld as dw >>> api_client = dw.api_client() >>> user_data = api_client.get_...
7.237841
8.646677
0.837066
try: return self._user_api.fetch_contributing_projects( **kwargs).to_dict() except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def fetch_contributing_projects(self, **kwargs)
Fetch projects that the currently authenticated user has access to :returns: Authenticated user projects :rtype: dict :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld as dw >>> api_client = dw.api_client() >>> ...
6.950372
8.377724
0.829625
api_client = self._build_api_client( default_mimetype_header_accept=desired_mimetype) sql_api = kwargs.get('sql_api_mock', _swagger.SqlApi(api_client)) owner_id, dataset_id = parse_dataset_key(dataset_key) try: response = sql_api.sql_post( ...
def sql(self, dataset_key, query, desired_mimetype='application/json', **kwargs)
Executes SQL queries against a dataset via POST :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param query: SQL query :type query: str :param include_table_schema: Flags indicating to include table schema in the response ...
4.591908
5.102289
0.89997
api_client = self._build_api_client( default_mimetype_header_accept=desired_mimetype) sparql_api = kwargs.get('sparql_api_mock', _swagger.SparqlApi(api_client)) owner_id, dataset_id = parse_dataset_key(dataset_key) try: res...
def sparql(self, dataset_key, query, desired_mimetype='application/sparql-results+json', **kwargs)
Executes SPARQL queries against a dataset via POST :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param query: SPARQL query :type query: str :returns: file object that can be used in file parsers and data handling modules. ...
4.573383
4.695522
0.973988
owner_id, dataset_id = parse_dataset_key(dataset_key) try: return self._download_api.download_dataset(owner_id, dataset_id) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def download_dataset(self, dataset_key)
Return a .zip containing all files within the dataset as uploaded. :param dataset_key : Dataset identifier, in the form of owner/id :type dataset_key: str :returns: .zip file contain files within dataset :rtype: file object :raises RestApiException: If a server error occurs ...
4.566533
5.748378
0.794404
owner_id, dataset_id = parse_dataset_key(dataset_key) try: return self._streams_api.append_records(owner_id, dataset_id, stream_id, body) except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def append_records(self, dataset_key, stream_id, body)
Append records to a stream. :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param stream_id: Stream unique identifier. :type stream_id: str :param body: Object body :type body: obj :raises RestApiException: If a server erro...
4.241158
5.839172
0.726329
try: owner_id, project_id = parse_dataset_key(project_key) return self._projects_api.get_project(owner_id, project_id).to_dict() except _swagger.rest.ApiException as e: raise RestApiError(cause=e)
def get_project(self, project_key)
Retrieve an existing project This method retrieves metadata about an existing project :param project_key: Project identifier, in the form of owner/id :type project_key: str :returns: Project definition, with all attributes :rtype: dict :raises RestApiException: If a ser...
5.097481
6.354125
0.802232
request = self.__build_project_obj( lambda: _swagger.ProjectCreateRequest( title=kwargs.get('title'), visibility=kwargs.get('visibility') ), lambda name, url, description, labels: _swagger.FileCreateRequest( ...
def create_project(self, owner_id, **kwargs)
Create a new project :param owner_id: Username of the creator of a project. :type owner_id: str :param title: Project title (will be used to generate project id on creation) :type title: str :param objective: Short project objective. :type objecti...
4.246566
4.403484
0.964365
request = self.__build_project_obj( lambda: _swagger.ProjectPatchRequest(), lambda name, url, description, labels: _swagger.FileCreateOrUpdateRequest( name=name, source=_swagger.FileSourceCreateOrUpdateRequest(url=url), ...
def update_project(self, project_key, **kwargs)
Update an existing project :param project_key: Username and unique identifier of the creator of a project in the form of owner/id. :type project_key: str :param title: Project title :type title: str :param objective: Short project objective. :type objective: ...
5.127034
5.385196
0.952061
request = self.__build_project_obj( lambda: _swagger.ProjectCreateRequest( title=kwargs.get('title'), visibility=kwargs.get('visibility') ), lambda name, url, description, labels: _swagger.FileCreateRequest( ...
def replace_project(self, project_key, **kwargs)
Replace an existing Project *Create a project with a given id or completely rewrite the project, including any previously added files or linked datasets, if one already exists with the given id.* :param project_key: Username and unique identifier of the creator of a project...
4.844431
4.786182
1.01217
try: project_owner_id, project_id = parse_dataset_key(project_key) dataset_owner_id, dataset_id = parse_dataset_key(dataset_key) self._projects_api.add_linked_dataset(project_owner_id, project_id, ...
def add_linked_dataset(self, project_key, dataset_key)
Link project to an existing dataset This method links a dataset to project :param project_key: Project identifier, in the form of owner/id :type project_key: str :param dataset_key: Dataset identifier, in the form of owner/id :type project_key: str :raises RestApiExcept...
2.977828
3.216328
0.925847
try: project_owner, project_id = parse_dataset_key(project_key) return self._insights_api.get_insight(project_owner, project_id, insight_id, ...
def get_insight(self, project_key, insight_id, **kwargs)
Retrieve an insight :param project_key: Project identifier, in the form of projectOwner/projectid :type project_key: str :param insight_id: Insight unique identifier. :type insight_id: str :returns: Insight definition, with all attributes :rtype: object :...
4.558425
5.143166
0.886307
try: project_owner, project_id = parse_dataset_key(project_key) return self._insights_api.get_insights_for_project(project_owner, project_id, **kwargs) ...
def get_insights_for_project(self, project_key, **kwargs)
Get insights for a project. :param project_key: Project identifier, in the form of projectOwner/projectid :type project_key: str :returns: Insight results :rtype: object :raises RestApiException: If a server error occurs Examples -------- >>> imp...
4.55457
4.967386
0.916895
request = self.__build_insight_obj( lambda: _swagger.InsightCreateRequest( title=kwargs.get('title'), body=_swagger.InsightBody( image_url=kwargs.get('image_url'), embed_url=kwargs.get('embed_url'), ...
def create_insight(self, project_key, **kwargs)
Create a new insight :param project_key: Project identifier, in the form of projectOwner/projectid :type project_key: str :param title: Insight title :type title: str :param description: Insight description. :type description: str, optional :param image_u...
3.760427
3.80637
0.98793
request = self.__build_insight_obj( lambda: _swagger.InsightPutRequest( title=kwargs.get('title'), body=_swagger.InsightBody( image_url=kwargs.get('image_url'), embed_url=kwargs.get('embed_url'), mar...
def replace_insight(self, project_key, insight_id, **kwargs)
Replace an insight. :param project_key: Projrct identifier, in the form of projectOwner/projectid :type project_key: str :param insight_id: Insight unique identifier. :type insight_id: str :param title: Insight title :type title: str :param description: I...
4.224493
4.330254
0.975576
request = self.__build_insight_obj( lambda: _swagger.InsightPatchRequest(), kwargs) project_owner, project_id = parse_dataset_key(project_key) try: self._insights_api.update_insight(project_owner, project_id, ...
def update_insight(self, project_key, insight_id, **kwargs)
Update an insight. **Note that only elements included in the request will be updated. All omitted elements will remain untouched. :param project_key: Projrct identifier, in the form of projectOwner/projectid :type project_key: str :param insight_id: Insight unique identi...
6.535026
7.277898
0.897928
projectOwner, projectId = parse_dataset_key(project_key) try: self._insights_api.delete_insight(projectOwner, projectId, insight_id) except _swagger.rest.ApiException as e: ...
def delete_insight(self, project_key, insight_id)
Delete an existing insight. :params project_key: Project identifier, in the form of projectOwner/projectId :type project_key: str :params insight_id: Insight unique id :type insight_id: str :raises RestApiException: If a server error occurs Examples ----...
6.504088
7.033459
0.924735
match = re.match(DATASET_KEY_PATTERN, dataset_key) if not match: raise ValueError('Invalid dataset key. Key must include user and ' 'dataset names, separated by (i.e. user/dataset).') return match.groups()
def parse_dataset_key(dataset_key)
Parse a dataset URL or path and return the owner and the dataset id :param dataset_key: Dataset key (in the form of owner/id) or dataset URL :type dataset_key: str :returns: User name of the dataset owner and ID of the dataset :rtype: dataset_owner, dataset_id :raises ValueError: If the provided ke...
4.38184
5.525053
0.793086
return cls({k: LazyLoadedValue( lambda k=k: loader_func(k), type_hint=type_hint) for k in keys})
def from_keys(cls, keys, loader_func, type_hint=None)
Factory method for `LazyLoadedDict` Accepts a ``loader_func`` that is to be applied to all ``keys``. :param keys: List of keys to create the dictionary with :type keys: iterable :param loader_func: Function to be applied to all keys :type loader_func: function :param ty...
5.491101
4.328727
1.268526
if name is None: raise ValueError("Invalid value for `name`, must not be `None`") if name is not None and len(name) > 128: raise ValueError("Invalid value for `name`, length must be less than or equal to `128`") if name is not None and len(name) < 1: ...
def name(self, name)
Sets the name of this FileCreateOrUpdateRequest. File name. Should include type extension always when possible. Must not include slashes. :param name: The name of this FileCreateOrUpdateRequest. :type: str
1.471921
1.387412
1.060912
allowed_values = ["raw data", "documentation", "visualization", "clean data", "script", "report"] if not set(labels).issubset(set(allowed_values)): raise ValueError( "Invalid values for `labels` [{0}], must be a subset of [{1}]" .format(", ".join(map(...
def labels(self, labels)
Sets the labels of this FileCreateOrUpdateRequest. File labels. :param labels: The labels of this FileCreateOrUpdateRequest. :type: list[str]
3.039821
2.494991
1.218369
if user is None: raise ValueError("Invalid value for `user`, must not be `None`") if user is not None and len(user) > 1024: raise ValueError("Invalid value for `user`, length must be less than or equal to `1024`") self._user = user
def user(self, user)
Sets the user of this WebCredentials. The name of the account to login to. :param user: The user of this WebCredentials. :type: str
1.842158
1.872977
0.983545
if password is not None and len(password) > 1024: raise ValueError("Invalid value for `password`, length must be less than or equal to `1024`") self._password = password
def password(self, password)
Sets the password of this WebCredentials. The secret password. This field is write-only. It is omitted by read operations. If authorization is required, the `password` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the...
2.422413
2.710828
0.893606
if owner is None: raise ValueError("Invalid value for `owner`, must not be `None`") if owner is not None and len(owner) > 31: raise ValueError("Invalid value for `owner`, length must be less than or equal to `31`") if owner is not None and len(owner) < 3: ...
def owner(self, owner)
Sets the owner of this OauthTokenReference. User name of the owner of the OAuth token within data.world. :param owner: The owner of this OauthTokenReference. :type: str
1.500206
1.480466
1.013334
if site is None: raise ValueError("Invalid value for `site`, must not be `None`") if site is not None and len(site) > 255: raise ValueError("Invalid value for `site`, length must be less than or equal to `255`") if site is not None and len(site) < 3: ...
def site(self, site)
Sets the site of this OauthTokenReference. :param site: The site of this OauthTokenReference. :type: str
1.601777
1.559635
1.02702
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.sql_get_with_http_info(owner, id, query, **kwargs) else: (data) = self.sql_get_with_http_info(owner, id, query, **kwargs) return data
def sql_get(self, owner, id, query, **kwargs)
SQL query (via GET) This endpoint executes SQL queries against a dataset. SQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: * `text/csv` * `application/json` * `applicat...
1.52894
1.549823
0.986525
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.sql_post_with_http_info(owner, id, query, **kwargs) else: (data) = self.sql_post_with_http_info(owner, id, query, **kwargs) return data
def sql_post(self, owner, id, query, **kwargs)
SQL query This endpoint executes SQL queries against a dataset. SQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: * `text/csv` * `application/json` * `application/json-l...
1.489161
1.551659
0.959722
if url is None: raise ValueError("Invalid value for `url`, must not be `None`") if url is not None and len(url) > 4096: raise ValueError("Invalid value for `url`, length must be less than or equal to `4096`") if url is not None and len(url) < 1: raise...
def url(self, url)
Sets the url of this FileSourceCreateRequest. Source URL of file. Must be an http, https. :param url: The url of this FileSourceCreateRequest. :type: str
1.600459
1.527159
1.047998
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.upload_file_with_http_info(owner, id, name, **kwargs) else: (data) = self.upload_file_with_http_info(owner, id, name, **kwargs) return data
def upload_file(self, owner, id, name, **kwargs)
Upload file Upload one file at a time to a dataset. This endpoint expects requests of type `application/octet-stream`. For example, assuming that you want to upload a local file named `file1.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset` and choose its name on data.world to b...
1.416167
1.495496
0.946954
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.upload_files_with_http_info(owner, id, file, **kwargs) else: (data) = self.upload_files_with_http_info(owner, id, file, **kwargs) return data
def upload_files(self, owner, id, file, **kwargs)
Upload files Upload multiple files at once to a dataset via multipart request. This endpoint expects requests of type `multipart/form-data` and you can include one or more parts named `file`, each containing a different file to be uploaded. For example, assuming that, you want to upload two local files named ...
1.423666
1.502451
0.947562
# TODO Move network request to RestApiClient owner_id, dataset_id = parse_dataset_key(dataset_key) params = { "query": query } if parameters and query_type == "sparql": # if SPARQL, then the parameters should be a Mapping containing # ...
def query(self, dataset_key, query, query_type="sql", parameters=None)
Query an existing dataset :param dataset_key: Dataset identifier, in the form of owner/id or of a url :type dataset_key: str :param query: SQL or SPARQL query :type query: str :param query_type: The type of the query. Must be either 'sql' or 'sparql'. (De...
3.391372
3.14238
1.079237
owner_id, dataset_id = parse_dataset_key(dataset_key) cache_dir = path.join(self._config.cache_dir, owner_id, dataset_id, 'latest') backup_dir = None if path.isdir(cache_dir) and force_update: backup_dir = path.join(self._config.cache_di...
def load_dataset(self, dataset_key, force_update=False, auto_update=False)
Load a dataset from the local filesystem, downloading it from data.world first, if necessary. This function returns an object of type `LocalDataset`. The object allows access to metedata via it's `describe()` method and to all the data via three properties `raw_data`, `tables` and `data...
2.360804
2.283165
1.034005
try: return RemoteFile(self._config, dataset_key, file_name, mode=mode, **kwargs) except Exception as e: raise RestApiError(cause=e)
def open_remote_file(self, dataset_key, file_name, mode='w', **kwargs)
Open a remote file object that can be used to write to or read from a file in a data.world dataset :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param file_name: The name of the file to open :type file_name: str :param mode: the ...
4.277523
9.499159
0.450305
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.add_files_by_source_with_http_info(owner, id, body, **kwargs) else: (data) = self.add_files_by_source_with_http_info(owner, id, body, **kwargs) return data
def add_files_by_source(self, owner, id, body, **kwargs)
Add files This method allows files published on the web to be added to a data.world dataset via their URL. The source URL will be stored so you can easily update your file anytime it changes via the *fetch latest* link on the [data.world](https://data.world/) dataset page or by triggering the GET:/sync endpoint...
1.361906
1.514776
0.899081
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.create_dataset_with_http_info(owner, body, **kwargs) else: (data) = self.create_dataset_with_http_info(owner, body, **kwargs) return data
def create_dataset(self, owner, body, **kwargs)
Create a dataset Create a new dataset. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(respons...
1.464222
1.593515
0.918863
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.delete_dataset_with_http_info(owner, id, **kwargs) else: (data) = self.delete_dataset_with_http_info(owner, id, **kwargs) return data
def delete_dataset(self, owner, id, **kwargs)
Delete a dataset Permanently deletes a dataset and all data associated with it. This operation cannot be undone, although a new dataset may be created with the same id. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` funct...
1.475277
1.548219
0.952887
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.delete_file_and_sync_source_with_http_info(owner, id, name, **kwargs) else: (data) = self.delete_file_and_sync_source_with_http_info(owner, id, name, **kwargs) return data
def delete_file_and_sync_source(self, owner, id, name, **kwargs)
Delete a file Delete a single file from a dataset by their name, including files added via URL. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def ca...
1.358853
1.448507
0.938106
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.delete_files_and_sync_sources_with_http_info(owner, id, name, **kwargs) else: (data) = self.delete_files_and_sync_sources_with_http_info(owner, id, name, **kwargs) return d...
def delete_files_and_sync_sources(self, owner, id, name, **kwargs)
Delete files Delete one or more files from a dataset by their name, including files added via URL. **Batching** Note that the `name` parameter can be include multiple times in the query string, once for each file that is to be deleted together in a single request. This method makes a synchronous H...
1.354786
1.434684
0.94431
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.get_dataset_with_http_info(owner, id, **kwargs) else: (data) = self.get_dataset_with_http_info(owner, id, **kwargs) return data
def get_dataset(self, owner, id, **kwargs)
Retrieve a dataset Return details on the dataset. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> ppr...
1.503029
1.562272
0.962079
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.patch_dataset_with_http_info(owner, id, body, **kwargs) else: (data) = self.patch_dataset_with_http_info(owner, id, body, **kwargs) return data
def patch_dataset(self, owner, id, body, **kwargs)
Update a dataset Update an existing dataset. Note that only elements or files included in the request will be updated. All omitted elements or files will remain untouched. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` fu...
1.451619
1.570504
0.924301
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.replace_dataset_with_http_info(owner, id, body, **kwargs) else: (data) = self.replace_dataset_with_http_info(owner, id, body, **kwargs) return data
def replace_dataset(self, owner, id, body, **kwargs)
Create / Replace a dataset Create a dataset with a given id or completely rewrite the dataset, including any previously added files, if one already exists with the given id. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` ...
1.431065
1.565156
0.914327
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.sync_with_http_info(owner, id, **kwargs) else: (data) = self.sync_with_http_info(owner, id, **kwargs) return data
def sync(self, owner, id, **kwargs)
Sync files Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. This method mak...
1.502432
1.586076
0.947263
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.sync_via_get_with_http_info(owner, id, **kwargs) else: (data) = self.sync_via_get_with_http_info(owner, id, **kwargs) return data
def sync_via_get(self, owner, id, **kwargs)
Sync files (via GET) Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. This m...
1.391651
1.514391
0.918951
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.fetch_contributing_datasets_with_http_info(**kwargs) else: (data) = self.fetch_contributing_datasets_with_http_info(**kwargs) return data
def fetch_contributing_datasets(self, **kwargs)
List datasets as contributor Fetch datasets that the currently authenticated user has access to because he or she is a contributor. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiv...
1.659099
1.620619
1.023744
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.fetch_contributing_projects_with_http_info(**kwargs) else: (data) = self.fetch_contributing_projects_with_http_info(**kwargs) return data
def fetch_contributing_projects(self, **kwargs)
List projects as contributor Fetch projects that the currently authenticated user has access to because he or she is a contributor. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiv...
1.646294
1.645683
1.000372
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.fetch_datasets_with_http_info(**kwargs) else: (data) = self.fetch_datasets_with_http_info(**kwargs) return data
def fetch_datasets(self, **kwargs)
List datasets as owner Fetch datasets that the currently authenticated user has access to because he or she is the owner of the dataset. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when r...
1.68002
1.675781
1.00253
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.fetch_liked_datasets_with_http_info(**kwargs) else: (data) = self.fetch_liked_datasets_with_http_info(**kwargs) return data
def fetch_liked_datasets(self, **kwargs)
List liked datasets Fetch datasets that the currently authenticated user likes. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(...
1.619271
1.596374
1.014343
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.fetch_liked_projects_with_http_info(**kwargs) else: (data) = self.fetch_liked_projects_with_http_info(**kwargs) return data
def fetch_liked_projects(self, **kwargs)
List liked projects Fetch projects that the currently authenticated user likes. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(...
1.592219
1.638024
0.972037
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.fetch_projects_with_http_info(**kwargs) else: (data) = self.fetch_projects_with_http_info(**kwargs) return data
def fetch_projects(self, **kwargs)
List projects owned Fetch projects that the currently authenticated user has access to because he or she is the owner of the project. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when rece...
1.622496
1.723356
0.941475
kwargs['_return_http_data_only'] = True if kwargs.get('callback'): return self.get_user_data_with_http_info(**kwargs) else: (data) = self.get_user_data_with_http_info(**kwargs) return data
def get_user_data(self, **kwargs)
Get user data Return profile information for the currently authenticated user. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(r...
1.561565
1.638944
0.952787