Skip to content

Commit

Permalink
Allow non ASCII in JSON dump with env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank995 committed Dec 10, 2024
1 parent f0d59c6 commit 4f26ad9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/zenml/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def handle_int_env_var(var: str, default: int = 0) -> int:
ENV_ZENML_PIPELINE_RUN_API_TOKEN_EXPIRATION = (
"ZENML_PIPELINE_API_TOKEN_EXPIRATION"
)
ENV_ZENML_ALLOW_NON_ASCII_MATERIALIZERS_DUMPS = "ZENML_ALLOW_NON_ASCII_MATERIALIZERS_DUMPS"

# ZenML Server environment variables
ENV_ZENML_SERVER_PREFIX = "ZENML_SERVER_"
Expand Down
8 changes: 8 additions & 0 deletions src/zenml/utils/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@

import yaml

from zenml.constants import (
ENV_ZENML_ALLOW_NON_ASCII_MATERIALIZERS_DUMPS,
handle_bool_env_var,
)
from zenml.io import fileio
from zenml.utils import io_utils

ZENML_ALLOW_NON_ASCII_MATERIALIZERS_DUMPS = handle_bool_env_var(
ENV_ZENML_ALLOW_NON_ASCII_MATERIALIZERS_DUMPS, False
)

def write_yaml(
file_path: str,
Expand Down Expand Up @@ -142,6 +149,7 @@ def write_json(
file_path,
json.dumps(
contents,
ensure_ascii=not ZENML_ALLOW_NON_ASCII_MATERIALIZERS_DUMPS,
cls=encoder,
),
)
Expand Down

0 comments on commit 4f26ad9

Please sign in to comment.