Skip to content

Commit

Permalink
Merge pull request #89 from SciCatProject/test-1104-2
Browse files Browse the repository at this point in the history
Metadata stuff
  • Loading branch information
YooSunYoung authored Nov 4, 2024
2 parents 18f94e4 + 91e7616 commit 427a2a9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/scicat_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,27 @@ def to_dict(value: Any) -> dict:
raise ValueError(
"Invalid value. Must be able to convert to a dictionary. Got ", value
)
elif isinstance(value, dict):
return value

return dict(value)


def to_list(value: Any) -> list:
if isinstance(value, str):
result = ast.literal_eval(value)
if isinstance(result, list):
return result
else:
raise ValueError(
"Invalid value. Must be able to convert to a dictionary. Got ", value
)
elif isinstance(value, list):
return value
else:
raise TypeError()


_DtypeConvertingMap = MappingProxyType(
{
"string": to_string,
Expand All @@ -80,6 +97,7 @@ def to_dict(value: Any) -> dict:
"float": to_float,
"date": to_date,
"dict": to_dict,
"list": to_list,
"email": to_string,
# TODO: Add email converter
}
Expand Down Expand Up @@ -175,7 +193,7 @@ def extract_variables_values(
else value
)
_operator = _get_operator(variable_recipe.operator)
if variable_recipe.field:
if variable_recipe.field is not None:
value = _operator(value, variable_recipe.field)
else:
value = _operator(value)
Expand Down

0 comments on commit 427a2a9

Please sign in to comment.