mike dupont
commited on
Commit
·
06731e2
1
Parent(s):
f9be86e
app
Browse files
app.py
CHANGED
@@ -58,12 +58,26 @@ if st.button("Process data"):
|
|
58 |
url,
|
59 |
mode,
|
60 |
model,
|
61 |
-
"\"{prompt}\""]
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
67 |
def get_out_files(path='.'):
|
68 |
"""Recursive function to find all files in given directory path."""
|
69 |
files = []
|
@@ -82,6 +96,46 @@ def get_out_files(path='.'):
|
|
82 |
return files
|
83 |
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if st.button(f"Scan output {input_dir}"):
|
86 |
st.write('Going to scan')
|
87 |
outfiles = get_out_files(input_dir)
|
|
|
58 |
url,
|
59 |
mode,
|
60 |
model,
|
61 |
+
"\"{prompt}\""]
|
62 |
+
p = subprocess.Popen(cmd,
|
63 |
+
stdout=subprocess.PIPE,
|
64 |
+
stderr=subprocess.PIPE,
|
65 |
+
)
|
66 |
+
readable = {
|
67 |
+
p.stdout.fileno(): sys.stdout.buffer, # log separately
|
68 |
+
p.stderr.fileno(): sys.stderr.buffer,
|
69 |
+
}
|
70 |
+
while readable:
|
71 |
+
for fd in select(readable, [], [])[0]:
|
72 |
+
data = os.read(fd, 1024) # read available
|
73 |
+
if not data: # EOF
|
74 |
+
del readable[fd]
|
75 |
+
else:
|
76 |
+
st.write(data.decode("utf-8"))
|
77 |
+
readable[fd].write(data)
|
78 |
+
readable[fd].flush()
|
79 |
|
80 |
+
##
|
81 |
def get_out_files(path='.'):
|
82 |
"""Recursive function to find all files in given directory path."""
|
83 |
files = []
|
|
|
96 |
return files
|
97 |
|
98 |
|
99 |
+
if st.button(f"Scan output {input_dir}"):
|
100 |
+
st.write('Going to scan')
|
101 |
+
outfiles = get_out_files(input_dir)
|
102 |
+
if len(outfiles) > limit:
|
103 |
+
outfiles = outfiles[0:limit]
|
104 |
+
#st.write(outfiles)
|
105 |
+
|
106 |
+
for x in outfiles:
|
107 |
+
if os.path.isdir(x):
|
108 |
+
pass
|
109 |
+
else:
|
110 |
+
(p,f) =os.path.split(x)
|
111 |
+
with open(x, "r") as fp:
|
112 |
+
btn = st.download_button(
|
113 |
+
label="Download text" + f,
|
114 |
+
data=fp,
|
115 |
+
file_name=f,
|
116 |
+
mime="application/text"
|
117 |
+
)
|
118 |
+
|
119 |
+
###
|
120 |
+
|
121 |
+
def get_out_files(path='.'):
|
122 |
+
"""Recursive function to find all files in given directory path."""
|
123 |
+
files = []
|
124 |
+
for item in os.listdir(path):
|
125 |
+
fp = os.path.join(path, item)
|
126 |
+
if os.path.isdir(fp):
|
127 |
+
files.append(fp)
|
128 |
+
files += get_out_files(fp)
|
129 |
+
else:
|
130 |
+
if fp.endswith(".test"):
|
131 |
+
files.append(fp)
|
132 |
+
#st.write(fp)
|
133 |
+
else:
|
134 |
+
#st.write("skip"+fp)
|
135 |
+
pass
|
136 |
+
return files
|
137 |
+
|
138 |
+
|
139 |
if st.button(f"Scan output {input_dir}"):
|
140 |
st.write('Going to scan')
|
141 |
outfiles = get_out_files(input_dir)
|