From c5e93f9852da23f0cf9b198346321595b60c15e9 Mon Sep 17 00:00:00 2001 From: Jeff Rhoades <37990507+rhoadesScholar@users.noreply.github.com> Date: Mon, 28 Apr 2025 16:32:20 -0400 Subject: [PATCH 01/23] Add percent completion property to Evaluation model and update version template for status display Implement download_results view for evaluation results in JSON format Update .gitignore to include VS Code specific files --- .gitignore | 4 ++ frx_challenges/web/models.py | 18 ++++++ frx_challenges/web/templates/version.html | 72 ++++++++++++++--------- frx_challenges/web/views/versions.py | 23 ++++++++ 4 files changed, 88 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 23ff20a..253c6a9 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,7 @@ cython_debug/ # MyST _build + +# VS Code +.DS_Store +.vscode/ \ No newline at end of file diff --git a/frx_challenges/web/models.py b/frx_challenges/web/models.py index f7c1ca8..a6b0306 100644 --- a/frx_challenges/web/models.py +++ b/frx_challenges/web/models.py @@ -144,6 +144,24 @@ def ordered_results(self) -> list: results_list.append(None) return results_list + @property + def percent_complete(self) -> str: + """ + Return the percentage of completion of this evaluation + """ + if self.status == Evaluation.Status.EVALUATED: + return "100%" + elif self.status == Evaluation.Status.EVALUATING: + if self.result: + percent_complete = self.result.get( + "num_evals_done", 0 + ) / self.result.get("total_evals", 1) + return f"{int(percent_complete * 100)}%" + else: + return "0%" + else: + return "0%" + def __str__(self): return f"({self.status}) {self.result} {self.version.data_uri}" diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 211cbd6..68ee29a 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -1,36 +1,50 @@ {% extends "page.html" %} {% load static %} {% block body %} -
-

- Version {{ version.id }} for - {{ version.submission.name }} -

-
-
- Status: {{ evaluation.status }} - {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} - - Check for updates - - {% endif %} -
-
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} ago -
-
-
-

Result

- {% if evaluation.status == 'EVALUATED' %} - {% for result_item in results_display %} -
- {{ result_item.display_name }} -

{{ result_item.value }}

-
- {% endfor %} +
+

+ Version {{ version.id }} for + {{ version.submission.name }} +

+
+
+ Status: + {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} + {% if evaluation.status == "EVALUATING" %} + {{ evaluation.percent_complete }} evaluated {% else %} -
Evaluation results will be displayed here once completed
+ {{ evaluation.status }} {% endif %} + + Check for updates + + {% else %} + {{ evaluation.status }} + {% endif %} +
+
+ {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago +
+
+
+

Result

+ {% if is_collaborator %} + + {% endif %} + {% if evaluation.status == 'EVALUATED' %} + {% for result_item in results_display %} +
+ {{ result_item.display_name }} +

{{ result_item.value }}

+ {% endfor %} + {% else %} +
Evaluation results will be displayed here once completed
+ {% endif %}
-{% endblock body %} +
+{% endblock body %} \ No newline at end of file diff --git a/frx_challenges/web/views/versions.py b/frx_challenges/web/views/versions.py index f8229d2..32edd70 100644 --- a/frx_challenges/web/views/versions.py +++ b/frx_challenges/web/views/versions.py @@ -1,3 +1,4 @@ +import json import os import tempfile @@ -51,6 +52,28 @@ def upload(request: HttpRequest, id: int) -> HttpResponse: ) +@login_required +def download_results(request: HttpRequest, id: int) -> HttpResponse: + version = Version.objects.get(id=id) + is_collaborator = _validate_collaborator(request, version.submission.id) + if not is_collaborator: + raise Http404( + "Full results files are only available to submission collaborators." + ) + evaluation = version.latest_evaluation + if not evaluation.result: + raise Http404("No results available for this version.") + + # Create a JSON response from the evaluation results + response = HttpResponse( + content_type="application/json", + ) + response["Content-Disposition"] = f'attachment; filename="results_{id}.json"' + + response.write(json.dumps(evaluation.result, indent=4)) + return response + + def view(request: HttpRequest, id: int) -> HttpResponse: version = Version.objects.get(id=id) evaluation = version.latest_evaluation From 921bc8f28456ab73519aca552563ee6494186201 Mon Sep 17 00:00:00 2001 From: Jeff Rhoades <37990507+rhoadesScholar@users.noreply.github.com> Date: Mon, 28 Apr 2025 17:11:39 -0400 Subject: [PATCH 02/23] Fix download results URL path and update link in version template --- frx_challenges/web/templates/version.html | 2 +- frx_challenges/web/urls.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 68ee29a..30d0e71 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -31,7 +31,7 @@

