Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anisbhsl committed Oct 18, 2023
1 parent beb41a1 commit 9dd2063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
24 changes: 11 additions & 13 deletions pynequa/models.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
from typing import Dict, List, Optional
from abc import abstractmethod
from abc import abstractmethod, ABC
from dataclasses import dataclass, field
import logging
from loguru import logger

logging.basicConfig(level=logging.DEBUG)


class SinequaBaseModel:
class AbstractParams(ABC):
"""
Abstract base class for all Sinequa models.
"""

@abstractmethod
def generate_payload(self, **kwargs) -> Dict:
"""
This is abstract method for SinequaBaseModel.
This is abstract method for AbstractParams.
Every child class should implement this method.
"""
raise NotImplementedError()


@dataclass
class TreeParams(SinequaBaseModel):
class TreeParams(AbstractParams):
"""
Represents the parameters for configuring a tree parameters.
Expand Down Expand Up @@ -52,7 +50,7 @@ def generate_payload(self, **kwargs) -> Dict:


@dataclass
class SelectParams(SinequaBaseModel):
class SelectParams(AbstractParams):
expression: str = ""
facet: str = ""

Expand All @@ -68,7 +66,7 @@ def generate_payload(self, **kwargs) -> Dict:


@dataclass
class OpenParams(SinequaBaseModel):
class OpenParams(AbstractParams):
expression: str = ""
facet: str = ""

Expand All @@ -84,7 +82,7 @@ def generate_payload(self, **kwargs) -> Dict:


@dataclass
class AdvancedParams(SinequaBaseModel):
class AdvancedParams(AbstractParams):
col_name: str = ""
col_value: str = None
value: str or int = None
Expand All @@ -103,13 +101,13 @@ def generate_payload(self, **kwargs) -> Dict:
}

if self.debug:
logging.debug(payload)
logger.debug(payload)

return payload


@dataclass
class QueryParams(SinequaBaseModel):
class QueryParams(AbstractParams):
name: str = "" # required
action: Optional[str] = None
search_text: str = "" # required
Expand Down Expand Up @@ -240,6 +238,6 @@ def generate_payload(self, **kwargs) -> Dict:
query_name = kwargs.get("query_name")
payload = self._prepare_query_args(query_name)
if self.debug:
logging.debug(payload)
logger.debug(payload)

return payload
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Requests==2.31.0
setuptools==61.2.0
sphinx-click==4.4.0
loguru==0.7.2

0 comments on commit 9dd2063

Please sign in to comment.