Делаю сейв, тут запускается FastAPI.
This commit is contained in:
parent
57b2836861
commit
f709052990
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM python:3.9-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
@ -1,5 +1,5 @@
|
||||
paths:
|
||||
starccm: '/home/user/Siemens/19.02.009-R8/STAR-CCM+19.02.009-R8/star/bin/starccm+'
|
||||
starccm: 'C:/Program Files/Siemens/19.04.007-R8/STAR-CCM+19.04.007-R8/star/bin/starccm+'
|
||||
chemkin: '/media/user/Projects/burner_data/chemkin'
|
||||
main: '/media/user/Data/experiment_data'
|
||||
|
||||
|
@ -25,6 +25,17 @@ services:
|
||||
volumes:
|
||||
- clickhouse_data:/var/lib/clickhouse
|
||||
|
||||
fastapi:
|
||||
build: .
|
||||
container_name: fastapi-app
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
- db
|
||||
- clickhouse
|
||||
volumes:
|
||||
- .:/app # Связываем текущую директорию с контейнером для доступа к коду
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
clickhouse_data:
|
||||
|
31
main.py
Normal file
31
main.py
Normal file
@ -0,0 +1,31 @@
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
from new_experiment_planner import run_experiment # Импортируем функцию из твоего скрипта
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Модель данных для передачи параметров
|
||||
class ExperimentParameters(BaseModel):
|
||||
outer_blades_count: str
|
||||
outer_blades_length: str
|
||||
outer_blades_angle: str
|
||||
middle_blades_count: str
|
||||
load: str
|
||||
recycling: str
|
||||
|
||||
# Эндпоинт для запуска эксперимента
|
||||
@app.post("/run_experiment/")
|
||||
def run_experiment_api(params: ExperimentParameters):
|
||||
try:
|
||||
# Вызываем функцию run_experiment с параметрами
|
||||
run_experiment(
|
||||
params.outer_blades_count,
|
||||
params.outer_blades_length,
|
||||
params.outer_blades_angle,
|
||||
params.middle_blades_count,
|
||||
params.load,
|
||||
params.recycling
|
||||
)
|
||||
return {"status": "success", "message": "Experiment started successfully."}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"An error occurred: {str(e)}")
|
@ -210,6 +210,7 @@ def run_experiment(outer_blades_count, outer_blades_length, outer_blades_angle,
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="Запуск экспериментов с энергетической установкой ГМУ-45")
|
||||
parser.add_argument("outer_blades_count", type=str, help="Количество лопаток во внешнем контуре")
|
||||
parser.add_argument("outer_blades_length", type=str, help="Ширина лопаток во внешнем контуре")
|
||||
@ -220,5 +221,11 @@ if __name__ == "__main__":
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
run_experiment(args.outer_blades_count, args.outer_blades_length, args.outer_blades_angle, args.middle_blades_count,
|
||||
args.load, args.recycling)
|
||||
run_experiment(
|
||||
args.outer_blades_count,
|
||||
args.outer_blades_length,
|
||||
args.outer_blades_angle,
|
||||
args.middle_blades_count,
|
||||
args.load,
|
||||
args.recycling
|
||||
)
|
||||
|
@ -5,4 +5,6 @@ psycopg[binary]
|
||||
clickhouse-driver
|
||||
pandas
|
||||
pydantic-settings
|
||||
clickhouse-connect
|
||||
clickhouse-connect
|
||||
fastapi
|
||||
uvicorn
|
Loading…
Reference in New Issue
Block a user