Result

{% if is_collaborator %} {% endif %} diff --git a/frx_challenges/web/urls.py b/frx_challenges/web/urls.py index 9a9bc4d..b1c31be 100644 --- a/frx_challenges/web/urls.py +++ b/frx_challenges/web/urls.py @@ -4,6 +4,9 @@ urlpatterns = [ path("upload/", versions.upload, name="upload"), + path( + "download-results/", versions.download_results, name="download-results" + ), path("page/", pages.view, name="page-view"), path("file/", pages.content_file, name="content-file"), path("leaderboard", default.leaderboard, name="leaderboard"), From 51708574cb9a41bbc514cf1061d72af641d4668f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 21:12:46 +0000 Subject: [PATCH 03/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .gitignore | 2 +- .../web/static/webpack-output/main.css | 27 +++--- frx_challenges/web/templates/version.html | 85 ++++++++++--------- 3 files changed, 59 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index 253c6a9..5f88199 100644 --- a/.gitignore +++ b/.gitignore @@ -166,4 +166,4 @@ _build # VS Code .DS_Store -.vscode/ \ No newline at end of file +.vscode/ diff --git a/frx_challenges/web/static/webpack-output/main.css b/frx_challenges/web/static/webpack-output/main.css index 11c68d3..7c78302 100644 --- a/frx_challenges/web/static/webpack-output/main.css +++ b/frx_challenges/web/static/webpack-output/main.css @@ -71,11 +71,13 @@ --bs-dark-border-subtle: #adb5bd; --bs-white-rgb: 255, 255, 255; --bs-black-rgb: 0, 0, 0; - --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, - "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, - "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; - --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, - "Liberation Mono", "Courier New", monospace; + --bs-font-sans-serif: + system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", + "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", + "Segoe UI Symbol", "Noto Color Emoji"; + --bs-font-monospace: + SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", + monospace; --bs-gradient: linear-gradient( 180deg, rgba(255, 255, 255, 0.15), @@ -2167,8 +2169,8 @@ textarea.form-control-lg { -moz-appearance: none; appearance: none; background-color: var(--bs-body-bg); - background-image: var(--bs-form-select-bg-img), - var(--bs-form-select-bg-icon, none); + background-image: + var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px 12px; @@ -2878,8 +2880,8 @@ textarea.form-control.is-invalid { --bs-btn-border-color: transparent; --bs-btn-border-radius: var(--bs-border-radius); --bs-btn-hover-border-color: transparent; - --bs-btn-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), - 0 1px 1px rgba(0, 0, 0, 0.075); + --bs-btn-box-shadow: + inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075); --bs-btn-disabled-opacity: 0.65; --bs-btn-focus-box-shadow: 0 0 0 0.25rem rgba(var(--bs-btn-focus-shadow-rgb), 0.5); @@ -4422,9 +4424,10 @@ fieldset:disabled .btn { .accordion { --bs-accordion-color: var(--bs-body-color); --bs-accordion-bg: var(--bs-body-bg); - --bs-accordion-transition: color 0.15s ease-in-out, - background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, - box-shadow 0.15s ease-in-out, border-radius 0.15s ease; + --bs-accordion-transition: + color 0.15s ease-in-out, background-color 0.15s ease-in-out, + border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, + border-radius 0.15s ease; --bs-accordion-border-color: var(--bs-border-color); --bs-accordion-border-width: var(--bs-border-width); --bs-accordion-border-radius: var(--bs-border-radius); diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 30d0e71..f705af7 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -1,50 +1,51 @@ {% extends "page.html" %} {% load static %} {% block body %} -
-

- Version {{ version.id }} for - {{ version.submission.name }} -

-
-
- Status: - {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} - {% if evaluation.status == "EVALUATING" %} - {{ evaluation.percent_complete }} evaluated - {% else %} - {{ evaluation.status }} +
+

+ Version {{ version.id }} for + {{ version.submission.name }} +

+
+
+ Status: + {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} + {% if evaluation.status == "EVALUATING" %} + {{ evaluation.percent_complete }} evaluated + {% else %} + {{ evaluation.status }} + {% endif %} + + Check for updates + + {% else %} + {{ evaluation.status }} + {% endif %} +
+
+ {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago +
+
+
+

Result

+ {% if is_collaborator %} + {% endif %} - - Check for updates - + {% if evaluation.status == 'EVALUATED' %} + {% for result_item in results_display %} +
+ {{ result_item.display_name }} +

{{ result_item.value }}

+
+ {% endfor %} {% else %} - {{ evaluation.status }} +
Evaluation results will be displayed here once completed
{% endif %}
-
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} - ago -
-
-
-

Result

- {% if is_collaborator %} - - {% endif %} - {% if evaluation.status == 'EVALUATED' %} - {% for result_item in results_display %} -
- {{ result_item.display_name }} -

{{ result_item.value }}

-
- {% endfor %} - {% else %} -
Evaluation results will be displayed here once completed
- {% endif %}
-
-{% endblock body %} \ No newline at end of file +{% endblock body %} From f41f1542f3c7964e3b01cd58be7ab2ef546faa12 Mon Sep 17 00:00:00 2001 From: jnywong Date: Sun, 15 Jun 2025 16:01:36 +0100 Subject: [PATCH 04/23] Add GHA to build image on PR request --- .github/workflows/build-image.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/build-image.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..30c3ae9 --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,30 @@ +name: Build and push image on PR + +on: + pull_request: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: cleanup disk space + run: | + sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc + df -h + + - name: Checkout files in repo + uses: actions/checkout@main + + - name: Build the image and push to quay.io if not a pull request + uses: jupyterhub/repo2docker-action@master + with: + DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + DOCKER_REGISTRY: "quay.io" + LATEST_TAG_OFF: true + IMAGE_NAME: "2i2c-org/frx-challenges" + + - name: Show how much disk space is left + run: df -h From f1c986b7675deed02b1d68e8b3e0c3b80fb2ba62 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 09:48:13 +0100 Subject: [PATCH 05/23] Add GHA to build image on PR request --- .github/workflows/build-image.yaml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 30c3ae9..da5c0de 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -2,12 +2,19 @@ name: Build and push image on PR on: pull_request: + paths-ignore: + - "docs/**" + - "**.md" + - ".github/workflows/*" + - "!.github/workflows/publish-chart.yaml" branches: - main jobs: build-and-push: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: cleanup disk space run: | @@ -17,7 +24,24 @@ jobs: - name: Checkout files in repo uses: actions/checkout@main - - name: Build the image and push to quay.io if not a pull request + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Set up QEMU (for docker buildx) + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx (for chartpress multi-arch builds) + uses: docker/setup-buildx-action@v3 + + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build the image and push to quay.io uses: jupyterhub/repo2docker-action@master with: DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} From 864c23cf02740a0f926a2982b8b9d370661549af Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 11:06:52 +0100 Subject: [PATCH 06/23] Update publish-chart.yaml --- .github/workflows/publish-chart.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml index a371a3f..8f149ac 100644 --- a/.github/workflows/publish-chart.yaml +++ b/.github/workflows/publish-chart.yaml @@ -5,12 +5,6 @@ name: Publish chart # Trigger the workflow on pushed tags or commits to main branch. on: - pull_request: - paths-ignore: - - "docs/**" - - "**.md" - - ".github/workflows/*" - - "!.github/workflows/publish-chart.yaml" push: paths-ignore: - "docs/**" From 7b20dc1ec230b3f6d5b2c6a5c5838454efccd869 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 11:14:11 +0100 Subject: [PATCH 07/23] Remove docker login action --- .github/workflows/build-image.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index da5c0de..3ee0532 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -34,13 +34,6 @@ jobs: - name: Set up Docker Buildx (for chartpress multi-arch builds) uses: docker/setup-buildx-action@v3 - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - - name: Build the image and push to quay.io uses: jupyterhub/repo2docker-action@master with: From 743d351cf7eda6ceac0bab159daa8f7b35391ea4 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 11:23:19 +0100 Subject: [PATCH 08/23] Add login action back --- .github/workflows/build-image.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 3ee0532..da5c0de 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -34,6 +34,13 @@ jobs: - name: Set up Docker Buildx (for chartpress multi-arch builds) uses: docker/setup-buildx-action@v3 + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + - name: Build the image and push to quay.io uses: jupyterhub/repo2docker-action@master with: From efb395769dcd1e89163b69315ca47c9aaa615dea Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 11:30:57 +0100 Subject: [PATCH 09/23] Regenerate robot account credentials --- .github/workflows/build-image.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index da5c0de..678e522 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -38,14 +38,14 @@ jobs: uses: docker/login-action@v3 with: registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} + username: ${{ secrets.QUAY_ROBOT_USERNAME }} + password: ${{ secrets.QUAY_ROBOT_TOKEN }} - name: Build the image and push to quay.io uses: jupyterhub/repo2docker-action@master with: - DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + DOCKER_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.QUAY_ROBOT_TOKEN }} DOCKER_REGISTRY: "quay.io" LATEST_TAG_OFF: true IMAGE_NAME: "2i2c-org/frx-challenges" From 47be808242af564b56ea390c9d48bc5ed4d53f81 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 11:38:52 +0100 Subject: [PATCH 10/23] Fix typo --- .github/workflows/build-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 678e522..05ee941 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -48,7 +48,7 @@ jobs: DOCKER_PASSWORD: ${{ secrets.QUAY_ROBOT_TOKEN }} DOCKER_REGISTRY: "quay.io" LATEST_TAG_OFF: true - IMAGE_NAME: "2i2c-org/frx-challenges" + IMAGE_NAME: "2i2c/frx-challenges" - name: Show how much disk space is left run: df -h From 1044a23a5fd4904a2927fbb194d5659f9e5c6d53 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 12:22:29 +0100 Subject: [PATCH 11/23] Publish chart on PR and push to main --- .github/workflows/publish-chart.yaml | 47 ++++++---------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml index 8f149ac..7261717 100644 --- a/.github/workflows/publish-chart.yaml +++ b/.github/workflows/publish-chart.yaml @@ -35,29 +35,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.11" - - - name: Decide to publish or not - id: publishing - shell: python - run: | - import os - repo = "${{ github.repository }}" - event = "${{ github.event_name }}" - ref = "${{ github.event.ref }}" - publishing = "" - if ( - repo == "2i2c-org/frx-challenges" - and event == "push" - and ( - ref.startswith("refs/tags/") - or ref == "refs/heads/main" - ) - ): - publishing = "true" - print("Publishing chart") - with open(os.environ["GITHUB_OUTPUT"], "a") as f: - f.write(f"publishing={publishing}\n") + python-version: "3.12" - name: Set up QEMU (for docker buildx) uses: docker/setup-qemu-action@v3 @@ -65,10 +43,12 @@ jobs: - name: Set up Docker Buildx (for chartpress multi-arch builds) uses: docker/setup-buildx-action@v3 - - name: Setup push rights to Quay.io - if: steps.publishing.outputs.publishing - run: | - docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} - name: Set up push rights to frx-challenges-helm-chart # This was setup by... @@ -80,7 +60,6 @@ jobs: # 3. Registering the public key (gh-pages.pub) as a deploy key # with push rights for the 2i2c-org/frx-challenges-helm-chart repo: # https://github.com/2i2c-org/frx-challenges-helm-chart/settings/keys - if: steps.publishing.outputs.publishing run: | mkdir -p ~/.ssh ssh-keyscan github.com >> ~/.ssh/known_hosts @@ -98,21 +77,13 @@ jobs: git config --global user.email "github-actions@github.com" git config --global user.name "github-actions" - - name: Build image, push if necessary - env: - PUBLISHING: ${{ steps.publishing.outputs.publishing }} + - name: Build image and push run: | - CHARTPRESS_ARGS="" - if [[ "${PUBLISHING}" == "true" ]]; then - CHARTPRESS_ARGS="--push" - fi chartpress \ --builder docker-buildx \ - --platform linux/amd64 --platform linux/arm64 \ - ${CHARTPRESS_ARGS} + --platform linux/amd64 --platform linux/arm64 - name: Publish chart with chartpress - if: steps.publishing.outputs.publishing run: | set -eux From 9a4dc980b1f00fe095d15fa581c77d277e73b7cd Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 12:35:25 +0100 Subject: [PATCH 12/23] Remove extra GHA --- .github/workflows/build-image.yaml | 54 ------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 .github/workflows/build-image.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml deleted file mode 100644 index 05ee941..0000000 --- a/.github/workflows/build-image.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build and push image on PR - -on: - pull_request: - paths-ignore: - - "docs/**" - - "**.md" - - ".github/workflows/*" - - "!.github/workflows/publish-chart.yaml" - branches: - - main - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: cleanup disk space - run: | - sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc - df -h - - - name: Checkout files in repo - uses: actions/checkout@main - - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Set up QEMU (for docker buildx) - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx (for chartpress multi-arch builds) - uses: docker/setup-buildx-action@v3 - - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_ROBOT_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} - - - name: Build the image and push to quay.io - uses: jupyterhub/repo2docker-action@master - with: - DOCKER_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.QUAY_ROBOT_TOKEN }} - DOCKER_REGISTRY: "quay.io" - LATEST_TAG_OFF: true - IMAGE_NAME: "2i2c/frx-challenges" - - - name: Show how much disk space is left - run: df -h From a4981ec76d2a22b83cb79ba62710092fa3048477 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 12:36:46 +0100 Subject: [PATCH 13/23] Add on pull_request --- .github/workflows/publish-chart.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml index 7261717..78d38ed 100644 --- a/.github/workflows/publish-chart.yaml +++ b/.github/workflows/publish-chart.yaml @@ -5,6 +5,12 @@ name: Publish chart # Trigger the workflow on pushed tags or commits to main branch. on: + pull_request: + paths-ignore: + - "docs/**" + - "**.md" + - ".github/workflows/*" + - "!.github/workflows/publish-chart.yaml" push: paths-ignore: - "docs/**" From c9a947e1894a53a3fbe5fbb7b2aa80e844437d43 Mon Sep 17 00:00:00 2001 From: jnywong Date: Mon, 16 Jun 2025 17:19:20 +0100 Subject: [PATCH 14/23] Update GHA --- .github/workflows/build-image.yaml | 55 ---------------------------- .github/workflows/publish-chart.yaml | 47 +++++------------------- 2 files changed, 9 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/build-image.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml deleted file mode 100644 index 3b45727..0000000 --- a/.github/workflows/build-image.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Build and push image on PR - -on: - pull_request: - paths-ignore: - - "docs/**" - - "**.md" - - ".github/workflows/*" - - "!.github/workflows/build-image.yaml" - - "!.github/workflows/publish-chart.yaml" - branches: - - main - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: cleanup disk space - run: | - sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc - df -h - - - name: Checkout files in repo - uses: actions/checkout@main - - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Set up QEMU (for docker buildx) - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx (for chartpress multi-arch builds) - uses: docker/setup-buildx-action@v3 - - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - - - name: Build the image and push to quay.io - uses: jupyterhub/repo2docker-action@master - with: - DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} - DOCKER_REGISTRY: "quay.io" - LATEST_TAG_OFF: true - IMAGE_NAME: "2i2c-org/frx-challenges" - - - name: Show how much disk space is left - run: df -h diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml index a371a3f..78d38ed 100644 --- a/.github/workflows/publish-chart.yaml +++ b/.github/workflows/publish-chart.yaml @@ -41,29 +41,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.11" - - - name: Decide to publish or not - id: publishing - shell: python - run: | - import os - repo = "${{ github.repository }}" - event = "${{ github.event_name }}" - ref = "${{ github.event.ref }}" - publishing = "" - if ( - repo == "2i2c-org/frx-challenges" - and event == "push" - and ( - ref.startswith("refs/tags/") - or ref == "refs/heads/main" - ) - ): - publishing = "true" - print("Publishing chart") - with open(os.environ["GITHUB_OUTPUT"], "a") as f: - f.write(f"publishing={publishing}\n") + python-version: "3.12" - name: Set up QEMU (for docker buildx) uses: docker/setup-qemu-action@v3 @@ -71,10 +49,12 @@ jobs: - name: Set up Docker Buildx (for chartpress multi-arch builds) uses: docker/setup-buildx-action@v3 - - name: Setup push rights to Quay.io - if: steps.publishing.outputs.publishing - run: | - docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} - name: Set up push rights to frx-challenges-helm-chart # This was setup by... @@ -86,7 +66,6 @@ jobs: # 3. Registering the public key (gh-pages.pub) as a deploy key # with push rights for the 2i2c-org/frx-challenges-helm-chart repo: # https://github.com/2i2c-org/frx-challenges-helm-chart/settings/keys - if: steps.publishing.outputs.publishing run: | mkdir -p ~/.ssh ssh-keyscan github.com >> ~/.ssh/known_hosts @@ -104,21 +83,13 @@ jobs: git config --global user.email "github-actions@github.com" git config --global user.name "github-actions" - - name: Build image, push if necessary - env: - PUBLISHING: ${{ steps.publishing.outputs.publishing }} + - name: Build image and push run: | - CHARTPRESS_ARGS="" - if [[ "${PUBLISHING}" == "true" ]]; then - CHARTPRESS_ARGS="--push" - fi chartpress \ --builder docker-buildx \ - --platform linux/amd64 --platform linux/arm64 \ - ${CHARTPRESS_ARGS} + --platform linux/amd64 --platform linux/arm64 - name: Publish chart with chartpress - if: steps.publishing.outputs.publishing run: | set -eux From 83bf4c1d5b00edfa42f63213a79fe01474d4b597 Mon Sep 17 00:00:00 2001 From: Jeff Rhoades <37990507+rhoadesScholar@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:48:09 +0000 Subject: [PATCH 15/23] Refactor version template for improved readability and structure --- frx_challenges/web/templates/version.html | 82 +++++++++++------------ 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index f705af7..ebbad2d 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -1,51 +1,47 @@ {% extends "page.html" %} {% load static %} {% block body %} -
-

- Version {{ version.id }} for - {{ version.submission.name }} -

-
-
- Status: - {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} - {% if evaluation.status == "EVALUATING" %} - {{ evaluation.percent_complete }} evaluated - {% else %} - {{ evaluation.status }} - {% endif %} - - Check for updates - - {% else %} - {{ evaluation.status }} - {% endif %} -
-
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} - ago -
-
-
-

