Skip to content

Commit

Permalink
fix: project model mapping causes error in retrieving project convers…
Browse files Browse the repository at this point in the history
…ion settings (#63)

Signed-off-by: Christoph Auer <CAU@zurich.ibm.com>
Co-authored-by: Christoph Auer <CAU@zurich.ibm.com>
  • Loading branch information
cau-git and cau-git authored Feb 1, 2023
1 parent 60f29f9 commit 798f2af
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions deepsearch/documents/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,26 @@ def from_ccs_spec(cls, obj):
raise ValueError("CCS spec can not be None")
if obj.get("clusters") and len(obj.get("clusters")):
model_dict = obj.get("clusters")[0]
clusters = parse_obj_as(ConversionModel, model_dict)

clusters = cls._make_conversion_model(model_dict)

instance = cls(clusters=clusters)
if obj.get("tables") and len(obj.get("tables")):
model_dict = obj.get("tables")[0]
instance.tables = parse_obj_as(ConversionModel, model_dict)

instance.tables = cls._make_conversion_model(model_dict)

return instance
else:
raise ValueError("CCS spec must have non-empty clusters")

@classmethod
def _make_conversion_model(cls, model_dict):
if "model_config_key" in model_dict.keys():
return ProjectConversionModel.from_ccs_spec(model_dict)
else:
return DefaultConversionModel.from_ccs_spec(model_dict)

def to_ccs_spec(self):
obj = {
"clusters": [self.clusters.to_ccs_spec()],
Expand Down

0 comments on commit 798f2af

Please sign in to comment.