Skip to content

Commit 4fde464

Browse files
update openssa.contrib.streamlit_ssa_prob_solver
1 parent ef50fa9 commit 4fde464

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

openssa/contrib/streamlit_ssa_prob_solver/__init__.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from openssa.core.ooda_rag.heuristic import TaskDecompositionHeuristic
1414
from openssa.core.ooda_rag.custom import CustomSSM
1515
from openssa.core.ooda_rag.ooda_ssa import OodaSSA
16-
from openssa.l2.resource.file import DirOrFilePath, FilePathSet, FileResource
16+
from openssa.l2.resource.file import DirOrFileStrPath, FileStrPathSet, FileResource
1717

1818
if TYPE_CHECKING:
1919
from collections.abc import Iterable, MutableMapping
@@ -46,7 +46,7 @@ class SSAProbSolver:
4646
# some typing for clarity to developers/maintainers
4747
# =================================================
4848
type Uid = int | str | UUID # accepted type(s) for unique IDs of SSAProbSolver instances & SSA conversations
49-
type DocSrcHash = DirOrFilePath | FilePathSet # type for documentary knowledge source hashes
49+
type DocSrcHash = DirOrFileStrPath | FileStrPathSet # type for documentary knowledge source hashes
5050

5151
# relevant Streamlit Session State (SSS) elements
5252
# ===============================================
@@ -62,7 +62,7 @@ class SSAProbSolver:
6262
def __init__(self, unique_name: Uid, domain: str = '',
6363
problem: str = '', expert_instructions: str = '',
6464
fine_tuned_model_url: str = '',
65-
doc_src_path: DirOrFilePath = '', doc_src_file_relpaths: FilePathSet = frozenset()):
65+
doc_src_path: DirOrFileStrPath = '', doc_src_file_relpaths: FileStrPathSet = frozenset()):
6666
# pylint: disable=too-many-arguments
6767
"""Initialize and start running SSAProbSolver instance."""
6868
# initialize Streamlit Session State (SSS) elements if necessary
@@ -90,20 +90,20 @@ def __init__(self, unique_name: Uid, domain: str = '',
9090

9191
# set Documentary Knowledge Source Path & any specific File Relative Paths if given
9292
if doc_src_path:
93-
self.doc_src_path: DirOrFilePath = doc_src_path
93+
self.doc_src_path: DirOrFileStrPath = doc_src_path
9494
if doc_src_file_relpaths:
95-
self.doc_src_file_relpaths: FilePathSet = doc_src_file_relpaths
95+
self.doc_src_file_relpaths: FileStrPathSet = doc_src_file_relpaths
9696

9797
# start running in Streamlit app page
9898
self.run()
9999

100100
@classmethod
101101
def _init_sss(cls):
102102
if cls.DOC_SRC_PATHS_SSS_KEY not in sss:
103-
sss[cls.DOC_SRC_PATHS_SSS_KEY]: defaultdict[cls.Uid, DirOrFilePath] = defaultdict(str)
103+
sss[cls.DOC_SRC_PATHS_SSS_KEY]: defaultdict[cls.Uid, DirOrFileStrPath] = defaultdict(str)
104104

105105
if cls.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY not in sss:
106-
sss[cls.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY]: defaultdict[cls.Uid, defaultdict[DirOrFilePath, FilePathSet]] = \
106+
sss[cls.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY]: defaultdict[cls.Uid, defaultdict[DirOrFileStrPath, FileStrPathSet]] = \
107107
defaultdict(lambda: defaultdict(frozenset))
108108

109109
if cls.PROBLEMS_SSS_KEY not in sss:
@@ -149,23 +149,23 @@ def fine_tuned_model_url(self, fine_tuned_model_url: str, /):
149149
sss[self.FINE_TUNED_MODELS_SSS_KEY][self.unique_name]: str = fine_tuned_model_url
150150

151151
@property
152-
def doc_src_path(self) -> DirOrFilePath:
152+
def doc_src_path(self) -> DirOrFileStrPath:
153153
return sss[self.DOC_SRC_PATHS_SSS_KEY][self.unique_name]
154154

155155
@doc_src_path.setter
156-
def doc_src_path(self, path: DirOrFilePath, /):
156+
def doc_src_path(self, path: DirOrFileStrPath, /):
157157
assert (clean_path := path.strip().rstrip('/')), ValueError(f'{path} not non-empty path')
158158

159159
if clean_path != sss[self.DOC_SRC_PATHS_SSS_KEY][self.unique_name]:
160-
sss[self.DOC_SRC_PATHS_SSS_KEY][self.unique_name]: DirOrFilePath = clean_path
160+
sss[self.DOC_SRC_PATHS_SSS_KEY][self.unique_name]: DirOrFileStrPath = clean_path
161161

162162
@property
163163
def _doc_file_src(self) -> FileResource:
164164
assert (_ := self.doc_src_path), ValueError('Documentary Knowledge Source Path not yet specified')
165165
return FileResource(_)
166166

167167
@property
168-
def doc_src_file_relpaths(self) -> FilePathSet:
168+
def doc_src_file_relpaths(self) -> FileStrPathSet:
169169
assert self._doc_file_src.is_dir, ValueError('Documentary Knowledge Source Path not directory')
170170

171171
return sss[self.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY][self.unique_name][self.doc_src_path]
@@ -176,7 +176,7 @@ def doc_src_file_relpaths(self, file_relpaths: Iterable[str], /):
176176

177177
if (file_relpath_set := frozenset(file_relpaths)) != \
178178
sss[self.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY][self.unique_name][self.doc_src_path]:
179-
sss[self.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY][self.unique_name][self.doc_src_path]: FilePathSet = file_relpath_set
179+
sss[self.DOC_SRC_FILE_RELPATH_SETS_SSS_KEY][self.unique_name][self.doc_src_path]: FileStrPathSet = file_relpath_set
180180

181181
@property
182182
def _hashable_doc_src_repr(self) -> DocSrcHash:
@@ -317,10 +317,10 @@ def run(self):
317317
placeholder='Resources Directory/File Path (Local|S3)',
318318
disabled=False,
319319
label_visibility='visible'):
320-
self.doc_src_path: DirOrFilePath = doc_src_path
320+
self.doc_src_path: DirOrFileStrPath = doc_src_path
321321

322322
if self._doc_file_src.is_dir:
323-
self.doc_src_file_relpaths: FilePathSet = frozenset(
323+
self.doc_src_file_relpaths: FileStrPathSet = frozenset(
324324
st.multiselect(label='Specific File Relpaths _(if cherry-picking)_',
325325
options=self._doc_file_src.file_paths(relative=True),
326326
default=sorted(self.doc_src_file_relpaths),

0 commit comments

Comments
 (0)