diff --git a/docs/README.md b/docs/README.md index 4b56b64..0c6c2c2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1,41 @@ -# DataRush Docs +# Website + +This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. + +### Installation + +``` +$ yarn +``` + +### Local Development + +``` +$ yarn start +``` + +This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. + +### Build + +``` +$ yarn build +``` + +This command generates static content into the `build` directory and can be served using any static contents hosting service. + +### Deployment + +Using SSH: + +``` +$ USE_SSH=true yarn deploy +``` + +Not using SSH: + +``` +$ GIT_USER= yarn deploy +``` + +If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. diff --git a/services/backend/apps/competition/models.py b/services/backend/apps/competition/models.py index 1a114b9..4a9bf78 100644 --- a/services/backend/apps/competition/models.py +++ b/services/backend/apps/competition/models.py @@ -47,9 +47,6 @@ class Competition(BaseModel): def __str__(self): return self.title - - @property - def class Meta: verbose_name = "соревнование" diff --git a/services/backend/apps/task/tasks.py b/services/backend/apps/task/tasks.py index a9f5ad6..9899246 100644 --- a/services/backend/apps/task/tasks.py +++ b/services/backend/apps/task/tasks.py @@ -19,7 +19,6 @@ ALLOWED_MODULES = { "csv", "math", "statistics", - "statsmodels", } @@ -64,28 +63,18 @@ def validate_code(code_str): raise SecurityException(f"Security check failed: {e!s}") -def secure_exec(code_str, result_path, input_files=None): +def secure_exec(code_str, result_path): original_dir = os.getcwd() original_stdout = sys.stdout sys.stdout = captured_stdout = StringIO() result_content = None - if input_files is None: - input_files = [] - with tempfile.TemporaryDirectory() as temp_dir: try: os.chdir(temp_dir) - - for file in input_files: - file_path = os.path.join(temp_dir, file["bind_at"]) - os.makedirs(os.path.dirname(file_path), exist_ok=True) - with open(file_path, "wb") as f: - f.write(file["content"]) - restricted_globals = { "__builtins__": { - "open": open, + "open": lambda f, *a, **kw: open(f, *a, **kw), "print": print, "str": str, "int": int, @@ -116,15 +105,11 @@ def secure_exec(code_str, result_path, input_files=None): @app.task(bind=True) -def analyze_data_task( - self, code_str, result_path, expected_bytes, input_files=[] -): +def analyze_data_task(self, code_str, result_path, expected_bytes): try: validate_code(code_str) - result_content = secure_exec(code_str, result_path, input_files) - - print(result_content * 1024) + result_content = secure_exec(code_str, result_path) result_hash = hashlib.sha256(result_content).hexdigest() expected_hash = hashlib.sha256(expected_bytes).hexdigest() diff --git a/services/backend/apps/task/tests/__init__.py b/services/backend/apps/task/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/services/backend/apps/task/tests/test_tasks.py b/services/backend/apps/task/tests/test_tasks.py deleted file mode 100644 index b61bb11..0000000 --- a/services/backend/apps/task/tests/test_tasks.py +++ /dev/null @@ -1,30 +0,0 @@ -import unittest - -from apps.task.tasks import analyze_data_task - - -class TestAnalyzeDataTask(unittest.TestCase): - def test_task_execution_basic(self): - code_str = 'print("Hello, World!")' - result_path = "stdout" - expected_bytes = b"Hello, World!\n" - result = analyze_data_task(code_str, result_path, expected_bytes) - self.assertTrue(result["success"]) - self.assertTrue(result["match"]) - - def test_task_execution_with_files(self): - code_str = """ -with open("file.txt") as f: - print(f.read()) - """ - result_path = "stdout" - expected_bytes = b"some_content\n" - result = analyze_data_task( - code_str, - result_path, - expected_bytes, - input_files=[{"bind_at": "file.txt", "content": b"some_content"}], - ) - print(result) - self.assertTrue(result["success"]) - self.assertTrue(result["match"])