VNOI-Admin / OJ

A modern open-source online judge and contest platform system.
https://oj.vnoi.info
GNU Affero General Public License v3.0
154 stars 70 forks source link

Lỗi khi chấm scratch #299

Closed phuleethanh closed 1 year ago

phuleethanh commented 1 year ago

Xây dựng site thành công, khi chấm các ngôn ngữ khác bình thường, tuy nhiên chấm scratch đang bị lỗi:

Một lỗi hệ thống vừa xảy ra trong quá trình chấm bài. Admin VDcoder đã được thông báo về lỗi này. Bạn có thể thử nộp lại bài trong vài giây nữa

Thông tin về lỗi Traceback (most recent call last): File "/judge/dmoj/judge.py", line 406, in _worker_process_main ipc_msg = next(case_gen) ^^^^^^^^^^^^^^ File "/judge/dmoj/judge.py", line 441, in _grade_cases self.grader = problem.grader_class( ^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/graders/base.py", line 11, in init self.binary = self._generate_binary() ^^^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/graders/standard.py", line 104, in _generate_binary return executors[self.language].Executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/executors/SCRATCH.py", line 28, in init super().init(problem_id, source_code, kwargs) File "/judge/dmoj/executors/script_executor.py", line 13, in init self.create_files(problem_id, source_code) File "/judge/dmoj/executors/SCRATCH.py", line 79, in create_files source_code = download_source_code( ^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/utils/helper_files.py", line 122, in download_source_code r = requests.get(link, stream=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/env/lib/python3.11/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/env/lib/python3.11/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/env/lib/python3.11/site-packages/requests/sessions.py", line 573, in request prep = self.prepare_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/env/lib/python3.11/site-packages/requests/sessions.py", line 484, in prepare_request p.prepare( File "/env/lib/python3.11/site-packages/requests/models.py", line 368, in prepare self.prepare_url(url, params) File "/env/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url raise MissingSchema( requests.exceptions.MissingSchema: Invalid URL '/submission_file/aplusb/1/09b3bdf0-3eeb-47f7-8d74-83bca68f7be1.json': No scheme supplied. Perhaps you meant https:///submission_file/aplusb/1/09b3bdf0-3eeb-47f7-8d74-83bca68f7be1.json?

Mình nghĩ là phần cài đặt site để chấm scratch đang sai ở đâu đó, rất mong admin chỉ giúp cách sửa lỗi này?

phuleethanh commented 1 year ago

Sau khi mình đổi từ node18 sang thành node16 thì nó chấm nhưng báo lỗi khác thế này: Traceback (most recent call last): File "/judge/dmoj/judge.py", line 406, in _worker_process_main ipc_msg = next(case_gen) ^^^^^^^^^^^^^^ File "/judge/dmoj/judge.py", line 441, in _grade_cases self.grader = problem.grader_class( ^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/graders/base.py", line 11, in init self.binary = self._generate_binary() ^^^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/graders/standard.py", line 104, in _generate_binary return executors[self.language].Executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/executors/SCRATCH.py", line 28, in init super().init(problem_id, source_code, **kwargs) File "/judge/dmoj/executors/script_executor.py", line 13, in init self.create_files(problem_id, source_code) File "/judge/dmoj/executors/SCRATCH.py", line 79, in create_files source_code = download_source_code( ^^^^^^^^^^^^^^^^^^^^^ File "/judge/dmoj/utils/helper_files.py", line 126, in download_source_code raise InternalError(repr(e)) dmoj.error.InternalError: HTTPError('404 Client Error: Not Found for url: http://vdcoder.hopto.org/submission_file/aplusb/1/7a54d31a-2c85-4c50-af7a-de06b7707fcd.json')

hieplpvip commented 1 year ago

Chào thầy,

Thầy đã setup MEDIA_ROOT trong nginx.conf chưa ạ?

https://github.com/VNOI-Admin/vnoj-docs/blob/eed4dfa8e6c82537e7b5763ca474c9d53c8582f4/sample_files/nginx.conf#L46-L62

phuleethanh commented 1 year ago

Xin hỏi cái MEDIA_ROOT này phải set như thế nào? Mình đã thử đặt root /root/site/; với site là thư mục đã đổi tên từ OJ thành sau khi clone về. Và một số cách khác nhưng chưa được. Mình thấy trong thư mục site có thư mục submission_file

hieplpvip commented 1 year ago

Thầy set giống MEDIA_ROOT trong local_settings.py

phuleethanh commented 1 year ago

Trong local_settings.py: MEDIA_ROOT = '/tmp/media' Trong nginx.conf: mình set thế này location /submission_file { alias /tmp/media/; } Khi nộp bài thì thấy trong thư mục /tmp/media vẫn có thư mục submission_file. Nhưng vẫn chưa chấm được. Xin hỏi phải sửa tiếp thế nào vậy?

hieplpvip commented 1 year ago

Thầy set thế này ạ:

location /submission_file {
  root/tmp/media/;
}

Với lại thầy nên để MEDIA_ROOT ở chỗ khác vì /tmp/ sẽ bị xoá lúc reboot

phuleethanh commented 1 year ago

Trong local_settings.py mình để: MEDIA_ROOT = '/media/' Trong nginx.conf mình thêm 3 cái này: location /martor { root /media/; } location /pdf { root /media/; } location /submission_file { root /media/; } Thế đã sửa hết 3 lỗi: up ảnh bài viết thành công, tạo bài từ tệp pdf thành công, chấm scratch thành công. Cảm ơn Hiệp đã hỗ trợ rất nhiều.

long-nguyen12 commented 4 months ago

Thầy set thế này ạ:

location /submission_file {
  root/tmp/media/;
}

Với lại thầy nên để MEDIA_ROOT ở chỗ khác vì /tmp/ sẽ bị xoá lúc reboot

Chào các thầy ạ. Hiện tại em đang setup một server để chấm scratch nhưng đang gặp lỗi như mình ạ. Em đã thử các bước như trên nhưng vẫn không thành công. Rất mong được cac thầy hỗ trợ ạ. Dưới đây là file config nginx của em ạ.

server {
        #listen 443 ssl;
        listen 80;
        server_name <>;

        location / {
            proxy_pass http://192.168.1.1:8000;
        }
        location ~ /\. {
            deny all;
            return 404;
        }
        location /martor {
            root /mnt/media/;
        }
        location /pdf {
            root /mnt/media/;
        }
        location /submission_file {
            root /mnt/media/;
        }
    }
phuleethanh commented 4 months ago

Bạn thử xoá mnt đi, để lại root /media/; xem sao

long-nguyen12 commented 4 months ago

Bạn thử xoá mnt đi, để lại root /media/; xem sao

Em đã xoá mnt thử lại với root /media/; vẫn không được ạ. Các file đều đã được up lên nhưng không thể chấm ạ

long-nguyen12 commented 4 months ago

Bạn thử xoá mnt đi, để lại root /media/; xem sao

Thầy cho em hỏi là thầy còn config gì về MEDIA không ạ

phuleethanh commented 4 months ago

File nginx dạo trước của mình đây

server { listen 80; listen [::]:80;

server_name 103.179.173.167;

add_header X-UA-Compatible "IE=Edge,chrome=1";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

#Them cai nay: de cho phep test kich thuoc toi da 30MB
client_max_body_size 48M;

charset utf-8;
try_files $uri @icons;
error_page 502 504 /502.html;

location ~ ^/502\.html$|^/logo\.png$|^/robots\.txt$ {
    root /root/site/;
}

location @icons {
    root /root/site/resources/icons;
    error_page 403 = @uwsgi;
    error_page 404 = @uwsgi;
}

location @uwsgi {
    uwsgi_read_timeout 600;
    # Change this path if you did so in uwsgi.ini
    uwsgi_pass unix:///tmp/dmoj-site.sock;
    include uwsgi_params;
    uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}

location /static {
    gzip_static on;
    expires max;
    # root /root/site;
    # Comment out root, and use the following if it doesn't end in /static.
    alias /tmp/static/;
}
#3 cai sau la phai co: khong la loi cham scratch, loi upanh, loi pdf
location /martor {
    root /media/;
}

location /pdf {
    root /media/;
}

location /submission_file {
    root /media/;
}

# Uncomment these sections if you are using the event server.
location /event/ {
    proxy_pass http://103.179.173.167:15100/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
}

location /channels/ {
    proxy_read_timeout          120;
    proxy_pass http://103.179.173.167:15102;
}

}

phuleethanh commented 4 months ago

À mà bạn nên cài bằng vnoj-docker ấy, cài cái được ngay, quá trình cài cũng đơn giản hơn nhiều nữa

long-nguyen12 commented 4 months ago

File nginx dạo trước của mình đây

server { listen 80; listen [::]:80;

server_name 103.179.173.167;

add_header X-UA-Compatible "IE=Edge,chrome=1";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

#Them cai nay: de cho phep test kich thuoc toi da 30MB
client_max_body_size 48M;

charset utf-8;
try_files $uri @icons;
error_page 502 504 /502.html;

location ~ ^/502\.html$|^/logo\.png$|^/robots\.txt$ {
    root /root/site/;
}

location @icons {
    root /root/site/resources/icons;
    error_page 403 = @uwsgi;
    error_page 404 = @uwsgi;
}

location @uwsgi {
    uwsgi_read_timeout 600;
    # Change this path if you did so in uwsgi.ini
    uwsgi_pass unix:///tmp/dmoj-site.sock;
    include uwsgi_params;
    uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
}

location /static {
    gzip_static on;
    expires max;
    # root /root/site;
    # Comment out root, and use the following if it doesn't end in /static.
    alias /tmp/static/;
}
#3 cai sau la phai co: khong la loi cham scratch, loi upanh, loi pdf
location /martor {
    root /media/;
}

location /pdf {
    root /media/;
}

location /submission_file {
    root /media/;
}

# Uncomment these sections if you are using the event server.
location /event/ {
    proxy_pass http://103.179.173.167:15100/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
}

location /channels/ {
    proxy_read_timeout          120;
    proxy_pass http://103.179.173.167:15102;
}

}

thầy cho em hỏi là file .conf của nginx thầy để ở đâu vậy ạ