Skip to content

Commit

Permalink
Remove datastore create update
Browse files Browse the repository at this point in the history
Fix readthedocs
Update for changes to Frictionless in HDX Python Utilities
  • Loading branch information
Mike committed Apr 11, 2022
1 parent e775ee4 commit cadfcb0
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 388 deletions.
21 changes: 16 additions & 5 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
version: 2
mkdocs: {} # tell readthedocs to use mkdocs
python:
version: 3.7
install:
- requirements: docs/.readthedocs-requirements.txt

mkdocs:
configuration: mkdocs.yml
fail_on_warning: false

build:
os: ubuntu-20.04
tools:
python: "3.10"
jobs:
pre_build:
- pip install pydoc-markdown==4.5.1
- pip install mkdocs==1.3.0
- pydoc-markdown
- mv docs/content/* docs
- rmdir docs/content
16 changes: 2 additions & 14 deletions docs/main.md → doc/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ The library has detailed API documentation which can be found in the menu on the


## Breaking Changes
From 5.6.0, creating and updating datastores removed

From 5.4.0, Configuration class moved to hdx.api.configuration and Locations class moved to hdx.api.locations

From 5.3.0, only supports Python 3.6 and above
Expand Down Expand Up @@ -670,20 +672,6 @@ There is a getter to read the value back:

file_to_upload = resource.get_file_to_upload()

If you wish to set up the data preview feature in HDX and your file (HDX or externally hosted) is a csv, then you can
call the **create\_datastore** or **update\_datastore** methods. If you do not pass any parameters, all fields in the
csv will be assumed to be text.

resource.create_datastore()
resource.update_datastore()

More fine grained control is possible by passing certain parameters and using other related methods eg.

resource.create_datastore(schema={"id": "FIELD", "type": "TYPE"}, primary_key="PRIMARY_KEY_OF_SCHEMA", delete_first=0 (No) / 1 (Yes) / 2 (If no primary key), path="LOCAL_PATH_OF_UPLOADED_FILE") -> None:
resource.create_datastore_from_yaml_schema(yaml_path="PATH_TO_YAML_SCHEMA", delete_first=0 (No) / 1 (Yes) / 2 (If no primary key), path="LOCAL_PATH_OF_UPLOADED_FILE")
resource.update_datastore(schema={"id": "FIELD", "type": "TYPE"}, primary_key="PRIMARY_KEY_OF_SCHEMA", path="LOCAL_PATH_OF_UPLOADED_FILE") -> None:
resource.update_datastore_from_json_schema(json_path="PATH_TO_JSON_SCHEMA", path="LOCAL_PATH_OF_UPLOADED_FILE")

## Showcase Management
The **Showcase** class enables you to manage showcases, creating, deleting and updating (as for other HDX objects)
according to your permissions.
Expand Down
2 changes: 0 additions & 2 deletions docs/.readthedocs-requirements.txt

This file was deleted.

9 changes: 2 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ packages = ["hdx.api", "hdx.data", "hdx.facades"]

[tool.pydoc-markdown.renderer]
type = "mkdocs"
output_directory = "docs/build"
output_directory = "docs"

[tool.pydoc-markdown.renderer.mkdocs_config]
site_name = "HDX Python API"
Expand All @@ -81,7 +81,7 @@ output_directory = "docs/build"
[[tool.pydoc-markdown.renderer.pages]]
title = "Home"
name = "index"
source ="docs/main.md"
source ="doc/main.md"

[[tool.pydoc-markdown.renderer.pages]]
title = "API Documentation"
Expand Down Expand Up @@ -130,11 +130,6 @@ output_directory = "docs/build"
title = "Keyword Arguments Facade"
contents = ["hdx.facades.keyword_arguments.*"]

[tool.readthedocs-custom-steps]
script = """
pydoc-markdown --build --site-dir "$PWD/_build/html"
"""

[tool.tox]
legacy_tox_ini = """
[tox]
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ckanapi==4.6
defopt==6.3.0
hdx-python-country==3.1.3
email_validator==1.1.3
hdx-python-country==3.1.5
ndg-httpsclient==0.5.1
pyasn1==0.4.8
pyOpenSSL==22.0.0
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ python_requires = >=3.6
install_requires =
ckanapi >= 4.6
defopt
hdx-python-country>=3.1.3
email_validator
hdx-python-country>=3.1.5
ndg-httpsclient
pyasn1
pyOpenSSL
Expand Down
4 changes: 2 additions & 2 deletions src/hdx/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ def generate_resource_from_rows(
Resource: The created resource
"""
filepath = join(folder, filename)
write_list_to_csv(filepath, rows, headers=headers)
write_list_to_csv(filepath, rows, columns=headers)
resource = res_module.Resource(resourcedata)
resource.set_file_type("csv")
resource.set_file_to_upload(filepath)
Expand Down Expand Up @@ -2437,7 +2437,7 @@ def datecol_function(row):
if qc["numeric"]:
try:
float(row[qc["numeric"]])
except ValueError:
except (TypeError, ValueError):
continue
bites_disabled[i] = False
if qc["cutdown"]:
Expand Down
Loading

0 comments on commit cadfcb0

Please sign in to comment.