Skip to content

Commit

Permalink
refactor: allow non-str keys in KiaraDict data type
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Nov 14, 2023
1 parent d189cd7 commit 02b2890
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/kiara/data_types/included_core_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ def _pretty_print_as__terminal_renderable(
table.add_column("value")

data: KiaraDict = value.data
data_json = orjson_dumps(data.dict_data, option=orjson.OPT_INDENT_2)
data_json = orjson_dumps(
data.dict_data, option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS
)
table.add_row(
"dict data", Syntax(data_json, "json", background_color="default")
)
Expand Down
4 changes: 2 additions & 2 deletions src/kiara/models/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sub-class a pydantic BaseModel or implement custom base classes.
"""

from typing import Any, Dict, Mapping
from typing import Any, Dict, Hashable, Mapping

from pydantic import BaseModel, Field, PrivateAttr

Expand All @@ -20,7 +20,7 @@

class KiaraDict(BaseModel, Mapping):

dict_data: Dict[str, Any] = Field(description="The data.")
dict_data: Dict[Hashable, Any] = Field(description="The data.")
data_schema: Dict[str, Any] = Field(description="The schema.")
python_class: PythonClass = Field(
description="The python class of which model instances are created. This is mostly meant as a hint for client applications."
Expand Down
4 changes: 2 additions & 2 deletions src/kiara/models/module/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def from_file(
kiara: Union["Kiara", None] = None,
pipeline_name: Union[None, str] = None,
# module_map: Optional[Mapping[str, Any]] = None,
):
) -> "PipelineConfig":

data = get_data_from_file(path)
_pipeline_name = data.pop("pipeline_name", None)
Expand Down Expand Up @@ -522,7 +522,7 @@ def from_string(
kiara: Union["Kiara", None] = None,
pipeline_name: Union[None, str] = None,
# module_map: Optional[Mapping[str, Any]] = None,
):
) -> "PipelineConfig":

data = get_data_from_string(string_data)
_pipeline_name = data.pop("pipeline_name", None)
Expand Down

0 comments on commit 02b2890

Please sign in to comment.