Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added encoding option, docstring and kept format of original file #7

Conversation

samuelberntzen
Copy link

I encountered encoding error while testing Cube Core and trying to load my manifest.json from file. My manifest.json file was utf-8 encoded, which caused UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10168: .

Python version 3.9 which Cube Core docker image is using defaults to locale.getprefferedencoding(), which seems to be ascii on the docker image of Cube Core.

  • Added numpy docstring for from_file() and from_url() methods
  • Added possibility to set desired encoding for a local file. It not set, defaults to locale.getpreferredencoding()

Example of usage with Dbt.from_file():

from cube_dbt import Dbt

# with utf-8 encoding
dbt = Dbt.from_file("path/to/manifest.json", encoding="utf-8").filter(paths=["marts/"])

# without specifying encoding
dbt = Dbt.from_file("path/to/manifest.json").filter(paths=["marts/"])

Not needed in from_url() method because urlopen uses Content-Type headers to set encoding.

** new PR from new branch to prevent too many file edits

@samuelberntzen samuelberntzen deleted the feature/encoding_param_and_docstring branch March 26, 2024 08:55
@samuelberntzen samuelberntzen restored the feature/encoding_param_and_docstring branch March 26, 2024 08:55
@samuelberntzen samuelberntzen closed this by deleting the head repository Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant