mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 22:07:10 +00:00
some lol and keks
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
REGISTRY_LOGIN=devitq
|
||||
REGISTRY_PASSWORD=14zQrbzDTM0WXK@CogMQikAvP74Rj4
|
||||
REGISTRY_PASSWORD=prod-zAoUDyHwkgRfQPyVvskH
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Change all vars before going to production and remove all comments (!)
|
||||
# Below all environment variables and default values
|
||||
|
||||
REGISTRY_USERNAME=
|
||||
|
||||
REGISTRY_PASSWORD=
|
||||
|
||||
REGISTRY_URL=gitlab.prodcontest.ru:5050
|
||||
|
||||
DOCKER_IMAGE=gitlab.prodcontest.ru:5050/team-15/project/custom-python
|
||||
@@ -14,5 +14,5 @@ REGISTRY_PASSWORD = os.getenv("REGISTRY_USERNAME", None)
|
||||
REGISTRY_URL = os.getenv("REGISTRY_URL", "gitlab.prodcontest.ru:5050")
|
||||
|
||||
DOCKER_IMAGE = os.getenv(
|
||||
"IMAGE", default="gitlab.prodcontest.ru:5050/team-15/project/custom-python"
|
||||
"DOCKER_IMAGE", default="gitlab.prodcontest.ru:5050/team-15/project/custom-python"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import docker.errors
|
||||
from fastapi import FastAPI, HTTPException, status
|
||||
from pydantic import BaseModel, Field, HttpUrl, constr
|
||||
from pydantic import BaseModel, Field, HttpUrl
|
||||
import aiohttp
|
||||
import asyncio
|
||||
import docker
|
||||
@@ -20,13 +21,24 @@ ALLOWED_FILENAME_CHARS = r"[^a-zA-Z0-9_\-.]"
|
||||
|
||||
app = FastAPI()
|
||||
docker_client = docker.from_env()
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
docker_client.login(
|
||||
username=config.REGISTRY_LOGIN,
|
||||
password=config.REGISTRY_PASSWORD,
|
||||
registry=config.REGISTRY_URL,
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def pull_docker_image():
|
||||
client = docker.from_env()
|
||||
image_name = config.DOCKER_IMAGE
|
||||
try:
|
||||
client.images.pull(image_name)
|
||||
print(f"Successfully pulled {image_name}")
|
||||
except docker.errors.DockerException as e:
|
||||
print(f"Error pulling {image_name}: {e}")
|
||||
|
||||
|
||||
class FileDetails(BaseModel):
|
||||
@@ -93,9 +105,7 @@ async def download_file(
|
||||
session: aiohttp.ClientSession, url: str, dest_path: str
|
||||
) -> None:
|
||||
try:
|
||||
async with session.get(
|
||||
url, timeout=aiohttp.ClientTimeout(total=30)
|
||||
) as resp:
|
||||
async with session.get(url, timeout=aiohttp.ClientTimeout(total=30)) as resp:
|
||||
if resp.status != 200:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@@ -276,9 +286,7 @@ async def execute_code(request: ExecutionRequest) -> ExecutionResponse:
|
||||
return ExecutionResponse(
|
||||
success=success,
|
||||
hash_match=(
|
||||
result_hash == request.expected_hash
|
||||
if request.expected_hash
|
||||
else None
|
||||
result_hash == request.expected_hash if request.expected_hash else None
|
||||
),
|
||||
output=output[:5000],
|
||||
result_hash=result_hash,
|
||||
|
||||
Reference in New Issue
Block a user