Result

- {% if is_collaborator %} - +
+

+ Version {{ version.id }} for + {{ version.submission.name }} +

+
+
+ Status: + {% if evaluation.status not in ["EVALUATED", "FAILED"] %} + {% if evaluation.status == "EVALUATING" %} + {{ evaluation.percent_complete }} evaluated + {% else %} + {{ evaluation.status }} {% endif %} - {% if evaluation.status == 'EVALUATED' %} - {% for result_item in results_display %} -
- {{ result_item.display_name }} -

{{ result_item.value }}

-
- {% endfor %} + + Check for updates + {% else %} -
Evaluation results will be displayed here once completed
+ {{ evaluation.status }} {% endif %}
+
+ {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago +
+
+
+

Result

+ {% if is_collaborator %} + (download results) + {% endif %} + {% if evaluation.status == 'EVALUATED' %} + {% for result_item in results_display %} +
+ {{ result_item.display_name }} +

{{ result_item.value }}

+
+ {% endfor %} + {% else %} +
Evaluation results will be displayed here once completed
+ {% endif %}
-{% endblock body %} +
+{% endblock body %} \ No newline at end of file From afbeb9eb3deb68607f9ca27da8332f61acd292b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:48:21 +0000 Subject: [PATCH 16/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- frx_challenges/web/templates/version.html | 78 +++++++++++------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index ebbad2d..36448c6 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -1,47 +1,47 @@ {% extends "page.html" %} {% load static %} {% block body %} -
-

- Version {{ version.id }} for - {{ version.submission.name }} -

-
-
- Status: - {% if evaluation.status not in ["EVALUATED", "FAILED"] %} - {% if evaluation.status == "EVALUATING" %} - {{ evaluation.percent_complete }} evaluated - {% else %} - {{ evaluation.status }} +
+

+ Version {{ version.id }} for + {{ version.submission.name }} +

+
+
+ Status: + {% if evaluation.status not in ["EVALUATED", "FAILED"] %} + {% if evaluation.status == "EVALUATING" %} + {{ evaluation.percent_complete }} evaluated + {% else %} + {{ evaluation.status }} + {% endif %} + + Check for updates + + {% else %} + {{ evaluation.status }} + {% endif %} +
+
+ {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago +
+
+
+

Result

+ {% if is_collaborator %} + (download results) {% endif %} - - Check for updates - + {% if evaluation.status == 'EVALUATED' %} + {% for result_item in results_display %} +
+ {{ result_item.display_name }} +

{{ result_item.value }}

+
+ {% endfor %} {% else %} - {{ evaluation.status }} +
Evaluation results will be displayed here once completed
{% endif %}
-
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} - ago -
-
-
-

Result

- {% if is_collaborator %} - (download results) - {% endif %} - {% if evaluation.status == 'EVALUATED' %} - {% for result_item in results_display %} -
- {{ result_item.display_name }} -

{{ result_item.value }}

-
- {% endfor %} - {% else %} -
Evaluation results will be displayed here once completed
- {% endif %}
-
-{% endblock body %} \ No newline at end of file +{% endblock body %} From 439ca6f96af3f064b10b8b7694b30cd79646fa3d Mon Sep 17 00:00:00 2001 From: Jeff Rhoades <37990507+rhoadesScholar@users.noreply.github.com> Date: Tue, 17 Jun 2025 17:06:37 -0400 Subject: [PATCH 17/23] Update version.html --- frx_challenges/web/templates/version.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 36448c6..2d3c797 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -9,7 +9,7 @@

Status: - {% if evaluation.status not in ["EVALUATED", "FAILED"] %} + {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} {% if evaluation.status == "EVALUATING" %} {{ evaluation.percent_complete }} evaluated {% else %} From 3b5db7fdd0227730fc7a1c4ad76ca24d2010bea3 Mon Sep 17 00:00:00 2001 From: jnywong Date: Wed, 18 Jun 2025 10:28:12 +0100 Subject: [PATCH 18/23] Fix 'is_collaborator' logic --- frx_challenges/web/templates/version.html | 2 +- frx_challenges/web/views/versions.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 2d3c797..18b7ae1 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -30,7 +30,7 @@

Result

{% if is_collaborator %} - (download results) + Download results {% endif %} {% if evaluation.status == 'EVALUATED' %} {% for result_item in results_display %} diff --git a/frx_challenges/web/views/versions.py b/frx_challenges/web/views/versions.py index 32edd70..219a1ee 100644 --- a/frx_challenges/web/views/versions.py +++ b/frx_challenges/web/views/versions.py @@ -77,6 +77,7 @@ def download_results(request: HttpRequest, id: int) -> HttpResponse: def view(request: HttpRequest, id: int) -> HttpResponse: version = Version.objects.get(id=id) evaluation = version.latest_evaluation + is_collaborator = _validate_collaborator(request, version.submission.id) results_display = [] if evaluation.result: @@ -95,6 +96,7 @@ def view(request: HttpRequest, id: int) -> HttpResponse: "version": version, "evaluation": evaluation, "results_display": results_display, + "is_collaborator": is_collaborator, }, ) From 15c7cabcbe5ccf3d22db4cb4ee9a998cbee374f0 Mon Sep 17 00:00:00 2001 From: jnywong Date: Wed, 18 Jun 2025 10:48:27 +0100 Subject: [PATCH 19/23] Fix function input --- frx_challenges/web/views/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frx_challenges/web/views/versions.py b/frx_challenges/web/views/versions.py index 219a1ee..d7ba731 100644 --- a/frx_challenges/web/views/versions.py +++ b/frx_challenges/web/views/versions.py @@ -55,7 +55,7 @@ def upload(request: HttpRequest, id: int) -> HttpResponse: @login_required def download_results(request: HttpRequest, id: int) -> HttpResponse: version = Version.objects.get(id=id) - is_collaborator = _validate_collaborator(request, version.submission.id) + is_collaborator = _validate_collaborator(request, id) if not is_collaborator: raise Http404( "Full results files are only available to submission collaborators." From d74a0726d295d988be4a29264338047524eb7b57 Mon Sep 17 00:00:00 2001 From: jnywong Date: Wed, 18 Jun 2025 12:11:54 +0100 Subject: [PATCH 20/23] Add if condition --- frx_challenges/web/templates/version.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index 18b7ae1..d9dca9e 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -29,7 +29,7 @@

Result

- {% if is_collaborator %} + {% if is_collaborator and evaluation.status == 'EVALUATED' %} Download results {% endif %} {% if evaluation.status == 'EVALUATED' %} From 8b90cbfa97eea47d42f9c39763486bdd68eef59c Mon Sep 17 00:00:00 2001 From: Jenny Wong Date: Wed, 18 Jun 2025 15:09:37 +0100 Subject: [PATCH 21/23] Update frx_challenges/web/views/versions.py --- frx_challenges/web/views/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frx_challenges/web/views/versions.py b/frx_challenges/web/views/versions.py index d7ba731..b056f09 100644 --- a/frx_challenges/web/views/versions.py +++ b/frx_challenges/web/views/versions.py @@ -77,7 +77,7 @@ def download_results(request: HttpRequest, id: int) -> HttpResponse: def view(request: HttpRequest, id: int) -> HttpResponse: version = Version.objects.get(id=id) evaluation = version.latest_evaluation - is_collaborator = _validate_collaborator(request, version.submission.id) + is_collaborator = _validate_collaborator(request, id) results_display = [] if evaluation.result: From dbd7287a061c2a4780b42ffa7246ea9ed2d54d10 Mon Sep 17 00:00:00 2001 From: Jeff Rhoades <37990507+rhoadesScholar@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:50:28 +0000 Subject: [PATCH 22/23] Remove percent_complete property from Evaluation model and clean up version.html template structure --- frx_challenges/web/models.py | 18 ------ frx_challenges/web/templates/version.html | 76 +++++++++++------------ 2 files changed, 36 insertions(+), 58 deletions(-) diff --git a/frx_challenges/web/models.py b/frx_challenges/web/models.py index a6b0306..f7c1ca8 100644 --- a/frx_challenges/web/models.py +++ b/frx_challenges/web/models.py @@ -144,24 +144,6 @@ def ordered_results(self) -> list: results_list.append(None) return results_list - @property - def percent_complete(self) -> str: - """ - Return the percentage of completion of this evaluation - """ - if self.status == Evaluation.Status.EVALUATED: - return "100%" - elif self.status == Evaluation.Status.EVALUATING: - if self.result: - percent_complete = self.result.get( - "num_evals_done", 0 - ) / self.result.get("total_evals", 1) - return f"{int(percent_complete * 100)}%" - else: - return "0%" - else: - return "0%" - def __str__(self): return f"({self.status}) {self.result} {self.version.data_uri}" diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index d9dca9e..fd26ec0 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -1,47 +1,43 @@ {% extends "page.html" %} {% load static %} {% block body %} -
-

- Version {{ version.id }} for - {{ version.submission.name }} -

-
-
- Status: - {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} - {% if evaluation.status == "EVALUATING" %} - {{ evaluation.percent_complete }} evaluated - {% else %} - {{ evaluation.status }} - {% endif %} - - Check for updates - - {% else %} - {{ evaluation.status }} - {% endif %} -
-
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} - ago -
-
-
-

