From f7d32de1432529494df6b144973a31b92ffb4570 Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Tue, 21 May 2024 14:10:18 +0100 Subject: [PATCH] Remove spinner from learning uploader (#1415) Small refactor before #1390. The spinner was fun when the tool was primarily used locally, but now it's annoying in CI and is an extra dependency. See an example of the new behaviour in the [test](https://github.com/Qiskit/documentation/actions/runs/9173882338/job/25223510491#step:5:102). --- .../pyproject.toml | 1 - .../src/learning_uploader/upload.py | 22 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/scripts/ibm-quantum-learning-uploader/pyproject.toml b/scripts/ibm-quantum-learning-uploader/pyproject.toml index 9fb6946ffe5..5003554f321 100644 --- a/scripts/ibm-quantum-learning-uploader/pyproject.toml +++ b/scripts/ibm-quantum-learning-uploader/pyproject.toml @@ -18,7 +18,6 @@ classifiers = [ ] dependencies = [ "pyyaml", - "yaspin", "requests~=2.28" ] diff --git a/scripts/ibm-quantum-learning-uploader/src/learning_uploader/upload.py b/scripts/ibm-quantum-learning-uploader/src/learning_uploader/upload.py index a46d613aab0..2c89345f450 100644 --- a/scripts/ibm-quantum-learning-uploader/src/learning_uploader/upload.py +++ b/scripts/ibm-quantum-learning-uploader/src/learning_uploader/upload.py @@ -6,8 +6,6 @@ import random import requests import sys -from yaspin import yaspin -from yaspin.spinners import Spinners class Lesson: @@ -73,28 +71,30 @@ def push(self, lesson: Lesson): Wrapper for `_push` to handle spinner and Exceptions """ base_msg = f"Push \033[1m{lesson.name}\033[0m" - spinner = yaspin(Spinners.dots12, text=base_msg, color="blue") - spinner.start() - def _log_fn(msg): - spinner.text = f"{base_msg}: {msg}" + def _log_fn(msg, state="working"): + """ + Display event to terminal + msg: Event message + state: 'working'|'fail'|'complete' + """ + emoji = { "working": "🔄", "fail": "❌", "complete": "✅" }[state] + print(f"{emoji} {base_msg}: {msg}") try: web_page = self._push(lesson, _log_fn) except KeyboardInterrupt: - _log_fn("Cancelled by user") - spinner.fail("❌") + _log_fn("Cancelled by user", state="fail") lesson.delete_zip() sys.exit() except Exception as err: - spinner.fail("❌") + _log_fn("Something went wrong", state="fail") lesson.delete_zip() raise err - spinner.text = base_msg - spinner.ok("✅") + _log_fn("Complete!", state="complete") if not self.hide_urls: print(f" \033[30m╷\033[0m Web page: \033[96m{web_page}\033[0m")