Spaces:
Running
Running
MVPilgrim
commited on
Commit
·
fbd7ce3
1
Parent(s):
ae54c88
debug
Browse files
app.py
CHANGED
@@ -42,8 +42,16 @@ try:
|
|
42 |
logger.info(f"startup.sh stdout: {result.stdout}")
|
43 |
logger.info(f"startup.sh stderr: {result.stderr}")
|
44 |
logger.info(f"Return code: {result.returncode}")
|
45 |
-
except:
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
logger.info("### Running startup.sh complete")
|
48 |
if 'runStartup' not in st.session_state:
|
49 |
st.session_state.runStartup = True
|
@@ -81,30 +89,31 @@ try:
|
|
81 |
######################################################
|
82 |
# Connect to the Weaviate vector database.
|
83 |
#if 'client' not in st.session_state:
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
)
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
# client = st.session_state.client
|
102 |
|
103 |
|
104 |
#######################################################
|
105 |
# Read each text input file, parse it into a document,
|
106 |
# chunk it, collect chunks and document name.
|
107 |
-
if not client.collections.exists("Documents") or not client.collections.exists("
|
108 |
logger.info("#### Read and chunk input text files.")
|
109 |
for filename in os.listdir(pathString):
|
110 |
logger.info(filename)
|
|
|
42 |
logger.info(f"startup.sh stdout: {result.stdout}")
|
43 |
logger.info(f"startup.sh stderr: {result.stderr}")
|
44 |
logger.info(f"Return code: {result.returncode}")
|
45 |
+
except Exception as e:
|
46 |
+
emsg = str(e)
|
47 |
+
logger.error(f"subprocess.run EXCEPTION. e: {emsg}")
|
48 |
+
try:
|
49 |
+
with open("/app/startup.log", "r") as file:
|
50 |
+
content = file.read()
|
51 |
+
print(content)
|
52 |
+
except Exception as e2:
|
53 |
+
emsg = str(e2)
|
54 |
+
logger.error(f"#### Displaying startup.log EXCEPTION. e2: {emsg}")
|
55 |
logger.info("### Running startup.sh complete")
|
56 |
if 'runStartup' not in st.session_state:
|
57 |
st.session_state.runStartup = True
|
|
|
89 |
######################################################
|
90 |
# Connect to the Weaviate vector database.
|
91 |
#if 'client' not in st.session_state:
|
92 |
+
if not st.session_state.client:
|
93 |
+
logger.info("#### Create Weaviate db client connection.")
|
94 |
+
client = weaviate.WeaviateClient(
|
95 |
+
connection_params=ConnectionParams.from_params(
|
96 |
+
http_host="localhost",
|
97 |
+
http_port="8080",
|
98 |
+
http_secure=False,
|
99 |
+
grpc_host="localhost",
|
100 |
+
grpc_port="50051",
|
101 |
+
grpc_secure=False
|
102 |
+
),
|
103 |
+
additional_config=AdditionalConfig(
|
104 |
+
timeout=Timeout(init=60, query=1800, insert=1800), # Values in seconds
|
105 |
+
)
|
106 |
)
|
107 |
+
client.connect()
|
108 |
+
st.session_state.client = client
|
109 |
+
else:
|
110 |
+
client = st.session_state.client
|
|
|
111 |
|
112 |
|
113 |
#######################################################
|
114 |
# Read each text input file, parse it into a document,
|
115 |
# chunk it, collect chunks and document name.
|
116 |
+
if not client.collections.exists("Documents") or not client.collections.exists("Documes") :
|
117 |
logger.info("#### Read and chunk input text files.")
|
118 |
for filename in os.listdir(pathString):
|
119 |
logger.info(filename)
|