Result

- {% if is_collaborator and evaluation.status == 'EVALUATED' %} - Download results - {% endif %} - {% if evaluation.status == 'EVALUATED' %} - {% for result_item in results_display %} -
- {{ result_item.display_name }} -

{{ result_item.value }}

-
- {% endfor %} +
+

+ Version {{ version.id }} for + {{ version.submission.name }} +

+
+
+ Status: + {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} + {{ evaluation.status }} + + Check for updates + {% else %} -
Evaluation results will be displayed here once completed
+ {{ evaluation.status }} {% endif %}
+
+ {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago +
+
+
+

Result

+ {% if is_collaborator and evaluation.status == 'EVALUATED' %} + Download results + {% endif %} + {% if evaluation.status == 'EVALUATED' %} + {% for result_item in results_display %} +
+ {{ result_item.display_name }} +

{{ result_item.value }}

+
+ {% endfor %} + {% else %} +
Evaluation results will be displayed here once completed
+ {% endif %}
-{% endblock body %} +
+{% endblock body %} \ No newline at end of file From b2d12baf6f53d4416680499d65607741ae88478e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:50:44 +0000 Subject: [PATCH 23/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- frx_challenges/web/templates/version.html | 72 +++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/frx_challenges/web/templates/version.html b/frx_challenges/web/templates/version.html index fd26ec0..63e7788 100644 --- a/frx_challenges/web/templates/version.html +++ b/frx_challenges/web/templates/version.html @@ -1,43 +1,43 @@ {% extends "page.html" %} {% load static %} {% block body %} -
-

- Version {{ version.id }} for - {{ version.submission.name }} -

-
-
- Status: - {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} - {{ evaluation.status }} - - Check for updates - +
+

+ Version {{ version.id }} for + {{ version.submission.name }} +

+
+
+ Status: + {% if evaluation.status != "EVALUATED" and evaluation.status != "FAILED" %} + {{ evaluation.status }} + + Check for updates + + {% else %} + {{ evaluation.status }} + {% endif %} +
+
+ {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} + ago +
+
+
+

Result

+ {% if is_collaborator and evaluation.status == 'EVALUATED' %} + Download results + {% endif %} + {% if evaluation.status == 'EVALUATED' %} + {% for result_item in results_display %} +
+ {{ result_item.display_name }} +

{{ result_item.value }}

+
+ {% endfor %} {% else %} - {{ evaluation.status }} +
Evaluation results will be displayed here once completed
{% endif %}
-
- {{ version.user.username }} uploaded {{ version.filename }} {{ version.created_at|timesince }} - ago -
-
-
-

Result

- {% if is_collaborator and evaluation.status == 'EVALUATED' %} - Download results - {% endif %} - {% if evaluation.status == 'EVALUATED' %} - {% for result_item in results_display %} -
- {{ result_item.display_name }} -

{{ result_item.value }}

-
- {% endfor %} - {% else %} -
Evaluation results will be displayed here once completed
- {% endif %}
-
-{% endblock body %} \ No newline at end of file +{% endblock body %}