From 6d67a1176e0d64da06fbd60d887168d6e6b4787d Mon Sep 17 00:00:00 2001 From: csae8092 Date: Tue, 23 Jan 2024 08:59:16 +0100 Subject: [PATCH] updated test workflow actions --- .github/workflows/test.yml | 4 +- issue__112_fix_image_urls.ipynb | 87 ++++++--------------------------- set_env_variables.sh | 2 +- 3 files changed, 18 insertions(+), 75 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ac86e6..fa03400 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.11 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ${{ env.pythonLocation }} key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }} diff --git a/issue__112_fix_image_urls.ipynb b/issue__112_fix_image_urls.ipynb index 18edf3b..9d5176a 100644 --- a/issue__112_fix_image_urls.ipynb +++ b/issue__112_fix_image_urls.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "id": "eda7419e", "metadata": {}, "outputs": [], @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "id": "f03b29bb", "metadata": {}, "outputs": [], @@ -24,85 +24,28 @@ }, { "cell_type": "code", - "execution_count": 25, - "id": "8ec94f95", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "e730f9bf96b4439e86ded04fdaa525f4", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "0it [00:00, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "for x in tqdm(items, total=len(items)):\n", - " img_name = x.img_url.split('/')[-1].split('&')[0]\n", - " new_url = URL_STUB.format(quote(img_name))\n", - " x.img_url = new_url\n", - " x.save()" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "id": "a8048e89", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://commons.wikimedia.org/w/index.php?title=Special:Redirect/file/{}'" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "URL_STUB" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "054659cb", + "execution_count": null, + "id": "e8e31fb5", "metadata": {}, "outputs": [], "source": [ - "hansi = None" + "items.count()" ] }, { "cell_type": "code", - "execution_count": 28, - "id": "4b1ad510", + "execution_count": null, + "id": "8ec94f95", "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "argument of type 'NoneType' is not iterable", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[28], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[43mURL_STUB\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mhansi\u001b[49m:\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124masd\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[0;31mTypeError\u001b[0m: argument of type 'NoneType' is not iterable" - ] - } - ], + "outputs": [], "source": [ - "if URL_STUB in hansi:\n", - " print(\"asd\")" + "for x in tqdm(items, total=len(items)):\n", + " img_name = x.img_url.split('/')[-1].split('&')[0]\n", + " new_url = URL_STUB.format(quote(img_name))\n", + " if len(new_url) > 300:\n", + " new_url = None\n", + " x.img_url = new_url\n", + " x.save()" ] }, { diff --git a/set_env_variables.sh b/set_env_variables.sh index e0a3156..77758e8 100644 --- a/set_env_variables.sh +++ b/set_env_variables.sh @@ -1 +1 @@ -export $(grep -v '^#' .env | xargs) \ No newline at end of file +export $(grep -v '^#' .secret | xargs) \ No newline at end of file