Skip to content

Commit

Permalink
added function to return csv filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
pr4deepr committed Jan 15, 2024
1 parent 9e19163 commit c6fb782
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions core/lls_core/models/output.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pydantic import Field, DirectoryPath, validator
from strenum import StrEnum
from pathlib import Path
from typing import TYPE_CHECKING

from typing import TYPE_CHECKING, Union
from pandas import DataFrame
from lls_core.models.utils import FieldAccessModel, enum_choices

if TYPE_CHECKING:
Expand Down Expand Up @@ -65,3 +65,12 @@ def make_filepath(self, suffix: str) -> Path:
Returns a filepath for the resulting data
"""
return self.save_dir / Path(self.save_name + suffix).with_suffix("." + self.file_extension)

def make_filepath_df(self, suffix: str,result:Union[DataFrame,list]) -> Path:
"""
Returns a filepath for the non-image data
"""
if isinstance(result, DataFrame):
return self.save_dir / Path(self.save_name + suffix).with_suffix(".csv")

return
2 changes: 1 addition & 1 deletion core/lls_core/models/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def save(self) -> Iterable[Path]:
"""
for roi, result in self.process():
if isinstance(result, DataFrame):
path = self.lattice_data.make_filepath(make_filename_prefix(roi_index=roi))
path = self.lattice_data.make_filepath_df(make_filename_prefix(roi_index=roi),result)
result.to_csv(str(path))
yield path
else:
Expand Down

0 comments on commit c6fb782

Please sign in to comment.