Skip to content

Commit

Permalink
reorganize schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerhutcherson committed Dec 7, 2023
1 parent 0ee70fa commit 17ef0f9
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions redisvl/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,32 @@ def _validate_fields_model(self, fields: Union[Dict[str, Any], FieldsModel]) ->
except Exception as e:
raise ValueError("Failed to create fields model.") from e

@property
def index_name(self) -> str:
return self._index.name

@property
def index_prefix(self) -> str:
return self._index.prefix

@property
def key_separator(self) -> str:
return self._index.key_separator

@property
def storage_type(self) -> str:
return self._index.storage_type

@property
def index_fields(self) -> list:
redis_fields = []
for field_name in self._fields.__fields__.keys():
field_group = getattr(self._fields, field_name)
if field_group is not None:
for field in field_group:
redis_fields.append(field.as_field())
return redis_fields

@classmethod
def from_params(
cls,
Expand Down Expand Up @@ -217,31 +243,6 @@ def from_data(

return cls.from_params(fields=schema_fields, **kwargs)

@property
def index_name(self) -> str:
return self._index.name

@property
def index_prefix(self) -> str:
return self._index.prefix

@property
def key_separator(self) -> str:
return self._index.key_separator

@property
def storage_type(self) -> str:
return self._index.storage_type

@property
def index_fields(self):
redis_fields = []
for field_name in self._fields.__fields__.keys():
field_group = getattr(self._fields, field_name)
if field_group is not None:
for field in field_group:
redis_fields.append(field.as_field())
return redis_fields

def dump(self) -> Dict[str, Any]:
"""
Expand Down

0 comments on commit 17ef0f9

Please sign in to comment.