MVPilgrim commited on
Commit
fbd7ce3
·
1 Parent(s): ae54c88
Files changed (1) hide show
  1. app.py +29 -20
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
- logger.error(f"subprocess.run() encountered error.")
 
 
 
 
 
 
 
 
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
- logger.info("#### Create Weaviate db client connection.")
85
- client = weaviate.WeaviateClient(
86
- connection_params=ConnectionParams.from_params(
87
- http_host="localhost",
88
- http_port="8080",
89
- http_secure=False,
90
- grpc_host="localhost",
91
- grpc_port="50051",
92
- grpc_secure=False
93
- ),
94
- additional_config=AdditionalConfig(
95
- timeout=Timeout(init=60, query=1800, insert=1800), # Values in seconds
 
 
96
  )
97
- )
98
- client.connect()
99
- # st.session_state.client = client
100
- #else:
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("Documents") :
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)