Skip to content

Commit

Permalink
AI 스크립트 및 데이터 파일 절대경로 보정
Browse files Browse the repository at this point in the history
  • Loading branch information
SalkCoding committed Dec 18, 2024
1 parent ecf9e0b commit 27246e3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ RUN apt update && apt upgrade -y && apt install -y python3 python3-pip && \
# 작업 디렉토리 설정
WORKDIR /app

COPY ai /app/ai

# 빌드 이미지에서 생성된 JAR 파일을 런타임 이미지로 복사
COPY --from=build /app/build/libs/*.jar /app/ohlottery.jar

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

@Service
public class LotteryAINumberService {

private final URL scriptURL
= getClass().getClassLoader().getResource("ai/lottery_probability_predictor.py");

public JsonNode getAINumberResults() {
JsonNode aiNumberResults = null;

try {
ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptURL.getPath());
ProcessBuilder processBuilder = new ProcessBuilder("python3", "/app/ai/lottery_probability_predictor.py");
Process process = processBuilder.start();

BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

@Service
@RequiredArgsConstructor
public class LotteryAIPriceService {

private final URL scriptURL
= getClass().getClassLoader().getResource("ai/lottery_prediction.py");

public String executePythonPredictionScript() {
try {
// Python 스크립트 실행
ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptURL.getPath());
ProcessBuilder processBuilder = new ProcessBuilder("python3", "/app/ai/lottery_prediction.py");
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();

Expand All @@ -31,7 +27,7 @@ public String executePythonPredictionScript() {

int exitCode = process.waitFor();
if (exitCode != 0) {
throw new RuntimeException("Python 스크립트 실행 실패. Exit code: " + exitCode);
throw new RuntimeException("Python 스크립트 실행 실패. Exit code(" + exitCode + "), " + output);
}

return output.toString();
Expand Down

0 comments on commit 27246e3

Please sign in to comment.