Skip to content

Commit

Permalink
ResultChat class was modified
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin committed Aug 21, 2024
1 parent 10cf55c commit 525baf8
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions evdschat/core/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from evdspy.EVDSlocal.index_requests.get_series_indexes_exp import Result

from enum import Enum
from typing import Any
from typing import Any


class Status(Enum):
success= 1
failed= 0
unknown= 2
success = 1
failed = 0
unknown = 2


@dataclass
Expand All @@ -19,7 +20,8 @@ class ResultChat(Result):

def __str__(self):
content = super().__str__()
return f"""
return (
f"""
! get_series_exp function returns instance of this class
<ResultChat>
status : {self.status.name} => Indicates the status of the result
Expand All @@ -29,24 +31,43 @@ def __str__(self):
write : Callable => Creates an Excel file with data and metadata in two sheets
to_excel : Callable => Same as write to meet pandas to_excel function
""" + content
"""
+ content
)


def create_result(result: Any, status: Status = None, reason: str = "") -> ResultChat:
if status is None:
status = Status.unknown

if isinstance(result, Result):
return ResultChat(data=result.data, metadata=result.metadata, write=result.write, status=status, reason=reason)
return ResultChat(
data=result.data,
metadata=result.metadata,
write=result.write,
status=status,
reason=reason,
)

if isinstance(result, pd.DataFrame):
r = Result(data=result, metadata=pd.DataFrame(), write=None) # Replace None with a suitable write function if available
return ResultChat(data=r.data, metadata=r.metadata, write=r.write, status=status, reason=reason)
r = Result(data=result, metadata=pd.DataFrame(), write=None)
return ResultChat(
data=r.data,
metadata=r.metadata,
write=r.write,
status=status,
reason=reason,
)

if result is None:
r = Result(data=pd.DataFrame(), metadata=pd.DataFrame(), write=None) # Replace None with a suitable write function if available
return ResultChat(data=r.data, metadata=r.metadata, write=r.write, status=status, reason=reason)

r = Result(data=pd.DataFrame(), metadata=pd.DataFrame(), write=None)
return ResultChat(
data=r.data,
metadata=r.metadata,
write=r.write,
status=status,
reason=reason,
)


__all__ = ["ResultChat"]

0 comments on commit 525baf8

Please sign in to comment.