Skip to content

Commit

Permalink
Set _env_status earlier when updating settings (#499)
Browse files Browse the repository at this point in the history
* Set _env_status earlier when updating settings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
david-yz-liu and pre-commit-ci[bot] authored Apr 2, 2024
1 parent 04c71d7 commit 77ecd57
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented here.
## [v2.4.1]
- Fix bug that prevented copies of instructor directories from being deleted (#483)
- Add STACK_ROOT to containers as well as notes in readme (#484)
- Ensure _env_status is updated to "setup" earlier when a request to update test settings is made (#499)

## [v2.4.0]
- Fix bug that prevented test results from being returned when a feedback file could not be found (#458)
Expand Down
10 changes: 9 additions & 1 deletion client/autotest_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from werkzeug.exceptions import HTTPException
import os
import sys
import time
import rq
import json
import io
Expand Down Expand Up @@ -108,6 +109,11 @@ def _update_settings(settings_id, user):
if error:
abort(make_response(jsonify(message=error), 422))

test_settings["_user"] = user
test_settings["_last_access"] = int(time.time())
test_settings["_env_status"] = "setup"
REDIS_CONNECTION.hset("autotest:settings", key=settings_id, value=json.dumps(test_settings))

queue = rq.Queue("settings", connection=REDIS_CONNECTION)
data = {"user": user, "settings_id": settings_id, "test_settings": test_settings, "file_url": file_url}
queue.enqueue_call(
Expand Down Expand Up @@ -198,7 +204,9 @@ def settings(settings_id, **_kw):
@authorize
def create_settings(user):
settings_id = REDIS_CONNECTION.incr("autotest:settings_id")
REDIS_CONNECTION.hset("autotest:settings", key=settings_id, value=json.dumps({"_user": user}))
REDIS_CONNECTION.hset(
"autotest:settings", key=settings_id, value=json.dumps({"_user": user, "_env_status": "setup"})
)
_update_settings(settings_id, user)
return {"settings_id": settings_id}

Expand Down
5 changes: 0 additions & 5 deletions server/autotest_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,6 @@ def ignore_missing_dir_error(


def update_test_settings(user, settings_id, test_settings, file_url):
test_settings["_user"] = user
test_settings["_last_access"] = int(time.time())
test_settings["_env_status"] = "setup"
redis_connection().hset("autotest:settings", key=settings_id, value=json.dumps(test_settings))

try:
settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id))

Expand Down

0 comments on commit 77ecd57

Please sign in to comment.