Skip to content

Commit

Permalink
log add context
Browse files Browse the repository at this point in the history
  • Loading branch information
zgqgit committed Jan 19, 2024
1 parent 0aa5000 commit b3a7501
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV HTTPS_PROXY=
RUN mkdir -p /opt/bisheng-unstructured/bin
COPY ./docker/entrypoint.sh /opt/bisheng-unstructured/bin/
COPY config /opt/bisheng-unstructured/
COPY ./src/bisheng_unstructured/ /opt/bisheng-unstructured/
COPY ./src/ /opt/bisheng-unstructured/

# FIX the high risk scan
RUN rm -f /opt/texlive/2023/texmf-dist/scripts/tlcockpit/tlcockpit.jar
Expand Down
9 changes: 4 additions & 5 deletions src/bisheng_unstructured/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def update_config(inp: ConfigInput):

if inp.rt_ep is not None:
# update environment
os.environ['rt_server'] = inp.rt_ep
os.environ["rt_server"] = inp.rt_ep
pdf_model_params = {}
for k, v in pdf_model_params_temp.items():
pdf_model_params[k] = v.format(inp.rt_ep)
Expand All @@ -81,7 +81,7 @@ async def update_config(inp: ConfigInput):
config_dict = inp.dict()

# update persist data
with open(config_file, 'wb') as file:
with open(config_file, "wb") as file:
file.write(json.loads(config_dict))

pipeline.update_config(config_dict)
Expand All @@ -95,7 +95,6 @@ async def config():

@app.post("/v1/etl4llm/predict", response_model=UnstructuredOutput)
async def etl4_llm(inp: UnstructuredInput):

filename = inp.filename
b64_data = inp.b64_data
file_type = filename.rsplit(".", 1)[1].lower()
Expand All @@ -114,8 +113,8 @@ async def etl4_llm(inp: UnstructuredInput):
with open(file_path, "wb") as fout:
fout.write(base64.b64decode(b64_data[0]))
except Exception:
logger.error(f"b64_data is damaged filename=[{inp.filename}]")
return Exception(f"b64_data is damaged")
logger.error(f"b64_data is damaged filename=[{inp.filename}]", exc_info=True)
raise Exception(f"b64_data is damaged")
else:
headers = inp.parameters.get("headers", {})
ssl_verify = inp.parameters.get("ssl_verify", True)
Expand Down
5 changes: 2 additions & 3 deletions src/bisheng_unstructured/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ def partition_image(filename, model_params, **kwargs):


class Pipeline(object):

def __init__(self, config_file: str):
''' k8s 使用cm 创建环境变量'''
"""k8s 使用cm 创建环境变量"""
tmp_dict = json.load(open(config_file))
rt_ep = os.getenv("rt_server")
if rt_ep:
Expand Down Expand Up @@ -89,7 +88,7 @@ def to_pdf(self, inp: UnstructuredInput) -> UnstructuredOutput:
result = UnstructuredOutput(b64_pdf=output)
return result
except Exception as e:
logger.error(f"error in topdf filename=[{inp.filename}] err=[{e}]")
logger.error(f"error in topdf filename=[{inp.filename}] err=[{e}]", exc_info=True)
return UnstructuredOutput(status_code=400, status_message=str(e))

def predict(self, inp: UnstructuredInput) -> UnstructuredOutput:
Expand Down

0 comments on commit b3a7501

Please sign in to comment.