13
13
from openssa .core .ooda_rag .heuristic import TaskDecompositionHeuristic
14
14
from openssa .core .ooda_rag .custom import CustomSSM
15
15
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
17
17
18
18
if TYPE_CHECKING :
19
19
from collections .abc import Iterable , MutableMapping
@@ -46,7 +46,7 @@ class SSAProbSolver:
46
46
# some typing for clarity to developers/maintainers
47
47
# =================================================
48
48
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
50
50
51
51
# relevant Streamlit Session State (SSS) elements
52
52
# ===============================================
@@ -62,7 +62,7 @@ class SSAProbSolver:
62
62
def __init__ (self , unique_name : Uid , domain : str = '' ,
63
63
problem : str = '' , expert_instructions : str = '' ,
64
64
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 ()):
66
66
# pylint: disable=too-many-arguments
67
67
"""Initialize and start running SSAProbSolver instance."""
68
68
# initialize Streamlit Session State (SSS) elements if necessary
@@ -90,20 +90,20 @@ def __init__(self, unique_name: Uid, domain: str = '',
90
90
91
91
# set Documentary Knowledge Source Path & any specific File Relative Paths if given
92
92
if doc_src_path :
93
- self .doc_src_path : DirOrFilePath = doc_src_path
93
+ self .doc_src_path : DirOrFileStrPath = doc_src_path
94
94
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
96
96
97
97
# start running in Streamlit app page
98
98
self .run ()
99
99
100
100
@classmethod
101
101
def _init_sss (cls ):
102
102
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 )
104
104
105
105
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 ]] = \
107
107
defaultdict (lambda : defaultdict (frozenset ))
108
108
109
109
if cls .PROBLEMS_SSS_KEY not in sss :
@@ -149,23 +149,23 @@ def fine_tuned_model_url(self, fine_tuned_model_url: str, /):
149
149
sss [self .FINE_TUNED_MODELS_SSS_KEY ][self .unique_name ]: str = fine_tuned_model_url
150
150
151
151
@property
152
- def doc_src_path (self ) -> DirOrFilePath :
152
+ def doc_src_path (self ) -> DirOrFileStrPath :
153
153
return sss [self .DOC_SRC_PATHS_SSS_KEY ][self .unique_name ]
154
154
155
155
@doc_src_path .setter
156
- def doc_src_path (self , path : DirOrFilePath , / ):
156
+ def doc_src_path (self , path : DirOrFileStrPath , / ):
157
157
assert (clean_path := path .strip ().rstrip ('/' )), ValueError (f'{ path } not non-empty path' )
158
158
159
159
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
161
161
162
162
@property
163
163
def _doc_file_src (self ) -> FileResource :
164
164
assert (_ := self .doc_src_path ), ValueError ('Documentary Knowledge Source Path not yet specified' )
165
165
return FileResource (_ )
166
166
167
167
@property
168
- def doc_src_file_relpaths (self ) -> FilePathSet :
168
+ def doc_src_file_relpaths (self ) -> FileStrPathSet :
169
169
assert self ._doc_file_src .is_dir , ValueError ('Documentary Knowledge Source Path not directory' )
170
170
171
171
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], /):
176
176
177
177
if (file_relpath_set := frozenset (file_relpaths )) != \
178
178
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
180
180
181
181
@property
182
182
def _hashable_doc_src_repr (self ) -> DocSrcHash :
@@ -317,10 +317,10 @@ def run(self):
317
317
placeholder = 'Resources Directory/File Path (Local|S3)' ,
318
318
disabled = False ,
319
319
label_visibility = 'visible' ):
320
- self .doc_src_path : DirOrFilePath = doc_src_path
320
+ self .doc_src_path : DirOrFileStrPath = doc_src_path
321
321
322
322
if self ._doc_file_src .is_dir :
323
- self .doc_src_file_relpaths : FilePathSet = frozenset (
323
+ self .doc_src_file_relpaths : FileStrPathSet = frozenset (
324
324
st .multiselect (label = 'Specific File Relpaths _(if cherry-picking)_' ,
325
325
options = self ._doc_file_src .file_paths (relative = True ),
326
326
default = sorted (self .doc_src_file_relpaths ),
0 commit comments