Skip to content

Commit 3411e07

Browse files
authored
Fix cleanup sonarqube findings (#2106)
* fix: update dockerignore and gitignore to exclude sonarqube work dir Signed-off-by: Chris Jowett <[email protected]> * fix: remove useless equality check Signed-off-by: Chris Jowett <[email protected]> * fix: use sonarqube Dockerfile recommendations Signed-off-by: Chris Jowett <[email protected]> --------- Signed-off-by: Chris Jowett <[email protected]>
1 parent 8e36fe9 commit 3411e07

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ models
55
examples/chatbot-ui/models
66
examples/rwkv/models
77
examples/**/models
8-
Dockerfile*
8+
Dockerfile*
9+
10+
# SonarQube
11+
.scannerwork

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ prepare
4444
*.pb.go
4545
*pb2.py
4646
*pb2_grpc.py
47+
48+
# SonarQube
49+
.scannerwork

Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG BASE_IMAGE=ubuntu:22.04
33
ARG GRPC_BASE_IMAGE=${BASE_IMAGE}
44

55
# extras or core
6-
FROM ${BASE_IMAGE} as requirements-core
6+
FROM ${BASE_IMAGE} AS requirements-core
77

88
USER root
99

@@ -24,7 +24,7 @@ RUN apt-get update && \
2424
apt-get install -y ca-certificates curl python3-pip unzip && apt-get clean
2525

2626
# Install Go
27-
RUN curl -L -s https://go.dev/dl/go$GO_VERSION.linux-$TARGETARCH.tar.gz | tar -C /usr/local -xz
27+
RUN curl -L -s https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -xz
2828
ENV PATH $PATH:/usr/local/go/bin
2929

3030
# Install grpc compilers
@@ -80,7 +80,7 @@ RUN test -n "$TARGETARCH" \
8080
###################################
8181
###################################
8282

83-
FROM requirements-core as requirements-extras
83+
FROM requirements-core AS requirements-extras
8484

8585
RUN apt install -y gpg && \
8686
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \
@@ -105,7 +105,7 @@ RUN if [ ! -e /usr/bin/python ]; then \
105105
###################################
106106
###################################
107107

108-
FROM ${GRPC_BASE_IMAGE} as grpc
108+
FROM ${GRPC_BASE_IMAGE} AS grpc
109109

110110
ARG MAKEFLAGS
111111
ARG GRPC_VERSION=v1.58.0
@@ -121,16 +121,15 @@ RUN apt-get update && \
121121

122122
RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc
123123

124-
RUN cd grpc && \
125-
mkdir -p cmake/build && \
126-
cd cmake/build && \
127-
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF ../.. && \
124+
WORKDIR /build/grpc/cmake/build
125+
126+
RUN cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF ../.. && \
128127
make
129128

130129
###################################
131130
###################################
132131

133-
FROM requirements-${IMAGE_TYPE} as builder
132+
FROM requirements-${IMAGE_TYPE} AS builder
134133

135134
ARG GO_TAGS="stablediffusion tts"
136135
ARG GRPC_BACKENDS
@@ -168,9 +167,11 @@ RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
168167

169168
COPY --from=grpc /build/grpc ./grpc/
170169

171-
RUN cd /build/grpc/cmake/build && make install
170+
WORKDIR /build/grpc/cmake/build
171+
RUN make install
172172

173173
# Rebuild with defaults backends
174+
WORKDIR /build
174175
RUN make build
175176

176177
RUN if [ ! -d "/build/sources/go-piper/piper-phonemize/pi/lib/" ]; then \
@@ -288,7 +289,7 @@ RUN mkdir -p /build/models
288289

289290
# Define the health check command
290291
HEALTHCHECK --interval=1m --timeout=10m --retries=10 \
291-
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1
292+
CMD curl -f ${HEALTHCHECK_ENDPOINT} || exit 1
292293

293294
VOLUME /build/models
294295
EXPOSE 8080

core/http/endpoints/openai/assistant.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -455,21 +455,19 @@ func DeleteAssistantFileEndpoint(cl *config.BackendConfigLoader, ml *model.Model
455455
for i, assistant := range Assistants {
456456
if assistant.ID == assistantID {
457457
for j, fileId := range assistant.FileIDs {
458-
if fileId == fileId {
459-
Assistants[i].FileIDs = append(Assistants[i].FileIDs[:j], Assistants[i].FileIDs[j+1:]...)
460-
461-
// Check if the file exists in the assistantFiles slice
462-
for i, assistantFile := range AssistantFiles {
463-
if assistantFile.ID == fileId {
464-
// Remove the file from the assistantFiles slice
465-
AssistantFiles = append(AssistantFiles[:i], AssistantFiles[i+1:]...)
466-
utils.SaveConfig(appConfig.ConfigsDir, AssistantsFileConfigFile, AssistantFiles)
467-
return c.Status(fiber.StatusOK).JSON(DeleteAssistantFileResponse{
468-
ID: fileId,
469-
Object: "assistant.file.deleted",
470-
Deleted: true,
471-
})
472-
}
458+
Assistants[i].FileIDs = append(Assistants[i].FileIDs[:j], Assistants[i].FileIDs[j+1:]...)
459+
460+
// Check if the file exists in the assistantFiles slice
461+
for i, assistantFile := range AssistantFiles {
462+
if assistantFile.ID == fileId {
463+
// Remove the file from the assistantFiles slice
464+
AssistantFiles = append(AssistantFiles[:i], AssistantFiles[i+1:]...)
465+
utils.SaveConfig(appConfig.ConfigsDir, AssistantsFileConfigFile, AssistantFiles)
466+
return c.Status(fiber.StatusOK).JSON(DeleteAssistantFileResponse{
467+
ID: fileId,
468+
Object: "assistant.file.deleted",
469+
Deleted: true,
470+
})
473471
}
474472
}
475473
}

0 commit comments

Comments
 (0)